提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" |
|
3 |
:close-on-press-escape="false" append-to-body> |
|
4 |
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" |
|
5 |
label-width="120px"> |
|
6 |
<el-row> |
|
7 |
<el-col :span="12"> |
|
8 |
<el-form-item prop="devNo" :label="$t('healthEvaluate.devName')"> |
|
9 |
<el-select |
|
10 |
style="width: 100%" |
|
11 |
v-model="dataForm.devNo" |
|
12 |
filterable |
|
13 |
placeholder="请选择"> |
|
14 |
<el-option |
|
15 |
v-for="(item, index) in devList" |
|
16 |
:key="index" |
|
17 |
:label="item.name" |
|
18 |
:value="item.no"> |
|
19 |
<span style="float: left">{{ item.name }}</span> |
|
20 |
<span style="float: right; color: #8492a6; font-size: 13px">{{ item.no }}</span> |
|
21 |
</el-option> |
|
22 |
</el-select> |
|
23 |
</el-form-item> |
|
24 |
</el-col> |
|
25 |
<el-col :span="12"> |
|
26 |
<el-form-item prop="modelCode" :label="$t('healthEvaluate.modelCode')"> |
|
27 |
<el-input v-model="dataForm.modelCode" |
|
28 |
:placeholder="$t('healthEvaluate.modelCode')"></el-input> |
|
29 |
</el-form-item> |
|
30 |
</el-col> |
|
31 |
<!--<el-col :span="24"> |
|
32 |
<el-form-item prop="modelUrl" :label="$t('healthEvaluate.modelUrl')"> |
|
33 |
<el-input v-model="dataForm.modelUrl" |
|
34 |
:placeholder="$t('healthEvaluate.modelUrl')"></el-input> |
|
35 |
</el-form-item> |
|
36 |
</el-col>--> |
|
37 |
</el-row> |
|
38 |
<el-divider content-position="left">评价指标</el-divider> |
|
39 |
<el-row :gutter="20"> |
|
40 |
<el-col :span="4"> |
|
41 |
<el-button type="primary" size="mini" @click="addRow()">{{ $t('add') }}</el-button> |
|
42 |
</el-col> |
|
43 |
</el-row> |
|
44 |
<el-table :data="dataForm.indexList" border |
|
45 |
style="width: 100%; margin-top: 5px;"> |
|
46 |
<el-table-column |
|
47 |
prop="" |
|
48 |
label="输入排序" |
|
49 |
width="80" |
|
50 |
align="center"> |
|
51 |
<template slot-scope="scope"> |
|
52 |
<el-input-number size="mini" v-model="scope.row.paramOrder" :min="1" :max="50" |
|
53 |
:precision="0" |
|
54 |
:controls="false" clearable |
|
55 |
style="width:100%;hight:100%"></el-input-number> |
|
56 |
</template> |
|
57 |
</el-table-column> |
|
58 |
<el-table-column |
|
59 |
prop="" |
|
60 |
label="指标类型" |
|
61 |
align="center"> |
|
62 |
<template slot-scope="scope"> |
|
63 |
<dict-select-tag size="mini" style="width: 100%;" v-model="scope.row.indexType" dictCode="health_index_type" |
|
64 |
placeholder="指标类型"></dict-select-tag> |
|
65 |
</template> |
|
66 |
</el-table-column> |
|
67 |
<el-table-column |
|
68 |
prop="" |
|
69 |
label="参数类型" |
|
70 |
min-width="80" |
|
71 |
align="center"> |
|
72 |
<template slot-scope="scope"> |
|
73 |
<dict-select-tag style="width: 100%" size="mini" v-model="scope.row.paramType" dictCode="paramtype" |
|
74 |
@change="scope.row.paramId = ''" |
|
75 |
placeholder="请选择"></dict-select-tag> |
|
76 |
</template> |
|
77 |
</el-table-column> |
|
78 |
<el-table-column |
|
79 |
prop="" |
|
80 |
label="参数名称" |
|
81 |
min-width="160" |
|
82 |
align="center"> |
|
83 |
<template slot-scope="scope"> |
|
84 |
<!--测点选项--> |
|
85 |
<el-select v-if="scope.row.paramType === 'point'" |
|
86 |
style="width: 100%" size="mini" |
|
87 |
v-model="scope.row.paramId" filterable clearable |
|
88 |
placeholder="请选择"> |
|
89 |
<el-option |
|
90 |
v-for="(item, index) in pointList" |
|
91 |
:key="index" |
|
92 |
:label="item.pointName" |
|
93 |
:value="item.pointNo"> |
|
94 |
</el-option> |
|
95 |
</el-select> |
|
96 |
|
|
97 |
<!--指标项--> |
|
98 |
<el-select v-else-if="scope.row.paramType === 'ind'" |
|
99 |
style="width: 100%" size="mini" |
|
100 |
v-model="scope.row.paramId" filterable clearable |
|
101 |
placeholder="请选择"> |
|
102 |
<el-option |
|
103 |
v-for="(item, index) in indItemList" |
|
104 |
:key="index" |
|
105 |
:label="item.itemName" |
|
106 |
:value="item.itemNo"> |
|
107 |
</el-option> |
|
108 |
</el-select> |
|
109 |
|
|
110 |
<!--温振数据--> |
|
111 |
<el-select v-else-if="scope.row.paramType === 'wz'" |
|
112 |
style="width: 100%" size="mini" |
|
113 |
v-model="scope.row.paramId" filterable clearable |
|
114 |
placeholder="请选择"> |
|
115 |
<el-option |
|
116 |
v-for="(item, index) in wzList" |
|
117 |
:key="index" |
|
118 |
:label="item.tagName" |
|
119 |
:value="item.tagCode"> |
|
120 |
</el-option> |
|
121 |
</el-select> |
|
122 |
|
|
123 |
<!--其他--> |
|
124 |
<el-input v-else |
|
125 |
style="width: 100%" size="mini" |
|
126 |
v-model="scope.row.paramId"> |
|
127 |
</el-input> |
|
128 |
</template> |
|
129 |
</el-table-column> |
|
130 |
<el-table-column |
|
131 |
prop="" |
|
132 |
label="参数长度" |
|
133 |
width="100" |
|
134 |
align="center"> |
|
135 |
<template slot-scope="scope"> |
|
136 |
<el-input-number size="mini" |
|
137 |
v-model="scope.row.dataLength" |
|
138 |
:min="1" :max="10000" :precision="0" :controls="false" clearable |
|
139 |
style="width:100%;hight:100%"></el-input-number> |
|
140 |
</template> |
|
141 |
</el-table-column> |
|
142 |
<el-table-column |
|
143 |
prop="" |
|
144 |
label="额定值" |
|
145 |
width="100" |
|
146 |
align="center"> |
|
147 |
<template slot-scope="scope"> |
|
148 |
<el-input-number size="mini" |
|
149 |
v-model="scope.row.nominalValue" |
|
150 |
:min="0" :max="100000" :controls="false" clearable |
|
151 |
style="width:100%;hight:100%"></el-input-number> |
|
152 |
</template> |
|
153 |
</el-table-column> |
|
154 |
</el-table> |
|
155 |
</el-form> |
|
156 |
<template slot="footer"> |
|
157 |
<el-button :loading="loading" @click="visible = false">{{ $t('cancel') }}</el-button> |
|
158 |
<el-button :loading="loading" type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|
159 |
</template> |
|
160 |
</el-dialog> |
|
161 |
</template> |
|
162 |
<script> |
|
163 |
import debounce from 'lodash/debounce' |
|
164 |
import DictSelectTag from "@/components/dict/dict-select-tag"; |
|
165 |
|
|
166 |
export default { |
|
167 |
components: {DictSelectTag}, |
|
168 |
data() { |
|
169 |
return { |
|
170 |
visible: false, |
|
171 |
loading: false, |
|
172 |
devList: [], |
|
173 |
devMap: {}, |
|
174 |
modelList: [], |
|
175 |
modelMap: {}, |
|
176 |
pointList: [], |
|
177 |
pointMap: {}, |
|
178 |
indItemList: [], |
|
179 |
indItemMap: {}, |
|
180 |
wzList: [], |
|
181 |
wzMap: {}, |
|
182 |
paramAllMap: {}, |
|
183 |
dataForm: { |
|
184 |
id: '', |
|
185 |
devId: '', |
|
186 |
devNo: '', |
|
187 |
devName: '', |
|
188 |
modelCode: '', |
|
189 |
modelUrl: '', |
|
190 |
healthLevel: '10', |
|
191 |
healthScore: '100', |
|
192 |
abnormalCount: 0, |
|
193 |
isPushed: 0, |
|
194 |
isEnable: 1, |
|
195 |
indexList: [] |
|
196 |
} |
|
197 |
} |
|
198 |
}, |
|
199 |
computed: { |
|
200 |
dataRule() { |
|
201 |
return { |
|
202 |
devNo: [ |
|
203 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
204 |
], |
|
205 |
modelCode: [ |
|
206 |
{required: true, message: this.$t('validate.required'), trigger: 'blur'} |
|
207 |
] |
|
208 |
} |
|
209 |
} |
|
210 |
}, |
|
211 |
methods: { |
|
212 |
init() { |
|
213 |
this.visible = true |
|
214 |
this.$nextTick(() => { |
|
215 |
this.$refs['dataForm'].resetFields() |
|
216 |
this.dataForm.indexList = [] |
|
217 |
Promise.all([ |
|
218 |
this.getDevList(), |
|
219 |
this.getPointList(), |
|
220 |
this.getIndItemList(), |
|
221 |
this.getWzList() |
|
222 |
]).then(() => { |
|
223 |
if (this.dataForm.id) { |
|
224 |
this.getInfo() |
|
225 |
} |
|
226 |
}) |
|
227 |
}) |
|
228 |
}, |
|
229 |
// 获取设备列表 |
|
230 |
getDevList() { |
|
231 |
let params = { |
|
232 |
pid: '0' |
|
233 |
} |
|
234 |
return this.$http.get(`/iailab-ntt-model/device/device-info/list`, {params: params}).then(({data: res}) => { |
|
235 |
if (res.code !== 0) { |
|
236 |
return this.$message.error(res.msg) |
|
237 |
} |
|
238 |
this.devList = res.data |
|
239 |
res.data.forEach(function (value) { |
|
240 |
this.devMap[value.no] = value.name |
|
241 |
}, this) |
|
242 |
}) |
|
243 |
}, |
|
244 |
// 获取信息 |
|
245 |
getInfo() { |
|
246 |
this.loading = true |
|
247 |
this.$http.get(`/iailab-ntt-model/device/health-evaluate/${this.dataForm.id}`).then(({data: res}) => { |
|
248 |
this.loading = false |
|
249 |
if (res.code !== 0) { |
|
250 |
return this.$message.error(res.msg) |
|
251 |
} |
|
252 |
this.dataForm = { |
|
253 |
...this.dataForm, |
|
254 |
...res.data |
|
255 |
} |
|
256 |
}).catch(() => { |
|
257 |
}) |
|
258 |
}, |
|
259 |
// 添加行 |
|
260 |
addRow() { |
|
261 |
this.dataForm.indexList.push({ |
|
262 |
indexType: '', |
|
263 |
paramOrder: '', |
|
264 |
paramType: 'point', |
|
265 |
paramId: '', |
|
266 |
paramName: '', |
|
267 |
dataLength: '', |
|
268 |
nominalValue: '', |
|
269 |
}) |
|
270 |
}, |
|
271 |
// 删除行 |
|
272 |
deleteRow(index, rows) { |
|
273 |
rows.splice(index, 1) |
|
274 |
}, |
|
275 |
// 获取测点列表 |
|
276 |
getPointList() { |
|
277 |
let params; |
|
278 |
params = { |
|
279 |
isEnable: 1, |
|
280 |
pointNoLike: 'M00003' |
|
281 |
} |
|
282 |
this.pointList = [] |
|
283 |
return this.$http.get(`/iailab-ntt-data/da/point/pointNo`, {params: params}).then(({data: res}) => { |
|
284 |
if (res.code !== 0) { |
|
285 |
return this.$message.error(res.msg) |
|
286 |
} |
|
287 |
res.data.forEach(function (value) { |
|
288 |
this.pointList.push(value) |
|
289 |
this.pointMap[value.pointNo] = value.pointName |
|
290 |
this.paramAllMap['point_' + value.pointNo] = value.pointName |
|
291 |
}, this) |
|
292 |
}) |
|
293 |
}, |
|
294 |
// 获取指标项列表 |
|
295 |
getIndItemList() { |
|
296 |
let params; |
|
297 |
params = { |
|
298 |
isEnable: 1 |
|
299 |
} |
|
300 |
this.indItemList = [] |
|
301 |
return this.$http.get(`/iailab-ntt-data/ind/item/list`, {params: params}).then(({data: res}) => { |
|
302 |
if (res.code !== 0) { |
|
303 |
return this.$message.error(res.msg) |
|
304 |
} |
|
305 |
res.data.forEach(function (value) { |
|
306 |
this.indItemList.push(value) |
|
307 |
this.indItemMap[value.itemNo] = value.itemName |
|
308 |
this.paramAllMap['ind_' + value.itemNo] = value.itemName |
|
309 |
}, this) |
|
310 |
}) |
|
311 |
}, |
|
312 |
// 获取温振列表 |
|
313 |
getWzList() { |
|
314 |
let params = { |
|
315 |
httpApiCode: 'SDDeviceTemperature' |
|
316 |
} |
|
317 |
this.wzList = [] |
|
318 |
return this.$http.get(`/iailab-ntt-data/http/tag/tagNo`, {params: params}).then(({data: res}) => { |
|
319 |
if (res.code !== 0) { |
|
320 |
return this.$message.error(res.msg) |
|
321 |
} |
|
322 |
res.data.forEach(function (value) { |
|
323 |
this.wzList.push(value) |
|
324 |
this.wzMap[value.tagCode] = value.tagName |
|
325 |
this.paramAllMap['wz_' + value.tagCode] = value.tagName |
|
326 |
}, this) |
|
327 |
}) |
|
328 |
}, |
|
329 |
|
|
330 |
// 表单提交 |
|
331 |
dataFormSubmitHandle: debounce(function () { |
|
332 |
let that = this |
|
333 |
this.$refs['dataForm'].validate((valid) => { |
|
334 |
if (!valid) { |
|
335 |
return false |
|
336 |
} |
|
337 |
this.dataForm.devName = this.devMap[this.dataForm.devNo] |
|
338 |
this.dataForm.indexList.forEach(function (item) { |
|
339 |
item['paramName'] = that.paramAllMap[item.paramType + '_' + item.paramId] |
|
340 |
}) |
|
341 |
this.loading = true |
|
342 |
this.$http[!this.dataForm.id ? 'post' : 'put']('/iailab-ntt-model/device/health-evaluate', { |
|
343 |
...this.dataForm |
|
344 |
}).then(({data: res}) => { |
|
345 |
this.loading = false |
|
346 |
if (res.code !== 0) { |
|
347 |
return this.$message.error(res.msg) |
|
348 |
} |
|
349 |
this.$message({ |
|
350 |
message: this.$t('prompt.success'), |
|
351 |
type: 'success', |
|
352 |
duration: 500, |
|
353 |
onClose: () => { |
|
354 |
this.visible = false |
|
355 |
this.$emit('refreshDataList') |
|
356 |
} |
|
357 |
}) |
|
358 |
}).catch(() => { |
|
359 |
}) |
|
360 |
}) |
|
361 |
}, 1000, {'leading': true, 'trailing': false}) |
|
362 |
} |
|
363 |
} |
|
364 |
</script> |