提交 | 用户 | 时间
|
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" @change="changeScxt"/> |
|
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="jkxtbm"> |
|
22 |
<el-select v-model="dataForm.jkxtbm" placeholder="请选择"> |
|
23 |
<el-option |
|
24 |
v-for="item in jkxtOptions" |
|
25 |
:key="item.jkxtbm" |
|
26 |
:label="item.jkxtmc" |
|
27 |
:value="item.jkxtbm"> |
|
28 |
</el-option> |
|
29 |
</el-select> |
|
30 |
</el-form-item> |
|
31 |
</el-col> |
|
32 |
</el-row> |
|
33 |
<el-row :gutter="20"> |
|
34 |
<el-col :span="12"> |
|
35 |
<el-form-item label="设备编码" prop="lsh"> |
|
36 |
<el-input v-model="dataForm.lsh" placeholder="2位流水码" maxlength="2" clearable> |
|
37 |
<template slot="prepend">{{dataForm.jkxtbm}}</template> |
|
38 |
</el-input> |
|
39 |
</el-form-item> |
|
40 |
</el-col> |
|
41 |
<el-col :span="12"> |
|
42 |
<el-form-item label="设备名称" prop="sbmc"> |
|
43 |
<el-input v-model="dataForm.sbmc" placeholder="设备名称" maxlength="50" clearable></el-input> |
|
44 |
</el-form-item> |
|
45 |
</el-col> |
|
46 |
</el-row> |
|
47 |
</el-form> |
|
48 |
<span slot="footer" class="dialog-footer"> |
|
49 |
<el-button @click="visible = false">取消</el-button> |
|
50 |
<el-button type="primary" @click="dataFormSubmit()">确定</el-button> |
|
51 |
</span> |
|
52 |
</el-dialog> |
|
53 |
</template> |
|
54 |
|
|
55 |
<script> |
|
56 |
import DictSelectTag from '@/components/dict/dict-select-tag' |
|
57 |
export default { |
|
58 |
components: { |
|
59 |
DictSelectTag |
|
60 |
}, |
|
61 |
data () { |
|
62 |
return { |
|
63 |
visible: false, |
|
64 |
noDisabled: false, |
|
65 |
roleList: [], |
|
66 |
jkxtOptions: [], |
|
67 |
dataForm: { |
|
68 |
id: 0, |
|
69 |
mkbm: '', |
|
70 |
scxtbm: '', |
|
71 |
jkxtbm: '', |
|
72 |
lsh: '', |
|
73 |
sbbm: '', |
|
74 |
sbmc: '' |
|
75 |
}, |
|
76 |
dataRule: { |
|
77 |
mkbm: [ |
|
78 |
{ required: true, message: '煤矿不能为空', trigger: 'blur' } |
|
79 |
], |
|
80 |
scxtbm: [ |
|
81 |
{ required: true, message: '生产系统不能为空', trigger: 'blur' } |
|
82 |
], |
|
83 |
jkxtbm: [ |
|
84 |
{ required: true, message: '监控系统不能为空', trigger: 'blur' } |
|
85 |
], |
|
86 |
lsh: [ |
|
87 |
{ required: true, message: '流水号不能为空', trigger: 'blur' } |
|
88 |
], |
|
89 |
sbmc: [ |
|
90 |
{ required: true, message: '监控系统名称不能为空', trigger: 'blur' } |
|
91 |
] |
|
92 |
} |
|
93 |
} |
|
94 |
}, |
|
95 |
methods: { |
|
96 |
init (id) { |
|
97 |
this.dataForm.id = id || 0 |
|
98 |
this.visible = true |
|
99 |
this.$nextTick(() => { |
|
100 |
this.$refs['dataForm'].resetFields() |
|
101 |
}) |
|
102 |
if (id) { |
|
103 |
this.$http({ |
|
104 |
url: `/data/data/device/info/${this.dataForm.id}`, |
|
105 |
method: 'get', |
|
106 |
params: this.$http.adornParams() |
|
107 |
}).then(({data}) => { |
|
108 |
if (data && data.code === 0) { |
|
109 |
this.dataForm.mkbm = data.data.mkbm |
|
110 |
this.dataForm.scxtbm = data.data.scxtbm |
|
111 |
this.dataForm.jkxtbm = data.data.jkxtbm |
|
112 |
this.dataForm.lsh = data.data.lsh |
|
113 |
this.dataForm.sbbm = data.data.sbbm |
|
114 |
this.dataForm.sbmc = data.data.sbmc |
|
115 |
this.getJkxt(this.dataForm.scxtbm) |
|
116 |
} |
|
117 |
}) |
|
118 |
} |
|
119 |
}, |
|
120 |
|
|
121 |
changeScxt () { |
|
122 |
this.dataForm.jkxtbm = '' |
|
123 |
if (this.dataForm.scxtbm) { |
|
124 |
this.jkxtOptions = [] |
|
125 |
this.getJkxt(this.dataForm.scxtbm) |
|
126 |
} |
|
127 |
}, |
|
128 |
|
|
129 |
getJkxt (scxtbm) { |
|
130 |
this.$http({ |
|
131 |
url: `/data/data/jkxt/all-list`, |
|
132 |
method: 'get', |
|
133 |
params: this.$http.adornParams({ |
|
134 |
'scxtbm': scxtbm |
|
135 |
}) |
|
136 |
}).then(({data}) => { |
|
137 |
if (data && data.code === 0) { |
|
138 |
this.jkxtOptions = data.data |
|
139 |
} |
|
140 |
}) |
|
141 |
}, |
|
142 |
|
|
143 |
// 表单提交 |
|
144 |
dataFormSubmit () { |
|
145 |
this.$refs['dataForm'].validate((valid) => { |
|
146 |
if (valid) { |
|
147 |
this.$http['post'](`/data/data/device/${!this.dataForm.id ? 'save' : 'update'}`, this.dataForm).then(({ data: res }) => { |
|
148 |
if (res.code !== 0) { |
|
149 |
return this.$message.error(res.msg) |
|
150 |
} |
|
151 |
this.$message({ |
|
152 |
message: this.$t('prompt.success'), |
|
153 |
type: 'success', |
|
154 |
duration: 500, |
|
155 |
onClose: () => { |
|
156 |
this.visible = false |
|
157 |
this.$emit('refreshDataList') |
|
158 |
} |
|
159 |
}) |
|
160 |
}).catch(() => {}) |
|
161 |
} |
|
162 |
}) |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
</script> |
|
167 |
<style> |
|
168 |
.el-select { |
|
169 |
width:100% |
|
170 |
} |
|
171 |
.el-input-group__append { |
|
172 |
padding: 0 5px 0 5px |
|
173 |
} |
|
174 |
.el-input-group__prepend { |
|
175 |
padding: 0 5px 0 5px |
|
176 |
} |
|
177 |
</style> |