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;
/**
* 订单号
*/
orderNo?: string | number;
/**
* 订单内容
*/
rentalOrder?: any;
}
export interface OrderChargeForm extends BaseEntity {

View File

@@ -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<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) {
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 { 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<string | number>('');
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<number>();//传index对应详情的某条数据,对该条数据进行编辑修改
const detailIndex = ref<number>(); //传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) {
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({
sumPeices: Number((formValues.peices * value).toFixed(2)),
area: totalArea, // 房间总面积
// 其他需要自动填充的字段
});
}
},
},
},
{
label: '房间面积',
fieldName: 'area',
component: 'Input',
componentProps: {
disabled: true,
},
rules: 'required',
},
{
label: '计量单位',
fieldName: 'measure',
@@ -180,13 +204,15 @@ 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){
if (!data || Object.keys(data).length === 0) {
//modalApi.getData()为空时表示添加
isAdd.value = true;
}else if(data.readonly){
} else if (data.readonly) {
isView.value = true;
}else{
} else {
//表示编辑
isUpdate.value = true;
}
@@ -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() {
<template>
<BasicModal :title="title">
<BasicForm >
</BasicForm>
<BasicForm> </BasicForm>
</BasicModal>
</template>
<style scoped>

View File

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

View File

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

View File

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