沙钢智慧能源系统前端代码
houzhongjian
2024-10-09 314507f8ddadd9c66e98d260c3b2a5dad1a04015
提交 | 用户 | 时间
314507 1 <template>
H 2   <ContentWrap>
3     <!-- 搜索工作栏 -->
4     <el-form
5       ref="queryFormRef"
6       :inline="true"
7       :model="queryParams"
8       class="-mb-15px"
9       label-width="130px"
10     >
11       <el-form-item label="应用名" prop="name">
12         <el-input
13           v-model="queryParams.name"
14           class="!w-240px"
15           clearable
16           placeholder="请输入应用名"
17           @keyup.enter="handleQuery"
18         />
19       </el-form-item>
20       <el-form-item label="社交平台" prop="socialType">
21         <el-select
22           v-model="queryParams.socialType"
23           class="!w-240px"
24           clearable
25           placeholder="请选择社交平台"
26         >
27           <el-option
28             v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_SOCIAL_TYPE)"
29             :key="dict.value"
30             :label="dict.label"
31             :value="dict.value"
32           />
33         </el-select>
34       </el-form-item>
35       <el-form-item label="用户类型" prop="userType">
36         <el-select
37           v-model="queryParams.userType"
38           class="!w-240px"
39           clearable
40           placeholder="请选择用户类型"
41         >
42           <el-option
43             v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
44             :key="dict.value"
45             :label="dict.label"
46             :value="dict.value"
47           />
48         </el-select>
49       </el-form-item>
50       <el-form-item label="客户端编号" prop="clientId">
51         <el-input
52           v-model="queryParams.clientId"
53           class="!w-240px"
54           clearable
55           placeholder="请输入客户端编号"
56           @keyup.enter="handleQuery"
57         />
58       </el-form-item>
59       <el-form-item label="状态" prop="status">
60         <el-select v-model="queryParams.status" class="!w-240px" clearable placeholder="请选择状态">
61           <el-option
62             v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
63             :key="dict.value"
64             :label="dict.label"
65             :value="dict.value"
66           />
67         </el-select>
68       </el-form-item>
69       <el-form-item>
70         <el-button @click="handleQuery">
71           <Icon class="mr-5px" icon="ep:search" />
72           搜索
73         </el-button>
74         <el-button @click="resetQuery">
75           <Icon class="mr-5px" icon="ep:refresh" />
76           重置
77         </el-button>
78         <el-button
79           v-hasPermi="['system:social-client:create']"
80           plain
81           type="primary"
82           @click="openForm('create')"
83         >
84           <Icon class="mr-5px" icon="ep:plus" />
85           新增
86         </el-button>
87       </el-form-item>
88     </el-form>
89   </ContentWrap>
90
91   <!-- 列表 -->
92   <ContentWrap>
93     <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
94       <el-table-column align="center" label="编号" prop="id" />
95       <el-table-column align="center" label="应用名" prop="name" />
96       <el-table-column align="center" label="社交平台" prop="socialType">
97         <template #default="scope">
98           <dict-tag :type="DICT_TYPE.SYSTEM_SOCIAL_TYPE" :value="scope.row.socialType" />
99         </template>
100       </el-table-column>
101       <el-table-column align="center" label="用户类型" prop="userType">
102         <template #default="scope">
103           <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
104         </template>
105       </el-table-column>
106       <el-table-column align="center" label="客户端编号" prop="clientId" width="180px" />
107       <el-table-column align="center" label="状态" prop="status">
108         <template #default="scope">
109           <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
110         </template>
111       </el-table-column>
112       <el-table-column
113         :formatter="dateFormatter"
114         align="center"
115         label="创建时间"
116         prop="createTime"
117         width="180px"
118       />
119       <el-table-column align="center" label="操作">
120         <template #default="scope">
121           <el-button
122             v-hasPermi="['system:social-client:update']"
123             link
124             type="primary"
125             @click="openForm('update', scope.row.id)"
126           >
127             编辑
128           </el-button>
129           <el-button
130             v-hasPermi="['system:social-client:delete']"
131             link
132             type="danger"
133             @click="handleDelete(scope.row.id)"
134           >
135             删除
136           </el-button>
137         </template>
138       </el-table-column>
139     </el-table>
140     <!-- 分页 -->
141     <Pagination
142       v-model:limit="queryParams.pageSize"
143       v-model:page="queryParams.pageNo"
144       :total="total"
145       @pagination="getList"
146     />
147   </ContentWrap>
148
149   <!-- 表单弹窗:添加/修改 -->
150   <SocialClientForm ref="formRef" @success="getList" />
151 </template>
152
153 <script lang="ts" setup>
154 import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
155 import { dateFormatter } from '@/utils/formatTime'
156 import * as SocialClientApi from '@/api/system/social/client'
157 import SocialClientForm from './SocialClientForm.vue'
158
159 defineOptions({ name: 'SocialClient' })
160
161 const message = useMessage() // 消息弹窗
162 const { t } = useI18n() // 国际化
163
164 const loading = ref(true) // 列表的加载中
165 const total = ref(0) // 列表的总页数
166 const list = ref([]) // 列表的数据
167 const queryParams = reactive({
168   pageNo: 1,
169   pageSize: 10,
170   name: undefined,
171   socialType: undefined,
172   userType: undefined,
173   clientId: undefined,
174   status: undefined
175 })
176 const queryFormRef = ref() // 搜索的表单
177
178 /** 查询列表 */
179 const getList = async () => {
180   loading.value = true
181   try {
182     const data = await SocialClientApi.getSocialClientPage(queryParams)
183     list.value = data.list
184     total.value = data.total
185   } finally {
186     loading.value = false
187   }
188 }
189
190 /** 搜索按钮操作 */
191 const handleQuery = () => {
192   queryParams.pageNo = 1
193   getList()
194 }
195
196 /** 重置按钮操作 */
197 const resetQuery = () => {
198   queryFormRef.value.resetFields()
199   handleQuery()
200 }
201
202 /** 添加/修改操作 */
203 const formRef = ref()
204 const openForm = (type: string, id?: number) => {
205   formRef.value.open(type, id)
206 }
207
208 /** 删除按钮操作 */
209 const handleDelete = async (id: number) => {
210   try {
211     // 删除的二次确认
212     await message.delConfirm()
213     // 发起删除
214     await SocialClientApi.deleteSocialClient(id)
215     message.success(t('common.delSuccess'))
216     // 刷新列表
217     await getList()
218   } catch {}
219 }
220
221 /** 初始化 **/
222 onMounted(() => {
223   getList()
224 })
225 </script>