houzhongjian
2024-10-18 d916dfba2efa2d9359f5b432350a15e5ed1a0af4
提交 | 用户 | 时间
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"
17           class="!w-240px"
18         />
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"
26           class="!w-240px"
27         />
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"
35           class="!w-240px"
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>
56       </el-form-item>
57     </el-form>
58   </ContentWrap>
59
60   <!-- 列表 -->
61   <ContentWrap>
660c92 62     <el-table border stripe v-loading="loading" :data="list">
15a226 63       <el-table-column fixed label="测点编码" header-align="center" align="left" min-width="110" prop="pointNo" />
e9d8f9 64       <el-table-column label="测点名称" header-align="center" align="left" min-width="200" prop="pointName" />
65       <el-table-column label="测点类型" align="center" prop="pointType" width="100">
66         <template #default="scope">
67           <dict-tag :type="DICT_TYPE.DATA_POINT_TYPE" :value="scope.row.pointType" />
68         </template>
69       </el-table-column>
70       <el-table-column label="数据类型" align="center" prop="dataType" width="100">
71         <template #default="scope">
72           <dict-tag :type="DICT_TYPE.POINT_DATA_TYPE" :value="scope.row.dataType" />
15a226 73         </template>
L 74       </el-table-column>
75       <el-table-column label="值类型" align="center" prop="valueType" width="120">
76         <template #default="scope">
77           <dict-tag :type="DICT_TYPE.VALUETYPE" :value="scope.row.valueType" />
e9d8f9 78         </template>
79       </el-table-column>
80       <el-table-column label="测量单位" align="center" prop="unit" width="100"/>
1c14d6 81       <el-table-column label="单位转换" align="center" prop="unittransfactor" />
L 82       <el-table-column label="默认值" align="center" prop="defaultValue" />
e9d8f9 83       <el-table-column label="采集频率" align="center" prop="minfreqid" width="100"/>
84       <el-table-column label="数据源类型" align="center" prop="sourceType" width="100"/>
85       <el-table-column label="数据源名称" align="center" prop="sourceName" width="100"/>
86       <el-table-column label="测点Tag" header-align="center" align="left" prop="tagNo" min-width="150"/>
87       <el-table-column label="是否启用" align="center" prop="isEnable" width="100">
85c27f 88         <template #default="scope">
89           <el-tag v-if="scope.row.isEnable === 1" size="small">是</el-tag>
90           <el-tag v-else size="small" type="danger">否</el-tag>
91         </template>
92       </el-table-column>
1c14d6 93
e9d8f9 94       <el-table-column label="操作" align="center" min-width="110" fixed="right" width="120">
1c14d6 95         <template #default="scope">
L 96           <el-button
97             link
98             type="primary"
99             @click="openForm('update', scope.row.id)"
85c27f 100             v-hasPermi="['data:point:update']"
1c14d6 101           >
L 102             编辑
103           </el-button>
104           <el-button
105             link
106             type="danger"
107             @click="handleDelete(scope.row.id)"
85c27f 108             v-hasPermi="['data:point:delete']"
1c14d6 109           >
L 110             删除
111           </el-button>
112         </template>
113       </el-table-column>
114     </el-table>
115     <!-- 分页 -->
116     <Pagination
117       :total="total"
118       v-model:page="queryParams.pageNo"
119       v-model:limit="queryParams.pageSize"
120       @pagination="getList"
121     />
122   </ContentWrap>
123
124   <!-- 表单弹窗:添加/修改 -->
125   <DaPointForm ref="formRef" @success="getList" />
126
127 </template>
128 <script lang="ts" setup>
129 import DaPointForm from './DaPointForm.vue'
130 import * as DaPoint from '@/api/data/da/point'
15a226 131 import {DICT_TYPE} from "@/utils/dict";
1c14d6 132
85c27f 133 defineOptions({name: 'DataPoint'})
1c14d6 134
L 135   const message = useMessage() // 消息弹窗
136   const {t} = useI18n() // 国际化
137
138   const loading = ref(true) // 列表的加载中
139   const total = ref(0) // 列表的总页数
140   const list = ref([]) // 列表的数据
141   const queryParams = reactive({
142     pageNo: 1,
143     pageSize: 10,
144     pointNo: undefined,
145     pointName: undefined,
e9d8f9 146     tagNo: undefined,
1c14d6 147   })
L 148   const queryFormRef = ref() // 搜索的表单
149   const exportLoading = ref(false) // 导出的加载中
150
151   /** 查询列表 */
152   const getList = async () => {
153     loading.value = true
154     try {
155       const page = await DaPoint.getDaPointPage(queryParams)
156       list.value = page.list
157       total.value = page.total
158     } finally {
159       loading.value = false
160     }
161   }
162
163   /** 搜索按钮操作 */
164   const handleQuery = () => {
165     queryParams.pageNo = 1
166     getList()
167   }
168
169   /** 重置按钮操作 */
170   const resetQuery = () => {
171     queryFormRef.value.resetFields()
172     handleQuery()
173   }
174
175   /** 添加/修改操作 */
176   const formRef = ref()
177   const openForm = (type: string, id?: number) => {
178     formRef.value.open(type, id)
179   }
180
181   /** 删除按钮操作 */
182   const handleDelete = async (id: number) => {
183     try {
184       // 删除的二次确认
185       await message.delConfirm()
186       // 发起删除
187       await DaPoint.deleteDaPoint(id)
188       message.success(t('common.delSuccess'))
189       // 刷新列表
190       await getList()
191     } catch {
192     }
193   }
194
195   /** 初始化 **/
196   onMounted(async () => {
197     await getList()
198   })
199 </script>