提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog |
|
3 |
:title="!dataForm.id ? '新增' : '修改'" |
|
4 |
:close-on-click-modal="false" |
|
5 |
:visible.sync="visible" |
|
6 |
append-to-body> |
|
7 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px"> |
|
8 |
<!--<el-row :gutter="20"> |
|
9 |
<el-col :span="12"> |
|
10 |
<el-form-item label="所属公司" prop="unit2"> |
|
11 |
<dict-select-tag v-model="dataForm.unit2" placeholder="所属公司" dictCode="unit2" /> |
|
12 |
</el-form-item> |
|
13 |
</el-col> |
|
14 |
<el-col :span="12"> |
|
15 |
<el-form-item label="所属单位" prop="ssdw"> |
|
16 |
<dict-select-tag v-model="dataForm.ssdw" placeholder="所属单位" dictCode="ssdw" /> |
|
17 |
</el-form-item> |
|
18 |
</el-col> |
|
19 |
</el-row>--> |
|
20 |
<el-row :gutter="20"> |
|
21 |
<el-col :span="12"> |
|
22 |
<el-form-item label="项目代码" prop="itemCode"> |
|
23 |
<el-input v-model="dataForm.itemCode" placeholder="项目代码" clearable></el-input> |
|
24 |
</el-form-item> |
|
25 |
</el-col> |
|
26 |
<el-col :span="12"> |
|
27 |
<el-form-item label="项目名称" prop="itemName"> |
|
28 |
<el-input v-model="dataForm.itemName" placeholder="项目名称" clearable></el-input> |
|
29 |
</el-form-item> |
|
30 |
</el-col> |
|
31 |
</el-row> |
|
32 |
<el-row :gutter="20"> |
|
33 |
<el-col :span="12"> |
|
34 |
<el-form-item label="统计类别" prop="itemType"> |
|
35 |
<dict-select-tag v-model="dataForm.itemType" placeholder="类别" dictCode="data-item-type" /> |
|
36 |
</el-form-item> |
|
37 |
</el-col> |
|
38 |
<el-col :span="12"> |
|
39 |
<el-form-item label="单位" prop="unit"> |
|
40 |
<el-input v-model="dataForm.unit" placeholder="单位" clearable></el-input> |
|
41 |
</el-form-item> |
|
42 |
</el-col> |
|
43 |
</el-row> |
|
44 |
<el-row :gutter="20"> |
|
45 |
<el-col :span="12"> |
|
46 |
<el-form-item label="测点" prop="pointCode"> |
|
47 |
<el-select |
|
48 |
v-model="dataForm.pointCode" |
|
49 |
filterable |
|
50 |
@change="changePoint" |
|
51 |
placeholder="请选择"> |
|
52 |
<el-option |
|
53 |
v-for="(item, index) in pointList" |
|
54 |
:key="index" |
|
55 |
:label="item.cdmc" |
|
56 |
:value="item.cdbm"> |
|
57 |
</el-option> |
|
58 |
</el-select> |
|
59 |
</el-form-item> |
|
60 |
</el-col> |
|
61 |
<el-col :span="12"> |
|
62 |
<el-form-item label="默认值" prop="defaultValue"> |
|
63 |
<el-input v-model="dataForm.defaultValue" placeholder="默认值"></el-input> |
|
64 |
</el-form-item> |
|
65 |
</el-col> |
|
66 |
</el-row> |
|
67 |
<el-row :gutter="20"> |
|
68 |
<el-col :span="12"> |
|
69 |
<el-form-item label="班次" prop="bc"> |
|
70 |
<dict-select-tag v-model="dataForm.bc" placeholder="班次" dictCode="bc" /> |
|
71 |
</el-form-item> |
|
72 |
</el-col> |
|
73 |
<el-col :span="12"> |
|
74 |
<el-form-item label="生产系统" prop="xtCode"> |
|
75 |
<dict-select-tag v-model="dataForm.xtCode" placeholder="生产系统" dictCode="scxt" /> |
|
76 |
</el-form-item> |
|
77 |
</el-col> |
|
78 |
</el-row> |
|
79 |
<el-row :gutter="20"> |
|
80 |
<el-col :span="12"> |
|
81 |
<el-form-item label="配置时间" prop="clockConfig"> |
|
82 |
<el-select |
|
83 |
v-model="dataForm.clockConfig" |
|
84 |
filterable |
|
85 |
placeholder="请选择"> |
|
86 |
<el-option |
|
87 |
v-for="(item, index) in clockList" |
|
88 |
:key="index" |
|
89 |
:label="item.clockName" |
|
90 |
:value="item.clockCode"> |
|
91 |
</el-option> |
|
92 |
</el-select> |
|
93 |
</el-form-item> |
|
94 |
</el-col> |
|
95 |
<el-col :span="12"> |
|
96 |
<el-form-item label="状态" prop="status"> |
|
97 |
<dict-select-tag v-model="dataForm.status" placeholder="状态" dictCode="enable" /> |
|
98 |
</el-form-item> |
|
99 |
</el-col> |
|
100 |
</el-row> |
|
101 |
<el-row> |
|
102 |
<el-col :span="12"> |
|
103 |
<el-form-item prop="ext1" :label="$t('sysDictItem.ext1')"> |
|
104 |
<el-input v-model="dataForm.ext1" :placeholder="$t('sysDictItem.ext1')"></el-input> |
|
105 |
</el-form-item> |
|
106 |
</el-col> |
|
107 |
<el-col :span="12"> |
|
108 |
<el-form-item prop="ext2" :label="$t('sysDictItem.ext2')"> |
|
109 |
<el-input v-model="dataForm.ext2" :placeholder="$t('sysDictItem.ext2')"></el-input> |
|
110 |
</el-form-item> |
|
111 |
</el-col> |
|
112 |
</el-row> |
|
113 |
<el-row> |
|
114 |
<el-col :span="12"> |
|
115 |
<el-form-item prop="ext3" :label="$t('sysDictItem.ext3')"> |
|
116 |
<el-input v-model="dataForm.ext3" :placeholder="$t('sysDictItem.ext3')"></el-input> |
|
117 |
</el-form-item> |
|
118 |
</el-col> |
|
119 |
<el-col :span="12"> |
|
120 |
<el-form-item prop="ext4" :label="$t('sysDictItem.ext4')"> |
|
121 |
<el-input v-model="dataForm.ext4" :placeholder="$t('sysDictItem.ext4')"></el-input> |
|
122 |
</el-form-item> |
|
123 |
</el-col> |
|
124 |
</el-row> |
|
125 |
<el-row> |
|
126 |
<el-col :span="12"> |
|
127 |
<el-form-item prop="ext5" :label="$t('sysDictItem.ext5')"> |
|
128 |
<el-input v-model="dataForm.ext5" :placeholder="$t('sysDictItem.ext5')"></el-input> |
|
129 |
</el-form-item> |
|
130 |
</el-col> |
|
131 |
</el-row> |
|
132 |
<el-row :gutter="20"> |
|
133 |
<el-col :span="24"> |
|
134 |
<el-form-item label="描述" prop="description"> |
|
135 |
<el-input v-model="dataForm.description" placeholder="描述"></el-input> |
|
136 |
</el-form-item> |
|
137 |
</el-col> |
|
138 |
</el-row> |
|
139 |
</el-form> |
|
140 |
<span slot="footer" class="dialog-footer"> |
|
141 |
<el-button @click="visible = false">取消</el-button> |
|
142 |
<el-button type="primary" @click="dataFormSubmit()">确定</el-button> |
|
143 |
</span> |
|
144 |
</el-dialog> |
|
145 |
</template> |
|
146 |
|
|
147 |
<script> |
|
148 |
import DictSelectTag from '@/components/dict/dict-select-tag' |
|
149 |
export default { |
|
150 |
components: { |
|
151 |
DictSelectTag |
|
152 |
}, |
|
153 |
data () { |
|
154 |
return { |
|
155 |
loading: false, |
|
156 |
visible: false, |
|
157 |
dataForm: { |
|
158 |
id: '', |
|
159 |
unit2: '', |
|
160 |
ssdw: '', |
|
161 |
itemCode: '', |
|
162 |
itemName: '', |
|
163 |
itemType: '', |
|
164 |
unit: '', |
|
165 |
pointCode: '', |
|
166 |
pointName: '', |
|
167 |
bc: '', |
|
168 |
xtCode: '', |
|
169 |
defaultValue: '0', |
|
170 |
description: '', |
|
171 |
clockConfig: '', |
|
172 |
status: '1', |
|
173 |
ext1: '', |
|
174 |
ext2: '', |
|
175 |
ext3: '', |
|
176 |
ext4: '', |
|
177 |
ext5: '', |
|
178 |
}, |
|
179 |
dataRule: { |
|
180 |
unit2: [ |
|
181 |
{ required: true, message: '所属公司不能为空', trigger: 'blur' } |
|
182 |
], |
|
183 |
ssdw: [ |
|
184 |
{ required: true, message: '所属单位不能为空', trigger: 'blur' } |
|
185 |
], |
|
186 |
itemCode: [ |
|
187 |
{ required: true, message: '项目代码不能为空', trigger: 'blur' } |
|
188 |
], |
|
189 |
itemName: [ |
|
190 |
{ required: true, message: '项目名称不能为空', trigger: 'blur' } |
|
191 |
], |
|
192 |
itemType: [ |
|
193 |
{ required: true, message: '类别不能为空', trigger: 'blur' } |
|
194 |
], |
|
195 |
pointCode: [ |
|
196 |
{ required: true, message: '点编码不能为空', trigger: 'blur' } |
|
197 |
], |
|
198 |
clockConfig: [ |
|
199 |
{ required: true, message: '时钟配置不能为空', trigger: 'blur' } |
|
200 |
], |
|
201 |
status: [ |
|
202 |
{ required: true, message: '状态不能为空', trigger: 'blur' } |
|
203 |
] |
|
204 |
}, |
|
205 |
pointList: [], |
|
206 |
pointMap: {}, |
|
207 |
clockList: [] |
|
208 |
} |
|
209 |
}, |
|
210 |
methods: { |
|
211 |
init (id, dictId) { |
|
212 |
this.getPointList() |
|
213 |
this.getClockList() |
|
214 |
this.dataForm.id = id || 0 |
|
215 |
this.dataForm.dictId = dictId |
|
216 |
this.visible = true |
|
217 |
this.$nextTick(() => { |
|
218 |
this.$refs['dataForm'].resetFields() |
|
219 |
if (this.dataForm.id) { |
|
220 |
this.getInfo() |
|
221 |
} |
|
222 |
}) |
|
223 |
}, |
|
224 |
// 获取信息 |
|
225 |
getInfo() { |
|
226 |
this.$http.get(`/data/index-data/item/info/${this.dataForm.id}`).then(({code, data, msg}) => { |
|
227 |
if (code !== 0) { |
|
228 |
return this.$message.error(msg) |
|
229 |
} |
|
230 |
this.dataForm = { |
|
231 |
...this.dataForm, |
|
232 |
...data |
|
233 |
} |
|
234 |
}).catch(() => { |
|
235 |
}) |
|
236 |
}, |
|
237 |
/** |
|
238 |
* 查询所有采集点 |
|
239 |
*/ |
|
240 |
getPointList () { |
|
241 |
this.$http({ |
|
242 |
url: '/data/data/point/list/all', |
|
243 |
method: 'get', |
|
244 |
params: { |
|
245 |
'pointtypeid': '7d9fe1db-d7a1-407a-a267-ef2edab5cb6b' |
|
246 |
} |
|
247 |
}).then(({data}) => { |
|
248 |
if (data && data.code === 0) { |
|
249 |
this.pointList = data.data |
|
250 |
this.pointList.forEach(function (value) { |
|
251 |
this.pointMap[value.cdbm] = value.cdmc |
|
252 |
}, this) |
|
253 |
} else { |
|
254 |
this.pointList = [] |
|
255 |
} |
|
256 |
}) |
|
257 |
}, |
|
258 |
/** |
|
259 |
* 查询所有时钟配置 |
|
260 |
*/ |
|
261 |
getClockList () { |
|
262 |
this.$http({ |
|
263 |
url: '/data/index-data/clock/list/all', |
|
264 |
method: 'get', |
|
265 |
params: {} |
|
266 |
}).then(({data}) => { |
|
267 |
if (data && data.code === 0) { |
|
268 |
this.clockList = data.data |
|
269 |
} else { |
|
270 |
this.clockList = [] |
|
271 |
} |
|
272 |
}) |
|
273 |
}, |
|
274 |
changePoint (value) { |
|
275 |
this.dataForm.pointName = this.pointMap[value] |
|
276 |
}, |
|
277 |
// 表单提交 |
|
278 |
dataFormSubmit () { |
|
279 |
this.$refs['dataForm'].validate((valid) => { |
|
280 |
if (valid) { |
|
281 |
this.loading = true |
|
282 |
this.$http['post'](`/data/index-data/item/${!this.dataForm.id ? 'add' : 'update'}`, this.dataForm).then(({ data: res }) => { |
|
283 |
this.loading = false |
|
284 |
if (res.code !== 0) { |
|
285 |
return this.$message.error(res.msg) |
|
286 |
} |
|
287 |
this.$message({ |
|
288 |
message: this.$t('prompt.success'), |
|
289 |
type: 'success', |
|
290 |
duration: 500, |
|
291 |
onClose: () => { |
|
292 |
this.visible = false |
|
293 |
this.$emit('refreshDataList') |
|
294 |
} |
|
295 |
}) |
|
296 |
}).catch(() => {this.loading = false}) |
|
297 |
} |
|
298 |
}) |
|
299 |
} |
|
300 |
} |
|
301 |
} |
|
302 |
</script> |
|
303 |
<style> |
|
304 |
.el-select { |
|
305 |
width:100% |
|
306 |
} |
|
307 |
.el-input-group__append { |
|
308 |
padding: 0 5px 0 5px |
|
309 |
} |
|
310 |
.el-input-group__prepend { |
|
311 |
padding: 0 5px 0 5px |
|
312 |
} |
|
313 |
</style> |