提交 | 用户 | 时间
|
759b1c
|
1 |
<template> |
H |
2 |
<div class="app-container"> |
|
3 |
<!-- 搜索工作栏 --> |
|
4 |
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> |
|
5 |
<el-form-item label="参数名称" prop="name"> |
|
6 |
<el-input v-model="queryParams.name" placeholder="请输入参数名称" clearable style="width: 240px" |
|
7 |
@keyup.enter.native="handleQuery"/> |
|
8 |
</el-form-item> |
|
9 |
<el-form-item label="参数键名" prop="key"> |
|
10 |
<el-input v-model="queryParams.key" placeholder="请输入参数键名" clearable style="width: 240px" |
|
11 |
@keyup.enter.native="handleQuery"/> |
|
12 |
</el-form-item> |
|
13 |
<el-form-item label="系统内置" prop="type"> |
|
14 |
<el-select v-model="queryParams.type" placeholder="系统内置" clearable> |
|
15 |
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_CONFIG_TYPE)" :key="parseInt(dict.value)" |
|
16 |
:label="dict.label" :value="parseInt(dict.value)"/> |
|
17 |
</el-select> |
|
18 |
</el-form-item> |
|
19 |
<el-form-item label="创建时间" prop="createTime"> |
|
20 |
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" |
|
21 |
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> |
|
22 |
</el-form-item> |
|
23 |
<el-form-item> |
|
24 |
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> |
|
25 |
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> |
|
26 |
</el-form-item> |
|
27 |
</el-form> |
|
28 |
|
|
29 |
<el-row :gutter="10" class="mb8"> |
|
30 |
<el-col :span="1.5"> |
|
31 |
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" |
|
32 |
v-hasPermi="['infra:config:create']">新增</el-button> |
|
33 |
</el-col> |
|
34 |
<el-col :span="1.5"> |
|
35 |
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading" |
|
36 |
v-hasPermi="['infra:config:export']">导出</el-button> |
|
37 |
</el-col> |
|
38 |
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> |
|
39 |
</el-row> |
|
40 |
|
|
41 |
<el-table v-loading="loading" :data="configList"> |
|
42 |
<el-table-column label="参数主键" align="center" prop="id" /> |
|
43 |
<el-table-column label="参数分类" align="center" prop="category" /> |
|
44 |
<el-table-column label="参数名称" align="center" prop="name" :show-overflow-tooltip="true" /> |
|
45 |
<el-table-column label="参数键名" align="center" prop="key" :show-overflow-tooltip="true" /> |
|
46 |
<el-table-column label="参数键值" align="center" prop="value" /> |
|
47 |
<el-table-column label="系统内置" align="center" prop="type"> |
|
48 |
<template v-slot="scope"> |
|
49 |
<dict-tag :type="DICT_TYPE.INFRA_CONFIG_TYPE" :value="scope.row.type" /> |
|
50 |
</template> |
|
51 |
</el-table-column> |
|
52 |
<el-table-column label="是否可见" align="center" prop="visible"> |
|
53 |
<template v-slot="scope"> |
|
54 |
<span>{{ scope.row.visible ? '是' : '否' }}</span> |
|
55 |
</template> |
|
56 |
</el-table-column> |
|
57 |
<el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" /> |
|
58 |
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
|
59 |
<template v-slot="scope"> |
|
60 |
<span>{{ parseTime(scope.row.createTime) }}</span> |
|
61 |
</template> |
|
62 |
</el-table-column> |
|
63 |
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
|
64 |
<template v-slot="scope"> |
|
65 |
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" |
|
66 |
v-hasPermi="['infra:config:update']">修改</el-button> |
|
67 |
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" |
|
68 |
v-hasPermi="['infra:config:delete']">删除</el-button> |
|
69 |
</template> |
|
70 |
</el-table-column> |
|
71 |
</el-table> |
|
72 |
|
|
73 |
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" @pagination="getList"/> |
|
74 |
|
|
75 |
<!-- 添加或修改参数配置对话框 --> |
|
76 |
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> |
|
77 |
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
|
78 |
<el-form-item label="参数分类" prop="category"> |
|
79 |
<el-input v-model="form.category" placeholder="请输入参数分类" /> |
|
80 |
</el-form-item> |
|
81 |
<el-form-item label="参数名称" prop="name"> |
|
82 |
<el-input v-model="form.name" placeholder="请输入参数名称" /> |
|
83 |
</el-form-item> |
|
84 |
<el-form-item label="参数键名" prop="key"> |
|
85 |
<el-input v-model="form.key" placeholder="请输入参数键名" /> |
|
86 |
</el-form-item> |
|
87 |
<el-form-item label="参数键值" prop="value"> |
|
88 |
<el-input v-model="form.value" placeholder="请输入参数键值" /> |
|
89 |
</el-form-item> |
|
90 |
<el-form-item label="是否可见" prop="type"> |
|
91 |
<el-radio-group v-model="form.visible"> |
|
92 |
<el-radio :key="true" :label="true">是</el-radio> |
|
93 |
<el-radio :key="false" :label="false">否</el-radio> |
|
94 |
</el-radio-group> |
|
95 |
</el-form-item> |
|
96 |
<el-form-item label="备注" prop="remark"> |
|
97 |
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> |
|
98 |
</el-form-item> |
|
99 |
</el-form> |
|
100 |
<div slot="footer" class="dialog-footer"> |
|
101 |
<el-button type="primary" @click="submitForm">确 定</el-button> |
|
102 |
<el-button @click="cancel">取 消</el-button> |
|
103 |
</div> |
|
104 |
</el-dialog> |
|
105 |
</div> |
|
106 |
</template> |
|
107 |
|
|
108 |
<script> |
|
109 |
import { listConfig, getConfig, delConfig, addConfig, updateConfig, exportConfig } from "@/api/infra/config"; |
|
110 |
|
|
111 |
export default { |
|
112 |
name: "InfraConfig", |
|
113 |
data() { |
|
114 |
return { |
|
115 |
// 遮罩层 |
|
116 |
loading: true, |
|
117 |
// 导出遮罩层 |
|
118 |
exportLoading: false, |
|
119 |
// 显示搜索条件 |
|
120 |
showSearch: true, |
|
121 |
// 总条数 |
|
122 |
total: 0, |
|
123 |
// 参数表格数据 |
|
124 |
configList: [], |
|
125 |
// 弹出层标题 |
|
126 |
title: "", |
|
127 |
// 是否显示弹出层 |
|
128 |
open: false, |
|
129 |
// 类型数据字典 |
|
130 |
typeOptions: [], |
|
131 |
// 查询参数 |
|
132 |
queryParams: { |
|
133 |
pageNo: 1, |
|
134 |
pageSize: 10, |
|
135 |
name: undefined, |
|
136 |
key: undefined, |
|
137 |
type: undefined, |
|
138 |
createTime: [] |
|
139 |
}, |
|
140 |
// 表单参数 |
|
141 |
form: {}, |
|
142 |
// 表单校验 |
|
143 |
rules: { |
|
144 |
category: [ |
|
145 |
{ required: true, message: "参数分类不能为空", trigger: "blur" } |
|
146 |
], |
|
147 |
name: [ |
|
148 |
{ required: true, message: "参数名称不能为空", trigger: "blur" } |
|
149 |
], |
|
150 |
key: [ |
|
151 |
{ required: true, message: "参数键名不能为空", trigger: "blur" } |
|
152 |
], |
|
153 |
value: [ |
|
154 |
{ required: true, message: "参数键值不能为空", trigger: "blur" } |
|
155 |
] |
|
156 |
} |
|
157 |
}; |
|
158 |
}, |
|
159 |
created() { |
|
160 |
this.getList(); |
|
161 |
}, |
|
162 |
methods: { |
|
163 |
/** 查询参数列表 */ |
|
164 |
getList() { |
|
165 |
this.loading = true; |
|
166 |
listConfig(this.queryParams).then(response => { |
|
167 |
this.configList = response.data.list; |
|
168 |
this.total = response.data.total; |
|
169 |
this.loading = false; |
|
170 |
} |
|
171 |
); |
|
172 |
}, |
|
173 |
// 取消按钮 |
|
174 |
cancel() { |
|
175 |
this.open = false; |
|
176 |
this.reset(); |
|
177 |
}, |
|
178 |
// 表单重置 |
|
179 |
reset() { |
|
180 |
this.form = { |
|
181 |
id: undefined, |
|
182 |
name: undefined, |
|
183 |
key: undefined, |
|
184 |
value: undefined, |
|
185 |
remark: undefined |
|
186 |
}; |
|
187 |
this.resetForm("form"); |
|
188 |
}, |
|
189 |
/** 搜索按钮操作 */ |
|
190 |
handleQuery() { |
|
191 |
this.queryParams.pageNo = 1; |
|
192 |
this.getList(); |
|
193 |
}, |
|
194 |
/** 重置按钮操作 */ |
|
195 |
resetQuery() { |
|
196 |
this.resetForm("queryForm"); |
|
197 |
this.handleQuery(); |
|
198 |
}, |
|
199 |
/** 新增按钮操作 */ |
|
200 |
handleAdd() { |
|
201 |
this.reset(); |
|
202 |
this.open = true; |
|
203 |
this.title = "添加参数"; |
|
204 |
}, |
|
205 |
/** 修改按钮操作 */ |
|
206 |
handleUpdate(row) { |
|
207 |
this.reset(); |
|
208 |
const id = row.id || this.ids |
|
209 |
getConfig(id).then(response => { |
|
210 |
this.form = response.data; |
|
211 |
this.open = true; |
|
212 |
this.title = "修改参数"; |
|
213 |
}); |
|
214 |
}, |
|
215 |
/** 提交按钮 */ |
|
216 |
submitForm: function() { |
|
217 |
this.$refs["form"].validate(valid => { |
|
218 |
if (valid) { |
|
219 |
if (this.form.id !== undefined) { |
|
220 |
updateConfig(this.form).then(response => { |
|
221 |
this.$modal.msgSuccess("修改成功"); |
|
222 |
this.open = false; |
|
223 |
this.getList(); |
|
224 |
}); |
|
225 |
} else { |
|
226 |
addConfig(this.form).then(response => { |
|
227 |
this.$modal.msgSuccess("新增成功"); |
|
228 |
this.open = false; |
|
229 |
this.getList(); |
|
230 |
}); |
|
231 |
} |
|
232 |
} |
|
233 |
}); |
|
234 |
}, |
|
235 |
/** 删除按钮操作 */ |
|
236 |
handleDelete(row) { |
|
237 |
const ids = row.id || this.ids; |
|
238 |
this.$modal.confirm('是否确认删除参数编号为"' + ids + '"的数据项?').then(function() { |
|
239 |
return delConfig(ids); |
|
240 |
}).then(() => { |
|
241 |
this.getList(); |
|
242 |
this.$modal.msgSuccess("删除成功"); |
|
243 |
}).catch(() => {}); |
|
244 |
}, |
|
245 |
/** 导出按钮操作 */ |
|
246 |
handleExport() { |
|
247 |
this.$modal.confirm('是否确认导出所有参数数据项?').then(() => { |
|
248 |
// 处理查询参数 |
|
249 |
let params = {...this.queryParams}; |
|
250 |
params.pageNo = undefined; |
|
251 |
params.pageSize = undefined; |
|
252 |
this.exportLoading = true; |
|
253 |
return exportConfig(params); |
|
254 |
}).then(response => { |
|
255 |
this.$download.excel(response, '参数配置.xls'); |
|
256 |
this.exportLoading = false; |
|
257 |
}).catch(() => {}); |
|
258 |
}, |
|
259 |
} |
|
260 |
}; |
|
261 |
</script> |