From 71b14ab1c5f43ed00057cf0ecad6c9567210204b Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 07 十一月 2025 11:07:29 +0800
Subject: [PATCH] feat: 1.3.0.1

---
 src/views/EmploymentManage/components/AddOrEditEmploymentView.vue |  165 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 146 insertions(+), 19 deletions(-)

diff --git a/src/views/EmploymentManage/components/AddOrEditEmploymentView.vue b/src/views/EmploymentManage/components/AddOrEditEmploymentView.vue
index 47cbc93..e537ff5 100644
--- a/src/views/EmploymentManage/components/AddOrEditEmploymentView.vue
+++ b/src/views/EmploymentManage/components/AddOrEditEmploymentView.vue
@@ -3,6 +3,17 @@
     <AppContainer>
       <PageFormLayout title="鍩烘湰淇℃伅">
         <ProForm :model="form" ref="productFormRef" label-width="110px" :is-read="isDetail">
+          <ProFormItemV2
+            label="渚涘簲鍟�:"
+            prop="supplierEnterpriseId"
+            :check-rules="[{ message: '璇烽�夋嫨渚涘簲鍟�' }]"
+          >
+            <ProFormSelect
+              v-model="form.supplierEnterpriseId"
+              :value-enum="supplierEnterpriseSelect"
+              placeholder="璇烽�夋嫨渚涘簲鍟�"
+            ></ProFormSelect>
+          </ProFormItemV2>
           <ProFormCol>
             <ProFormColItem :span="12">
               <ProFormItemV2
@@ -11,6 +22,25 @@
                 :check-rules="[{ message: '璇疯緭鍏ヤ换鍔″悕绉�' }]"
               >
                 <ProFormText v-model.trim="form.name" placeholder="璇疯緭鍏ヤ换鍔″悕绉�" />
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
+          <ProFormCol>
+            <ProFormColItem :span="12">
+              <ProFormItemV2
+                label="闇�姹備汉鏁�:"
+                prop="needPeopleNumber"
+                :check-rules="[{ message: '璇疯緭鍏ラ渶姹備汉鏁�' }]"
+              >
+                <ProFormInputNumber
+                  :controls="false"
+                  v-model="form.needPeopleNumber"
+                  placeholder="璇疯緭鍏ラ渶姹備汉鏁�"
+                  :min="0"
+                  :max="999999999999"
+                  :precision="0"
+                  unit="浜�"
+                ></ProFormInputNumber>
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
@@ -56,12 +86,7 @@
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
-          <template
-            v-if="
-              form.billingMethod === EnumBillingMethod.Hour ||
-              form.billingMethod === EnumBillingMethod.Day
-            "
-          >
+          <template v-if="form.billingMethod === EnumBillingMethod.Hour">
             <ProFormCol>
               <ProFormColItem :span="12">
                 <ProFormItemV2
@@ -69,7 +94,9 @@
                   prop="verifyWorkHours"
                   :check-rules="[{ message: '璇疯緭鍏ユ牳瀹氬伐鏃�' }]"
                 >
+                  <span v-if="isDetail && !form.verifyWorkHours"></span>
                   <ProFormInputNumber
+                    v-else
                     :controls="false"
                     v-model="form.verifyWorkHours"
                     placeholder="璇疯緭鍏ユ牳瀹氬伐鏃�"
@@ -88,7 +115,9 @@
                   prop="timeoutServiceFee"
                   :check-rules="[{ message: '璇疯緭鍏ヨ秴鏃舵湇鍔¤垂' }]"
                 >
+                  <span v-if="isDetail && !form.timeoutServiceFee"></span>
                   <ProFormInputNumber
+                    v-else
                     :controls="false"
                     v-model="form.timeoutServiceFee"
                     placeholder="璇疯緭鍏ヨ秴鏃舵湇鍔¤垂"
@@ -101,7 +130,25 @@
               </ProFormColItem>
             </ProFormCol>
           </template>
-
+          <ProFormCol v-if="form.billingMethod === EnumBillingMethod.Piece">
+            <ProFormColItem :span="12">
+              <ProFormItemV2
+                label="鎬讳欢鏁�:"
+                prop="totalPieceQuantity"
+                :check-rules="[{ message: '璇疯緭鍏ユ�讳欢鏁�' }]"
+              >
+                <ProFormInputNumber
+                  :controls="false"
+                  v-model="form.totalPieceQuantity"
+                  placeholder="璇疯緭鍏ユ�讳欢鏁�"
+                  :min="0"
+                  :max="999999999999"
+                  unit="浠�"
+                  :disabled="feeCannotEdit"
+                ></ProFormInputNumber>
+              </ProFormItemV2>
+            </ProFormColItem>
+          </ProFormCol>
           <ProFormCol>
             <ProFormColItem :span="12">
               <ProFormItemV2
@@ -270,7 +317,20 @@
               <ProFormItemV2
                 label="浠诲姟鏃堕棿:"
                 prop="time"
-                :check-rules="[{ message: '璇烽�夋嫨浠诲姟鏃堕棿', type: 'array' }]"
+                :check-rules="[
+                  { message: '璇烽�夋嫨浠诲姟鏃堕棿', type: 'array' },
+                  {
+                    validator: (rule, value, callback) => {
+                      if (form.billingMethod === EnumBillingMethod.Month) {
+                        if (dayjs(form.time[1]).diff(dayjs(form.time[0]), 'month') < 1) {
+                          callback(new Error('鏈堢粨浠诲姟鏃朵换鍔℃椂闂撮渶澶т簬涓�涓湀'));
+                        }
+                        callback();
+                      }
+                      callback();
+                    },
+                  },
+                ]"
               >
                 <ProFormDatePicker
                   v-model="form.time"
