Browse Source

系统字典项添加支持 父级Id

master
jianjun 4 years ago
parent
commit
7a9103ad9b
  1. 1
      epmet-oper-web/src/i18n/zh-CN.js
  2. 1
      epmet-oper-web/src/i18n/zh-TW.js
  3. 34
      epmet-oper-web/src/views/modules/sys/dict-data-add-or-update.vue
  4. 16
      epmet-oper-web/src/views/modules/sys/dict-data.vue
  5. 3
      epmet-oper-web/src/views/modules/sys/dict-type.vue

1
epmet-oper-web/src/i18n/zh-CN.js

@ -290,6 +290,7 @@ t.dict.dictName = '字典名称'
t.dict.dictType = '字典类型'
t.dict.dictLabel = '字典标签'
t.dict.dictValue = '字典值'
t.dict.dictPValue = '父级字典值'
t.dict.sort = '排序'
t.dict.remark = '备注'
t.dict.createDate = '创建时间'

1
epmet-oper-web/src/i18n/zh-TW.js

@ -288,6 +288,7 @@ t.dict.dictName = '字典名稱'
t.dict.dictType = '字典類型'
t.dict.dictLabel = '字典標籤'
t.dict.dictValue = '字典值'
t.dict.dictPValue = '父級字典值'
t.dict.sort = '排序'
t.dict.remark = '備註'
t.dict.createDate = '創建時間'

34
epmet-oper-web/src/views/modules/sys/dict-data-add-or-update.vue

@ -1,6 +1,17 @@
<template>
<el-dialog :visible.sync="visible" :title="!dataForm.id ? $t('add') : $t('update')" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" label-width="120px">
<el-form-item :label="$t('dict.dictPValue')">
<el-select v-model="dataForm.dictPValue"
placeholder="请选择"
class="overtime-input">
<el-option v-for="item in pDictList"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item prop="dictValue" :label="$t('dict.dictValue')">
<el-input v-model="dataForm.dictValue" :placeholder="$t('dict.dictValue')"></el-input>
</el-form-item>
@ -27,11 +38,14 @@ export default {
data () {
return {
visible: false,
pDictList: [],
dataForm: {
id: '',
dictTypeId: '',
dictLabel: '',
dictValue: '',
dictPValue: '',
dictType: '',
sort: 0,
remark: ''
}
@ -57,9 +71,11 @@ export default {
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
this.dataForm.dictPValue = ''
if (this.dataForm.id) {
this.getInfo()
}
this.initPDictList()
})
},
//
@ -74,12 +90,30 @@ export default {
}
}).catch(() => {})
},
//
async initPDictList () {
let params = {
dictType: this.dataForm.dictType
}
this.$http
.post('/sys/dict/data/dictlist', params)
.then(({ data: res }) => {
if (res.code === 0) {
this.pDictList = res.data
console.log(this.pDictList)
}
})
},
//
dataFormSubmitHandle: debounce(function () {
this.$refs['dataForm'].validate((valid) => {
if (!valid) {
return false
}
console.log('===',this.dataForm.dictPValue=== '');
if (this.dataForm.dictPValue === ''){
this.dataForm.dictPValue = null;
}
this.$http[!this.dataForm.id ? 'post' : 'put']('/sys/dict/data', this.dataForm).then(({ data: res }) => {
if (res.code !== 0) {
return this.$message.error(res.msg)

16
epmet-oper-web/src/views/modules/sys/dict-data.vue

@ -22,9 +22,9 @@
<el-button type="primary"
@click="addOrUpdateHandle()">{{ $t('add') }}</el-button>
</el-form-item>
<el-form-item>
<el-buttontype="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-buttontype=>
</el-form-item>
<!-- <el-form-item>
<el-button type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
</el-form-item>-->
</el-form>
<el-table v-loading="dataListLoading"
:data="dataList"
@ -44,6 +44,10 @@
:label="$t('dict.dictLabel')"
header-align="center"
align="center"></el-table-column>
<el-table-column prop="dictPValue"
:label="$t('dict.dictPValue')"
header-align="center"
align="center"></el-table-column>
<el-table-column prop="sort"
:label="$t('dict.sort')"
sortable="custom"
@ -107,7 +111,8 @@ export default {
dataForm: {
dictTypeId: '0',
dictLabel: '',
dictValue: ''
dictValue: '',
dictType: ''
}
}
},
@ -116,7 +121,9 @@ export default {
},
created () {
this.dataForm.dictTypeId = this.$route.params.dictTypeId || '0'
this.dataForm.dictType = this.$route.params.dictType || '0'
this.getDataList()
console.log(this.dataForm)
},
methods: {
// /
@ -125,6 +132,7 @@ export default {
this.$nextTick(() => {
this.$refs.addOrUpdate.dataForm.id = id
this.$refs.addOrUpdate.dataForm.dictTypeId = this.dataForm.dictTypeId
this.$refs.addOrUpdate.dataForm.dictType = this.dataForm.dictType
this.$refs.addOrUpdate.init()
})
}

3
epmet-oper-web/src/views/modules/sys/dict-type.vue

@ -129,7 +129,8 @@ export default {
title: `${this.$route.meta.title} - ${row.dictType}`,
path: 'sys/dict-data',
params: {
dictTypeId: row.id
dictTypeId: row.id,
dictType:row.dictType
}
}
//

Loading…
Cancel
Save