提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-dialog :visible.sync="visible" title="模型配置" :close-on-click-modal="false" |
|
3 |
:close-on-press-escape="false"> |
|
4 |
<el-form :model="dataForm" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" |
|
5 |
:label-width="$i18n.locale === 'en-US' ? '160px' : '100px'"> |
|
6 |
<el-divider content-position="left">设备指标配置</el-divider> |
|
7 |
<el-row :gutter="24"> |
|
8 |
<el-col :span="4"> |
|
9 |
<el-button icon="add" type="primary" size="mini" @click="addRow(1)">{{ $t('add') }}</el-button> |
|
10 |
</el-col> |
|
11 |
</el-row> |
|
12 |
<el-table v-loading="dataListLoading" :data="dataForm.deviceIndexList" border |
|
13 |
style="width: 100%; margin-top: 5px;"> |
|
14 |
<el-table-column |
|
15 |
prop="" |
|
16 |
label="指标名称" |
|
17 |
min-width="250" |
|
18 |
align="center"> |
|
19 |
<template slot-scope="scope"> |
|
20 |
<el-select style="width: 100%" size="mini" |
|
21 |
v-model="scope.row.indexNo" filterable clearable |
|
22 |
placeholder="请选择"> |
|
23 |
<el-option |
|
24 |
v-for="(item, index) in pointList" |
|
25 |
:key="index" |
|
26 |
:label="item.tagName" |
|
27 |
:value="item.tagCode"> |
|
28 |
</el-option> |
|
29 |
</el-select> |
|
30 |
</template> |
|
31 |
</el-table-column> |
|
32 |
<el-table-column |
|
33 |
prop="" |
|
34 |
label="指标上限" |
|
35 |
width="150" |
|
36 |
align="center"> |
|
37 |
<template slot-scope="scope"> |
|
38 |
<el-input-number size="mini" |
|
39 |
v-model="scope.row.indexUpperLimit" |
|
40 |
:min="1" :max="10000" :precision="0" :controls="false" clearable |
|
41 |
style="width:100%;hight:100%"></el-input-number> |
|
42 |
</template> |
|
43 |
</el-table-column> |
|
44 |
<el-table-column |
|
45 |
prop="" |
|
46 |
label="指标下限" |
|
47 |
width="150" |
|
48 |
align="center"> |
|
49 |
<template slot-scope="scope"> |
|
50 |
<el-input-number size="mini" |
|
51 |
v-model="scope.row.indexLowerLimit" |
|
52 |
:min="1" :max="10000" :precision="0" :controls="false" clearable |
|
53 |
style="width:100%;hight:100%"></el-input-number> |
|
54 |
</template> |
|
55 |
</el-table-column> |
|
56 |
<el-table-column |
|
57 |
prop="" |
|
58 |
label="指标长度" |
|
59 |
width="150" |
|
60 |
align="center"> |
|
61 |
<template slot-scope="scope"> |
|
62 |
<el-input-number size="mini" |
|
63 |
v-model="scope.row.dataLength" |
|
64 |
:min="1" :max="10000" :precision="0" :controls="false" clearable |
|
65 |
style="width:100%;hight:100%"></el-input-number> |
|
66 |
</template> |
|
67 |
</el-table-column> |
|
68 |
<el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="100"> |
|
69 |
<template slot-scope="scope"> |
|
70 |
<el-button |
|
71 |
@click.native.prevent="deleteRow(scope.$index, dataForm.deviceIndexList)" |
|
72 |
type="text" |
|
73 |
size="mini"> |
|
74 |
删除 |
|
75 |
</el-button> |
|
76 |
</template> |
|
77 |
</el-table-column> |
|
78 |
</el-table> |
|
79 |
</el-form> |
|
80 |
<template slot="footer"> |
|
81 |
<el-button @click="visible = false">{{ $t('cancel') }}</el-button> |
|
82 |
<el-button type="primary" @click="dataFormSubmitHandle()">{{ $t('confirm') }}</el-button> |
|
83 |
</template> |
|
84 |
</el-dialog> |
|
85 |
</template> |
|
86 |
|
|
87 |
<script> |
|
88 |
import debounce from 'lodash/debounce' |
|
89 |
import DictSelectTag from "@/components/dict/dict-select-tag.vue"; |
|
90 |
|
|
91 |
export default { |
|
92 |
components: {DictSelectTag}, |
|
93 |
data() { |
|
94 |
return { |
|
95 |
dataListLoading: false, |
|
96 |
visible: false, |
|
97 |
loading: false, |
|
98 |
dataForm: { |
|
99 |
id: '', |
|
100 |
deviceId: '', |
|
101 |
deviceIndexList: [] |
|
102 |
}, |
|
103 |
pointList: [] |
|
104 |
} |
|
105 |
}, |
|
106 |
methods: { |
|
107 |
init() { |
|
108 |
this.dataListLoading = false |
|
109 |
this.visible = true |
|
110 |
this.loading = true |
|
111 |
this.$nextTick(() => { |
|
112 |
this.$refs['dataForm'].resetFields() |
|
113 |
this.dataForm.deviceIndexList = [] |
|
114 |
Promise.all([ |
|
115 |
this.getPointList() |
|
116 |
]).then(() => { |
|
117 |
if (this.dataForm.id) { |
|
118 |
this.getInfo() |
|
119 |
} |
|
120 |
}) |
|
121 |
}) |
|
122 |
}, |
|
123 |
// 获取信息 |
|
124 |
getInfo() { |
|
125 |
this.$http.get(`/iailab-ntt-model/device/device-info/${this.dataForm.id}`).then(({data: res}) => { |
|
126 |
if (res.code !== 0) { |
|
127 |
return this.$message.error(res.msg) |
|
128 |
} |
|
129 |
this.dataForm = { |
|
130 |
...this.dataForm, |
|
131 |
...res.data |
|
132 |
} |
|
133 |
this.loading = false |
|
134 |
}).catch(() => { |
|
135 |
}) |
|
136 |
}, |
|
137 |
// 添加行 |
|
138 |
addRow(id) { |
|
139 |
if (id == 1) { |
|
140 |
this.dataForm.deviceIndexList.push({ |
|
141 |
indexNo: '', |
|
142 |
indexLowerLimit:'', |
|
143 |
indexUpperLimit: '', |
|
144 |
dataLength: '', |
|
145 |
indexType: 'point' |
|
146 |
}) |
|
147 |
} |
|
148 |
}, |
|
149 |
// 删除行 |
|
150 |
deleteRow(index, rows) { |
|
151 |
rows.splice(index, 1) |
|
152 |
}, |
|
153 |
// 获取测点列表 |
|
154 |
getPointList() { |
|
155 |
let params = { |
|
156 |
id: this.dataForm.id, |
|
157 |
deviceId: this.dataForm.deviceId |
|
158 |
} |
|
159 |
this.pointList = [] |
|
160 |
return this.$http.get(`/iailab-ntt-data/http/tag/tagNo`, {params: params}).then(({data: res}) => { |
|
161 |
if (res.code !== 0) { |
|
162 |
return this.$message.error(res.msg) |
|
163 |
} |
|
164 |
res.data.forEach(function (value) { |
|
165 |
this.pointList.push(value) |
|
166 |
}, this) |
|
167 |
console.log(this.pointList) |
|
168 |
}) |
|
169 |
}, |
|
170 |
// 表单提交 |
|
171 |
dataFormSubmitHandle: debounce(function () { |
|
172 |
this.$refs['dataForm'].validate((valid) => { |
|
173 |
if (!valid) { |
|
174 |
return false |
|
175 |
} |
|
176 |
this.loading = true |
|
177 |
this.$http[!this.dataForm.id ? 'post' : 'put']('/iailab-ntt-model/device/device-info', this.dataForm).then(({data: res}) => { |
|
178 |
this.loading = false |
|
179 |
if (res.code !== 0) { |
|
180 |
return this.$message.error(res.msg) |
|
181 |
} |
|
182 |
this.$message({ |
|
183 |
message: this.$t('prompt.success'), |
|
184 |
type: 'success', |
|
185 |
duration: 500, |
|
186 |
onClose: () => { |
|
187 |
this.visible = false |
|
188 |
this.$emit('refreshDataList') |
|
189 |
} |
|
190 |
}) |
|
191 |
}).catch(() => { |
|
192 |
}) |
|
193 |
}) |
|
194 |
}, 1000, {'leading': true, 'trailing': false}) |
|
195 |
} |
|
196 |
} |
|
197 |
</script> |