feat: 更新业务需求

This commit is contained in:
fyy
2025-09-13 00:14:26 +08:00
parent 912dc3b50c
commit 90d9e1c714
2 changed files with 34 additions and 19 deletions

View File

@@ -77,7 +77,6 @@ const detailSchema = [
valueField: 'id', valueField: 'id',
mode: 'multiple', mode: 'multiple',
onChange: async (value: any, option: any) => { onChange: async (value: any, option: any) => {
console.log(value, option);
let totalArea: any = 0; let totalArea: any = 0;
totalArea = option.reduce((sum: any, item: any) => { totalArea = option.reduce((sum: any, item: any) => {
// 假设每个选项有一个area字段根据实际情况调整 // 假设每个选项有一个area字段根据实际情况调整
@@ -87,11 +86,17 @@ const detailSchema = [
area: totalArea, // 房间总面积 area: totalArea, // 房间总面积
// 其他需要自动填充的字段 // 其他需要自动填充的字段
}); });
const formValues = await formApi.getValues();
if (formValues.peices && totalArea) {
await formApi.setValues({
sumPeices: Number((formValues.peices * totalArea).toFixed(2)),
});
}
}, },
}, },
}, },
{ {
label: '房间面积', label: '房间面积(㎡)',
fieldName: 'area', fieldName: 'area',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
@@ -204,20 +209,25 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData(); const data = modalApi.getData();
console.log(data);
currentUnitId.value = modalApi.getData().unitId; currentUnitId.value = modalApi.getData().unitId;
detailIndex.value = modalApi.getData().index; detailIndex.value = modalApi.getData().index;
if (!data || Object.keys(data).length === 0) { if (data.update) {
//modalApi.getData()为空时表示添加 //有index表示编辑
isAdd.value = true; isUpdate.value = true;
data.roomId = data.roomId
.split(',')
.filter((id: string) => id.trim() !== '');
} else if (data.readonly) { } else if (data.readonly) {
isView.value = true; isView.value = true;
data.roomId = data.roomId
.split(',')
.filter((id: string) => id.trim() !== '');
data.area = data.sumPeices / data.peices;
} else { } else {
//表示编辑 isAdd.value = true;
isUpdate.value = true;
} }
// TODO: 获取详情数据 // TODO: 获取详情数据
await formApi.setValues(modalApi.getData()); await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
@@ -237,6 +247,7 @@ async function handleConfirm() {
data.name = selectedService.name; data.name = selectedService.name;
data.id = selectedService.id; data.id = selectedService.id;
} }
data.roomId = data.roomId.join(',');
if (isUpdate.value) { if (isUpdate.value) {
data.index = detailIndex.value; data.index = detailIndex.value;
emit('editReload', data); emit('editReload', data);

View File

@@ -402,11 +402,11 @@ const detailGridOptions: VxeGridProps = {
default: ({ row }) => (row.stater === 1 ? '启用' : '禁用'), default: ({ row }) => (row.stater === 1 ? '启用' : '禁用'),
}, },
}, },
{ // {
title: '保洁面积', // title: '保洁面积',
field: 'area', // field: 'area',
width: 'auto', // width: 'auto',
}, // },
{ {
title: '合计费用', title: '合计费用',
field: 'sumPeices', field: 'sumPeices',
@@ -446,7 +446,7 @@ const detailColumns = [
customRender: ({ value }: { value: number }) => customRender: ({ value }: { value: number }) =>
value === 1 ? '启用' : '禁用', value === 1 ? '启用' : '禁用',
}, },
{ title: '保洁面积', dataIndex: 'area', key: 'area' }, // { title: '保洁面积', dataIndex: 'area', key: 'area' },
{ {
title: '合计费用', title: '合计费用',
dataIndex: 'sumPeices', dataIndex: 'sumPeices',
@@ -469,7 +469,6 @@ const [CleanDetailModal, detailModalApi] = useVbenModal({
}); });
function handleAddDetail() { function handleAddDetail() {
console.log(currentUnitId);
detailModalApi.setData({ unitId: currentUnitId.value }); detailModalApi.setData({ unitId: currentUnitId.value });
detailModalApi.open(); detailModalApi.open();
} }
@@ -487,7 +486,12 @@ function handleDeleteDetail(record: any, index: number) {
} }
// 查看产品详情 // 查看产品详情
function handleViewDetail(record: any) { function handleViewDetail(record: any) {
detailModalApi.setData({ ...record, readonly: true, unitId: currentUnitId }); detailModalApi.setData({
...record,
readonly: true,
unitId: currentUnitId.value,
area: record.su,
});
detailModalApi.open(); detailModalApi.open();
} }
// 编辑产品详情 // 编辑产品详情
@@ -495,8 +499,8 @@ function handleEditDetail(record: any, index: number) {
detailModalApi.setData({ detailModalApi.setData({
...record, ...record,
index, index,
readonly: false, update: true,
unitId: currentUnitId, unitId: currentUnitId.value,
}); });
detailModalApi.open(); detailModalApi.open();
} }