提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
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 label="存储器" prop="storage"> |
|
21 |
<el-select |
|
22 |
v-model="queryParams.storage" |
|
23 |
placeholder="请选择存储器" |
|
24 |
clearable |
|
25 |
class="!w-240px" |
|
26 |
> |
|
27 |
<el-option |
|
28 |
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_FILE_STORAGE)" |
|
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="createTime"> |
|
36 |
<el-date-picker |
|
37 |
v-model="queryParams.createTime" |
|
38 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
39 |
type="daterange" |
|
40 |
start-placeholder="开始日期" |
|
41 |
end-placeholder="结束日期" |
|
42 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
43 |
class="!w-240px" |
|
44 |
/> |
|
45 |
</el-form-item> |
|
46 |
<el-form-item> |
|
47 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
48 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
49 |
<el-button |
|
50 |
type="primary" |
|
51 |
plain |
|
52 |
@click="openForm('create')" |
|
53 |
v-hasPermi="['infra:file-config:create']" |
|
54 |
> |
|
55 |
<Icon icon="ep:plus" class="mr-5px" /> 新增 |
|
56 |
</el-button> |
|
57 |
</el-form-item> |
|
58 |
</el-form> |
|
59 |
</ContentWrap> |
|
60 |
|
|
61 |
<!-- 列表 --> |
|
62 |
<ContentWrap> |
|
63 |
<el-table v-loading="loading" :data="list"> |
|
64 |
<el-table-column label="编号" align="center" prop="id" /> |
|
65 |
<el-table-column label="配置名" align="center" prop="name" /> |
|
66 |
<el-table-column label="存储器" align="center" prop="storage"> |
|
67 |
<template #default="scope"> |
|
68 |
<dict-tag :type="DICT_TYPE.INFRA_FILE_STORAGE" :value="scope.row.storage" /> |
|
69 |
</template> |
|
70 |
</el-table-column> |
|
71 |
<el-table-column label="备注" align="center" prop="remark" /> |
|
72 |
<el-table-column label="主配置" align="center" prop="primary"> |
|
73 |
<template #default="scope"> |
|
74 |
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.master" /> |
|
75 |
</template> |
|
76 |
</el-table-column> |
|
77 |
<el-table-column |
|
78 |
label="创建时间" |
|
79 |
align="center" |
|
80 |
prop="createTime" |
|
81 |
width="180" |
|
82 |
:formatter="dateFormatter" |
|
83 |
/> |
|
84 |
<el-table-column label="操作" align="center" width="240px"> |
|
85 |
<template #default="scope"> |
|
86 |
<el-button |
|
87 |
link |
|
88 |
type="primary" |
|
89 |
@click="openForm('update', scope.row.id)" |
|
90 |
v-hasPermi="['infra:file-config:update']" |
|
91 |
> |
|
92 |
编辑 |
|
93 |
</el-button> |
|
94 |
<el-button |
|
95 |
link |
|
96 |
type="primary" |
|
97 |
:disabled="scope.row.master" |
|
98 |
@click="handleMaster(scope.row.id)" |
|
99 |
v-hasPermi="['infra:file-config:update']" |
|
100 |
> |
|
101 |
主配置 |
|
102 |
</el-button> |
|
103 |
<el-button link type="primary" @click="handleTest(scope.row.id)"> 测试 </el-button> |
|
104 |
<el-button |
|
105 |
link |
|
106 |
type="danger" |
|
107 |
@click="handleDelete(scope.row.id)" |
|
108 |
v-hasPermi="['infra:file-config:delete']" |
|
109 |
> |
|
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 |
<FileConfigForm ref="formRef" @success="getList" /> |
|
126 |
</template> |
|
127 |
<script lang="ts" setup> |
|
128 |
import * as FileConfigApi from '@/api/infra/fileConfig' |
|
129 |
import FileConfigForm from './FileConfigForm.vue' |
|
130 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
131 |
import { dateFormatter } from '@/utils/formatTime' |
|
132 |
|
|
133 |
defineOptions({ name: 'InfraFileConfig' }) |
|
134 |
|
|
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 |
name: undefined, |
|
145 |
storage: undefined, |
|
146 |
createTime: [] |
|
147 |
}) |
|
148 |
const queryFormRef = ref() // 搜索的表单 |
|
149 |
|
|
150 |
/** 查询列表 */ |
|
151 |
const getList = async () => { |
|
152 |
loading.value = true |
|
153 |
try { |
|
154 |
const data = await FileConfigApi.getFileConfigPage(queryParams) |
|
155 |
list.value = data.list |
|
156 |
total.value = data.total |
|
157 |
} finally { |
|
158 |
loading.value = false |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
/** 搜索按钮操作 */ |
|
163 |
const handleQuery = () => { |
|
164 |
queryParams.pageNo = 1 |
|
165 |
getList() |
|
166 |
} |
|
167 |
|
|
168 |
/** 重置按钮操作 */ |
|
169 |
const resetQuery = () => { |
|
170 |
queryFormRef.value.resetFields() |
|
171 |
handleQuery() |
|
172 |
} |
|
173 |
|
|
174 |
/** 添加/修改操作 */ |
|
175 |
const formRef = ref() |
|
176 |
const openForm = (type: string, id?: number) => { |
|
177 |
formRef.value.open(type, id) |
|
178 |
} |
|
179 |
|
|
180 |
/** 删除按钮操作 */ |
|
181 |
const handleDelete = async (id: number) => { |
|
182 |
try { |
|
183 |
// 删除的二次确认 |
|
184 |
await message.delConfirm() |
|
185 |
// 发起删除 |
|
186 |
await FileConfigApi.deleteFileConfig(id) |
|
187 |
message.success(t('common.delSuccess')) |
|
188 |
// 刷新列表 |
|
189 |
await getList() |
|
190 |
} catch {} |
|
191 |
} |
|
192 |
|
|
193 |
/** 主配置按钮操作 */ |
|
194 |
const handleMaster = async (id) => { |
|
195 |
try { |
|
196 |
await message.confirm('是否确认修改配置编号为"' + id + '"的数据项为主配置?') |
|
197 |
await FileConfigApi.updateFileConfigMaster(id) |
|
198 |
message.success(t('common.updateSuccess')) |
|
199 |
await getList() |
|
200 |
} catch {} |
|
201 |
} |
|
202 |
|
|
203 |
/** 测试按钮操作 */ |
|
204 |
const handleTest = async (id) => { |
|
205 |
try { |
|
206 |
const response = await FileConfigApi.testFileConfig(id) |
|
207 |
await message.confirm('是否要访问该文件?', '测试上传成功') |
|
208 |
window.open(response, '_blank') |
|
209 |
} catch {} |
|
210 |
} |
|
211 |
|
|
212 |
/** 初始化 **/ |
|
213 |
onMounted(() => { |
|
214 |
getList() |
|
215 |
}) |
|
216 |
</script> |