fix 字典数据类型选择功能修复
This commit is contained in:
parent
bb39c4bfd9
commit
3a7cf77d7b
@ -2,8 +2,8 @@
|
|||||||
<div class="system-edit-dic-container">
|
<div class="system-edit-dic-container">
|
||||||
<el-dialog :title="(ruleForm.dictCode!==0?'修改':'添加')+'字典'" v-model="isShowDialog" width="769px">
|
<el-dialog :title="(ruleForm.dictCode!==0?'修改':'添加')+'字典'" v-model="isShowDialog" width="769px">
|
||||||
<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="90px">
|
<el-form :model="ruleForm" ref="formRef" :rules="rules" size="default" label-width="90px">
|
||||||
<el-form-item label="字典类型">
|
<el-form-item label="字典类型" prop="dictType">
|
||||||
<el-input v-model="ruleForm.dictType" :disabled="true" />
|
<el-cascader v-model="ruleForm.dictType" :options="dictTypeOpt" :props="typeProps" clearable :show-all-levels="false"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="数据标签" prop="dictLabel">
|
<el-form-item label="数据标签" prop="dictLabel">
|
||||||
<el-input v-model="ruleForm.dictLabel" placeholder="请输入数据标签" />
|
<el-input v-model="ruleForm.dictLabel" placeholder="请输入数据标签" />
|
||||||
@ -45,9 +45,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, toRefs, defineComponent,ref, unref } from 'vue';
|
import { reactive, toRefs, ref, unref, getCurrentInstance } from 'vue';
|
||||||
import { getData,addData,editData } from '/@/api/system/dict/data';
|
import { getData,addData,editData } from '/@/api/system/dict/data';
|
||||||
import {ElMessage} from "element-plus";
|
import {ElMessage} from "element-plus";
|
||||||
|
import { optionselect } from '/@/api/system/dict/type';
|
||||||
interface RuleFormState {
|
interface RuleFormState {
|
||||||
dictCode: number;
|
dictCode: number;
|
||||||
dictLabel: string;
|
dictLabel: string;
|
||||||
@ -64,6 +65,7 @@ interface DicState {
|
|||||||
rules:{}
|
rules:{}
|
||||||
}
|
}
|
||||||
defineOptions({ name: "systemEditDicData"})
|
defineOptions({ name: "systemEditDicData"})
|
||||||
|
const {proxy} = getCurrentInstance() as any;
|
||||||
const prop = defineProps({
|
const prop = defineProps({
|
||||||
dictType:{
|
dictType:{
|
||||||
type:String,
|
type:String,
|
||||||
@ -72,6 +74,14 @@ const prop = defineProps({
|
|||||||
})
|
})
|
||||||
const emit = defineEmits(['dataList']);
|
const emit = defineEmits(['dataList']);
|
||||||
const formRef = ref<HTMLElement | null>(null);
|
const formRef = ref<HTMLElement | null>(null);
|
||||||
|
const dictTypeOpt = ref<RuleFormState>()
|
||||||
|
const typeProps = ref({
|
||||||
|
value: 'dictType',
|
||||||
|
label: 'dictName',
|
||||||
|
children: 'children',
|
||||||
|
emitPath: false,
|
||||||
|
checkStrictly:true
|
||||||
|
})
|
||||||
const state = reactive<DicState>({
|
const state = reactive<DicState>({
|
||||||
isShowDialog: false,
|
isShowDialog: false,
|
||||||
ruleForm: {
|
ruleForm: {
|
||||||
@ -85,6 +95,9 @@ const state = reactive<DicState>({
|
|||||||
dictType:prop.dictType
|
dictType:prop.dictType
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
dictType:[
|
||||||
|
{ required: true, message: "请选择字典类型", trigger: "change" }
|
||||||
|
],
|
||||||
dictLabel: [
|
dictLabel: [
|
||||||
{ required: true, message: "数据标签不能为空", trigger: "blur" }
|
{ required: true, message: "数据标签不能为空", trigger: "blur" }
|
||||||
],
|
],
|
||||||
@ -97,9 +110,16 @@ const state = reactive<DicState>({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const { isShowDialog,ruleForm,rules } = toRefs(state);
|
const { isShowDialog,ruleForm,rules } = toRefs(state);
|
||||||
|
const getTypeOpt = () => {
|
||||||
|
optionselect(true).then((res:any)=>{
|
||||||
|
const data = res.data.dictType??[]
|
||||||
|
dictTypeOpt.value = proxy.handleTree(data, 'dictId', 'pid', 'children', true)
|
||||||
|
})
|
||||||
|
}
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = (row: RuleFormState|null) => {
|
const openDialog = (row: RuleFormState|null) => {
|
||||||
resetForm();
|
getTypeOpt()
|
||||||
|
resetForm()
|
||||||
if (row){
|
if (row){
|
||||||
getData(row.dictCode).then((res:any)=>{
|
getData(row.dictCode).then((res:any)=>{
|
||||||
state.ruleForm = res.data.dict
|
state.ruleForm = res.data.dict
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
@pagination="dataList"
|
@pagination="dataList"
|
||||||
/>
|
/>
|
||||||
</el-card>
|
</el-card>
|
||||||
<EditDic ref="editDicRef" @dataList="dataList" :dict-type="tableData.param.dictType"/>
|
<EditDic ref="editDicRef" @dataList="dataList" :dict-type="selectedTypeCode"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -129,6 +129,7 @@ defineOptions({ name: "apiV1SystemDictDataList"})
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const editDicRef = ref();
|
const editDicRef = ref();
|
||||||
const queryRef = ref();
|
const queryRef = ref();
|
||||||
|
const selectedTypeCode = ref("");
|
||||||
const state = reactive<TableDataState>({
|
const state = reactive<TableDataState>({
|
||||||
ids:[],
|
ids:[],
|
||||||
tableData: {
|
tableData: {
|
||||||
@ -147,8 +148,9 @@ const state = reactive<TableDataState>({
|
|||||||
});
|
});
|
||||||
const { tableData } = toRefs(state);
|
const { tableData } = toRefs(state);
|
||||||
// 初始化表格数据
|
// 初始化表格数据
|
||||||
const initTableData = (typeId?: number) => {
|
const initTableData = (typeId?: number,code?:string) => {
|
||||||
state.tableData.param.typeId = typeId as number;
|
state.tableData.param.typeId = typeId as number;
|
||||||
|
selectedTypeCode.value = code as string;
|
||||||
dataList()
|
dataList()
|
||||||
};
|
};
|
||||||
const dataList=()=>{
|
const dataList=()=>{
|
||||||
|
@ -151,7 +151,7 @@ const filterNode = (value: string, data:any) => {
|
|||||||
// 节点单击事件
|
// 节点单击事件
|
||||||
const handleNodeClick = (data:TableDataRow) => {
|
const handleNodeClick = (data:TableDataRow) => {
|
||||||
selectedNode.value = data
|
selectedNode.value = data
|
||||||
dataViewRef.value.initTableData(data.dictId)
|
dataViewRef.value.initTableData(data.dictId,data.dictType)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCheckChange = (
|
const handleCheckChange = (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user