提交 | 用户 | 时间
|
850106
|
1 |
<template> |
H |
2 |
<el-drawer |
|
3 |
direction="rtl" |
|
4 |
:visible.sync="visible" |
|
5 |
@close="handleClose" |
|
6 |
size="50%" |
|
7 |
append-to-body> |
|
8 |
<div style="padding: 10px;"> |
|
9 |
<el-form |
|
10 |
:inline="true" |
|
11 |
:model="dataForm" |
|
12 |
ref="dataForm" |
|
13 |
@keyup.enter.native="getDataList()" |
|
14 |
> |
|
15 |
<el-form-item prop="tagType"> |
|
16 |
<el-input |
|
17 |
v-model="dataForm.tagType" |
|
18 |
placeholder="Tag类型" |
|
19 |
clearable> |
|
20 |
</el-input> |
|
21 |
</el-form-item> |
|
22 |
<el-form-item prop="tagCode"> |
|
23 |
<el-input |
|
24 |
v-model="dataForm.tagCode" |
|
25 |
placeholder="Tag编码" |
|
26 |
clearable> |
|
27 |
</el-input> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item> |
|
30 |
<el-button @click="getDataList()" |
|
31 |
>{{ $t("query") }} |
|
32 |
</el-button> |
|
33 |
</el-form-item> |
|
34 |
<el-form-item> |
|
35 |
<el-button type="primary" @click="addOrUpdateHandle()" |
|
36 |
>新增 |
|
37 |
</el-button> |
|
38 |
</el-form-item> |
|
39 |
</el-form> |
|
40 |
<el-table |
|
41 |
v-loading="dataListLoading" |
|
42 |
:data="dataList" |
|
43 |
border |
|
44 |
style="width: 100%" |
|
45 |
> |
|
46 |
<el-table-column |
|
47 |
prop="tagType" |
|
48 |
label="Tag类型" |
|
49 |
header-align="center" |
|
50 |
align="left" |
|
51 |
min-width="100" |
|
52 |
></el-table-column> |
|
53 |
<el-table-column |
|
54 |
prop="tagCode" |
|
55 |
label="Tag编码" |
|
56 |
header-align="center" |
|
57 |
align="left" |
|
58 |
min-width="100" |
|
59 |
></el-table-column> |
|
60 |
<el-table-column |
|
61 |
prop="tagName" |
|
62 |
label="Tag名称" |
|
63 |
header-align="center" |
|
64 |
align="left" |
|
65 |
min-width="100" |
|
66 |
></el-table-column> |
|
67 |
</el-table> |
|
68 |
<el-pagination |
|
69 |
@size-change="sizeChangeHandle" |
|
70 |
@current-change="currentChangeHandle" |
|
71 |
:current-page="pageIndex" |
|
72 |
:page-sizes="[10, 20, 50, 100]" |
|
73 |
:page-size="pageSize" |
|
74 |
:total="totalPage" |
|
75 |
layout="total, sizes, prev, pager, next, jumper" |
|
76 |
> |
|
77 |
</el-pagination> |
|
78 |
</div> |
|
79 |
</el-drawer> |
|
80 |
</template> |
|
81 |
|
|
82 |
<script> |
|
83 |
export default { |
|
84 |
props: { |
|
85 |
address: String, |
|
86 |
}, |
|
87 |
data() { |
|
88 |
return { |
|
89 |
visible: false, |
|
90 |
dataForm: { |
|
91 |
tagType: '', |
|
92 |
tagCode: '', |
|
93 |
tagName: '' |
|
94 |
}, |
|
95 |
dataList: [], |
|
96 |
pageIndex: 1, |
|
97 |
pageSize: 10, |
|
98 |
totalPage: 0, |
|
99 |
dataListLoading: false, |
|
100 |
}; |
|
101 |
}, |
|
102 |
mounted() { |
|
103 |
this.getDataList(); |
|
104 |
}, |
|
105 |
|
|
106 |
methods: { |
|
107 |
init(name, code) { |
|
108 |
this.importUrl = '/proxyApi/iailab-ntt-data/http/tag/import/' + name |
|
109 |
this.listUrl = '/iailab-ntt-data/http/tag/page', |
|
110 |
this.deleteUrl = '/iailab-ntt-data/http/tag/delete', |
|
111 |
this.code = code |
|
112 |
this.visible = true; |
|
113 |
this.$nextTick(() => { |
|
114 |
this.$refs['dataForm'].resetFields() |
|
115 |
this.getDataList(); |
|
116 |
}); |
|
117 |
}, |
|
118 |
handleClose() { |
|
119 |
// this.$refs["dataForm"].resetFields(); |
|
120 |
this.dataList = []; |
|
121 |
}, |
|
122 |
// 获取数据列表 |
|
123 |
getDataList() { |
|
124 |
this.dataListLoading = true; |
|
125 |
this.$http({ |
|
126 |
url: this.listUrl, |
|
127 |
method: "get", |
|
128 |
params: this.$http.adornParams({ |
|
129 |
page: this.pageIndex, |
|
130 |
limit: this.pageSize, |
|
131 |
httpApiCode: this.code, |
|
132 |
}), |
|
133 |
}).then(({data}) => { |
|
134 |
if (data && data.code === 0) { |
|
135 |
this.dataList = data.page.list; |
|
136 |
this.totalPage = data.page.totalCount; |
|
137 |
} else { |
|
138 |
this.dataList = []; |
|
139 |
this.totalPage = 0; |
|
140 |
} |
|
141 |
this.dataListLoading = false; |
|
142 |
}); |
|
143 |
}, |
|
144 |
// 每页数 |
|
145 |
sizeChangeHandle(val) { |
|
146 |
this.pageSize = val; |
|
147 |
this.pageIndex = 1; |
|
148 |
this.getDataList(); |
|
149 |
}, |
|
150 |
// 当前页 |
|
151 |
currentChangeHandle(val) { |
|
152 |
this.pageIndex = val; |
|
153 |
this.getDataList(); |
|
154 |
}, |
|
155 |
// 多选 |
|
156 |
selectionChangeHandle(val) { |
|
157 |
this.dataListSelections = val; |
|
158 |
}, |
|
159 |
// 新增 / 修改 |
|
160 |
addOrUpdateHandle(id) { |
|
161 |
this.addOrUpdateVisible = true; |
|
162 |
this.$nextTick(() => { |
|
163 |
this.$refs.addOrUpdate.init( |
|
164 |
id, |
|
165 |
this.code, |
|
166 |
this.dataForm.device, |
|
167 |
this.dataForm.address, |
|
168 |
); |
|
169 |
}); |
|
170 |
}, |
|
171 |
// 删除 |
|
172 |
deleteHandle(id) { |
|
173 |
this.$confirm(`确定对选中项进行删除操作?`, "提示", { |
|
174 |
confirmButtonText: "确定", |
|
175 |
cancelButtonText: "取消", |
|
176 |
type: "warning", |
|
177 |
}) |
|
178 |
.then(() => { |
|
179 |
this.$http({ |
|
180 |
headers: { |
|
181 |
"Content-Type": "application/json", |
|
182 |
}, |
|
183 |
url: this.deleteUrl, |
|
184 |
method: "post", |
|
185 |
data: this.$http.adornData({ |
|
186 |
id: id, |
|
187 |
}), |
|
188 |
}).then(({data}) => { |
|
189 |
if (data && data.code === 0) { |
|
190 |
this.$message({ |
|
191 |
message: "操作成功", |
|
192 |
type: "success", |
|
193 |
duration: 1500, |
|
194 |
onClose: () => { |
|
195 |
this.getDataList(); |
|
196 |
}, |
|
197 |
}); |
|
198 |
} else { |
|
199 |
this.$message.error(data.msg); |
|
200 |
} |
|
201 |
}); |
|
202 |
}) |
|
203 |
.catch(() => { |
|
204 |
}); |
|
205 |
}, |
|
206 |
}, |
|
207 |
}; |
|
208 |
</script> |