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="120px">
7       <el-row :gutter="20">
8         <el-col :span="12">
9           <el-form-item label="煤矿" prop="mkbm">
10             <dict-select-tag v-model="dataForm.mkbm" placeholder="煤矿" dictCode="mkbm"/>
11           </el-form-item>
12         </el-col>
13         <el-col :span="12">
14           <el-form-item label="生产系统" prop="scxtbm">
15             <dict-select-tag v-model="dataForm.scxtbm" placeholder="生产系统" dictCode="scxtbm"/>
16           </el-form-item>
17         </el-col>
18       </el-row>
19       <el-row :gutter="20">
20         <el-col :span="12">
21           <el-form-item label="监控系统编码" prop="lsh">
22             <el-input v-model="dataForm.lsh" placeholder="2位流水码" maxlength="2" clearable>
23               <template slot="prepend">{{dataForm.mkbm + dataForm.scxtbm}}</template>
24             </el-input>
25           </el-form-item>
26         </el-col>
27         <el-col :span="12">
28           <el-form-item label="监控系统名称" prop="jkxtmc">
29             <el-input v-model="dataForm.jkxtmc" placeholder="监控系统名称" maxlength="50" clearable></el-input>
30           </el-form-item>
31         </el-col>
32       </el-row>
33     </el-form>
34     <span slot="footer" class="dialog-footer">
35       <el-button @click="visible = false">取消</el-button>
36       <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
37     </span>
38   </el-dialog>
39 </template>
40
41 <script>
42   import { isPositiveInteger } from '@/utils/validate'
43   import DictSelectTag from '@/components/dict/dict-select-tag'
44   export default {
45     components: {
46       DictSelectTag
47     },
48     data () {
49       var validateDatatypeno = (rule, value, callback) => {
50         if (!isPositiveInteger(value)) {
51           callback(new Error('编号应该为整数'))
52         } else {
53           callback()
54         }
55       }
56       return {
57         visible: false,
58         noDisabled: false,
59         roleList: [],
60         dataForm: {
61           id: 0,
62           mkbm: '',
63           scxtbm: '',
64           lsh: '',
65           jkxtbm: '',
66           jkxtmc: '',
67           descp: ''
68         },
69         dataRule: {
70           mkbm: [
71             { required: true, message: '煤矿不能为空', trigger: 'blur' }
72           ],
73           scxtbm: [
74             { required: true, message: '生产系统不能为空', trigger: 'blur' }
75           ],
76           lsh: [
77             { required: true, message: '流水号不能为空', trigger: 'blur' }
78           ],
79           jkxtmc: [
80             { required: true, message: '监控系统名称不能为空', trigger: 'blur' }
81           ]
82         }
83       }
84     },
85     methods: {
86       init (id) {
87         this.dataForm.id = id || 0
88         this.visible = true
89         this.$nextTick(() => {
90           this.$refs['dataForm'].resetFields()
91         })
92         if (id) {
93           this.$http({
94             url: `/data/data/jkxt/info/${this.dataForm.id}`,
95             method: 'get',
96             params: this.$http.adornParams()
97           }).then(({data}) => {
98             if (data && data.code === 0) {
99               this.dataForm.mkbm = data.data.mkbm
100               this.dataForm.scxtbm = data.data.scxtbm
101               this.dataForm.lsh = data.data.lsh
102               this.dataForm.jkxtbm = data.data.jkxtbm
103               this.dataForm.jkxtmc = data.data.jkxtmc
104             }
105           })
106         }
107       },
108       // 表单提交
109       dataFormSubmit () {
110         this.$refs['dataForm'].validate((valid) => {
111           if (valid) {
112             this.$http['post'](`/data/data/jkxt/${!this.dataForm.id ? 'save' : 'update'}`, this.dataForm).then(({ data: res }) => {
113               if (res.code !== 0) {
114                 return this.$message.error(res.msg)
115               }
116               this.$message({
117                 message: this.$t('prompt.success'),
118                 type: 'success',
119                 duration: 500,
120                 onClose: () => {
121                   this.visible = false
122                   this.$emit('refreshDataList')
123                 }
124               })
125             }).catch(() => {})
126           }
127         })
128       }
129     }
130   }
131 </script>
132 <style>
133   .el-select {
134     width:100%
135   }
136   .el-input-group__append {
137     padding: 0 5px 0 5px
138   }
139   .el-input-group__prepend {
140     padding: 0 5px 0 5px
141   }
142 </style>