Commit 7c140b98 authored by 张伯涛's avatar 张伯涛

字典和字典类型的增删改查,导出功能调节

parent 81c27d61
...@@ -30,7 +30,10 @@ export function getDicts(dictType) { ...@@ -30,7 +30,10 @@ export function getDicts(dictType) {
export function checkDictLabelUnique(dictLabel) { export function checkDictLabelUnique(dictLabel) {
return request({ return request({
url: '/system/dict/data/checkDictLabelUnique?dictLabel=' + dictLabel, url: '/system/dict/data/checkDictLabelUnique?dictLabel=' + dictLabel,
method: 'get' method: 'get',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}) })
} }
...@@ -40,7 +43,10 @@ export function addData(data) { ...@@ -40,7 +43,10 @@ export function addData(data) {
return request({ return request({
url: '/system/dict/data/add', url: '/system/dict/data/add',
method: 'post', method: 'post',
data: data data: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}) })
} }
...@@ -51,7 +57,10 @@ export function updateData(data) { ...@@ -51,7 +57,10 @@ export function updateData(data) {
return request({ return request({
url: '/system/dict/data/update/' + businessId, url: '/system/dict/data/update/' + businessId,
method: 'put', method: 'put',
data: data data: data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}) })
} }
...@@ -59,14 +68,17 @@ export function updateData(data) { ...@@ -59,14 +68,17 @@ export function updateData(data) {
export function delData(dictCode) { export function delData(dictCode) {
return request({ return request({
url: '/system/dict/data/deleteLogical/' + dictCode, url: '/system/dict/data/deleteLogical/' + dictCode,
method: 'delete' method: 'delete',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}) })
} }
// 导出字典数据 // 导出字典数据
export function exportData(query) { export function exportData(query) {
return request({ return request({
url: '/system/dict/data/export' + query.dictType, url: '/system/dict/data/export/' + query.dictType,
method: 'get', method: 'get',
params: query, params: query,
responseType: 'blob' responseType: 'blob'
......
...@@ -62,6 +62,12 @@ Vue.prototype.$uploadFile = uploadPublic ...@@ -62,6 +62,12 @@ Vue.prototype.$uploadFile = uploadPublic
Vue.prototype.$haveAuth = includePermission Vue.prototype.$haveAuth = includePermission
// set ElementUI lang to EN // set ElementUI lang to EN
Vue.prototype.$axios = xhr Vue.prototype.$axios = xhr
// 未解析的函数或方法 msgSuccess(),需添加以下代码
Vue.prototype.msgSuccess = function(msg) {
this.$message({ showClose: true, message: msg, type: 'success' })
}
Vue.prototype.$parseDate = (value, format) => { Vue.prototype.$parseDate = (value, format) => {
if (!value || value === '') { if (!value || value === '') {
return '-' return '-'
......
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="optionsContent"> <el-form v-show="showSearch" ref="queryForm" style="width: 100%" :model="queryParams" :inline="true">
<el-form ref="queryForm" style="width: 100%" :model="queryParams" :inline="true">
<el-form-item label="字典名称" prop="dictType"> <el-form-item label="字典名称" prop="dictType">
<el-select v-model="queryParams.dictType" placeholder="请选择字典名称" clearable size="small"> <el-select v-model="queryParams.dictType" placeholder="请选择字典名称" clearable size="small">
<el-option <el-option
...@@ -22,8 +21,8 @@ ...@@ -22,8 +21,8 @@
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="flag">
<el-select v-model="queryParams.status" placeholder="数据状态" clearable size="small"> <el-select v-model="queryParams.flag" placeholder="数据状态" clearable size="small">
<el-option <el-option
v-for="dict in statusOptions" v-for="dict in statusOptions"
:key="dict.dictValue" :key="dict.dictValue"
...@@ -33,59 +32,89 @@ ...@@ -33,59 +32,89 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" size="small" @click="handleQuery">查询</el-button> <el-button type="primary" size="small" @click="handleQuery">搜索</el-button>
<!-- <el-button size="small" @click="resetQuery">重置</el-button>--> <el-button size="small" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div style="white-space: nowrap"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button <el-button
v-hasPermi="['system:dictConfig:add']" v-hasPermi="['system:dict:add']"
type="primary" type="primary"
size="small" icon="el-icon-plus"
size="mini"
@click="handleAdd" @click="handleAdd"
>新增</el-button> >新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button <el-button
v-hasPermi="['system:dictConfig:export']" v-hasPermi="['system:dict:edit']"
type="success" type="success"
size="small" icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
v-hasPermi="['system:dict:remove']"
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
icon="el-icon-download"
size="mini"
@click="handleExport" @click="handleExport"
>导出</el-button> >导出
<!-- <el-button size="small" @click="resetQuery">重置</el-button>--> </el-button>
</div> </el-col>
</div> <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
</el-row>
<div class="placeholder" /> <div class="placeholder" />
<div style="padding:10px"> <div style="padding:10px">
<div class="mb12 font-small-bold">字典参数列表</div> <div class="mb12 font-small-bold">字典参数列表</div>
<el-table v-loading="loading" :data="dataList" border> <el-table v-loading="loading" :data="dataList" border @selection-change="handleSelectionChange">
<el-table-column type="index" label="序号" width="50" /> <el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column :show-overflow-tooltip="true" label="参数编码" prop="dictCode">--> <!-- <el-table-column :show-overflow-tooltip="true" label="参数编码" prop="dictCode">-->
<!-- <template slot-scope="scope">--> <!-- <template slot-scope="scope">-->
<!-- {{ scope.row.dictCode || '-' }}--> <!-- {{ scope.row.dictCode || '-' }}-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<el-table-column :show-overflow-tooltip="true" label="参数标签" prop="dictLabel"> <el-table-column label="字典编码" align="center" prop="businessId" />
<el-table-column :show-overflow-tooltip="true" label="字典标签" prop="dictLabel">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.dictLabel || '-' }} {{ scope.row.dictLabel || '-' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :show-overflow-tooltip="true" label="参数键值" prop="dictValue"> <el-table-column :show-overflow-tooltip="true" label="字典键值" prop="dictValue">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.dictValue || '-' }} {{ scope.row.dictValue || '-' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :show-overflow-tooltip="true" label="参数排序" prop="dictSort"> <el-table-column :show-overflow-tooltip="true" label="字典排序" prop="dictSort">
<template slot-scope="scope"> <template slot-scope="scope">
{{ isNaN(scope.row.dictSort) ? '-' : scope.row.dictSort }} {{ isNaN(scope.row.dictSort) ? '-' : scope.row.dictSort }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :show-overflow-tooltip="true" label="备注" prop="remark"> <el-table-column label="状态" align="center" prop="flag" :formatter="statusFormat" />
<el-table-column :show-overflow-tooltip="true" label="备注" prop="remarks">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.remark || '-' }} {{ scope.row.remarks || '-' }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :show-overflow-tooltip="true" label="创建时间" prop="createTime"> <el-table-column :show-overflow-tooltip="true" label="创建时间" prop="createDate">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.createTime | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span> <span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width"> <el-table-column label="操作" class-name="small-padding fixed-width">
...@@ -114,7 +143,6 @@ ...@@ -114,7 +143,6 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<!-- <el-table-column label="状态" prop="status" :formatter="statusFormat" />-->
</el-table> </el-table>
</div> </div>
<pagination <pagination
...@@ -126,7 +154,7 @@ ...@@ -126,7 +154,7 @@
/> />
<!-- 添加或修改参数配置对话框 --> <!-- 添加或修改参数配置对话框 -->
<el-dialog title="字典参数信息" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="字典类型"> <el-form-item label="字典类型">
<el-input v-model.trim="form.dictType" :disabled="true" show-word-limit maxlength="30" placeholder="请输入字典类型" /> <el-input v-model.trim="form.dictType" :disabled="true" show-word-limit maxlength="30" placeholder="请输入字典类型" />
...@@ -149,13 +177,13 @@ ...@@ -149,13 +177,13 @@
>{{ dict.dictLabel }}</el-radio> >{{ dict.dictLabel }}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remarks">
<el-input v-model.trim="form.remark" type="textarea" show-word-limit maxlength="200" placeholder="请输入内容" /> <el-input v-model.trim="form.remarks" type="textarea" show-word-limit maxlength="200" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
<el-button type="primary" :loading="manageLoading" :disabled="manageLoading" @click="submitForm">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
...@@ -205,6 +233,8 @@ export default { ...@@ -205,6 +233,8 @@ export default {
single: true, single: true,
// 非多个禁用 // 非多个禁用
multiple: true, multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数 // 总条数
total: 0, total: 0,
// 字典表格数据 // 字典表格数据
...@@ -238,7 +268,8 @@ export default { ...@@ -238,7 +268,8 @@ export default {
pageSize: 10, pageSize: 10,
dictName: undefined, dictName: undefined,
dictType: undefined, dictType: undefined,
status: '' status: '',
flag: undefined
}, },
// 表单参数 // 表单参数
form: {}, form: {},
...@@ -308,7 +339,7 @@ export default { ...@@ -308,7 +339,7 @@ export default {
}, },
// 数据状态字典翻译 // 数据状态字典翻译
statusFormat(row, column) { statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status) return this.selectDictLabel(this.statusOptions, row.flag)
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
...@@ -318,16 +349,18 @@ export default { ...@@ -318,16 +349,18 @@ export default {
// 表单重置 // 表单重置
reset() { reset() {
this.form = { this.form = {
bussinessId: undefined,
dictCode: undefined, dictCode: undefined,
dictLabel: undefined, dictLabel: undefined,
dictValue: undefined, dictValue: undefined,
dictSort: 0, dictSort: 0,
flag: '1',
status: '0', status: '0',
remark: undefined remarks: undefined
} }
this.resetForm('form') this.resetForm('form')
}, },
/** 查询按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
...@@ -342,63 +375,49 @@ export default { ...@@ -342,63 +375,49 @@ export default {
handleAdd() { handleAdd() {
this.reset() this.reset()
this.open = true this.open = true
this.title = '添加' this.title = '添加字典数据'
this.form.dictType = this.queryParams.dictType this.form.dictType = this.queryParams.dictType
this.form.status = '0'
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictCode) this.ids = selection.map(item => item.businessId)
this.single = selection.length !== 1 this.single = selection.length !== 1
this.multiple = !selection.length this.multiple = !selection.length
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset() this.reset()
const dictCode = row.dictCode || this.ids const dictCode = row.businessId || this.ids
getData(dictCode).then(response => { getData(dictCode).then(response => {
this.form = response.data this.form = response.data
this.form.dictLabelOne = response.data.dictLabel this.form.dictLabelOne = response.data.dictLabel
this.open = true this.open = true
this.title = '字典数据信息' this.title = '修改字典数据'
}) })
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.manageLoading = true if (this.form.businessId !== undefined) {
if (this.form.dictCode) {
updateData(this.form).then(response => { updateData(this.form).then(response => {
if (response.code === 200) { this.msgSuccess('修改成功')
this.$message({ this.open = false
message: '修改成功',
type: 'success'
})
this.cancel()
this.getList() this.getList()
} })
this.manageLoading = false
}).catch(() => { this.manageLoading = false })
} else { } else {
addData(this.form).then(response => { addData(this.form).then(response => {
if (response.code === 200) { this.msgSuccess('新增成功')
this.$message({ this.open = false
message: '新增成功',
type: 'success'
})
this.cancel()
this.getList() this.getList()
} })
this.manageLoading = false
}).catch(() => { this.manageLoading = false })
} }
} }
}) })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const dictCodes = row.dictCode || this.ids const dictCodes = row.businessId || this.ids
this.$confirm('所选择数据被删除后不可再恢复,是否继续?', '提示', { this.$confirm('所选择数据被删除后不可再恢复,是否继续?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="状态" align="center" prop="flag" :formatter="statusFormat" /> <el-table-column label="状态" align="center" prop="flag" :formatter="statusFormat" />
<el-table-column label="备注" prop="remark" :show-overflow-tooltip="true"> <el-table-column label="备注" prop="remarks" :show-overflow-tooltip="true">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.remarks || '-' }} {{ scope.row.remarks || '-' }}
</template> </template>
...@@ -205,8 +205,8 @@ ...@@ -205,8 +205,8 @@
<!-- </el-option>--> <!-- </el-option>-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remarks">
<el-input v-model.trim="form.remark" maxlength="200" type="textarea" placeholder="请输入内容" /> <el-input v-model.trim="form.remarks" maxlength="200" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
...@@ -417,7 +417,7 @@ export default { ...@@ -417,7 +417,7 @@ export default {
dictName: undefined, dictName: undefined,
dictType: undefined, dictType: undefined,
status: '0', status: '0',
remark: undefined, remarks: undefined,
flag: '1' flag: '1'
} }
}, },
...@@ -454,27 +454,6 @@ export default { ...@@ -454,27 +454,6 @@ export default {
this.title = '修改字典类型' this.title = '修改字典类型'
}) })
}, },
// handleUpdate(row) {
// this.reset()
// this.form.dictName = row.dictName
// this.form.dictType = row.dictType
// this.form.remark = row.remark
// this.form.dictNameOne = row.dictName
// this.form.dictTypeOne = row.dictType
// this.form.businessId = row.businessId
// const parentId = row.parentId
// if (parentId) {
// this.form.parentId = parentId
// selectDictType(this.options.find(item => { return item.businessId === parentId }).dictType).then(response => {
// this.optionsDict = response.data
// })
// }
// if (row.dataId) {
// this.form.dataId = row.dataId
// }
// this.open = true
// this.title = 'update'
// },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment