houzhongjian
2024-07-23 8501060c4f921d1e744c477e4dc08eb47b52693c
提交 | 用户 | 时间
850106 1 <template>
H 2   <el-dialog
3     :title="!dataForm.id ? '新增' : '修改'"
4     :close-on-click-modal="false"
5     :visible.sync="visible">
6     <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
7       <el-form-item label="名称" prop="name">
8         <el-input v-model="dataForm.name" placeholder="名称" maxlength="50" clearable></el-input>
9       </el-form-item>
10       <el-form-item label="名称" prop="order">
11         <el-input v-model="dataForm.order" placeholder="排序" maxlength="50" clearable></el-input>
12       </el-form-item>
13     </el-form>
14     <span slot="footer" class="dialog-footer">
15       <el-button @click="visible = false">取消</el-button>
16       <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
17     </span>
18   </el-dialog>
19 </template>
20
21 <script>
22   export default {
23     data () {
24       return {
25
26         visible: false,
27         roleList: [],
28         dataForm: {
29           id: 0,
30           name: '',
31           order: ''
32         },
33         dataRule: {
34           name: [
35             { required: true, message: '名称不能为空', trigger: 'blur' }
36           ],
37           order: [
38             { required: true, message: '排序不能为空', trigger: 'blur' }
39           ]
40         }
41       }
42     },
43     methods: {
44       init (id) {
45         this.dataForm.id = id || 0
46         this.visible = true
47         this.$nextTick(() => {
48           this.$refs['dataForm'].resetFields()
49         })
50         if (id) {
51           this.$http({
52             url: `/iailab-ntt-model/mcs/schedule-object/info/${this.dataForm.id}`,
53             method: 'get',
54             params: this.$http.adornParams()
55           }).then(({data}) => {
56             if (data && data.code === 0) {
57               this.dataForm.name = data.scheduleObject.name
58               this.dataForm.order = data.scheduleObject.order
59             }
60           })
61         }
62       },
63       // 表单提交
64       dataFormSubmit () {
65         this.$refs['dataForm'].validate((valid) => {
66           if (valid) {
67             this.$http({
68               url: `/iailab-ntt-model/mcs/schedule-object/${!this.dataForm.id ? 'save' : 'update'}`,
69               method: 'post',
70               data: this.$http.adornData({
71                 'id': this.dataForm.id || undefined,
72                 'name': this.dataForm.name,
73                 'order': this.dataForm.order
74               })
75             }).then(({data}) => {
76               if (data && data.code === 0) {
77                 this.$message({
78                   message: '操作成功',
79                   type: 'success',
80                   duration: 1500,
81                   onClose: () => {
82                     this.visible = false
83                     this.$emit('refreshDataList')
84                   }
85                 })
86               } else {
87                 this.$message.error(data.msg)
88               }
89             })
90           }
91         })
92       }
93     }
94   }
95 </script>
96 <style>
97   .el-select {
98     width: 100%
99   }
100 </style>