Explorar o código

对于服务所需的时间用表格校验

张田田 hai 3 meses
pai
achega
86f8ed5f4b

+ 26 - 13
src/service/AddItems.vue

@@ -114,6 +114,7 @@ const isDerivationModalOpen = ref(false);
 const rules: any = {
   name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
   conditioningProgramType: [{ required: true, message: '请选择方案类型', trigger: 'change' }],
+  offlineDuration: [{ required: true, message: '请输入服务所需时间', trigger: 'blur' }],
   institutionId: [
     {
       required: true,
@@ -207,10 +208,10 @@ function cancel() {
 }
 function doSubmit() {
   // 手动验证方案类型
-  if (!form.conditioningProgramType) {
-    message.error('请选择方案类型');
-    return;
-  }
+  // if (!form.conditioningProgramType) {
+  //   message.error('请选择方案类型');
+  //   return;
+  // }
 
   // 自定义验证:检查项目应用是否已选择
   if (!checkedList.value || checkedList.value.length === 0) {
@@ -269,10 +270,10 @@ function doSubmit() {
         return;
       }
       // 线下服务:服务所需时间必填
-      if (form.sellType === '2' && !form.offlineDuration) {
-        message.error('请输入服务所需时间');
-        return;
-      }
+      // if (form.sellType === '2' && !form.offlineDuration) {
+      //   message.error('请输入服务所需时间');
+      //   return;
+      // }
       // 实体商品:配送必填(itemsList 和 system 类型都需要)
       if (form.sellType === '1' && (!deliverArr.value || deliverArr.value.length === 0)) {
         message.error('请选择配送方式');
@@ -336,10 +337,10 @@ function doSubmit() {
   }
 
   // 商品图片必填
-  if (!fileList.value || fileList.value.length === 0) {
-    message.error('请上传商品图片');
-    return;
-  }
+  // if (!fileList.value || fileList.value.length === 0) {
+  //   message.error('请上传商品图片');
+  //   return;
+  // }
 
   formRef.value?.validate().then(() => {
     form.photo = fileList.value[0]?.response?.url || fileList.value[0]?.url || '';
@@ -781,6 +782,17 @@ watch(
     }
   }
 );
+
+// 监听项目应用变化,当只选择调理方案项目时,自动设置为一口价
+watch(
+  () => checkedList.value,
+  (newVal) => {
+    // 如果只选择了调理方案项目(包含 '2' 但不包含 '1'),自动设置为一口价
+    if (newVal.includes('2') && !newVal.includes('1')) {
+      form.pricingType = '0';
+    }
+  }
+);
 function deliveryChange(value: any) {
   form.isDelivery = value[value.length - 1];
 }
@@ -885,7 +897,7 @@ function handleDerivation() {
           <a-radio value="3">线上权益</a-radio>
         </a-radio-group>
       </a-form-item>
-      <a-form-item label="计价规则:" name="pricingType" :required="checkedList.includes('1')">
+      <a-form-item label="计价规则:" name="pricingType" :required="checkedList.includes('1') || (checkedList.includes('2') && !checkedList.includes('1'))">
         <a-radio-group v-model:value="form.pricingType">
           <a-radio value="0">一口价</a-radio>
           <a-radio value="1" v-if="!checkedList.includes('2')">按穴位/经络/部位</a-radio>
@@ -947,6 +959,7 @@ function handleDerivation() {
         </div>
       </a-form-item>
       <a-form-item label="服务所需时间:"
+      name="offlineDuration"
         v-if="(form.addType === 'itemsList' || form.addType === 'system') && showServiceRequiredTime" required>
         <a-input v-model:value="form.offlineDuration" placeholder="请输入" style="width: 200px" />
         <span style="margin-left: 8px">分钟</span>

+ 1 - 1
src/service/IntroduceProjectList.vue

@@ -83,7 +83,7 @@ function addProject(row: any) {
       id: 'add-items-modal',
       title: '新增项目',
       width: 1000,
-      height: 700,
+      height: 1000,
       escClosable: true,
       destroyOnClose: true,
       slots: {

+ 2 - 5
src/service/ServiceItemsList.vue

@@ -247,11 +247,8 @@ function editConfirmed(model?: SystemItemModel, index?: number) {
   } else {
     VxeUI.modal.open({
       title: model?.id ? `编辑项目` : `新增项目`,
-      height: 800,
-      width: 850,
-      // position: {
-      //   top: Math.min(100, window.innerHeight * 0.1),
-      // },
+      height: 1000,
+      width: 900,
       escClosable: true,
       destroyOnClose: true,
       id: `add-items-modal`,

+ 2 - 2
src/service/ServiceItemsSystem.vue

@@ -246,8 +246,8 @@ function editItems(model?: SystemItemModel, index?: number) {
   } else {
     VxeUI.modal.open({
       title: model?.id ? `编辑项目` : `新增项目`,
-      height: 700,
-      width: 850,
+      height: 1000,
+      width: 900,
       position: {
         top: Math.min(100, window.innerHeight * 0.1),
       },