dengzedong
2025-02-27 c1f166d492e9e1ebbd1be11ee7a46fc125df8464
提交 | 用户 | 时间
e26cd3 1 <template>
D 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="name">
12                 <el-input
13                         v-model="queryParams.name"
14                         placeholder="请输入名称"
15                         clearable
16                         @keyup.enter="handleQuery"
17                         class="!w-240px"
18                 />
19             </el-form-item>
20             <el-form-item>
21                 <el-button @click="handleQuery">
22                     <Icon icon="ep:search" class="mr-5px"/>
23                     搜索
24                 </el-button>
25                 <el-button @click="resetQuery">
26                     <Icon icon="ep:refresh" class="mr-5px"/>
27                     重置
28                 </el-button>
29                 <el-button
30                         type="primary"
31                         plain
32                         @click="openForm('create')"
33                 >
34                     <Icon icon="ep:plus" class="mr-5px"/>
35                     新增
36                 </el-button>
37             </el-form-item>
38         </el-form>
39     </ContentWrap>
40
41     <!-- 列表 -->
42     <ContentWrap>
43         <el-table v-loading="loading" :data="list">
44             <el-table-column label="名称" align="center" prop="name"/>
45             <el-table-column label="归档周期" align="center" prop="type"/>
46             <el-table-column label="归档点位" align="center" prop="point"/>
47             <el-table-column label="计算方法" align="center" prop="calculate"/>
48             <el-table-column label="是否启用" align="center" prop="isEnable"/>
49             <el-table-column label="操作" align="center" min-width="110" fixed="right">
50                 <template #default="scope">
51                     <el-button
52                             link
53                             type="primary"
54                             @click="openForm('update', scope.row.id)"
55                     >
56                         编辑
57                     </el-button>
58                     <el-button
59                             link
60                             type="primary"
61                             @click="openArcData(scope.row.id)"
62                     >
63                         历史值
64                     </el-button>
65                     <el-button
66                             link
67                             type="danger"
68                             @click="handleDelete(scope.row.id)"
69                     >
70                         删除
71                     </el-button>
72                 </template>
73             </el-table-column>
74         </el-table>
75         <!-- 分页 -->
76         <Pagination
77                 :total="total"
78                 v-model:page="queryParams.pageNo"
79                 v-model:limit="queryParams.pageSize"
80                 @pagination="getList"
81         />
82     </ContentWrap>
83
84     <!-- 表单弹窗:添加/修改 -->
85     <ArcSettingForm ref="formRef" @success="getList"/>
86
87     <!-- 历史值弹窗 -->
88     <ArcData ref="dataRef"/>
89
90 </template>
91 <script lang="ts" setup>
92     import * as ArcSetting from '@/api/data/arc/index'
93     import ArcSettingForm from './ArcSettingForm.vue'
94     import ArcData from './ArcData.vue'
95
96     defineOptions({name: 'DataArc'})
97
98     const message = useMessage() // 消息弹窗
99     const {t} = useI18n() // 国际化
100
101     const loading = ref(true) // 列表的加载中
102     const total = ref(0) // 列表的总页数
103     const list = ref([]) // 列表的数据
104     const queryParams = reactive({
105         pageNo: 1,
106         pageSize: 10,
107         name: undefined,
108         type: undefined
109     })
110     const queryFormRef = ref() // 搜索的表单
111     const exportLoading = ref(false) // 导出的加载中
112
113     /** 查询列表 */
114     const getList = async () => {
115         loading.value = true
116         try {
117             const page = await ArcSetting.getArcSettingPage(queryParams)
118             list.value = page.list
119             total.value = page.total
120         } finally {
121             loading.value = false
122         }
123     }
124
125     /** 搜索按钮操作 */
126     const handleQuery = () => {
127         queryParams.pageNo = 1
128         getList()
129     }
130
131     /** 重置按钮操作 */
132     const resetQuery = () => {
133         queryFormRef.value.resetFields()
134         handleQuery()
135     }
136
137     /** 添加/修改操作 */
138     const formRef = ref()
139     const openForm = (type: string, id?: number) => {
140         formRef.value.open(type, id)
141     }
142
143     /** 历史操作 */
144     const dataRef = ref()
145     const openArcData = (id?: string) => {
146       dataRef.value.open(id)
147     }
148
149     /** 删除按钮操作 */
150     const handleDelete = async (id: number) => {
151         try {
152             // 删除的二次确认
153             await message.delConfirm()
154             // 发起删除
155             await ArcSetting.deleteArcSetting(id)
156             message.success(t('common.delSuccess'))
157             // 刷新列表
158             await getList()
159         } catch {
160         }
161     }
162
163     /** 初始化 **/
164     onMounted(async () => {
165         await getList()
166     })
167 </script>