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

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

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