@@ -279,6 +339,7 @@
                   start-placeholder="寮�濮嬫棩鏈�"
                   end-placeholder="缁撴潫鏃ユ湡"
                   :disabled-date="disabledDate"
+                  @change="handleTimeChange"
                 ></ProFormDatePicker>
               </ProFormItemV2>
             </ProFormColItem>
@@ -305,14 +366,13 @@
             <ProFormColItem :span="12">
               <ProFormItemV2
                 label="楠屾敹鏂瑰紡:"
-                prop="checkReceiveMethod"
+                prop="checkReceiveMethods"
                 :check-rules="[{ message: '璇烽�夋嫨楠屾敹鏂瑰紡' }]"
               >
-                <ProFormRadio
-                  v-model="form.checkReceiveMethod"
+                <ProFormCheckbox
+                  v-model="form.checkReceiveMethods"
                   :value-enum="EnumTaskCheckReceiveMethodText"
-                  :button-style="false"
-                ></ProFormRadio>
+                ></ProFormCheckbox>
               </ProFormItemV2>
             </ProFormColItem>
           </ProFormCol>
@@ -383,21 +443,22 @@
 };
 defineProps<Props>();
 const route = useRoute();
+const router = useRouter();
 const id = route.params.id as string;
 const isEdit = !!id;
 
-const { settlementAccessList } = useEnterpriseWalletAccessSelect();
+const { supplierEnterpriseSelect } = useGetSupplierEnterpriseSelect();
 
 function disabledDate(time: Date) {
   return dayjs(time).isBefore(dayjs(), 'day');
 }
 
 function disabledapplyDate(time: Date) {
-  return dayjs(time).isBefore(form.time[0], 'day') || dayjs(time).isAfter(form.time[1], 'day');
+  return dayjs(time).isAfter(dayjs(form.time[1]), 'day') || dayjs(time).isBefore(dayjs(), 'day');
 }
 
 const feeCannotEdit = computed(() => {
-  return dayjs().isAfter(form.time[0], 'second');
+  return dayjs().isAfter(form.time[0], 'second') && isEdit;
 });
 
 const eventContext = useGlobalEventContext();
@@ -429,9 +490,12 @@
 });
 
 const form = reactive({
+  supplierEnterpriseId: '',
   name: '',
+  needPeopleNumber: null as number,
   billingMethod: EnumBillingMethod.Day,
   serviceFee: null,
+  totalPieceQuantity: null as number,
   settlementCycle: EnumSettlementCycle.Day,
   settlementDate: null as number,
   benefits: [] as string[],
@@ -445,9 +509,13 @@
   verifyWorkHours: null as number,
   timeoutServiceFee: null as number,
   description: '',
-  checkReceiveMethod: '' as any as EnumTaskCheckReceiveMethod,
+  checkReceiveMethods: [] as any as EnumTaskCheckReceiveMethod[],
   applyTime: [] as unknown as ModelValueType,
   settlementAccess: '' as any as EnumEnterpriseWalletAccess,
+});
+
+const { settlementAccessList } = useEnterpriseWalletAccessSelect({
+  supplierEnterpriseId: computed(() => form.supplierEnterpriseId),
 });
 
 const { isLoading } = useQuery({
@@ -462,8 +530,11 @@
   },
   placeholderData: () => ({} as API.GetTaskInfoQueryResult),
   onSuccess(data) {
+    form.supplierEnterpriseId = data.supplierEnterpriseId;
     form.name = data.name;
+    form.needPeopleNumber = data.needPeopleNumber;
     form.billingMethod = data.billingMethod;
+    form.totalPieceQuantity = data.totalPieceQuantity;
     form.serviceFee = data.serviceFee;
     form.settlementCycle = data.settlementCycle;
     form.settlementDate = data.settlementDate;
@@ -493,7 +564,7 @@
     form.verifyWorkHours = data.verifyWorkHours;
     form.timeoutServiceFee = data.timeoutServiceFee;
     form.description = data.description;
-    form.checkReceiveMethod = data.checkReceiveMethod;
+    form.checkReceiveMethods = data.checkReceiveMethods;
     form.applyTime = [
       format(data.applyBeginTime, 'YYYY-MM-DD 00:00:00'),
       format(data.applyEndTime, 'YYYY-MM-DD 23:59:59'),
@@ -507,11 +578,43 @@
   form.settlementDate = null as number;
 }
 
+function handleTimeChange() {
+  form.applyTime = [] as unknown as ModelValueType;
+}
+
 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 handleConfirm() {
   if (!productFormRef.value) return;
@@ -525,9 +628,33 @@
 }
 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',
+    //         });
+    //       }
+    //     },
+    //   });
+    // }
     let params: API.SaveTaskInfoCommand = {
+      supplierEnterpriseId: form.supplierEnterpriseId,
       name: form.name,
+      needPeopleNumber: form.needPeopleNumber,
       billingMethod: form.billingMethod,
+      totalPieceQuantity: form.totalPieceQuantity,
       serviceFee: form.serviceFee,
       settlementCycle: form.settlementCycle,
       settlementDate: form.settlementDate ? form.settlementDate : 0,
@@ -549,7 +676,7 @@
       verifyWorkHours: form.verifyWorkHours,
       timeoutServiceFee: form.timeoutServiceFee,
       description: form.description,
-      checkReceiveMethod: form.checkReceiveMethod,
+      checkReceiveMethods: form.checkReceiveMethods,
       settlementAccess: form.settlementAccess,
     };
     if (isEdit) {

--
Gitblit v1.9.1