提交 | 用户 | 时间
|
afc4d5
|
1 |
<template> |
D |
2 |
<el-drawer |
|
3 |
v-model="drawer" |
|
4 |
size="40%" |
31bb5f
|
5 |
title="参数列表" |
D |
6 |
direction="rtl" |
afc4d5
|
7 |
:before-close="handleClose" |
D |
8 |
> |
|
9 |
<!-- 搜索工作栏 --> |
|
10 |
<ContentWrap> |
|
11 |
<el-form |
|
12 |
class="-mb-15px" |
|
13 |
:model="queryParams" |
|
14 |
ref="queryFormRef" |
|
15 |
:inline="true" |
|
16 |
label-width="68px" |
|
17 |
> |
|
18 |
<el-form-item label="参数名称" prop="paramName"> |
|
19 |
<el-input |
|
20 |
v-model="queryParams.paramName" |
0c184a
|
21 |
placeholder="请输入参数名称" |
afc4d5
|
22 |
clearable |
D |
23 |
class="!w-240px" |
|
24 |
/> |
|
25 |
</el-form-item> |
|
26 |
<!-- <el-form-item label="参数编码" prop="paramCode">--> |
|
27 |
<!-- <el-input--> |
|
28 |
<!-- v-model="queryParams.paramCode"--> |
|
29 |
<!-- placeholder="请输入"--> |
|
30 |
<!-- clearable--> |
|
31 |
<!-- class="!w-240px"--> |
|
32 |
<!-- />--> |
|
33 |
<!-- </el-form-item>--> |
|
34 |
<el-form-item> |
|
35 |
<el-button @click="handleQuery"> |
|
36 |
<Icon icon="ep:search" class="mr-5px"/> |
|
37 |
搜索 |
|
38 |
</el-button> |
|
39 |
<el-button @click="resetQuery"> |
|
40 |
<Icon icon="ep:refresh" class="mr-5px"/> |
|
41 |
重置 |
|
42 |
</el-button> |
|
43 |
<el-button |
|
44 |
type="primary" |
|
45 |
plain |
|
46 |
@click="openForm('create')" |
|
47 |
> |
|
48 |
<Icon icon="ep:plus" class="mr-5px" /> |
|
49 |
新增 |
|
50 |
</el-button> |
|
51 |
|
|
52 |
</el-form-item> |
|
53 |
</el-form> |
|
54 |
</ContentWrap> |
|
55 |
|
|
56 |
<!-- 列表 --> |
|
57 |
<ContentWrap> |
|
58 |
<el-table |
|
59 |
v-loading="loading" |
|
60 |
:data="list" |
|
61 |
row-key="id" |
|
62 |
> |
|
63 |
<el-table-column prop="paramName" label="参数名称"/> |
|
64 |
<el-table-column prop="paramCode" label="参数编码"/> |
|
65 |
<el-table-column prop="paramValue" label="参数值"/> |
|
66 |
<el-table-column label="操作" align="center" width="150px"> |
|
67 |
<template #default="scope"> |
|
68 |
<div class="flex items-center justify-center"> |
|
69 |
<el-button |
|
70 |
link |
|
71 |
type="primary" |
|
72 |
@click="openForm('update', scope.row.id)" |
|
73 |
> |
|
74 |
编辑 |
|
75 |
</el-button> |
|
76 |
<el-button link type="danger" @click="handleDelete(scope.row.id)"> |
|
77 |
删除 |
|
78 |
</el-button> |
|
79 |
</div> |
|
80 |
</template> |
|
81 |
</el-table-column> |
|
82 |
</el-table> |
|
83 |
<!-- 分页 --> |
|
84 |
<Pagination |
|
85 |
v-model:limit="queryParams.limit" |
|
86 |
v-model:page="queryParams.page" |
|
87 |
:total="total" |
|
88 |
@pagination="getList" |
|
89 |
/> |
|
90 |
</ContentWrap> |
|
91 |
|
|
92 |
<!-- 表单弹窗:添加/修改 --> |
|
93 |
<ChartParamForm ref="formRef" @success="getList" /> |
|
94 |
</el-drawer> |
|
95 |
</template> |
|
96 |
<script lang="ts" setup> |
|
97 |
import {dateFormatter} from '@/utils/formatTime' |
|
98 |
import * as ChartParamApi from '@/api/model/mpk/chartParam' |
|
99 |
import ChartParamForm from './ChartParamForm.vue' |
|
100 |
|
|
101 |
import type {DrawerProps} from "element-plus"; |
|
102 |
|
|
103 |
defineOptions({name: 'ChartParam'}) |
|
104 |
|
|
105 |
const message = useMessage() // 消息弹窗 |
|
106 |
const {t} = useI18n() // 国际化 |
|
107 |
|
|
108 |
const drawer = ref(false) |
|
109 |
const loading = ref(true) // 列表的加载中 |
|
110 |
const total = ref(0) // 列表的总页数 |
|
111 |
const list = ref([]) // 字典表格数据 |
|
112 |
const queryParams = reactive({ |
|
113 |
page: 1, |
|
114 |
limit: 10, |
|
115 |
chartId: undefined, |
|
116 |
paramName: undefined, |
|
117 |
paramCode: undefined, |
|
118 |
}) |
|
119 |
const queryFormRef = ref() // 搜索的表单 |
|
120 |
|
|
121 |
const getList = async () => { |
|
122 |
loading.value = true |
|
123 |
try { |
|
124 |
const data = await ChartParamApi.getPage(queryParams) |
|
125 |
list.value = data.list |
|
126 |
total.value = data.total |
|
127 |
} finally { |
|
128 |
loading.value = false |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/** 搜索按钮操作 */ |
|
133 |
const handleQuery = () => { |
|
134 |
getList() |
|
135 |
} |
|
136 |
|
|
137 |
/** 重置按钮操作 */ |
|
138 |
const resetQuery = () => { |
|
139 |
queryFormRef.value.resetFields() |
|
140 |
handleQuery() |
|
141 |
} |
|
142 |
|
|
143 |
/** 添加/修改操作 */ |
|
144 |
const formRef = ref() |
|
145 |
const openForm = (type: string, id?: string) => { |
|
146 |
formRef.value.open(type, id, queryParams.chartId) |
|
147 |
} |
|
148 |
|
|
149 |
/** 删除按钮操作 */ |
|
150 |
const handleDelete = async (id: string) => { |
|
151 |
try { |
|
152 |
// 删除的二次确认 |
|
153 |
await message.delConfirm() |
|
154 |
// 发起删除 |
|
155 |
await ChartParamApi.del(id) |
|
156 |
message.success(t('common.delSuccess')) |
|
157 |
// 刷新列表 |
|
158 |
await getList() |
|
159 |
} catch { |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
/** 打开弹窗 */ |
|
164 |
const open = async (chartId?: string) => { |
|
165 |
resetForm() |
|
166 |
drawer.value = true |
|
167 |
queryParams.chartId = chartId |
|
168 |
if (chartId) { |
|
169 |
getList() |
|
170 |
} |
|
171 |
} |
|
172 |
defineExpose({open}) // 提供 open 方法,用于打开弹窗 |
|
173 |
|
|
174 |
/** 重置表单 */ |
|
175 |
const resetForm = () => { |
|
176 |
queryParams.chartId = '' |
|
177 |
queryParams.name = '' |
|
178 |
} |
|
179 |
|
|
180 |
const handleClose = (done: () => void) => { |
|
181 |
drawer.value = false |
|
182 |
} |
|
183 |
</script> |