优化字典

This commit is contained in:
陈裕财
2025-04-11 19:53:31 +08:00
parent 65e00fd134
commit 46555e1f5d
7 changed files with 195 additions and 33 deletions

View File

@@ -6,6 +6,8 @@ import MdpSelectImage from './mdp-select-image/Index.vue'
import MdpImage from './mdp-image/Index.vue'
import MdpSelectAtt from './mdp-select-att/Index.vue'
import MdpMetaItem from './mdp-meta-item/Index.vue'
import MdpMetaForm from './mdp-meta-item/Form.vue'
import MdpDictOptions from './mdp-meta-option/Options.vue'
import MdpMetaOption from './mdp-meta-option/Index.vue'
import MdpExtInfos from './mdp-ext-infos/Index.vue'
import MdpSelectCate from './mdp-select-cate/Index.vue'
@@ -30,8 +32,10 @@ const compLists = {
Vue.component('MdpImage', MdpImage)
Vue.component('MdpSelectAtt', MdpSelectAtt)
Vue.component('MdpMetaItem', MdpMetaItem)
Vue.component('MdpMetaForm', MdpMetaForm)
Vue.component('MdpSelectMeta', MdpSelectMeta)
Vue.component('MdpMetaOption', MdpMetaOption)
Vue.component('MdpDictOptions', MdpDictOptions)
Vue.component('MdpExtInfos', MdpExtInfos)
Vue.component('MdpCateTree', MdpCateTree)
Vue.component('MdpSelectCate', MdpSelectCate)

View File

@@ -110,8 +110,7 @@
</el-form>
<el-row v-if="showBtn!==false" class="footer">
<el-button @click="handleCancel">取消</el-button>
<el-row v-if="showBtn!==false" class="footer">
<el-button v-loading="load.edit" type="primary" @click="saveSubmit" :disabled="disBtn('addBtn')">提交</el-button>
</el-row>
</template>

View File

@@ -14,11 +14,11 @@
<template #header>
<el-space wrap >
<mdp-hi-query :column-configs="columnConfigs" v-model="hiQueryParams" @change="onHiQueryParamsChange"/>
<el-button icon="zoom-out" @click="searchReset()" title="重置查询条件并查询"/>
<el-button :disabled="disBtn('addBtn') || !checkBtnQx('addBtn',menuDefId) || !this.itemCpd || !this.itemCpd.id" type="primary" @click="openForm({parentOpType:currOpType,subOpType:'add',formData:addForm,item:itemCpd})" icon="plus"/>
<el-button :disabled="disBtn('delBtn') || !checkBtnQx('delBtn',menuDefId) || this.sels.length===0 || load.del==true" type="danger" v-loading="load.batchDel" @click="batchDel" icon="delete"/>
<el-button icon="zoom-out" @click="searchReset()" title="重置查询条件并查询" plain/>
<el-button plain :disabled="disBtn('addBtn') || !checkBtnQx('addBtn',menuDefId) || !this.itemCpd || !this.itemCpd.id" type="primary" @click="openForm({parentOpType:currOpType,subOpType:'add',formData:addForm,item:itemCpd})" icon="plus"/>
<el-button plain :disabled="disBtn('delBtn') || !checkBtnQx('delBtn',menuDefId) || this.sels.length===0 || load.del==true" type="danger" v-loading="load.batchDel" @click="batchDel" icon="delete"/>
<el-button icon="download" @click="export2Excel()" title="导出当前结果数据"/>
<el-button plain icon="download" @click="export2Excel()" title="导出当前结果数据"/>
<mdp-table-configs :column-configs="columnConfigs" v-model="checkedColumns"/>
</el-space>
</template>
@@ -120,7 +120,7 @@
style="float:right;"
/>
<!--新增修改明细 ItemOption 字典选项值界面-->
<mdp-dialog width="80%" :ref="refId+'FormDialog'">
<mdp-dialog width="80%" :ref="refId+'FormDialog'" top="20px">
<template #default="{visible,data}">
<item-option-form :item="item" :ref="refId+'Form'" :sub-op-type="data.subOpType" :form-data="data.formData" :visible="visible" :parent-op-type="currOpType" @close="onFormClose" @submit="afterFormSubmit" @fields-change="searchTableDatas"/>
</template>

View File

@@ -0,0 +1,91 @@
<template>
<mdp-meta-option :item="item" @row-click="onRowClick" :simple="true">
<template #title>
<el-button @click="openEditForm" v-if="item?.id" type="primary" icon="edit" plain/>
<el-text type="warning" v-if="item?.itemCode">{{ item?.itemName||itemCode }}</el-text>
<el-alert v-else type="warning">当前无字典请先创建字典 </el-alert>
<el-button @click="openAddForm" v-if="!item?.id" type="primary" icon="plus"/>
</template>
</mdp-meta-option>
<mdp-dialog fullscreen ref="metaForm">
<template #default="{data,visible}">
<MdpMetaForm :formData="data.formData" :subOpType="data.subOpType" :visible="visible" @submit="afterFormSubmit" @fields-change="onFieldsChange"/>
</template>
</mdp-dialog>
</template>
<script>
import { mapState } from 'pinia'
import { useUserStore } from '@/store/modules/user'
export default {
name:'MdpDictOptions',
computed: {
...mapState(useUserStore,['userInfo'])
},
props:{
itemCode:{
type: String,
default: '',
}
},
watch:{
itemCode(){
this.getItem()
}
},
data() {
return {
load:{list:false},
item:null,
}
},
methods: {
onRowClick(row){
},
createDict(){
},
getItem(){
if(!this.itemCode){
this.item=null;
return;
}
this.load.list=true;
this.$mdp.listItem({itemCode:this.itemCode}).then(res=>{
this.load.list=false;
if(res?.data?.length>0){
this.item=res.data[0]
}else{
this.item=null
}
})
},
afterFormSubmit(data){
this.getItem();
},
openAddForm(){
let formData={id:this.itemCode,itemCode:this.itemCode,categoryId:'all'}
this.$refs['metaForm'].open({formData:formData,subOpType:'add'})
},
openEditForm(){
let formData=this.item
this.$refs['metaForm'].open({formData:formData,subOpType:'edit'})
},
onFieldsChange(){
this.getItem();
}
},
mounted() {
this.getItem()
}
}
</script>
<style scoped>
</style>

View File

@@ -145,9 +145,9 @@
</span>
</div>
</span>
<mdp-dialog ref="mdpMetaDialog" width="70%">
<mdp-dialog ref="mdpMetaDialog" fullscreen>
<template #default="{visible,data}">
<mdp-meta-item v-if="data.itemCode" :visible="visible" sub-op-type="mng" :item-code="data.itemCode" @form-submit="onDictSubmit" @option-form-submit="onDictSubmit"/>
<mdp-dict-options v-if="data.itemCode" :visible="visible" sub-op-type="mng" :item-code="data.itemCode" @form-submit="onDictSubmit" @option-form-submit="onDictSubmit"/>
</template>
</mdp-dialog>
</span>

View File

@@ -17,36 +17,13 @@ export default {
data() {
return {
load:{list:false},
metaOption:null,
projectPhasePlansItem:null,
}
},
methods: {
onRowClick(row){
this.metaOption=null
this.metaOption=row
var item={itemCode:'projectPhasePlans'+row.id,categoryId:'all'};
this.$mdp.listItem(item).then(res=>{
var tips = res.tips
if(tips.isOk && res.data.length>0){
this.projectPhasePlansItem=res.data[0]
}else{
this.projectPhasePlansItem=null
}
})
},
createDict(){
var row=this.metaOption
var item={id:'projectPhasePlans'+row.id, itemCode:'projectPhasePlans'+row.id,categoryId:'all',name:row.name};
this.$mdp.addItem(item).then(res=>{
var tips = res.tips
if(tips.isOk){
this.$notify.success("创建字典成功")
this.projectPhasePlansItem=res.data
}else{
this.$notify.error(tips.msg)
}
})
},
},

View File

@@ -0,0 +1,91 @@
<template>
<mdp-meta-option :item="item" @row-click="onRowClick" :simple="true">
<template #title>
<el-button @click="openEditForm" v-if="item?.id" type="primary" icon="edit" plain/>
<el-text type="warning" v-if="item?.itemCode">{{ item?.itemName||itemCode }}</el-text>
<el-alert v-else type="warning">当前无字典请先创建字典 </el-alert>
<el-button @click="openAddForm" v-if="!item?.id" type="primary" icon="plus"/>
</template>
</mdp-meta-option>
<mdp-dialog fullscreen ref="metaForm">
<template #default="{data,visible}">
<MdpMetaForm :formData="data.formData" :subOpType="data.subOpType" :visible="visible" @submit="afterFormSubmit" @fields-change="onFieldsChange"/>
</template>
</mdp-dialog>
</template>
<script>
import { mapState } from 'pinia'
import { useUserStore } from '@/store/modules/user'
export default {
name:'XmDictList',
computed: {
...mapState(useUserStore,['userInfo'])
},
props:{
itemCode:{
type: String,
default: '',
}
},
watch:{
itemCode(){
this.getItem()
}
},
data() {
return {
load:{list:false},
item:null,
}
},
methods: {
onRowClick(row){
},
createDict(){
},
getItem(){
if(!this.itemCode){
this.item=null;
return;
}
this.load.list=true;
this.$mdp.listItem({itemCode:this.itemCode}).then(res=>{
this.load.list=false;
if(res?.data?.length>0){
this.item=res.data[0]
}else{
this.item=null
}
})
},
afterFormSubmit(data){
this.getItem();
},
openAddForm(){
let formData={id:this.itemCode,itemCode:this.itemCode,categoryId:'all'}
this.$refs['metaForm'].open({formData:formData,subOpType:'add'})
},
openEditForm(){
let formData=this.item
this.$refs['metaForm'].open({formData:formData,subOpType:'edit'})
},
onFieldsChange(){
this.getItem();
}
},
mounted() {
this.getItem()
}
}
</script>
<style scoped>
</style>