add.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div>
  3. <el-button size="mini" type="primary" @click="dialogFormVisible = true">新 建</el-button>
  4. <el-dialog title="新 建" append-to-body :visible.sync="dialogFormVisible" width="500px">
  5. <div slot="title" style="font-size: 15px">
  6. 新增工单模板
  7. </div>
  8. <el-row :gutter="20">
  9. <el-form :model="form" :rules="rules" ref="form" label-width="90px" label-position="right" size="mini">
  10. <el-col :span="24">
  11. <el-form-item label="模板名称" prop="name">
  12. <el-input v-model="form.name" placeholder="请输入模板名称"></el-input>
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="24">
  16. <el-form-item label="模板类型" prop="type">
  17. <el-select v-model="form.type">
  18. <el-option label="服务" value="服务"></el-option>
  19. <el-option label="安装调试" value="安装调试"></el-option>
  20. <el-option label="安装培训" value="安装培训"></el-option>
  21. </el-select>
  22. </el-form-item>
  23. </el-col>
  24. </el-form>
  25. </el-row>
  26. <div class="dialog-footer">
  27. <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
  28. <el-button size="small" type="warning" @click="onSubmit" class="normal-btn-width btn-warning">确 定</el-button>
  29. </div>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: "add",
  36. data(){
  37. return {
  38. dialogFormVisible:false,
  39. form:{
  40. "sa_workorder_templateid":0, //sa_brandid<=0时 为新增
  41. "name":"",
  42. "type":""
  43. },
  44. rules:{
  45. name:[
  46. { required: true, message: '请输入模板名称', trigger: 'blur'},
  47. ],
  48. type:[
  49. { required: true, message: '输入账户名称', trigger: 'blur'}
  50. ]
  51. }
  52. }
  53. },
  54. methods:{
  55. onSubmit(){
  56. console.log(this.form)
  57. this.$refs['form'].validate(async (valid) => {
  58. if (!valid) return false
  59. const res = await this.$api.requested({
  60. "id": "20230207140403",
  61. "version":1,
  62. "content": this.form
  63. })
  64. this.tool.showMessage(res,()=>{
  65. this.$emit('onSuccess')
  66. this.$refs['form'].resetFields();
  67. this.dialogFormVisible = false
  68. })
  69. })
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .dialog-footer {
  76. margin-top: 0;
  77. }
  78. .el-select {
  79. width: 100% !important;
  80. }
  81. </style>