houzhongjian
6 天以前 48175bd363565d32a46fa5b69733d84506e29789
提交 | 用户 | 时间
1c14d6 1 <template>
L 2   <!-- 搜索 -->
3   <ContentWrap>
4     <el-form
5       class="-mb-15px"
6       :model="queryParams"
7       ref="queryFormRef"
8       :inline="true"
9       label-width="68px"
10     >
11       <el-form-item label="测点编码" prop="pointNo">
12         <el-input
13           v-model="queryParams.pointNo"
14           placeholder="请输入测点编码"
15           clearable
16           @keyup.enter="handleQuery"
aba8b4 17           class="!w-200px"
1c14d6 18         />
L 19       </el-form-item>
20       <el-form-item label="测点名称" prop="pointName">
21         <el-input
22           v-model="queryParams.pointName"
23           placeholder="请输入测点名称"
24           clearable
25           @keyup.enter="handleQuery"
aba8b4 26           class="!w-200px"
1c14d6 27         />
L 28       </el-form-item>
e9d8f9 29       <el-form-item label="测点Tag" prop="tagNo">
30         <el-input
31           v-model="queryParams.tagNo"
32           placeholder="请输入测点Tag"
33           clearable
34           @keyup.enter="handleQuery"
aba8b4 35           class="!w-200px"
e9d8f9 36         />
37       </el-form-item>
1c14d6 38       <el-form-item>
L 39         <el-button @click="handleQuery">
40           <Icon icon="ep:search" class="mr-5px" />
41           搜索
42         </el-button>
43         <el-button @click="resetQuery">
44           <Icon icon="ep:refresh" class="mr-5px" />
45           重置
46         </el-button>
47         <el-button
48           type="primary"
49           plain
50           @click="openForm('create')"
85c27f 51           v-hasPermi="['data:point:create']"
1c14d6 52         >
L 53           <Icon icon="ep:plus" class="mr-5px" />
54           新增
55         </el-button>
031c25 56         <el-button
D 57           type="warning"
58           plain
59           @click="handleImport"
60           v-hasPermi="['data:point:import']"
61         >
62           <Icon icon="ep:upload" /> 导入
63         </el-button>
64         <el-button
65           type="success"
66           plain
67           @click="handleExport"
68           :loading="exportLoading"
69           v-hasPermi="['data:point:export']"
70         >
71           <Icon icon="ep:download" />导出
72         </el-button>
5d8c73 73         <el-button
J 74           type="success"
75           plain
76           @click="enable"
77           v-hasPermi="['data:point:update']"
78         >启用
79         </el-button>
80         <el-button
81           type="danger"
82           plain
83           @click="disable"
84           v-hasPermi="['data:point:update']"
85         >禁用
86         </el-button>
1c14d6 87       </el-form-item>
L 88     </el-form>
89   </ContentWrap>
90
91   <!-- 列表 -->
92   <ContentWrap>
5d8c73 93     <el-table border stripe v-loading="loading" :data="list" @selection-change="selectionChangeHandle">
de0f62 94       <el-table-column type="selection" header-align="center" align="center" fixed="left" width="50"/>
5d8c73 95       <el-table-column fixed label="测点编码" header-align="center" align="left" min-width="130" prop="pointNo" />
de0f62 96       <el-table-column fixed label="测点名称" header-align="center" align="left" min-width="240" prop="pointName" />
e9d8f9 97       <el-table-column label="测点类型" align="center" prop="pointType" width="100">
98         <template #default="scope">
99           <dict-tag :type="DICT_TYPE.DATA_POINT_TYPE" :value="scope.row.pointType" />
100         </template>
101       </el-table-column>
102       <el-table-column label="数据类型" align="center" prop="dataType" width="100">
103         <template #default="scope">
104           <dict-tag :type="DICT_TYPE.POINT_DATA_TYPE" :value="scope.row.dataType" />
15a226 105         </template>
L 106       </el-table-column>
107       <el-table-column label="值类型" align="center" prop="valueType" width="120">
108         <template #default="scope">
df90c0 109           <dict-tag :type="DICT_TYPE.MEASURE_VALUE_TYPE" :value="scope.row.valueType" />
e9d8f9 110         </template>
111       </el-table-column>
c4b4d2 112       <el-table-column label="测量单位" align="center" prop="unit" width="80"/>
1c14d6 113       <el-table-column label="单位转换" align="center" prop="unittransfactor" />
c4b4d2 114       <el-table-column label="默认值" align="center" prop="defaultValue" width="100"/>
e9d8f9 115       <el-table-column label="采集频率" align="center" prop="minfreqid" width="100"/>
c4b4d2 116       <el-table-column label="数据源类型" align="center" prop="sourceType" min-width="100"/>
117       <el-table-column label="数据源名称" align="center" prop="sourceName" min-width="100"/>
e9d8f9 118       <el-table-column label="测点Tag" header-align="center" align="left" prop="tagNo" min-width="150"/>
de0f62 119       <el-table-column label="采集值" header-align="center" align="center" prop="collectValue" min-width="150"/>
120       <el-table-column label="采集质量" header-align="center" align="center" prop="collectQuality" min-width="150">
121         <template #default="scope">
122           <el-tag v-if="scope.row.collectQuality === 'Good'" size="small" type="success">{{scope.row.collectQuality}}</el-tag>
123           <el-tag v-if="scope.row.collectQuality === 'Bad'" size="small" type="danger">{{scope.row.collectQuality}}</el-tag>
124         </template>
125       </el-table-column>
126       <el-table-column label="采集时间" header-align="center" align="center" prop="collectTime" min-width="150"/>
5d8c73 127       <el-table-column label="是否启用" align="center" prop="isEnable" width="85">
85c27f 128         <template #default="scope">
129           <el-tag v-if="scope.row.isEnable === 1" size="small">是</el-tag>
130           <el-tag v-else size="small" type="danger">否</el-tag>
131         </template>
132       </el-table-column>
1c14d6 133
5d8c73 134       <el-table-column label="操作" align="center" min-width="130" fixed="right" width="120">
1c14d6 135         <template #default="scope">
L 136           <el-button
137             link
c4b4d2 138             size="mini"
1c14d6 139             type="primary"
L 140             @click="openForm('update', scope.row.id)"
85c27f 141             v-hasPermi="['data:point:update']"
1c14d6 142           >
L 143             编辑
144           </el-button>
c4b4d2 145           <el-button link size="mini" type="primary" @click="chartHandle(scope.row)">数据</el-button>
1c14d6 146           <el-button
L 147             link
c4b4d2 148             size="mini"
1c14d6 149             type="danger"
L 150             @click="handleDelete(scope.row.id)"
85c27f 151             v-hasPermi="['data:point:delete']"
1c14d6 152           >
L 153             删除
154           </el-button>
155         </template>
156       </el-table-column>
157     </el-table>
158     <!-- 分页 -->
159     <Pagination
160       :total="total"
161       v-model:page="queryParams.pageNo"
162       v-model:limit="queryParams.pageSize"
163       @pagination="getList"
164     />
165   </ContentWrap>
166
167   <!-- 表单弹窗:添加/修改 -->
168   <DaPointForm ref="formRef" @success="getList" />
169
031c25 170   <DaPointChart ref="chartView" />
D 171
172   <!-- 用户导入对话框 -->
173   <PointImportForm ref="importFormRef" @success="getList" />
1c14d6 174 </template>
L 175 <script lang="ts" setup>
176 import * as DaPoint from '@/api/data/da/point'
5d8c73 177 import {ref, reactive} from "vue";
031c25 178 import download from "@/utils/download";
D 179 import {DICT_TYPE, getDictOptions} from "@/utils/dict";
180 import DaPointForm from './DaPointForm.vue'
181 import DaPointChart from './DaPointChart.vue'
182 import * as UserApi from "@/api/system/user";
c52be7 183 import PointImportForm from './PointImportForm.vue'
1c14d6 184
85c27f 185 defineOptions({name: 'DataPoint'})
1c14d6 186
L 187   const message = useMessage() // 消息弹窗
188   const {t} = useI18n() // 国际化
189
190   const loading = ref(true) // 列表的加载中
191   const total = ref(0) // 列表的总页数
192   const list = ref([]) // 列表的数据
193   const queryParams = reactive({
194     pageNo: 1,
195     pageSize: 10,
196     pointNo: undefined,
197     pointName: undefined,
e9d8f9 198     tagNo: undefined,
1c14d6 199   })
L 200   const queryFormRef = ref() // 搜索的表单
201
202   /** 查询列表 */
203   const getList = async () => {
204     loading.value = true
205     try {
206       const page = await DaPoint.getDaPointPage(queryParams)
207       list.value = page.list
208       total.value = page.total
209     } finally {
210       loading.value = false
211     }
212   }
213
214   /** 搜索按钮操作 */
215   const handleQuery = () => {
216     queryParams.pageNo = 1
217     getList()
031c25 218   }
D 219
220   /** 查看数据操作 */
221   const chartView  = ref()
222   const chartHandle = (raw: object) => {
223     chartView.value.open(raw)
1c14d6 224   }
L 225
226   /** 重置按钮操作 */
227   const resetQuery = () => {
228     queryFormRef.value.resetFields()
229     handleQuery()
230   }
231
232   /** 添加/修改操作 */
233   const formRef = ref()
234   const openForm = (type: string, id?: number) => {
235     formRef.value.open(type, id)
236   }
237
238   /** 删除按钮操作 */
239   const handleDelete = async (id: number) => {
240     try {
241       // 删除的二次确认
242       await message.delConfirm()
243       // 发起删除
244       await DaPoint.deleteDaPoint(id)
245       message.success(t('common.delSuccess'))
246       // 刷新列表
247       await getList()
248     } catch {
249     }
250   }
031c25 251   /** 测点导入 */
D 252   const importFormRef = ref()
253   const handleImport = () => {
254     importFormRef.value.open()
255   }
1c14d6 256
031c25 257   /** 导出按钮操作 */
D 258   const exportLoading = ref(false)
259   const handleExport = async () => {
260     try {
261       // 导出的二次确认
262       await message.exportConfirm()
263       // 发起导出
264       exportLoading.value = true
265       const data = await DaPoint.exportDaPoint(queryParams)
813ce2 266       download.excel(data, '测点列表.xlsx')
031c25 267     } catch {
D 268     } finally {
269       exportLoading.value = false
270     }
271   }
5d8c73 272
J 273   let dataListSelections = reactive([])
274   // 多选
275   function selectionChangeHandle (val) {
276     dataListSelections = val
277   }
278   // 启用
279   async function enable() {
280     let ids = dataListSelections.map(item => {
281       return item.id
282     })
283     // 启用的二次确认
284     await message.enableConfirm(ids)
285
286     await DaPoint.enable(ids)
287     message.success(t('common.enableSuccess'))
288     await getList()
289   }
290   // 禁用
291   async function disable(){
292     let ids = dataListSelections.map(item => {
293       return item.id
294     })
295     // 启用的二次确认
296     await message.disableConfirm(ids,)
297
298     await DaPoint.disable(ids)
299     message.success(t('common.disableSuccess'))
300     await getList()
301   }
302
1c14d6 303   /** 初始化 **/
L 304   onMounted(async () => {
305     await getList()
306   })
307 </script>