|
@@ -25,6 +25,13 @@
|
|
|
:disabled="multiple"
|
|
|
@click="handelDelAll"
|
|
|
>批量删除</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ icon="el-icon-close"
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ @click="(() => { this.$router.push('/system/dict') })"
|
|
|
+ >返回</el-button>
|
|
|
|
|
|
<!-- 表格数据信息 -->
|
|
|
<el-table v-loading="loading" :data="dictList" row-key="id" @selection-change="handleSelectionChange">
|
|
@@ -55,44 +62,12 @@
|
|
|
:page.sync="queryParams.page"
|
|
|
:limit.sync="queryParams.limit"
|
|
|
align="right"
|
|
|
- @pagination="getDictListByType"
|
|
|
+ @pagination="getPageDictList"
|
|
|
/>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
|
|
|
<!-- 弹出框 -->
|
|
|
- <!-- <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="12">
|
|
|
- <el-form-item label="字典描述" prop="description">
|
|
|
- <el-input v-model="form.description" clearable placeholder="请输入字典名称" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <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="dictKeyType">
|
|
|
- <el-input v-model="form.dictKeyType" clearable placeholder="请输入字典值" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <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>
|
|
|
- </el-form>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button type="primary" @click="handelSubmit('form')">确 定</el-button>
|
|
|
- <el-button @click="handelCancel('form')">取 消</el-button>
|
|
|
- </span>
|
|
|
- </el-dialog> -->
|
|
|
<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>
|
|
@@ -131,8 +106,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getPageDictList, getAllDictList, getDictListByType, delDict, addDict } from '@/api/system/dict.js'
|
|
|
-import { getAllDictType, editDictType } from '@/api/system/dictType.js'
|
|
|
+import { getAllDictList, getDictListByType, delDict, addDict, getPageDictList, editDict } from '@/api/system/dict.js'
|
|
|
import selectTree from '@/components/SelectTree'
|
|
|
export default {
|
|
|
components: { selectTree },
|
|
@@ -143,9 +117,7 @@ export default {
|
|
|
// 查询参数
|
|
|
queryParams: {
|
|
|
page: 1,
|
|
|
- num: 10,
|
|
|
- // 字典类型
|
|
|
- keyType: null
|
|
|
+ num: 10
|
|
|
},
|
|
|
// 总条数
|
|
|
total: 0,
|
|
@@ -161,10 +133,10 @@ export default {
|
|
|
options: [],
|
|
|
// 表单验证
|
|
|
rules: {
|
|
|
- description: [
|
|
|
+ dictValue: [
|
|
|
{ required: true, message: '字典名称不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
- dictKeyType: [
|
|
|
+ dictKey: [
|
|
|
{ required: true, message: '字典值不能为空', trigger: 'blur' }
|
|
|
],
|
|
|
sortNum: [
|
|
@@ -176,18 +148,21 @@ export default {
|
|
|
// 删除字典id集合
|
|
|
ids: [],
|
|
|
// 自定义treeselect键名
|
|
|
- keyName: null
|
|
|
+ keyName: null,
|
|
|
+ // 字典类型
|
|
|
+ keyType: null
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
const { id, dictKeyType } = this.$route.query
|
|
|
this.form.dictTypeId = id
|
|
|
- this.queryParams.keyType = dictKeyType
|
|
|
- this.handelSearch()
|
|
|
+ this.keyType = dictKeyType
|
|
|
+ this.getDictListByType()
|
|
|
},
|
|
|
methods: {
|
|
|
/** 根据类型查字典列表数据 */
|
|
|
getDictListByType() {
|
|
|
+ this.queryParams.keyType = this.keyType
|
|
|
getDictListByType(this.queryParams).then(res => {
|
|
|
const data = res.data
|
|
|
this.dictList = this.$utils.toArrayTree(data.dicts)
|
|
@@ -195,21 +170,12 @@ export default {
|
|
|
this.getAllDictList()
|
|
|
})
|
|
|
},
|
|
|
- /** 查询所有字典类型 */
|
|
|
- getAllDictType() {
|
|
|
- getAllDictType(this.queryParams).then(res => {
|
|
|
- const data = res.data
|
|
|
- this.dictList = data.dictTypes
|
|
|
- this.total = data.count
|
|
|
- })
|
|
|
- },
|
|
|
/** 分页获取字典列表数据 */
|
|
|
getPageDictList() {
|
|
|
getPageDictList(this.queryParams).then(res => {
|
|
|
const data = res.data
|
|
|
this.dictList = this.$utils.toArrayTree(data.dictPage)
|
|
|
this.total = data.count
|
|
|
- this.getAllDictList()
|
|
|
})
|
|
|
},
|
|
|
/** 全量获取字典列表数据 */
|
|
@@ -223,12 +189,13 @@ export default {
|
|
|
/** 搜索 */
|
|
|
handelSearch() {
|
|
|
this.queryParams.page = 1
|
|
|
- this.getDictListByType()
|
|
|
+ this.getPageDictList()
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
handelReset() {
|
|
|
this.$refs['queryForm'].resetFields()
|
|
|
- this.handelSearch()
|
|
|
+ this.queryParams.page = 1
|
|
|
+ this.getDictListByType()
|
|
|
},
|
|
|
/** 新增按钮 */
|
|
|
handelAdd() {
|
|
@@ -237,14 +204,10 @@ export default {
|
|
|
this.reset()
|
|
|
},
|
|
|
/** 修改按钮 */
|
|
|
- handelEdit(id) {
|
|
|
- // this.queryParams.dictKey = id
|
|
|
- // getDictDetailByIdorKey(this.queryParams).then(res => {
|
|
|
- // const data = res.data
|
|
|
- // this.form = data.dicts[0]
|
|
|
- // })
|
|
|
- // this.dialogVisible = true
|
|
|
- // this.title = '修改字典'
|
|
|
+ handelEdit(row) {
|
|
|
+ this.form = row
|
|
|
+ this.dialogVisible = true
|
|
|
+ this.title = '修改字典'
|
|
|
},
|
|
|
/** 表格多选 */
|
|
|
handleSelectionChange(val) {
|
|
@@ -299,7 +262,6 @@ export default {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
if (valid) {
|
|
|
if (this.title === '添加字典') {
|
|
|
- console.log(this.form)
|
|
|
addDict(this.form).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
@@ -311,7 +273,11 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- editDictType(this.form).then(res => {
|
|
|
+ if (this.form.parentId === undefined) {
|
|
|
+ this.form.parentId = 0
|
|
|
+ return
|
|
|
+ }
|
|
|
+ editDict(this.form).then(res => {
|
|
|
if (res.code === 200) {
|
|
|
this.$message({
|
|
|
message: res.data,
|
|
@@ -335,10 +301,6 @@ export default {
|
|
|
if (this.$refs['form']) {
|
|
|
this.$refs['form'].resetFields()
|
|
|
}
|
|
|
- },
|
|
|
- /** 选择字典类型跳转 */
|
|
|
- hendelTo(row) {
|
|
|
- console.log(row)
|
|
|
}
|
|
|
}
|
|
|
}
|