| | |
| | | <LoadingLayout :loading="isLoading && isEdit"> |
| | | <AppContainer> |
| | | <PageFormLayout title="基本信息"> |
| | | <ProForm :model="form" ref="productFormRef" label-width="110px" :is-read="isDetail"> |
| | | <ProForm :model="form" ref="productFormRef" label-width="120px" :is-read="isDetail"> |
| | | <ProFormItemV2 |
| | | label="供应商:" |
| | | prop="supplierEnterpriseId" |
| | |
| | | v-model="form.supplierEnterpriseId" |
| | | :value-enum="supplierEnterpriseSelect" |
| | | placeholder="请选择供应商" |
| | | :disabled="isEdit" |
| | | @change="supplierEnterpriseChange" |
| | | ></ProFormSelect> |
| | | </ProFormItemV2> |
| | | <ProFormCol> |
| | |
| | | :max="999999999999" |
| | | :precision="0" |
| | | unit="人" |
| | | @change="calcTaskTotalServiceFee" |
| | | ></ProFormInputNumber> |
| | | </ProFormItemV2> |
| | | </ProFormColItem> |
| | |
| | | :showExtra="true" |
| | | :button-style="false" |
| | | :disabled="feeCannotEdit" |
| | | @change="calcTaskTotalServiceFee" |
| | | > |
| | | <template #extra> |
| | | <ProFormInputNumber |
| | |
| | | :max="999999999999" |
| | | :unit="EnumBillingMethodUnitText[form.billingMethod]" |
| | | :disabled="feeCannotEdit" |
| | | @change="calcTaskTotalServiceFee" |
| | | ></ProFormInputNumber> |
| | | </template> |
| | | </RadioWithExtra> |
| | |
| | | :max="999999999999" |
| | | unit="小时/天" |
| | | :disabled="feeCannotEdit" |
| | | @change="calcTaskTotalServiceFee" |
| | | ></ProFormInputNumber> |
| | | </ProFormItemV2> |
| | | </ProFormColItem> |
| | |
| | | :max="999999999999" |
| | | unit="件" |
| | | :disabled="feeCannotEdit" |
| | | @change="calcTaskTotalServiceFee" |
| | | ></ProFormInputNumber> |
| | | </ProFormItemV2> |
| | | </ProFormColItem> |
| | |
| | | <ProFormCheckbox |
| | | v-model="form.checkReceiveMethods" |
| | | :value-enum="EnumTaskCheckReceiveMethodText" |
| | | :disabled="isEdit" |
| | | ></ProFormCheckbox> |
| | | </ProFormItemV2> |
| | | </ProFormColItem> |
| | | </ProFormCol> |
| | | <ProFormItemV2 |
| | | label="保险产品:" |
| | | prop="insuranceProductId" |
| | | :check-rules="[{ message: '请选择保险产品' }]" |
| | | v-if=" |
| | | form.checkReceiveMethods.includes(EnumTaskCheckReceiveMethod.CheckIn) && |
| | | form.isConfiguredInsurance |
| | | " |
| | | > |
| | | <ProFormSelect |
| | | v-model="form.insuranceProductId" |
| | | :value-enum="enterpriseInsuranceProductSelect" |
| | | @change="calcTaskTotalServiceFee" |
| | | ></ProFormSelect> |
| | | </ProFormItemV2> |
| | | <ProFormItemV2 label="预计服务费总额:" prop="totalServiceFee"> |
| | | {{ `${toThousand(form.totalServiceFee)}元` }} |
| | | </ProFormItemV2> |
| | | <ProFormItemV2 |
| | | label="结算方式:" |
| | | prop="settlementAccess" |
| | |
| | | EnumSettlementCycleDateWeekArray, |
| | | EnumSettlementCycle, |
| | | EnumTaskCheckReceiveMethodText, |
| | | EnumEnterpriseWalletAccessText, |
| | | EnumTaskCheckReceiveMethod, |
| | | } from '@/constants'; |
| | | import { format, FormValidator } from '@/utils'; |
| | | import { format, FormValidator, toThousand } from '@/utils'; |
| | | import dayjs from 'dayjs'; |
| | | |
| | | defineOptions({ |
| | |
| | | checkReceiveMethods: [] as any as EnumTaskCheckReceiveMethod[], |
| | | applyTime: [] as unknown as ModelValueType, |
| | | settlementAccess: '' as any as EnumEnterpriseWalletAccess, |
| | | totalServiceFee: 0, |
| | | |
| | | insuranceProductId: '', |
| | | isConfiguredInsurance: false, |
| | | }); |
| | | |
| | | const { settlementAccessList } = useEnterpriseWalletAccessSelect({ |
| | | supplierEnterpriseId: computed(() => form.supplierEnterpriseId), |
| | | }); |
| | | |
| | | const { enterpriseInsuranceProductSelect } = useEnterpriseInsuranceProductSelect({ |
| | | supplierEnterpriseId: computed(() => form.supplierEnterpriseId), |
| | | isConfiguredInsurance: computed(() => form.isConfiguredInsurance), |
| | | }); |
| | | |
| | | const { isLoading } = useQuery({ |
| | |
| | | format(data.applyEndTime, 'YYYY-MM-DD 23:59:59'), |
| | | ]; |
| | | form.settlementAccess = data.settlementAccess; |
| | | form.totalServiceFee = data.estimatedServiceFee; |
| | | |
| | | form.insuranceProductId = data.insuranceProductId ?? ''; |
| | | |
| | | supplierEnterpriseChange(); |
| | | }, |
| | | enabled: isEdit, |
| | | }); |
| | |
| | | |
| | | function handleTimeChange() { |
| | | form.applyTime = [] as unknown as ModelValueType; |
| | | calcTaskTotalServiceFee(); |
| | | } |
| | | |
| | | function handleBack() { |
| | | closeViewPush(route, { |
| | | name: 'TaskManageList', |
| | | }); |
| | | } |
| | | |
| | | function calculateMonthInterval(startDate, endDate) { |
| | | const diffInDays = dayjs(endDate).diff(startDate, 'day'); |
| | | const monthInterval = Math.ceil(diffInDays / 30); |
| | | return monthInterval > 15 ? Math.ceil(monthInterval / 30) : monthInterval; |
| | | } |
| | | |
| | | function calculateServicesFee( |
| | | billingMethod: EnumBillingMethod, |
| | | serviceFee: number, |
| | | time: ModelValueType, |
| | | needPeopleNumber: number, |
| | | verifyWorkHours: number |
| | | ) { |
| | | const monthInterval = calculateMonthInterval(time[0], time[1]); |
| | | const dayInterval = dayjs(time[1]).diff(time[0], 'day'); |
| | | switch (billingMethod) { |
| | | case EnumBillingMethod.Month: |
| | | return monthInterval * serviceFee * needPeopleNumber; |
| | | case EnumBillingMethod.Day: |
| | | return serviceFee * dayInterval * needPeopleNumber; |
| | | case EnumBillingMethod.Hour: |
| | | return serviceFee * dayInterval * needPeopleNumber * verifyWorkHours; |
| | | case EnumBillingMethod.Piece: |
| | | return serviceFee * needPeopleNumber; |
| | | } |
| | | } |
| | | |
| | | const productFormRef = ref<FormInstance>(); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // function calculateMonthInterval(startDate, endDate) { |
| | | // const diffInDays = dayjs(endDate).diff(startDate, 'day'); |
| | | // const monthInterval = Math.ceil(diffInDays / 30); |
| | | // return monthInterval > 15 ? Math.ceil(monthInterval / 30) : monthInterval; |
| | | // } |
| | | |
| | | // const totalServiceFee = computed(() => { |
| | | // const monthInterval = calculateMonthInterval(form.time[0], form.time[1]); |
| | | // const dayInterval = dayjs(form.time[1]).diff(dayjs(form.time[0]), 'day'); |
| | | // switch (form.billingMethod) { |
| | | // case EnumBillingMethod.Month: |
| | | // return monthInterval * (form.serviceFee ?? 0) * (form.needPeopleNumber ?? 0); |
| | | // case EnumBillingMethod.Day: |
| | | // return dayInterval * (form.serviceFee ?? 0) * (form.needPeopleNumber ?? 0); |
| | | // case EnumBillingMethod.Hour: |
| | | // return ( |
| | | // dayInterval * |
| | | // (form.verifyWorkHours ?? 0) * |
| | | // (form.serviceFee ?? 0) * |
| | | // (form.needPeopleNumber ?? 0) |
| | | // ); |
| | | // case EnumBillingMethod.Piece: |
| | | // return (form.totalPieceQuantity ?? 0) * (form.serviceFee ?? 0); |
| | | // default: |
| | | // return form.totalServiceFee; |
| | | // } |
| | | // }); |
| | | |
| | | function supplierEnterpriseChange() { |
| | | if (form.supplierEnterpriseId) { |
| | | form.isConfiguredInsurance = supplierEnterpriseSelect.value?.find( |
| | | (item) => item.value === form.supplierEnterpriseId |
| | | )?.data?.isConfiguredInsurance; |
| | | } |
| | | } |
| | | |
| | | async function calcTaskTotalServiceFee() { |
| | | try { |
| | | let params: API.CalcTaskTotalServiceFeeCommand = { |
| | | billingMethod: form.billingMethod, |
| | | serviceFee: form.serviceFee ?? 0, |
| | | verifyWorkHours: form.verifyWorkHours ?? 0, |
| | | totalPieceQuantity: form.totalPieceQuantity, |
| | | needPeopleNumber: form.needPeopleNumber ?? 0, |
| | | beginTime: dayjs(form.time[0]).format('YYYY-MM-DD 00:00:00'), |
| | | endTime: dayjs(form.time[1]).format('YYYY-MM-DD 23:59:59'), |
| | | supplierEnterpriseId: form.supplierEnterpriseId, |
| | | checkReceiveMethods: form.checkReceiveMethods, |
| | | }; |
| | | if (form.insuranceProductId) { |
| | | params.insuranceProductId = form.insuranceProductId; |
| | | } |
| | | let res = await taskServices.calcTaskTotalServiceFee(params); |
| | | if (res) { |
| | | form.totalServiceFee = res.totalServiceFee; |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | |
| | | async function submit() { |
| | | try { |
| | | // const estimateServicesFee = calculateServicesFee( |
| | | // form.billingMethod, |
| | | // form.serviceFee, |
| | | // form.time, |
| | | // form.needPeopleNumber, |
| | | // form.verifyWorkHours |
| | | // ); |
| | | // if (estimateServicesFee > 10000) { |
| | | // Message.tipMessage('您当前账户余额不足,暂时无法发布任务,请充值后操作', { |
| | | // confirmButtonText: '立即充值', |
| | | // cancelButtonText: '取消', |
| | | // type: 'warning', |
| | | // callback: (action) => { |
| | | // if (action === 'confirm') { |
| | | // router.push({ |
| | | // name: 'BalanceManageV2', |
| | | // }); |
| | | // } |
| | | // }, |
| | | // }); |
| | | // } |
| | | await calcTaskTotalServiceFee(); |
| | | let params: API.SaveTaskInfoCommand = { |
| | | supplierEnterpriseId: form.supplierEnterpriseId, |
| | | name: form.name, |
| | |
| | | description: form.description, |
| | | checkReceiveMethods: form.checkReceiveMethods, |
| | | settlementAccess: form.settlementAccess, |
| | | insuranceProductId: form.insuranceProductId, |
| | | }; |
| | | if (form.billingMethod !== EnumBillingMethod.Face) { |
| | | params.serviceFee = form.serviceFee; |
| | | } |
| | | if (isEdit) { |
| | | params.id = id; |
| | | } |
| | | let res = await taskServices.saveTaskInfo(params); |
| | | let res = await taskServices.saveTaskInfo(params, { |
| | | skipErrorHandler: true, |
| | | }); |
| | | if (res) { |
| | | Message.successMessage('操作成功'); |
| | | eventContext.emit(isEdit ? 'taskManage:edit' : 'taskManage:add'); |
| | | handleBack(); |
| | | } |
| | | } catch (error) {} |
| | | } catch (error) { |
| | | if (error?.info?.errorCode == 'BalanceNotEnough') { |
| | | Message.tipMessage('您当前账户余额不足,暂时无法发布任务,请充值后操作', { |
| | | confirmButtonText: '立即充值', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | callback: (action) => { |
| | | if (action === 'confirm') { |
| | | router.push({ |
| | | name: 'BalanceManageV2', |
| | | }); |
| | | } |
| | | }, |
| | | }); |
| | | } else { |
| | | Message.errorMessage(error); |
| | | } |
| | | } |
| | | } |
| | | |
| | | function handleCheckBenefitsAllChange(val: boolean) { |