index.vue
8.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!--
* 功能:大屏配置
* 作者:闫李壮
* 日期:2024-6-15
-->
<template>
<div>
<a-card class="content">
<!-- 查询条件 start-->
<a-row>
<a-col :flex="1" style="margin-top: 4px;">
<a-form :model="searchModel" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
label-align="left"
auto-label-width>
<a-row :gutter="16">
<a-col :span="8">
<!-- 站点类型 -->
<a-form-item field="station" label="选择站点">
<a-tree-select allow-search
v-model="searchModel.deptId"
:data="siteList"
placeholder="请选择站点"
allow-clear
:fieldNames="{key: 'id', title: 'deptName'}"
:filter-tree-node="filterTreeNode">
</a-tree-select>
</a-form-item>
</a-col>
<a-col :span="8">
<!-- 模块类型 -->
<a-button type="primary" @click="search">
<template #icon>
<icon-search/>
</template>
{{ $t('global.search') }}
</a-button>
</a-col>
</a-row>
</a-form>
</a-col>
</a-row>
<!-- 查询条件 end-->
<!-- 分割线 -->
<a-divider style="margin-top: 0"/>
<!-- 按钮 -->
<a-row style="margin-bottom: 16px">
<a-col :span="12">
<a-space>
<a-button type="primary" @click="handleAdd">
新建大屏
</a-button>
</a-space>
</a-col>
</a-row>
<!-- 表格内容 start-->
<a-table :loading="loading"
:bordered="{ wrapper: true, cell: true }"
:columns="columns"
:data="renderData"
:pagination="pagination"
@page-change="handlePageChange"
@page-size-change="handlePageSizeChange">
<!-- 分组/站点 -->
<template #groupName="{ record }">
{{ record.groupName }} / {{ record.stationName }}
</template>
<!--模板类型-->
<template #pageType="{ record }">
{{ record.pageTemplate == 1 ? '默认模板' : record.pageTemplate == 2 ? '电力科技' : '-' }}
</template>
<!-- 状态 -->
<template #stopFlag="{ record }">
<stop-flag :value="record.stopFlag"></stop-flag>
</template>
<!-- 操作 -->
<template #operate="{ record }">
<a-button size="small" type="text" style="color:#0E88F6" status="success" @click="handlePreview(record)">预览
</a-button>
<a-button size="small" type="text" status="success" @click="handleCardConfig(record)">配置卡片</a-button>
<a-button size="small" type="text" :status="record.stopFlag == 1 ? 'normal' : 'warning'"
@click="handleStop(record)">
{{ record.stopFlag == 0 ? $t('global.forbidden') : $t('global.enable') }}
</a-button>
<a-button size="small" type="text" status="success" @click="handleUpdate(record.id)">{{ $t('global.edit') }}
</a-button>
<a-button size="small" type="text" status="danger" @click="handleDelete(record)">{{ $t('global.delete') }}
</a-button>
</template>
</a-table>
<!-- 表格内容 end-->
</a-card>
</div>
</template>
<script setup lang="ts">
import {onMounted, reactive, ref} from 'vue';
import useLoading from '@/hooks/loading';
import {Modal} from "@arco-design/web-vue";
import {BasePagination} from '@/api/common';
import {getConfigList, deleteConfigList, updateConfigStatus} from "@/api/manage/station";
import {useRouter} from 'vue-router';
import {getStationList} from '@/api/public';
import {processSelectableByCompany} from '@/utils/ruoyi';
import {notification} from "@/hooks/my-design";
import qs from "qs";
/*************************** 变量区域 begin ***************************/
//参数
//查询表单对象
const searchModel = ref({
deptId: '',
pageType: 1
});
//加载中
const {loading, setLoading} = useLoading(false);
//表格分页参数
const pagination: any = reactive({...BasePagination()});
//设置表格列
const columns: any = [
{
title: "单位",
dataIndex: "entName",
slotName: "entName",
},
{
title: "分组/站点",
dataIndex: "groupName",
slotName: "groupName",
},
{
title: "模板",
dataIndex: "pageType",
slotName: "pageType",
},
{
title: "标题",
dataIndex: "pageName",
slotName: "pageName",
},
{
title: "启用状态",
dataIndex: "stopFlag",
slotName: "stopFlag",
align: 'center',
width: 100,
fixed: "right"
},
{
title: "操作",
dataIndex: "operate",
width: 320,
slotName: 'operate',
align: 'center',
fixed: "right"
},
];
const siteList = ref<any>([]);
//路由
const router = useRouter();
const renderData = ref<any>([]);
/*************************** 变量区域 end ***************************/
/*************************** 方法区域 begin ***************************/
// 查询条件
const search = async () => {
pagination.current = 1;
await fetchData();
}
/**
* 站点搜索
* @param searchValue
* @param nodeData
*/
const filterTreeNode = (searchValue: any, nodeData: any) => {
return nodeData.deptName.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
}
/**
* 表格分页发生改变时触发
* @param val
*/
const handlePageChange = (val:number) => {
pagination.current = val;
fetchData();
}
/**
* 表格每页数据数量发生改变时触发
* @param val
*/
const handlePageSizeChange = (val:number) => {
pagination.pageSize = val;
fetchData();
}
/**
* 查询表格数据
*/
const fetchData = async () => {
setLoading(true);
try {
const res: any = await getConfigList({
pageSize: pagination.pageSize,
pageNum: pagination.current,
...searchModel.value,
});
if (res.code === 200) {
renderData.value = res.rows
pagination.total = res.total;
} else {
notification(res)
}
} catch (err) {
} finally {
setLoading(false);
}
}
/**
* 获取站点信息
*/
const fetchStationData = async () => {
try {
let res = await getStationList({});
if (res.code == 200) {
processSelectableByCompany(res.data)
siteList.value = res.data;
}
} catch (e) {
} finally {
}
}
// 删除
const handleDelete = (item: any) => {
Modal.error({
title: '提示',
content: `你确定要删除 ${item.pageName} 吗?`,
hideCancel: false,
bodyStyle: {
textAlign: 'center'
},
onOk: async () => {
try {
setLoading(true)
const res = await deleteConfigList(item.id)
if (res.code == 200) {
notification('success', '删除成功')
await fetchData();
}
} catch {
} finally {
setLoading(false)
}
},
});
}
// 新建
const handleCardConfig = (record: any) => {
router.push({
path: "/setting/station/dataList",
query: {
id: record.id,
entName: record.entName,
stationName: record.stationName,
deptId: record.deptId,
}
});
}
// 停用
const handleStop = (record: any) => {
const text = record.stopFlag == 1 ? '启用' : '停用';
const state = record.stopFlag == 1 ? 0 : 1;
Modal.warning({
title: '提示',
content: `你确定要${text} ${record.pageName} 吗?`,
hideCancel: false,
bodyStyle: {
textAlign: 'center'
},
onOk: async () => {
const data = {
id: record.id,
state: state
}
try {
setLoading(true)
const res = await updateConfigStatus(data)
if (res.code == 200) {
notification('success', text + '成功')
await fetchData();
}
} catch {
} finally {
setLoading(false)
}
},
});
}
// 预览
const handlePreview = (record: any) => {
const params = {
referer: window.location.href,
stationId: record.deptId,
isPre: 0
}
window.open(`${window.location.origin}/bi?${qs.stringify(params)}`, "_blank")
}
// 编辑
const handleUpdate = (id: number) => {
router.push({
path: "/setting/station/largeScreenDetail",
query: {
id
}
})
}
// 新建
const handleAdd = () => {
router.push({
path: "/setting/station/largeScreenDetail"
})
}
/*************************** 方法区域 end ***************************/
onMounted(async () => {
await fetchStationData();
await fetchData();
})
</script>
<style scoped></style>