feat()字典映射

dev-1
王熙朝 2024-04-27 20:31:59 +08:00
parent 744c5c6da2
commit 22708ed023
4 changed files with 78 additions and 34 deletions

View File

@ -66,3 +66,17 @@ export function selectDictData(data) {
data data
}) })
} }
// 删除
export function deleteDictType(dictType) {
return request({
url: '/system/dicts/deleteDictType?dictType=' + dictType,
method: 'post'
})
}
//详情
export function selectDictType(dictType) {
return request({
url: '/system/dicts/selectDictType?dictType=' + dictType,
method: 'post'
})
}

View File

@ -36,10 +36,15 @@
placement="left" placement="left"
width="200" width="200"
trigger="hover"> trigger="hover">
<el-table :data="dictMap[scope.row.dictionary]"> <span v-for="item in dictOut" :key="item.dictType">
<el-table-column prop="label" label="标签"></el-table-column> <span v-show="item.dictType == scope.row.dictionary">
<el-table-column prop="val" label="值"></el-table-column> <el-table :data="item.dictDataList">
</el-table> <el-table-column prop="dictLabel" label="标签"></el-table-column>
<el-table-column prop="dictValue" label="值"></el-table-column>
</el-table>
</span>
</span>
<el-tag slot="reference">{{scope.row.dictionary}}</el-tag> <el-tag slot="reference">{{scope.row.dictionary}}</el-tag>
</el-popover> </el-popover>
</template> </template>
@ -125,18 +130,22 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="字典"> <el-form-item label="字典">
<el-select v-model="form.dictionary"> <el-select v-model="form.dictionary">
<el-option v-for="(value, key) in dictMap" :key="key" :label="key" :value="key"></el-option> <el-option v-for="(val, key) in dictOut" :key="val.dictType" :label="val.dictType" :value="val.dictType"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-row v-if="form.dictionary!=null">
<el-form-item> <el-col :span="24">
<el-table :data="dictMap[form.dictionary]" striped border> <el-form-item>
<el-table-column property="label" label="标签"></el-table-column> <div v-on="selData2(form.dictionary)">
<el-table-column property="val" label="值"></el-table-column> <el-table :data="dictMap2.dictDataList">
</el-table> <el-table-column prop="dictLabel" label="标签"></el-table-column>
</el-form-item> <el-table-column prop="dictValue" label="值"></el-table-column>
</el-col> </el-table>
</div>
</el-form-item>
</el-col>
</el-row>
</el-row> </el-row>
</el-row> </el-row>
</el-form> </el-form>
@ -153,12 +162,12 @@ import {
selNameListStructure, selNameListStructure,
updateListStructure updateListStructure
} from '@/api/system/accredit' } from '@/api/system/accredit'
import data from "@/views/system/dict/data.vue" import { listDictType, selectDictType } from "@/api/system/dicts";
export default { export default {
props: { props: {
title: { title: {
type: Object type: String
}, },
}, },
name: 'OverallAssetStructure', name: 'OverallAssetStructure',
@ -180,20 +189,30 @@ export default {
dictionary: '' dictionary: ''
}, },
formStatus: false, formStatus: false,
tableName: '',
dictMap:{ dictMap:{
"性别(system_sex)": [ dictType: '',
{ label: '男', val: '1', isEdit: false }, dictDataList: []
{ label: '女', val: '2', isEdit: false }, },
{ label: '未知', val: '0', isEdit: false }, dictMap2:{
], dictType: '',
"开关(system_y_n)": [ dictDataList: []
{ label: '是', val: '1', isEdit: false }, },
{ label: '否', val: '0', isEdit: false } dictOut: [],
],
}
} }
}, },
methods: { methods: {
selData(thanName){
selectDictType(thanName).then(res => {
this.dictMap = res.data
})
},
selData2(thanName){
selectDictType(thanName).then(res => {
this.dictMap2 = res.data
})
},
update(row) { update(row) {
console.log(row) console.log(row)
this.form = row; this.form = row;
@ -208,7 +227,7 @@ export default {
}, },
init() { init() {
console.log(this.title) console.log(this.title)
if (this.title === null){ if (this.title === undefined){
listListstructure().then(res => { listListstructure().then(res => {
this.childrenList = res.data this.childrenList = res.data
}) })
@ -217,7 +236,10 @@ export default {
this.childrenList = res.data this.childrenList = res.data
}) })
} }
listDictType().then(res => {
this.dictOut = res.data
console.log(this.dictOut)
})
} }
}, },
// - 访this", // - 访this",

View File

@ -63,8 +63,10 @@
<span>{{val.dictType}}</span> <span>{{val.dictType}}</span>
<el-button style="float: right; padding: 3px 0" <el-button style="float: right; padding: 3px 0"
type="text" type="text"
@click="val.dictDataList.push({ dictCode:val.dictDataList.dictCode , dictType:val.dictType, dictLabel: null, dictValue: null, isEdit: true })" @click="val.dictDataList.push({ dictCode:0 , dictType:val.dictType, dictLabel: null, dictValue: null, isEdit: true })"
>新增</el-button> >新增</el-button>
<el-button style="float: right; padding: 3px 0"
@click="delType(val.dictType)">删除字典</el-button>
</div> </div>
<el-table :data="val.dictDataList" style="width: 100%" height="280px"> <el-table :data="val.dictDataList" style="width: 100%" height="280px">
<el-table-column prop="label" label="标签"> <el-table-column prop="label" label="标签">
@ -126,7 +128,7 @@
<script> <script>
import CountTo from 'vue-count-to' import CountTo from 'vue-count-to'
import OverallAssetStructure from './OverallAssetStructure.vue' import OverallAssetStructure from './OverallAssetStructure.vue'
import { listDictType, indexDictType, indexDictData, deleteDictData, selectDictData } from "@/api/system/dicts" import { listDictType, indexDictType, indexDictData, deleteDictData, selectDictData, deleteDictType } from "@/api/system/dicts"
import val from "quill"; import val from "quill";
export default { export default {
@ -168,7 +170,7 @@ export default {
selectDictData(row).then(res => { selectDictData(row).then(res => {
this.dictData = res.data this.dictData = res.data
}) })
this.dictData = true row.isEdit = true
}, },
editConfirm(row) { editConfirm(row) {
console.log(row) console.log(row)
@ -176,11 +178,18 @@ export default {
this.$message.error('字典标签或字典值,不可为空'); this.$message.error('字典标签或字典值,不可为空');
return; return;
} }
// indexDictData(row).then(res => { indexDictData(row).then(res => {
// this.$message.success(res.data) this.$message.success(res.data)
// }) })
row.isEdit = false; row.isEdit = false;
}, },
delType(row) {
console.log(row)
deleteDictType(row).then(res => {
this.$message.success(res.data)
})
this.init()
},
delData(row) { delData(row) {
deleteDictData(row).then(res => { deleteDictData(row).then(res => {
this.$message.success(res.data) this.$message.success(res.data)

View File

@ -30,7 +30,6 @@ import OverallAssets from "@/views/assets/table/dashboard/OverallAssets.vue";
import { selectFrimary } from "@/api/system/accredit"; import { selectFrimary } from "@/api/system/accredit";
export default { export default {
name: 'table',
components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets }, components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets },
data() { data() {
return { return {