|
| 1 | + |
| 2 | +<template> |
| 3 | + <BasicLayout> |
| 4 | + <template #wrapper> |
| 5 | + <el-card class="box-card"> |
| 6 | + <el-form ref="queryForm" :model="queryParams" :inline="true" label-width="68px"> |
| 7 | + |
| 8 | + <el-form-item> |
| 9 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| 10 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
| 11 | + </el-form-item> |
| 12 | + </el-form> |
| 13 | + |
| 14 | + <el-row :gutter="10" class="mb8"> |
| 15 | + <el-col :span="1.5"> |
| 16 | + <el-button |
| 17 | + v-permisaction="['sysconfig:sysconfig:add']" |
| 18 | + type="primary" |
| 19 | + icon="el-icon-plus" |
| 20 | + size="mini" |
| 21 | + @click="handleAdd" |
| 22 | + >新增 |
| 23 | + </el-button> |
| 24 | + </el-col> |
| 25 | + <el-col :span="1.5"> |
| 26 | + <el-button |
| 27 | + v-permisaction="['sysconfig:sysconfig:edit']" |
| 28 | + type="success" |
| 29 | + icon="el-icon-edit" |
| 30 | + size="mini" |
| 31 | + :disabled="single" |
| 32 | + @click="handleUpdate" |
| 33 | + >修改 |
| 34 | + </el-button> |
| 35 | + </el-col> |
| 36 | + <el-col :span="1.5"> |
| 37 | + <el-button |
| 38 | + v-permisaction="['sysconfig:sysconfig:remove']" |
| 39 | + type="danger" |
| 40 | + icon="el-icon-delete" |
| 41 | + size="mini" |
| 42 | + :disabled="multiple" |
| 43 | + @click="handleDelete" |
| 44 | + >删除 |
| 45 | + </el-button> |
| 46 | + </el-col> |
| 47 | + </el-row> |
| 48 | + |
| 49 | + <el-table v-loading="loading" :data="sysconfigList" @selection-change="handleSelectionChange"> |
| 50 | + <el-table-column type="selection" width="55" align="center" /> |
| 51 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| 52 | + <template slot-scope="scope"> |
| 53 | + <el-button |
| 54 | + v-permisaction="['sysconfig:sysconfig:edit']" |
| 55 | + size="mini" |
| 56 | + type="text" |
| 57 | + icon="el-icon-edit" |
| 58 | + @click="handleUpdate(scope.row)" |
| 59 | + >修改 |
| 60 | + </el-button> |
| 61 | + <el-button |
| 62 | + v-permisaction="['sysconfig:sysconfig:remove']" |
| 63 | + size="mini" |
| 64 | + type="text" |
| 65 | + icon="el-icon-delete" |
| 66 | + @click="handleDelete(scope.row)" |
| 67 | + >删除 |
| 68 | + </el-button> |
| 69 | + </template> |
| 70 | + </el-table-column> |
| 71 | + </el-table> |
| 72 | + |
| 73 | + <pagination |
| 74 | + v-show="total>0" |
| 75 | + :total="total" |
| 76 | + :page.sync="queryParams.pageIndex" |
| 77 | + :limit.sync="queryParams.pageSize" |
| 78 | + @pagination="getList" |
| 79 | + /> |
| 80 | + |
| 81 | + <!-- 添加或修改对话框 --> |
| 82 | + <el-dialog :title="title" :visible.sync="open" width="500px"> |
| 83 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> |
| 84 | + |
| 85 | + <el-form-item label="" prop="configName"> |
| 86 | + <el-input |
| 87 | + v-model="form.configName" |
| 88 | + placeholder="" |
| 89 | + /> |
| 90 | + </el-form-item> |
| 91 | + <el-form-item label="" prop="configKey"> |
| 92 | + <el-input |
| 93 | + v-model="form.configKey" |
| 94 | + placeholder="" |
| 95 | + /> |
| 96 | + </el-form-item> |
| 97 | + <el-form-item label="" prop="configValue"> |
| 98 | + <el-input |
| 99 | + v-model="form.configValue" |
| 100 | + placeholder="" |
| 101 | + /> |
| 102 | + </el-form-item> |
| 103 | + <el-form-item label="" prop="configType"> |
| 104 | + <el-input |
| 105 | + v-model="form.configType" |
| 106 | + placeholder="" |
| 107 | + /> |
| 108 | + </el-form-item> |
| 109 | + <el-form-item label="" prop="remark"> |
| 110 | + <el-input |
| 111 | + v-model="form.remark" |
| 112 | + placeholder="" |
| 113 | + /> |
| 114 | + </el-form-item> |
| 115 | + </el-form> |
| 116 | + <div slot="footer" class="dialog-footer"> |
| 117 | + <el-button type="primary" @click="submitForm">确 定</el-button> |
| 118 | + <el-button @click="cancel">取 消</el-button> |
| 119 | + </div> |
| 120 | + </el-dialog> |
| 121 | + </el-card> |
| 122 | + </template> |
| 123 | + </BasicLayout> |
| 124 | +</template> |
| 125 | + |
| 126 | +<script> |
| 127 | +import { addSysConfig, delSysConfig, getSysConfig, listSysConfig, updateSysConfig } from '@/api/sysconfig' |
| 128 | +
|
| 129 | +export default { |
| 130 | + name: 'Config', |
| 131 | + data() { |
| 132 | + return { |
| 133 | + // 遮罩层 |
| 134 | + loading: true, |
| 135 | + // 选中数组 |
| 136 | + ids: [], |
| 137 | + // 非单个禁用 |
| 138 | + single: true, |
| 139 | + // 非多个禁用 |
| 140 | + multiple: true, |
| 141 | + // 总条数 |
| 142 | + total: 0, |
| 143 | + // 弹出层标题 |
| 144 | + title: '', |
| 145 | + // 是否显示弹出层 |
| 146 | + open: false, |
| 147 | + isEdit: false, |
| 148 | + // 类型数据字典 |
| 149 | + typeOptions: [], |
| 150 | + sysconfigList: [], |
| 151 | +
|
| 152 | + // 查询参数 |
| 153 | + queryParams: { |
| 154 | + pageIndex: 1, |
| 155 | + pageSize: 10 |
| 156 | +
|
| 157 | + }, |
| 158 | + // 表单参数 |
| 159 | + form: { |
| 160 | + }, |
| 161 | + // 表单校验 |
| 162 | + rules: {} |
| 163 | + } |
| 164 | + }, |
| 165 | + created() { |
| 166 | + this.getList() |
| 167 | + }, |
| 168 | + methods: { |
| 169 | + /** 查询参数列表 */ |
| 170 | + getList() { |
| 171 | + this.loading = true |
| 172 | + listSysConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => { |
| 173 | + this.sysconfigList = response.data.list |
| 174 | + this.total = response.data.count |
| 175 | + this.loading = false |
| 176 | + } |
| 177 | + ) |
| 178 | + }, |
| 179 | + // 取消按钮 |
| 180 | + cancel() { |
| 181 | + this.open = false |
| 182 | + this.reset() |
| 183 | + }, |
| 184 | + // 表单重置 |
| 185 | + reset() { |
| 186 | + this.form = { |
| 187 | +
|
| 188 | + configId: undefined, |
| 189 | + configName: undefined, |
| 190 | + configKey: undefined, |
| 191 | + configValue: undefined, |
| 192 | + configType: undefined, |
| 193 | + remark: undefined |
| 194 | + } |
| 195 | + this.resetForm('form') |
| 196 | + }, |
| 197 | +
|
| 198 | + /** 搜索按钮操作 */ |
| 199 | + handleQuery() { |
| 200 | + this.queryParams.pageIndex = 1 |
| 201 | + this.getList() |
| 202 | + }, |
| 203 | + /** 重置按钮操作 */ |
| 204 | + resetQuery() { |
| 205 | + this.dateRange = [] |
| 206 | + this.resetForm('queryForm') |
| 207 | + this.handleQuery() |
| 208 | + }, |
| 209 | + /** 新增按钮操作 */ |
| 210 | + handleAdd() { |
| 211 | + this.reset() |
| 212 | + this.open = true |
| 213 | + this.title = '添加SysConfig' |
| 214 | + this.isEdit = false |
| 215 | + }, |
| 216 | + // 多选框选中数据 |
| 217 | + handleSelectionChange(selection) { |
| 218 | + this.ids = selection.map(item => item.configId) |
| 219 | + this.single = selection.length !== 1 |
| 220 | + this.multiple = !selection.length |
| 221 | + }, |
| 222 | + /** 修改按钮操作 */ |
| 223 | + handleUpdate(row) { |
| 224 | + this.reset() |
| 225 | + const configId = |
| 226 | + row.configId || this.ids |
| 227 | + getSysConfig(configId).then(response => { |
| 228 | + this.form = response.data |
| 229 | + this.open = true |
| 230 | + this.title = '修改SysConfig' |
| 231 | + this.isEdit = true |
| 232 | + }) |
| 233 | + }, |
| 234 | + /** 提交按钮 */ |
| 235 | + submitForm: function() { |
| 236 | + this.$refs['form'].validate(valid => { |
| 237 | + if (valid) { |
| 238 | + if (this.form.configId !== undefined) { |
| 239 | + updateSysConfig(this.form).then(response => { |
| 240 | + if (response.code === 200) { |
| 241 | + this.msgSuccess('修改成功') |
| 242 | + this.open = false |
| 243 | + this.getList() |
| 244 | + } else { |
| 245 | + this.msgError(response.msg) |
| 246 | + } |
| 247 | + }) |
| 248 | + } else { |
| 249 | + addSysConfig(this.form).then(response => { |
| 250 | + if (response.code === 200) { |
| 251 | + this.msgSuccess('新增成功') |
| 252 | + this.open = false |
| 253 | + this.getList() |
| 254 | + } else { |
| 255 | + this.msgError(response.msg) |
| 256 | + } |
| 257 | + }) |
| 258 | + } |
| 259 | + } |
| 260 | + }) |
| 261 | + }, |
| 262 | + /** 删除按钮操作 */ |
| 263 | + handleDelete(row) { |
| 264 | + const Ids = row.configId || this.ids |
| 265 | + this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', '警告', { |
| 266 | + confirmButtonText: '确定', |
| 267 | + cancelButtonText: '取消', |
| 268 | + type: 'warning' |
| 269 | + }).then(function() { |
| 270 | + return delSysConfig(Ids) |
| 271 | + }).then(() => { |
| 272 | + this.getList() |
| 273 | + this.msgSuccess('删除成功') |
| 274 | + }).catch(function() { |
| 275 | + }) |
| 276 | + } |
| 277 | + } |
| 278 | +} |
| 279 | +</script> |
0 commit comments