Compare commits
2 Commits
e590eaf58d
...
0c71c9193b
Author | SHA1 | Date | |
---|---|---|---|
0c71c9193b | |||
b6ea9bc5bb |
@ -26,6 +26,9 @@ const title = computed(() => {
|
||||
let plantListData: any[] = [];
|
||||
const detailIndex = ref<number>();//传index对应详情的某条数据,对该条数据进行编辑修改
|
||||
|
||||
// 新增:接收已选产品id
|
||||
const selectedIds = ref<any[]>([]);
|
||||
|
||||
// 添加数量最大值
|
||||
const productNumMax = ref<any>(0);
|
||||
|
||||
@ -39,7 +42,9 @@ const detailSchema = [
|
||||
api: async () => {
|
||||
const res = await plantsProductList({state:1,inventory:0});
|
||||
plantListData = res.rows || [];
|
||||
return res;
|
||||
// 过滤掉已选产品
|
||||
const filtered = plantListData.filter(item => !selectedIds.value.includes(item.id));
|
||||
return { ...res, rows: filtered };
|
||||
},
|
||||
resultField: 'rows',
|
||||
labelField: 'plantName',
|
||||
@ -82,6 +87,7 @@ const detailSchema = [
|
||||
componentProps: {
|
||||
min: 1,
|
||||
max: productNumMax,
|
||||
disabled: isView,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
@ -197,19 +203,21 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
const data = modalApi.getData();
|
||||
detailIndex.value = modalApi.getData().index;
|
||||
if(!data || Object.keys(data).length === 0){
|
||||
//modalApi.getData()为空时表示添加
|
||||
isAdd.value = true;
|
||||
}else if(data.readonly){
|
||||
detailIndex.value = data.index;
|
||||
// 新增:弹窗打开时同步 selectedIds
|
||||
selectedIds.value = data.selectedIds || [];
|
||||
if(data.readonly){
|
||||
//不存在detailIndex.value时表示查看
|
||||
isView.value = true;
|
||||
} else if(data.add){
|
||||
//modalApi.getData()为空时表示添加
|
||||
isAdd.value = true;
|
||||
}else{
|
||||
//表示编辑
|
||||
isUpdate.value = true;
|
||||
}
|
||||
// TODO: 获取详情数据
|
||||
await formApi.setValues(modalApi.getData());
|
||||
await formApi.setValues(data);
|
||||
await markInitialized();
|
||||
modalApi.modalLoading(false);
|
||||
},
|
||||
|
@ -72,7 +72,6 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
// 后端返回绿植产品包列表结构处理
|
||||
// detailTable.value = record.productList.map((item:any) => {...item.product,item.productNum,});
|
||||
detailTable.value = record.productList.map((item: any) => ({ ...item.product, productNum: item.productNum,productId: item.productId }));
|
||||
// console.log(detailTable.value);
|
||||
|
||||
await formApi.setValues(record);
|
||||
}
|
||||
@ -146,7 +145,9 @@ const detailColumns = [
|
||||
},
|
||||
];
|
||||
function handleAddDetail() {
|
||||
detailModalApi.setData({});
|
||||
// 传递已选产品id列表
|
||||
const selectedIds = detailTable.value.map((item: any) => item.productId || item.plantName);
|
||||
detailModalApi.setData({ selectedIds,add:true });
|
||||
detailModalApi.open();
|
||||
}
|
||||
//添加植物组合包产品
|
||||
@ -169,7 +170,9 @@ function handleViewDetail(record: any) {
|
||||
}
|
||||
// 编辑产品详情
|
||||
function handleEditDetail(record: any, index: number) {
|
||||
detailModalApi.setData({ ...record, index, readonly: false });
|
||||
// 编辑时,排除当前项id
|
||||
const selectedIds = detailTable.value.filter((_: any, i: number) => i !== index).map((item: any) => item.productId || item.plantName);
|
||||
detailModalApi.setData({ ...record, index, selectedIds,edit:true });
|
||||
detailModalApi.open();
|
||||
}
|
||||
//分类字典
|
||||
|
Loading…
Reference in New Issue
Block a user