Commit 84d36b30 authored by liwei's avatar liwei

修改了bug

parent 0fb54779
......@@ -8,7 +8,13 @@
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { formSchema } from './dict.data';
import { addDictType, changeFlagApi, DictDetailApi } from '@/api/system/dict/dict';
import {
addDictType,
changeFlagApi,
DictDetailApi,
getDictDataByType,
getDictListByPage
} from '@/api/system/dict/dict';
import { useMessage } from '@/hooks/web/useMessage';
defineOptions({ name: 'DictModal' });
......@@ -36,6 +42,7 @@
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
//修改
// 获取行数据的id
dictId.value = data.record.businessId;
// 通过id获取行详情信息
......@@ -47,6 +54,57 @@
});
});
}
//给父子典名称和数据赋值
var options = []
getDictListByPage().then(response => {
options = response.data.map(item => ({
label: item.dictName,
value: item.businessId,
}))
updateSchema({
field: 'parentId',
componentProps: {
options: options,
onChange: (value: any, option: any, form: any) => {
//调用接口 返回的参数赋值给dictValue
if (value !== undefined){
DictDetailApi(value).then(res=>{
const dictType = res.data.dictType
// 调用接口获取 dictValue 列表
getDictDataByType(dictType).then(response => {
const dictData = response.data || []; // 获取到的数据列表
// 更新 dictValue 字段的选项
//取出dictData里的dictLabel和dictValue
const options = dictData.map((item: any) => ({
label: item.dictLabel,
value: item.businessId,
}));
updateSchema({
field: 'dataId',
componentProps: {
options: options,
},
ifShow:true
});
}).catch(error => {
console.error('Error fetching dict values:', error);
});
})
} else {
const options = []
updateSchema({
field: 'dataId',
componentProps: {
options: options,
},
ifShow:false
});
}
},
},
});
})
});
async function handleSubmit() {
......
import { BasicColumn, FormSchema } from '@/components/Table';
import { h, defineComponent } from 'vue';
import { Switch } from 'ant-design-vue';
import {Select, Switch} from 'ant-design-vue';
import { useMessage } from '@/hooks/web/useMessage';
import {changeFlagApi, DictDetailApi, getDictDataByType} from '@/api/system/dict/dict';
import {
changeDataFlagApi,
changeFlagApi,
DictDetailApi,
getDictDataByType
} from '@/api/system/dict/dict';
import { log } from 'vxe-pc-ui';
import { useRouter } from 'vue-router';
import { rowProps } from 'ant-design-vue/es/grid/Row';
......@@ -10,6 +15,8 @@ import { getDictListByPage,getDictDataByType } from "@/api/system/dict/dict";
type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
{
title: '序号',
......@@ -93,13 +100,13 @@ export const searchFormSchema: FormSchema[] = [
field: 'dictName',
label: '字典名称',
component: 'Input',
colProps: { span: 8 },
colProps: { span: 7 },
},
{
field: 'dictType',
label: '字典类型',
component: 'Input',
colProps: { span: 8 },
colProps: { span: 7 },
},
{
field: 'flag',
......@@ -111,7 +118,7 @@ export const searchFormSchema: FormSchema[] = [
{ label: '停用', value: '0' },
],
},
colProps: { span: 8 },
colProps: { span: 7 },
},
{
field: 'date',
......@@ -121,9 +128,9 @@ export const searchFormSchema: FormSchema[] = [
format: 'YYYY-MM-DD', // 显示的日期格式
valueFormat: 'YYYY-MM-DD', // 提交的日期格式
placeholder: ['开始日期', '结束日期'], // 占位符
style: { width: '300px' }, // 控制宽度
style: { width: '100%' }, // 控制宽度
},
colProps: { span: 4 },
colProps: { span: 7 },
},
];
......@@ -159,52 +166,10 @@ export const formSchema: FormSchema[] = [
{
field: 'parentId',
label: '父字典名称',
component: 'ApiSelect',
componentProps: ({formModel,formActionType})=>{
return{
api: getDictListByPage,
labelField: 'dictName',
valueField: 'businessId',
resultField:'data',
onChange: (value: any, option: any, form: any) => {
//调用接口 返回的参数赋值给dictValue
if (value !== undefined){
DictDetailApi(value).then(res=>{
const dictType = res.data.dictType
// 调用接口获取 dictValue 列表
getDictDataByType(dictType).then(response => {
const dictData = response.data || []; // 获取到的数据列表
// 更新 dictValue 字段的选项
const { updateSchema } = formActionType //获取表单方法
//取出dictData里的dictLabel和dictValue
const options = dictData.map((item: any) => ({
label: item.dictLabel,
value: item.businessId,
}));
updateSchema({
field: 'dataId',
componentProps: {
options: options,
},
ifShow:true
});
}).catch(error => {
console.error('Error fetching dict values:', error);
});
})
} else {
const { updateSchema } = formActionType //获取表单方法
const options = []
updateSchema({
field: 'dataId',
componentProps: {
options: options,
},
ifShow:false
});
}
},
}
component: 'Select',
componentProps: {
options: [],
onChange: (value: any, option: any, form: any) => {},
},
},
{
......
......@@ -51,7 +51,7 @@
}
if (unref(isAdd)){
// 通过id获取菜单详情信息
const id = data.record.parentId
const id = data.record.businessId
const params = {
parentId: id,
}
......
......@@ -154,6 +154,13 @@ export const formSchema: FormSchema[] = [
field: 'orderNum',
label: '菜单排序',
component: 'InputNumber',
componentProps: {
min: 0, // 最小值
max: 9999, // 最大值(根据需要调整)
step: 1, // 每次增减的步长
placeholder: '请输入排序号', // 占位符
style: { width: '100%' }, // 样式(可选)
},
required: true,
},
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment