|
@@ -4,8 +4,11 @@
|
|
|
<el-col :span="24">
|
|
|
<!-- 表单查询 -->
|
|
|
<el-form ref="queryForm" :model="queryParams" :inline="true" size="small">
|
|
|
- <el-form-item label="部门名称" prop="departmentName">
|
|
|
- <el-input v-model="queryParams.departmentName" placeholder="请输入部门名称" clear />
|
|
|
+ <el-form-item label="字典名称" prop="description">
|
|
|
+ <el-input v-model="queryParams.description" placeholder="请输入字典名称" clear />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字典值" prop="dictKeyType">
|
|
|
+ <el-input v-model="queryParams.dictKeyType" placeholder="请输入字典值" clear />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handelSearch">搜索</el-button>
|
|
@@ -24,18 +27,26 @@
|
|
|
>批量删除</el-button>
|
|
|
|
|
|
<!-- 表格数据信息 -->
|
|
|
- <el-table v-loading="loading" :data="deptList" row-key="id" @selection-change="handleSelectionChange">
|
|
|
+ <el-table v-loading="loading" :data="dictList" row-key="id" @selection-change="handleSelectionChange">
|
|
|
<el-table-column type="selection" width="50" align="center" />
|
|
|
- <el-table-column key="departmentName" label="部门名称" align="center" prop="departmentName" />
|
|
|
- <el-table-column key="departmentDescribe" label="部门描述" align="center" prop="departmentDescribe" />
|
|
|
- <el-table-column key="departmentNum" label="排序号" align="center" prop="departmentNum" />
|
|
|
- <el-table-column key="updateTime" label="更新时间" align="center" prop="updateTime" />
|
|
|
- <el-table-column key="createTime" label="创建时间" align="center" prop="createTime" />
|
|
|
+ <el-table-column key="description" label="字典名称" align="center" prop="description" />
|
|
|
+ <el-table-column key="dictKeyType" label="字典值" align="center" prop="dictKeyType">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-link type="primary" @click="hendelTo(scope.row)">{{ scope.row.dictKeyType }}</el-link>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column key="sortNum" label="排序号" align="center" prop="sortNum" />
|
|
|
<el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button size="mini" type="text" icon="el-icon-edit" @click="handelEdit(scope.row.id)">修改
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handelEdit(scope.row)">修改
|
|
|
</el-button>
|
|
|
- <el-button size="mini" type="text" icon="el-icon-delete" @click="handelDel(scope.row.id)">删除
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ :disabled="!multiple"
|
|
|
+ @click="handelDel(scope.row.id)"
|
|
|
+ >删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -48,7 +59,7 @@
|
|
|
:page.sync="queryParams.page"
|
|
|
:limit.sync="queryParams.limit"
|
|
|
align="right"
|
|
|
- @pagination="getDeptList"
|
|
|
+ @pagination="getAllDictType"
|
|
|
/>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -57,34 +68,26 @@
|
|
|
<el-dialog :title="title" :visible.sync="dialogVisible" width="35%" append-to-body>
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
|
|
<el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="上级部门" prop="parentId">
|
|
|
- <selectTree v-model="form.parentId" :options="options" placeholder="请选择上级部门" :name="name" />
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="字典描述" prop="description">
|
|
|
+ <el-input v-model="form.description" clearable placeholder="请输入字典名称" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="部门名称" prop="departmentName">
|
|
|
- <el-input v-model="form.departmentName" clearable placeholder="请输入部门名称" />
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="字典类型" prop="dictKeyValue">
|
|
|
+ <el-input v-model="form.dictKeyValue" clearable placeholder="请输入字典名称" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="部门描述" prop="departmentDescribe">
|
|
|
- <el-input v-model="form.departmentDescribe" clearable placeholder="请输入部门描述" />
|
|
|
+ <el-form-item label="字典值" prop="dictKeyType">
|
|
|
+ <el-input v-model="form.dictKeyType" clearable placeholder="请输入字典值" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="显示排序" prop="departmentNum">
|
|
|
- <el-input-number
|
|
|
- v-model="form.departmentNum"
|
|
|
- placeholder="0"
|
|
|
- controls-position="right"
|
|
|
- :min="1"
|
|
|
- :max="10"
|
|
|
- />
|
|
|
+ <el-form-item label="显示排序" prop="sortNum">
|
|
|
+ <el-input-number v-model="form.sortNum" placeholder="0" controls-position="right" :min="1" :max="10" />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -98,12 +101,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getDeptList, addDept, getDeptById, editDept, delDept, getAllSonMenuList } from '@/api/system/dept.js'
|
|
|
-import { getDictList } from '@/api/system/dict.js'
|
|
|
-import selectTree from '@/components/SelectTree'
|
|
|
-import XEUtils from 'xe-utils'
|
|
|
+import { getAllDictType, editDictType, addDictType, delDictType } from '@/api/system/dictType.js'
|
|
|
export default {
|
|
|
- components: { selectTree },
|
|
|
data() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
@@ -116,67 +115,51 @@ export default {
|
|
|
// 总条数
|
|
|
total: 0,
|
|
|
// 表格数据
|
|
|
- deptList: [],
|
|
|
+ dictList: [],
|
|
|
// 弹出框
|
|
|
dialogVisible: false,
|
|
|
// 弹出框标题
|
|
|
title: '',
|
|
|
// 弹出框表单
|
|
|
form: {},
|
|
|
- // 菜单类别
|
|
|
+ // 字典树数据
|
|
|
options: [],
|
|
|
// 表单验证
|
|
|
rules: {
|
|
|
- departmentName: [
|
|
|
- { required: true, message: '部门单名称不能为空', trigger: 'blur' }
|
|
|
+ description: [
|
|
|
+ { required: true, message: '字典名称不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
- departmentDescribe: [
|
|
|
- { required: true, message: '部门描述不能为空', trigger: 'blur' }
|
|
|
+ dictKeyType: [
|
|
|
+ { required: true, message: '字典值不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
- departmentNum: [
|
|
|
+ sortNum: [
|
|
|
{ required: true, message: '排序不能为空', trigger: ['change', 'blur'] }
|
|
|
]
|
|
|
},
|
|
|
- // 修改菜单id
|
|
|
- id: null,
|
|
|
// 控制批量删除按钮
|
|
|
multiple: true,
|
|
|
- // 删除部门id集合
|
|
|
+ // 删除字典id集合
|
|
|
ids: [],
|
|
|
// 自定义treeselect键名
|
|
|
- name: null
|
|
|
+ keyName: null
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.handelSearch()
|
|
|
- getDictList().then(res => {
|
|
|
- console.log(res)
|
|
|
- })
|
|
|
},
|
|
|
methods: {
|
|
|
- /** 获取表格数据 */
|
|
|
- getDeptList() {
|
|
|
- getDeptList(this.queryParams).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- const data = res.data
|
|
|
- this.deptList = XEUtils.toArrayTree(data.departmentList)
|
|
|
- this.total = data.count
|
|
|
- this.getOptionsList()
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- /** 获取上级部门 */
|
|
|
- getOptionsList() {
|
|
|
- getAllSonMenuList().then(res => {
|
|
|
+ /** 查询所有字典类型 */
|
|
|
+ getAllDictType() {
|
|
|
+ getAllDictType(this.queryParams).then(res => {
|
|
|
const data = res.data
|
|
|
- this.options = data
|
|
|
- this.name = 'departmentName'
|
|
|
+ this.dictList = data.dictTypes
|
|
|
+ this.total = data.count
|
|
|
})
|
|
|
},
|
|
|
/** 搜索 */
|
|
|
handelSearch() {
|
|
|
this.queryParams.page = 1
|
|
|
- this.getDeptList()
|
|
|
+ this.getAllDictType()
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
handelReset() {
|
|
@@ -186,17 +169,14 @@ export default {
|
|
|
/** 新增按钮 */
|
|
|
handelAdd() {
|
|
|
this.dialogVisible = true
|
|
|
- this.title = '添加部门'
|
|
|
+ this.title = '添加字典'
|
|
|
this.reset()
|
|
|
},
|
|
|
/** 修改按钮 */
|
|
|
- handelEdit(id) {
|
|
|
- this.id = id
|
|
|
- getDeptById({ id }).then(res => {
|
|
|
- this.form = res.data
|
|
|
- })
|
|
|
+ handelEdit(row) {
|
|
|
+ this.form = row
|
|
|
this.dialogVisible = true
|
|
|
- this.title = '修改部门'
|
|
|
+ this.title = '修改字典'
|
|
|
},
|
|
|
/** 表格多选 */
|
|
|
handleSelectionChange(val) {
|
|
@@ -205,20 +185,13 @@ export default {
|
|
|
},
|
|
|
/** 删除按钮 */
|
|
|
handelDel(id) {
|
|
|
- this.$confirm('是否删除该部门?', '提示', {
|
|
|
+ this.$confirm('是否删除该字典?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- delDept([id]).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功'
|
|
|
- })
|
|
|
- this.getDeptList()
|
|
|
- }
|
|
|
- })
|
|
|
+ this.ids.push(id)
|
|
|
+ this.delDictType()
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -228,20 +201,12 @@ export default {
|
|
|
},
|
|
|
/** 批量删除 */
|
|
|
handelDelAll() {
|
|
|
- this.$confirm('是否批量删除部门?', '提示', {
|
|
|
+ this.$confirm('是否批量删除字典?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
- delDept(this.ids).then(res => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: '删除成功'
|
|
|
- })
|
|
|
- this.getDeptList()
|
|
|
- }
|
|
|
- })
|
|
|
+ this.delDictType()
|
|
|
}).catch(() => {
|
|
|
this.$message({
|
|
|
type: 'info',
|
|
@@ -249,30 +214,41 @@ export default {
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
+ /** 删除接口 */
|
|
|
+ delDictType() {
|
|
|
+ delDictType(this.ids).then(res => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功'
|
|
|
+ })
|
|
|
+ this.getAllDictType()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
/** 表单提交 */
|
|
|
handelSubmit(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- if (this.title === '添加部门') {
|
|
|
- addDept(this.form).then(res => {
|
|
|
+ if (this.title === '添加字典') {
|
|
|
+ addDictType(this.form).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
|
message: res.data,
|
|
|
type: 'success'
|
|
|
})
|
|
|
- this.getDeptList()
|
|
|
+ this.getAllDictType()
|
|
|
this.dialogVisible = false
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- this.form.id = this.id
|
|
|
- editDept(this.form).then(res => {
|
|
|
+ editDictType(this.form).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
|
message: res.data,
|
|
|
type: 'success'
|
|
|
})
|
|
|
- this.getDeptList()
|
|
|
+ this.getAllDictType()
|
|
|
this.dialogVisible = false
|
|
|
}
|
|
|
})
|
|
@@ -290,6 +266,10 @@ export default {
|
|
|
if (this.$refs['form']) {
|
|
|
this.$refs['form'].resetFields()
|
|
|
}
|
|
|
+ },
|
|
|
+ /** 选择字典类型跳转 */
|
|
|
+ hendelTo(row) {
|
|
|
+ this.$router.push('/system/dict/dict-detail/role/' + row.dictKeyType)
|
|
|
}
|
|
|
}
|
|
|
}
|