houzhongjian
2024-11-27 fd13b0017518273406ee1a9906c07d079e4a9ac4
提交 | 用户 | 时间
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">
J 94       <el-table-column type="selection" header-align="center" align="center" width="50"/>
95       <el-table-column fixed label="测点编码" header-align="center" align="left" min-width="130" prop="pointNo" />
96       <el-table-column label="测点名称" header-align="center" align="left" min-width="220" 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"/>
5d8c73 119       <el-table-column label="是否启用" align="center" prop="isEnable" width="85">
85c27f 120         <template #default="scope">
121           <el-tag v-if="scope.row.isEnable === 1" size="small">是</el-tag>
122           <el-tag v-else size="small" type="danger">否</el-tag>
123         </template>
124       </el-table-column>
1c14d6 125
5d8c73 126       <el-table-column label="操作" align="center" min-width="130" fixed="right" width="120">
1c14d6 127         <template #default="scope">
L 128           <el-button
129             link
c4b4d2 130             size="mini"
1c14d6 131             type="primary"
L 132             @click="openForm('update', scope.row.id)"
85c27f 133             v-hasPermi="['data:point:update']"
1c14d6 134           >
L 135             编辑
136           </el-button>
c4b4d2 137           <el-button link size="mini" type="primary" @click="chartHandle(scope.row)">数据</el-button>
1c14d6 138           <el-button
L 139             link
c4b4d2 140             size="mini"
1c14d6 141             type="danger"
L 142             @click="handleDelete(scope.row.id)"
85c27f 143             v-hasPermi="['data:point:delete']"
1c14d6 144           >
L 145             删除
146           </el-button>
147         </template>
148       </el-table-column>
149     </el-table>
150     <!-- 分页 -->
151     <Pagination
152       :total="total"
153       v-model:page="queryParams.pageNo"
154       v-model:limit="queryParams.pageSize"
155       @pagination="getList"
156     />
157   </ContentWrap>
158
159   <!-- 表单弹窗:添加/修改 -->
160   <DaPointForm ref="formRef" @success="getList" />
161
031c25 162   <DaPointChart ref="chartView" />
D 163
164   <!-- 用户导入对话框 -->
165   <PointImportForm ref="importFormRef" @success="getList" />
1c14d6 166 </template>
L 167 <script lang="ts" setup>
168 import * as DaPoint from '@/api/data/da/point'
5d8c73 169 import {ref, reactive} from "vue";
031c25 170 import download from "@/utils/download";
D 171 import {DICT_TYPE, getDictOptions} from "@/utils/dict";
172 import DaPointForm from './DaPointForm.vue'
173 import DaPointChart from './DaPointChart.vue'
174 import * as UserApi from "@/api/system/user";
c52be7 175 import PointImportForm from './PointImportForm.vue'
1c14d6 176
85c27f 177 defineOptions({name: 'DataPoint'})
1c14d6 178
L 179   const message = useMessage() // 消息弹窗
180   const {t} = useI18n() // 国际化
181
182   const loading = ref(true) // 列表的加载中
183   const total = ref(0) // 列表的总页数
184   const list = ref([]) // 列表的数据
185   const queryParams = reactive({
186     pageNo: 1,
187     pageSize: 10,
188     pointNo: undefined,
189     pointName: undefined,
e9d8f9 190     tagNo: undefined,
1c14d6 191   })
L 192   const queryFormRef = ref() // 搜索的表单
193
194   /** 查询列表 */
195   const getList = async () => {
196     loading.value = true
197     try {
198       const page = await DaPoint.getDaPointPage(queryParams)
199       list.value = page.list
200       total.value = page.total
201     } finally {
202       loading.value = false
203     }
204   }
205
206   /** 搜索按钮操作 */
207   const handleQuery = () => {
208     queryParams.pageNo = 1
209     getList()
031c25 210   }
D 211
212   /** 查看数据操作 */
213   const chartView  = ref()
214   const chartHandle = (raw: object) => {
215     chartView.value.open(raw)
1c14d6 216   }
L 217
218   /** 重置按钮操作 */
219   const resetQuery = () => {
220     queryFormRef.value.resetFields()
221     handleQuery()
222   }
223
224   /** 添加/修改操作 */
225   const formRef = ref()
226   const openForm = (type: string, id?: number) => {
227     formRef.value.open(type, id)
228   }
229
230   /** 删除按钮操作 */
231   const handleDelete = async (id: number) => {
232     try {
233       // 删除的二次确认
234       await message.delConfirm()
235       // 发起删除
236       await DaPoint.deleteDaPoint(id)
237       message.success(t('common.delSuccess'))
238       // 刷新列表
239       await getList()
240     } catch {
241     }
242   }
031c25 243   /** 测点导入 */
D 244   const importFormRef = ref()
245   const handleImport = () => {
246     importFormRef.value.open()
247   }
1c14d6 248
031c25 249   /** 导出按钮操作 */
D 250   const exportLoading = ref(false)
251   const handleExport = async () => {
252     try {
253       // 导出的二次确认
254       await message.exportConfirm()
255       // 发起导出
256       exportLoading.value = true
257       const data = await DaPoint.exportDaPoint(queryParams)
813ce2 258       download.excel(data, '测点列表.xlsx')
031c25 259     } catch {
D 260     } finally {
261       exportLoading.value = false
262     }
263   }
5d8c73 264
J 265   let dataListSelections = reactive([])
266   // 多选
267   function selectionChangeHandle (val) {
268     dataListSelections = val
269   }
270   // 启用
271   async function enable() {
272     let ids = dataListSelections.map(item => {
273       return item.id
274     })
275     // 启用的二次确认
276     await message.enableConfirm(ids)
277
278     await DaPoint.enable(ids)
279     message.success(t('common.enableSuccess'))
280     await getList()
281   }
282   // 禁用
283   async function disable(){
284     let ids = dataListSelections.map(item => {
285       return item.id
286     })
287     // 启用的二次确认
288     await message.disableConfirm(ids,)
289
290     await DaPoint.disable(ids)
291     message.success(t('common.disableSuccess'))
292     await getList()
293   }
294
1c14d6 295   /** 初始化 **/
L 296   onMounted(async () => {
297     await getList()
298   })
299 </script>