This commit is contained in:
15683799673
2025-09-12 23:05:47 +08:00
6 changed files with 164 additions and 85 deletions

View File

@@ -69,6 +69,14 @@ export interface OrderChargeVO {
* 单位 * 单位
*/ */
residentUnitId: string; residentUnitId: string;
/**
* 订单号
*/
orderNo?: string | number;
/**
* 订单内容
*/
rentalOrder?: any;
} }
export interface OrderChargeForm extends BaseEntity { export interface OrderChargeForm extends BaseEntity {

View File

@@ -7,12 +7,15 @@ import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
/** /**
* 查询保洁订单列表 * 查询保洁订单列表
* @param params * @param params
* @returns 保洁订单列表 * @returns 保洁订单列表
*/ */
export function clean_orderList(params?: Clean_orderQuery) { export function clean_orderList(params?: Clean_orderQuery) {
return requestClient.get<PageResult<Clean_orderVO>>('/property/clean_order/list', { params }); return requestClient.get<PageResult<Clean_orderVO>>(
'/property/clean_order/list',
{ params },
);
} }
/** /**
@@ -59,3 +62,14 @@ export function clean_orderUpdate(data: Clean_orderForm) {
export function clean_orderRemove(id: ID | IDS) { export function clean_orderRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/property/clean_order/${id}`); return requestClient.deleteWithMsg<void>(`/property/clean_order/${id}`);
} }
/**
* 查询单位的房间列表
* @param params
* @returns 保洁订单列表
*/
export function getRoomsByresidentUnitId(residentUnitId?: string | number) {
return requestClient.get<any>(
`/property/clean_order/residentUnitId/${residentUnitId}`,
);
}

View File

@@ -5,26 +5,28 @@ import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils'; import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { cleanList } from '#/api/property/clean'; import { cleanList } from '#/api/property/clean';
import { getRoomsByresidentUnitId } from '#/api/property/clean_order';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; 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 isUpdate = ref(false);
const isAdd = ref(false); const isAdd = ref(false);
const isView = ref(false); const isView = ref(false);
const currentUnitId = ref<string | number>('');
const title = computed(() => { const title = computed(() => {
if(isAdd.value){ if (isAdd.value) {
return $t('pages.common.add'); return $t('pages.common.add');
}else if(isView.value){ } else if (isView.value) {
return '查看'; return '查看';
}else{ } else {
return $t('pages.common.edit'); return $t('pages.common.edit');
} }
}); });
// 缓存清洁服务数据 // 缓存清洁服务数据
let cleanListData: any[] = []; let cleanListData: any[] = [];
const detailIndex = ref<number>();//传index对应详情的某条数据,对该条数据进行编辑修改 const detailIndex = ref<number>(); //传index对应详情的某条数据,对该条数据进行编辑修改
const detailSchema = [ const detailSchema = [
{ {
label: '劳务名称', label: '劳务名称',
@@ -33,7 +35,7 @@ const detailSchema = [
componentProps: { componentProps: {
disabled: isView, disabled: isView,
api: async () => { api: async () => {
const res = await cleanList({stater:1}); const res = await cleanList({ stater: 1 });
cleanListData = res.rows || []; cleanListData = res.rows || [];
return res; return res;
}, },
@@ -42,7 +44,7 @@ const detailSchema = [
valueField: 'id', valueField: 'id',
onChange: async (value: string) => { onChange: async (value: string) => {
// 找到选中的服务数据 // 找到选中的服务数据
const selectedService = cleanListData.find(item => item.id === value); const selectedService = cleanListData.find((item) => item.id === value);
if (selectedService) { if (selectedService) {
// 自动填充其他字段 // 自动填充其他字段
await formApi.setValues({ await formApi.setValues({
@@ -60,22 +62,44 @@ const detailSchema = [
rules: 'required', rules: 'required',
}, },
{ {
label: '保洁面积', label: '房间',
fieldName: 'area', fieldName: 'roomId',
component: 'InputNumber', component: 'ApiSelect',
rules: 'required', rules: 'required',
componentProps: { componentProps: {
disabled: isView, disabled: isView,
onChange: async (value: number) => { api: async () => {
const formValues = await formApi.getValues(); const res = await getRoomsByresidentUnitId(currentUnitId.value);
if (formValues.peices && value) { return res;
await formApi.setValues({ },
sumPeices: Number((formValues.peices * value).toFixed(2)), 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: '计量单位', label: '计量单位',
fieldName: 'measure', fieldName: 'measure',
@@ -180,15 +204,17 @@ 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;
detailIndex.value = modalApi.getData().index; detailIndex.value = modalApi.getData().index;
if(!data || Object.keys(data).length === 0){ if (!data || Object.keys(data).length === 0) {
//modalApi.getData()为空时表示添加 //modalApi.getData()为空时表示添加
isAdd.value = true; isAdd.value = true;
}else if(data.readonly){ } else if (data.readonly) {
isView.value = true; isView.value = true;
}else{ } else {
//表示编辑 //表示编辑
isUpdate.value = true; isUpdate.value = true;
} }
// TODO: 获取详情数据 // TODO: 获取详情数据
await formApi.setValues(modalApi.getData()); await formApi.setValues(modalApi.getData());
@@ -206,18 +232,18 @@ async function handleConfirm() {
} }
let data = cloneDeep(await formApi.getValues()); 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) { if (selectedService) {
data.name = selectedService.name; data.name = selectedService.name;
data.id = selectedService.id data.id = selectedService.id;
} }
if (isUpdate.value) { if (isUpdate.value) {
data.index = detailIndex.value; data.index = detailIndex.value;
emit('editReload', data); emit('editReload', data);
}else if(isAdd.value){ } else if (isAdd.value) {
emit('reload', data); emit('reload', data);
} }
handleClosed() handleClosed();
await markInitialized(); await markInitialized();
modalApi.close(); modalApi.close();
} catch (error) { } catch (error) {
@@ -238,8 +264,7 @@ async function handleClosed() {
<template> <template>
<BasicModal :title="title"> <BasicModal :title="title">
<BasicForm > <BasicForm> </BasicForm>
</BasicForm>
</BasicModal> </BasicModal>
</template> </template>
<style scoped> <style scoped>

View File

@@ -26,10 +26,11 @@ import cleanDetailModal from './clean-detail-modal.vue';
// import { modalSchema } from './data'; // import { modalSchema } from './data';
import { communityTree } from '#/api/property/community'; import { communityTree } from '#/api/property/community';
import { getDictOptions } from '#/utils/dict'; import { getDictOptions } from '#/utils/dict';
import type {Clean_orderForm} from "#/api/property/clean_order/model"; import type { Clean_orderForm } from '#/api/property/clean_order/model';
import { reactive } from 'vue';
const emit = defineEmits<{ reload: [] }>(); const emit = defineEmits<{ reload: [] }>();
let currentUnitId = ref<string | number>(''); //当前表单单位id
// 计算合计费用 // 计算合计费用
const totalSumPeices = computed(() => { const totalSumPeices = computed(() => {
return detailTable.value return detailTable.value
@@ -73,12 +74,28 @@ const modalSchema = [
}, },
}, },
{ {
label: '服务地址(房间号)', label: '申请单位',
component: 'TreeSelect', fieldName: 'unitId',
defaultValue: undefined, component: 'ApiSelect',
fieldName: 'location', componentProps: {
api: resident_unitList,
resultField: 'rows',
labelField: 'name',
valueField: 'id',
placeholder: '请选择单位',
onChange: (value: any) => {
currentUnitId.value = value;
},
},
rules: 'required', rules: 'required',
}, },
// {
// label: '服务地址(房间号)',
// component: 'TreeSelect',
// defaultValue: undefined,
// fieldName: 'location',
// rules: 'required',
// },
{ {
label: '开始时间', label: '开始时间',
fieldName: 'starTime', fieldName: 'starTime',
@@ -124,19 +141,7 @@ const modalSchema = [
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
}, },
{
label: '申请单位',
fieldName: 'unitId',
component: 'ApiSelect',
componentProps: {
api: resident_unitList,
resultField: 'rows',
labelField: 'name',
valueField: 'id',
placeholder: '请选择单位',
},
rules: 'required',
},
{ {
label: '支付状态', label: '支付状态',
fieldName: 'payState', fieldName: 'payState',
@@ -196,7 +201,7 @@ const modalSchema = [
helpMessage: false, helpMessage: false,
}, },
dependencies: { dependencies: {
show: (formValue:Clean_orderForm) => show: (formValue: Clean_orderForm) =>
isReadonly.value && formValue.imgUrl ? true : false, isReadonly.value && formValue.imgUrl ? true : false,
triggerFields: [''], triggerFields: [''],
}, },
@@ -221,7 +226,7 @@ const modalSchema = [
helpMessage: false, helpMessage: false,
}, },
dependencies: { dependencies: {
show: (formValue:Clean_orderForm) => show: (formValue: Clean_orderForm) =>
isReadonly.value && formValue.signImgUrl ? true : false, isReadonly.value && formValue.signImgUrl ? true : false,
triggerFields: [''], triggerFields: [''],
}, },
@@ -332,6 +337,7 @@ const [BasicModal, modalApi] = useVbenModal({
} }
} }
} }
currentUnitId.value = record.unitId;
await formApi.setValues(record); await formApi.setValues(record);
} }
await markInitialized(); await markInitialized();
@@ -463,7 +469,8 @@ const [CleanDetailModal, detailModalApi] = useVbenModal({
}); });
function handleAddDetail() { function handleAddDetail() {
detailModalApi.setData({}); console.log(currentUnitId);
detailModalApi.setData({ unitId: currentUnitId.value });
detailModalApi.open(); detailModalApi.open();
} }
// 添加订单服务详情 // 添加订单服务详情
@@ -480,12 +487,17 @@ function handleDeleteDetail(record: any, index: number) {
} }
// 查看产品详情 // 查看产品详情
function handleViewDetail(record: any) { function handleViewDetail(record: any) {
detailModalApi.setData({ ...record, readonly: true }); detailModalApi.setData({ ...record, readonly: true, unitId: currentUnitId });
detailModalApi.open(); detailModalApi.open();
} }
// 编辑产品详情 // 编辑产品详情
function handleEditDetail(record: any, index: number) { function handleEditDetail(record: any, index: number) {
detailModalApi.setData({ ...record, index, readonly: false }); detailModalApi.setData({
...record,
index,
readonly: false,
unitId: currentUnitId,
});
detailModalApi.open(); detailModalApi.open();
} }
@@ -636,7 +648,11 @@ async function handleAudit(params: any) {
: '添加保洁订单详情' : '添加保洁订单详情'
}} }}
</h3> </h3>
<a-button v-if="!isReadonly" type="primary" @click="handleAddDetail"> <a-button
v-if="!isReadonly && currentUnitId"
type="primary"
@click="handleAddDetail"
>
{{ $t('pages.common.add') }} {{ $t('pages.common.add') }}
</a-button> </a-button>
</div> </div>

View File

@@ -72,11 +72,11 @@ export const columns: VxeGridProps['columns'] = [
}, },
}, },
}, },
{ // {
title: '服务地址', // title: '服务地址',
field: 'locationName', // field: 'locationName',
width: '260', // width: '260',
}, // },
{ {
title: '合计费用(元)', title: '合计费用(元)',
field: 'sumPeices', field: 'sumPeices',
@@ -170,12 +170,25 @@ export const modalSchema: (isReadonly: boolean) => FormSchema[] = (
}, },
}, },
{ {
label: '服务地址(房间号)', label: '申请单位',
component: 'TreeSelect', fieldName: 'unitId',
defaultValue: undefined, component: 'ApiSelect',
fieldName: 'location', componentProps: {
api: resident_unitList,
resultField: 'rows',
labelField: 'name',
valueField: 'id',
placeholder: '请选择单位',
},
rules: 'required', rules: 'required',
}, },
// {
// label: '服务地址(房间号)',
// component: 'TreeSelect',
// defaultValue: undefined,
// fieldName: 'location',
// rules: 'required',
// },
{ {
label: '开始时间', label: '开始时间',
fieldName: 'starTime', fieldName: 'starTime',
@@ -221,19 +234,7 @@ export const modalSchema: (isReadonly: boolean) => FormSchema[] = (
component: 'Input', component: 'Input',
rules: 'required', rules: 'required',
}, },
{
label: '申请单位',
fieldName: 'unitId',
component: 'ApiSelect',
componentProps: {
api: resident_unitList,
resultField: 'rows',
labelField: 'name',
valueField: 'id',
placeholder: '请选择单位',
},
rules: 'required',
},
{ {
label: '支付状态', label: '支付状态',
fieldName: 'payState', fieldName: 'payState',

View File

@@ -33,6 +33,16 @@ const modalSchema = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '订单号',
fieldName: 'orderNo',
component: 'Input',
dependencies: {
show: () => isUpdate.value,
triggerFields: [''],
},
disabled: true,
},
{ {
label: '订单号', label: '订单号',
fieldName: 'orderId', fieldName: 'orderId',
@@ -42,15 +52,20 @@ const modalSchema = [
resultField: 'rows', resultField: 'rows',
labelField: 'orderNo', labelField: 'orderNo',
valueField: 'id', valueField: 'id',
onChange: async (value: string, option: any) => { onChange: async (value: any, option: any) => {
console.log(option);
await formApi.setValues({ await formApi.setValues({
residentUnitId: option.residentUnitId, // 假设订单数据中有 residentUnitId 字段 residentUnitId: option.residentUnitId, // 假设订单数据中有 residentUnitId 字段
// 其他需要自动填充的字段 // 其他需要自动填充的字段
}); });
}, },
}, },
disabled: isUpdate.value ? true : false,
rules: 'required', rules: 'required',
dependencies: {
show: () => !isUpdate.value,
triggerFields: [''],
},
}, },
{ {
component: 'ApiSelect', component: 'ApiSelect',
@@ -214,7 +229,7 @@ const [BasicModal, modalApi] = useVbenModal({
record.paymentMethod = record.paymentMethod?.toString(); record.paymentMethod = record.paymentMethod?.toString();
record.invoiceType = record.invoiceType?.toString(); record.invoiceType = record.invoiceType?.toString();
record.invoiceStatus = record.invoiceStatus?.toString(); record.invoiceStatus = record.invoiceStatus?.toString();
record.orderId = record.orderId; record.orderNo = record.rentalOrder?.orderNo;
record.residentUnitId = record.residentUnitId; record.residentUnitId = record.residentUnitId;
await formApi.setValues(record); await formApi.setValues(record);
} }