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