Эх сурвалжийг харах

售后管理新需求以及bug

cz 1 жил өмнө
parent
commit
3650a1b91d

+ 129 - 7
src/views/JXSK/afterSales/edit.vue

@@ -36,6 +36,7 @@
                   <van-icon
                     name="warning-o"
                     v-if="
+                      submitData[item.productId].quantity &&
                       submitData[item.productId].remark &&
                       submitData[item.productId].fileList.length > 0
                     "
@@ -48,12 +49,18 @@
               </template>
               <div>
                 <van-field
+                  v-model="submitData[item.productId].quantity"
+                  label="售后数量"
+                  type="digit"
+                  placeholder="请输入"
+                  label-align="top"
+                />
+                <van-field
                   v-model="submitData[item.productId].remark"
                   label="售后说明"
                   type="textarea"
                   placeholder="请输入"
                   label-align="top"
-                  :rules="[{ required: true, message: '请填写售后说明' }]"
                 />
                 <van-field name="uploader" label="现场照片">
                   <template #input>
@@ -106,10 +113,16 @@ const formData = reactive({
   data: {},
 });
 const rules = {
-  customerId: [
+  afterSalesRemark: [
     {
       required: true,
-      message: proxy.t("afterSales.pleaseSelectTheCustomerName"),
+      message: "请输入其他问题",
+    },
+  ],
+  amount: [
+    {
+      required: true,
+      message: "请输入售后金额",
     },
   ],
 };
@@ -127,8 +140,15 @@ const formConfig = reactive([
     slotName: "top",
   },
   {
+    type: "upload",
+    label: "售后附件",
+    readonly: true,
+    showUpload: false,
+    prop: "fileListOne",
+  },
+  {
     type: "title",
-    title: proxy.t("afterSales.originalPartsList"),
+    title: "配件问题",
   },
   {
     type: "slot",
@@ -136,12 +156,34 @@ const formConfig = reactive([
   },
   {
     type: "title",
+    title: "其他问题",
+  },
+  {
+    type: "input",
+    itemType: "textarea",
+    label: "",
+    prop: "afterSalesRemark",
+  },
+  {
+    type: "title",
+    title: "售后金额",
+  },
+  {
+    type: "input",
+    itemType: "number",
+    label: "",
+    prop: "amount",
+    clearable: true,
+  },
+  {
+    type: "title",
     title: proxy.t("afterSales.programFile"),
   },
   {
     type: "upload",
     label: " ",
     readonly: true,
+    showUpload: false,
     prop: "fileList",
   },
 ]);
@@ -163,6 +205,26 @@ const topConfig = ref([
     label: "规格型号",
     prop: "productSpec",
   },
+  {
+    label: "售后类型",
+    prop: "typeName",
+  },
+  {
+    label: "售后说明",
+    prop: "remark",
+  },
+  {
+    label: "客户联系人",
+    prop: "contactName",
+  },
+  {
+    label: "客户联系方式",
+    prop: "contactInfo",
+  },
+  {
+    label: "售后人员",
+    prop: "afterSalesPersonIdName",
+  },
 ]);
 
 const listConfig = ref([
@@ -178,7 +240,38 @@ const listConfig = ref([
 
 const onClickLeft = () => history.back();
 const submitData = ref({});
-const getDetails = (id) => {
+const afterSalesType = ref([]);
+const userList = ref([]);
+
+const getDetails = async (id) => {
+  const data1 = await proxy.getDictOne(["after_sales_type"]);
+  afterSalesType.value = data1["after_sales_type"].data.map((x) => ({
+    label: x.dictValue,
+    value: x.dictKey,
+  }));
+
+  const data2 = await proxy.get("/system/user/list?pageNum=1&pageSize=9999");
+  userList.value = data2.rows.map((item) => {
+    return {
+      label: item.userName,
+      value: item.userId,
+    };
+  });
+
+  proxy
+    .post("/fileInfo/getList", {
+      businessIdList: [id],
+    })
+    .then((fileObj) => {
+      if (fileObj.data && fileObj.data[id]) {
+        formData.data.fileListOne = fileObj.data[id].map((x) => ({
+          raw: x,
+          name: x.fileName,
+          url: x.fileUrl,
+        }));
+      }
+    });
+
   const status = route.query.status;
   proxy.post("/afterSalesRecord/detail", { id }).then(async (res) => {
     if (status == 0) {
@@ -186,6 +279,8 @@ const getDetails = (id) => {
         const e = res.data.bomDetailList[i];
         submitData.value[e.productId] = {
           accessoriesId: e.productId,
+          productName: e.productName,
+          quantity: null,
           remark: "",
           fileList: [],
         };
@@ -197,6 +292,8 @@ const getDetails = (id) => {
         const e = res.data.bomDetailList[i];
         submitData.value[e.productId] = {
           accessoriesId: e.productId,
+          productName: e.productName,
+          quantity: e.afterSalesRecordDetail.quantity,
           remark: e.afterSalesRecordDetail.remark,
           fileList: [],
         };
@@ -231,6 +328,16 @@ const getDetails = (id) => {
           }));
         });
     }
+    let typeName = afterSalesType.value.find((x) => x.value == res.data.type);
+    if (typeName) {
+      formData.data.typeName = typeName.label;
+    }
+    let userName = userList.value.find(
+      (x) => x.value == res.data.afterSalesPersonId
+    );
+    if (userName) {
+      formData.data.afterSalesPersonIdName = userName.label;
+    }
   });
 };
 
@@ -239,6 +346,7 @@ onMounted(() => {
     getDetails(route.query.id);
     if (route.query.status == 1) {
       formOption.hiddenSubmitBtn = true; //隐藏提交按钮
+      formOption.readonly = true;
     }
   }
 });
@@ -247,13 +355,27 @@ const onSubmit = () => {
   let arr = Object.values(submitData.value);
   for (let i = 0; i < arr.length; i++) {
     const e = arr[i];
-    if (e.fileList.length == 0) {
-      return showFailToast(`第${i + 1}个配件没传现场照片`);
+    if (e.quantity || e.remark.trim() || e.fileList.length > 0) {
+      if (!e.quantity) {
+        return showFailToast(`请填写${e.productName}配件的售后数量`);
+      }
+      if (!e.remark.trim()) {
+        return showFailToast(`请填写${e.productName}配件的售后说明`);
+      }
+      if (e.fileList.length == 0) {
+        return showFailToast(`请上传${e.productName}配件的现场照片`);
+      }
     }
   }
+
+  if (!(Number(formData.data.amount) > 0)) {
+    return showFailToast(`售后金额需大于0`);
+  }
   proxy
     .post("/afterSalesRecord/afterSales", {
       id: formData.data.id,
+      afterSalesRemark: formData.data.afterSalesRemark,
+      amount: formData.data.amount,
       afterSalesRecordDetailList: arr,
     })
     .then(