diff --git a/apps/web-antd/src/api/property/chargeManagement/model.d.ts b/apps/web-antd/src/api/property/chargeManagement/model.d.ts index b7f2b924..edcb53e2 100644 --- a/apps/web-antd/src/api/property/chargeManagement/model.d.ts +++ b/apps/web-antd/src/api/property/chargeManagement/model.d.ts @@ -69,6 +69,14 @@ export interface OrderChargeVO { * 单位 */ residentUnitId: string; + /** + * 订单号 + */ + orderNo?: string | number; + /** + * 订单内容 + */ + rentalOrder?: any; } export interface OrderChargeForm extends BaseEntity { diff --git a/apps/web-antd/src/api/property/clean_order/index.ts b/apps/web-antd/src/api/property/clean_order/index.ts index d7cea91f..a57905d3 100644 --- a/apps/web-antd/src/api/property/clean_order/index.ts +++ b/apps/web-antd/src/api/property/clean_order/index.ts @@ -7,12 +7,15 @@ import { commonExport } from '#/api/helper'; import { requestClient } from '#/api/request'; /** -* 查询保洁订单列表 -* @param params -* @returns 保洁订单列表 -*/ + * 查询保洁订单列表 + * @param params + * @returns 保洁订单列表 + */ export function clean_orderList(params?: Clean_orderQuery) { - return requestClient.get>('/property/clean_order/list', { params }); + return requestClient.get>( + '/property/clean_order/list', + { params }, + ); } /** @@ -59,3 +62,14 @@ export function clean_orderUpdate(data: Clean_orderForm) { export function clean_orderRemove(id: ID | IDS) { return requestClient.deleteWithMsg(`/property/clean_order/${id}`); } + +/** + * 查询单位的房间列表 + * @param params + * @returns 保洁订单列表 + */ +export function getRoomsByresidentUnitId(residentUnitId?: string | number) { + return requestClient.get( + `/property/clean_order/residentUnitId/${residentUnitId}`, + ); +} diff --git a/apps/web-antd/src/views/property/clean/cleanOrders/clean-detail-modal.vue b/apps/web-antd/src/views/property/clean/cleanOrders/clean-detail-modal.vue index f4272eaf..a7121979 100644 --- a/apps/web-antd/src/views/property/clean/cleanOrders/clean-detail-modal.vue +++ b/apps/web-antd/src/views/property/clean/cleanOrders/clean-detail-modal.vue @@ -5,26 +5,28 @@ import { $t } from '@vben/locales'; import { cloneDeep } from '@vben/utils'; import { useVbenForm } from '#/adapter/form'; import { cleanList } from '#/api/property/clean'; +import { getRoomsByresidentUnitId } from '#/api/property/clean_order'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; -const emit = defineEmits<{ reload: [data: any], editReload: [data: any] }>(); +const emit = defineEmits<{ reload: [data: any]; editReload: [data: any] }>(); const isUpdate = ref(false); const isAdd = ref(false); const isView = ref(false); +const currentUnitId = ref(''); const title = computed(() => { - if(isAdd.value){ + if (isAdd.value) { return $t('pages.common.add'); - }else if(isView.value){ + } else if (isView.value) { return '查看'; - }else{ + } else { return $t('pages.common.edit'); } }); // 缓存清洁服务数据 let cleanListData: any[] = []; -const detailIndex = ref();//传index对应详情的某条数据,对该条数据进行编辑修改 +const detailIndex = ref(); //传index对应详情的某条数据,对该条数据进行编辑修改 const detailSchema = [ { label: '劳务名称', @@ -33,7 +35,7 @@ const detailSchema = [ componentProps: { disabled: isView, api: async () => { - const res = await cleanList({stater:1}); + const res = await cleanList({ stater: 1 }); cleanListData = res.rows || []; return res; }, @@ -42,7 +44,7 @@ const detailSchema = [ valueField: 'id', onChange: async (value: string) => { // 找到选中的服务数据 - const selectedService = cleanListData.find(item => item.id === value); + const selectedService = cleanListData.find((item) => item.id === value); if (selectedService) { // 自动填充其他字段 await formApi.setValues({ @@ -60,22 +62,44 @@ const detailSchema = [ rules: 'required', }, { - label: '保洁面积', - fieldName: 'area', - component: 'InputNumber', + label: '房间', + fieldName: 'roomId', + component: 'ApiSelect', rules: 'required', componentProps: { disabled: isView, - onChange: async (value: number) => { - const formValues = await formApi.getValues(); - if (formValues.peices && value) { - await formApi.setValues({ - sumPeices: Number((formValues.peices * value).toFixed(2)), - }); - } + api: async () => { + const res = await getRoomsByresidentUnitId(currentUnitId.value); + return res; + }, + resultField: 'rows', + labelField: 'roomNumber', + valueField: 'id', + mode: 'multiple', + onChange: async (value: any, option: any) => { + console.log(value, option); + let totalArea: any = 0; + totalArea = option.reduce((sum: any, item: any) => { + // 假设每个选项有一个area字段,根据实际情况调整 + return sum + (parseFloat(item.area) || 0); + }, 0); + await formApi.setValues({ + area: totalArea, // 房间总面积 + // 其他需要自动填充的字段 + }); }, }, }, + { + label: '房间面积', + fieldName: 'area', + component: 'Input', + componentProps: { + disabled: true, + }, + rules: 'required', + }, + { label: '计量单位', fieldName: 'measure', @@ -180,15 +204,17 @@ const [BasicModal, modalApi] = useVbenModal({ } modalApi.modalLoading(true); const data = modalApi.getData(); + console.log(data); + currentUnitId.value = modalApi.getData().unitId; detailIndex.value = modalApi.getData().index; - if(!data || Object.keys(data).length === 0){ - //modalApi.getData()为空时表示添加 + if (!data || Object.keys(data).length === 0) { + //modalApi.getData()为空时表示添加 isAdd.value = true; - }else if(data.readonly){ - isView.value = true; - }else{ - //表示编辑 - isUpdate.value = true; + } else if (data.readonly) { + isView.value = true; + } else { + //表示编辑 + isUpdate.value = true; } // TODO: 获取详情数据 await formApi.setValues(modalApi.getData()); @@ -206,18 +232,18 @@ async function handleConfirm() { } let data = cloneDeep(await formApi.getValues()); // 获取选中的服务名称 - const selectedService = cleanListData.find(item => item.id === data.name); + const selectedService = cleanListData.find((item) => item.id === data.name); if (selectedService) { data.name = selectedService.name; - data.id = selectedService.id + data.id = selectedService.id; } if (isUpdate.value) { data.index = detailIndex.value; emit('editReload', data); - }else if(isAdd.value){ + } else if (isAdd.value) { emit('reload', data); } - handleClosed() + handleClosed(); await markInitialized(); modalApi.close(); } catch (error) { @@ -238,8 +264,7 @@ async function handleClosed() {