Просмотр исходного кода

解决报价导出问题和售后服务bug

hezhanp 7 месяцев назад
Родитель
Сommit
748eba94ae

+ 8 - 5
src/views/saleManage/quotation/index.vue

@@ -52,7 +52,7 @@
               size="small"
               icon="el-icon-download"
               @click="exportRowInfo()"
-              :disabled="selection?.length === 0"
+              :disabled="selection?.length !== 1"
               >导出</el-button
             >
 
@@ -438,15 +438,18 @@ export default {
     exportRowInfo() {
       const ids = this.selection.map((row) => row.id);
       if (ids.length === 0) {
-        this.$message.warning('请先选择需要导出的数据');
+        this.$message.warning('请选择需要导出的数据');
+        return;
+      }
+      if (ids.length > 1) {
+        this.$message.warning('只能选择一条数据进行导出');
         return;
       }
       getExport(ids);
     },
-    updatePrice(){
-      
+    updatePrice() {
       const ids = this.selection.map((row) => row.id);
-      updateProductPrice(ids)
+      updateProductPrice(ids);
     },
     //获取合同分类
     async getTreeData() {

+ 27 - 11
src/views/salesServiceManagement/components/info.vue

@@ -1832,20 +1832,36 @@ export default {
       this.form.tableList.splice(index, 1);
     },
     getValidate() {
-      return new Promise((resolve, reject) => {
-        this.$refs.form.validate((valid, obj) => {
-          if (obj) {
-            let messages = Object.keys(obj).map((key) => obj[key][0]);
-            if (messages.length > 0) {
-              this.$message.warning(messages[0].message);
+      return new Promise(async (resolve, reject) => {
+        const mainFormValid = await new Promise((res, rej) => {
+          this.$refs.form.validate((valid, obj) => {
+            if (obj) {
+              const messages = Object.keys(obj).map(
+                (key) => obj[key][0].message
+              );
+              if (messages.length) this.$message.warning(messages[0]);
             }
-          }
-          if (!valid) {
+            valid ? res(true) : rej(false);
+          });
+        }).catch(() => false);
+
+        if (!mainFormValid) {
+          reject(false);
+          return;
+        }
+
+        if (this.$refs.sparePartsRef) {
+          const sparePartsValid = await this.$refs.sparePartsRef
+            .getValidate()
+            .catch(() => false);
+          if (!sparePartsValid) {
             reject(false);
-          } else {
-            resolve(true);
+            return;
           }
-        });
+        }
+
+        // 所有验证通过
+        resolve(true);
       });
     },
     catch() {

+ 273 - 273
src/views/salesServiceManagement/components/saleorderDialog.vue

@@ -106,291 +106,291 @@
 </template>
 
 <script>
-  import { reviewStatus } from '@/enum/dict';
-  import {
-    getTableListHome,
-    getSaleOrderDetail
-  } from '@/api/saleManage/saleorder.js';
+import { reviewStatus } from '@/enum/dict';
+import {
+  getTableListHome,
+  getSaleOrderDetail
+} from '@/api/saleManage/saleorder.js';
 
-  const dayjs = require('dayjs');
+const dayjs = require('dayjs');
 
-  export default {
-    props: {
-      contractBookType: {
-        //合同类型 1销售 2采购
-        type: [String, Number],
-        default: 1
-      }
-    },
-    components: {},
+export default {
+  props: {
+    contractBookType: {
+      //合同类型 1销售 2采购
+      type: [String, Number],
+      default: 1
+    }
+  },
+  components: {},
 
-    data() {
-      return {
-        addRepairNotesDialog: false,
-        rowClickData: {},
-        selection: [],
-        packingList: [],
-        columns: [
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'orderNo',
-            label: '订单编码',
-            align: 'center',
-            slot: 'orderNo',
-            showOverflowTooltip: true,
-            minWidth: 200
-          },
-          {
-            prop: 'needProduce',
-            label: '订单类型',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 150,
-            formatter: (_row, _column, cellValue) => {
-              let businessType =
-                cellValue == 1
-                  ? '有客户生产性订单'
-                  : cellValue == 2
-                  ? '无客户生产性订单'
-                  : cellValue == 4
-                  ? '不定向订单'
-                  : '库存式订单';
+  data() {
+    return {
+      addRepairNotesDialog: false,
+      rowClickData: {},
+      selection: [],
+      packingList: [],
+      columns: [
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'orderNo',
+          label: '订单编码',
+          align: 'center',
+          slot: 'orderNo',
+          showOverflowTooltip: true,
+          minWidth: 200
+        },
+        {
+          prop: 'needProduce',
+          label: '订单类型',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 150,
+          formatter: (_row, _column, cellValue) => {
+            let businessType =
+              cellValue == 1
+                ? '有客户生产性订单'
+                : cellValue == 2
+                ? '无客户生产性订单'
+                : cellValue == 4
+                ? '不定向订单'
+                : '库存式订单';
 
-              return businessType;
-            }
-          },
-          {
-            prop: 'preOrderNo',
-            label: '预销售订单编码',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 200
-          },
-          {
-            prop: 'productNames',
-            label: '产品名称',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 140
-          },
-          {
-            minWidth: 160,
-            prop: 'productionCodes',
-            label: '生产编号',
-            align: 'center'
-          },
-          {
-            prop: 'batchNos',
-            label: '批次号',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 140
-          },
-          {
-            prop: 'productCount',
-            label: '数量',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 140
-          },
-          {
-            prop: 'orderStatus',
-            label: '审核状态',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 100,
-            formatter: (_row, _column, cellValue) => {
-              return reviewStatus[_row.orderStatus];
-            }
+            return businessType;
           }
-        ],
-        columnsPro: [
-          {
-            width: 45,
-            type: 'selection',
-            columnKey: 'selection',
-            align: 'center'
-          },
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryName',
-            label: '名称',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'productCategoryName',
-            label: '类型',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryCode',
-            label: '编码',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'productBrand',
-            label: '牌号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryModel',
-            label: '型号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'packingSpecification',
-            label: '规格',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'batchNo',
-            label: '批次号',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'measureQuantity',
-            label: '计量数量',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'singlePrice',
-            label: '单价(元)',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'barcodes',
-            label: '发货条码/车架号',
-            align: 'center',
-            showOverflowTooltip: true
+        },
+        {
+          prop: 'preOrderNo',
+          label: '预销售订单编码',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 200
+        },
+        {
+          prop: 'productNames',
+          label: '产品名称',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 140
+        },
+        {
+          minWidth: 160,
+          prop: 'productionCodes',
+          label: '生产编号',
+          align: 'center'
+        },
+        {
+          prop: 'batchNos',
+          label: '批次号',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 140
+        },
+        {
+          prop: 'productCount',
+          label: '数量',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 140
+        },
+        {
+          prop: 'orderStatus',
+          label: '审核状态',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 100,
+          formatter: (_row, _column, cellValue) => {
+            return reviewStatus[_row.orderStatus];
           }
-        ],
-        contactId: '',
-        searchForm: {}
-      };
-    },
-    created() {},
-    methods: {
-      // 初始化数据(父组件调用)
-      open(data, obj) {
-        this.contactId = data;
-        this.addRepairNotesDialog = true;
-        // 数据回显 ***
-        this.rowClickData.id = obj.orderId;
-        this.rowClickData.orderNo = obj.orderCode;
-        this.packingList = JSON.parse(JSON.stringify(obj.tableList));
-        this.$nextTick(() => {
-          this.packingList.forEach((row) => {
-            this.$refs.tableRef3.toggleRowSelection(row);
-          });
-          this.reload();
-        });
-      },
-
-      datasource({ page, limit, where, order }) {
-        return getTableListHome({
-          pageNum: page,
-          size: limit,
-          ...where
-        });
-      },
-      onSearch() {
-        let data = JSON.parse(JSON.stringify(this.searchForm));
-        if (data.time?.length > 0) {
-          data.createTimeStart = data.time[0];
-          data.createTimeEnd = data.time[1];
-        }
-        delete data.time;
-        this.reload(data);
-      },
-      reset() {
-        this.searchForm = {
-          orderNo: '',
-          contactName: '',
-          time: []
-        };
-        this.reload({});
-      },
-      reload(where) {
-        where = {
-          ...where,
-          // contractId: this.contractId,
-          contactId: this.contactId
-          // reviewStatus: 2
-        };
-        this.$refs.tableRefs2.reload({ page: 1, where });
-      },
-      async rowClick(row) {
-        this.rowClickData = { orderNo: row.orderNo, id: row.id };
-        this.getInfo(row);
-      },
-      handleClose() {
-        this.addRepairNotesDialog = false;
-        this.rowClickData = {};
-      },
-      submitAdd() {
-        if (!this.rowClickData.id) {
-          return this.$message.warning('请至少选择一条销售订单数据');
         }
-        if (this.selection.length > 1) {
-          return this.$message.warning('只能选择一条物品明细数据');
+      ],
+      columnsPro: [
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          align: 'center'
+        },
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryName',
+          label: '名称',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'productCategoryName',
+          label: '类型',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryCode',
+          label: '编码',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'productBrand',
+          label: '牌号',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryModel',
+          label: '型号',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'packingSpecification',
+          label: '规格',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'batchNo',
+          label: '批次号',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'measureQuantity',
+          label: '计量数量',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'singlePrice',
+          label: '单价(元)',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'barcodes',
+          label: '发货条码/车架号',
+          align: 'center',
+          showOverflowTooltip: true
         }
-        this.$emit('changeParent', {
-          orderCode: this.rowClickData.orderNo,
-          orderId: this.rowClickData.id,
-          tableList: this.selection
+      ],
+      contactId: '',
+      searchForm: {}
+    };
+  },
+  created() {},
+  methods: {
+    // 初始化数据(父组件调用)
+    open(data, obj) {
+      this.contactId = data;
+      this.addRepairNotesDialog = true;
+      // 数据回显 ***
+      this.rowClickData.id = obj.orderId;
+      this.rowClickData.orderNo = obj.orderCode;
+      this.packingList = JSON.parse(JSON.stringify(obj.tableList));
+      this.$nextTick(() => {
+        this.packingList.forEach((row) => {
+          this.$refs.tableRef3.toggleRowSelection(row);
         });
-        this.handleClose();
-      },
+        this.reload();
+      });
+    },
 
-      async getInfo(row) {
-        const res = await getSaleOrderDetail(row.id);
-        let list = res.productList.map((el) => {
-          el.categoryCode = el.productCode;
-          el.categoryName = el.productName;
-          el.categoryModel = el.modelType;
-          el.measureQuantity = el.totalCount;
-          el.barcodes = el.carCode;
-          el.packingSpecification = el.specification;
-          el.shipmentDate = row.createTime || null;
-          (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
-            (el.warrantyStatus = this.getTime(row.createTime)[1]);
-          return el;
-        });
-        this.packingList = list;
-      },
-      getTime(createTime) {
-        let date = new Date(createTime);
-        date.setMonth(date.getMonth() + 13); // 月份加13月
-        let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
-        let warrantyStatus =
-          new Date(time).getTime() > new Date().getTime() ? 0 : 1;
-        return [time, warrantyStatus];
+    datasource({ page, limit, where, order }) {
+      return getTableListHome({
+        pageNum: page,
+        size: limit,
+        ...where
+      });
+    },
+    onSearch() {
+      let data = JSON.parse(JSON.stringify(this.searchForm));
+      if (data.time?.length > 0) {
+        data.createTimeStart = data.time[0];
+        data.createTimeEnd = data.time[1];
       }
+      delete data.time;
+      this.reload(data);
+    },
+    reset() {
+      this.searchForm = {
+        orderNo: '',
+        contactName: '',
+        time: []
+      };
+      this.reload({});
+    },
+    reload(where) {
+      where = {
+        ...where,
+        // contractId: this.contractId,
+        contactId: this.contactId
+        // reviewStatus: 2
+      };
+      this.$refs.tableRefs2.reload({ page: 1, where });
+    },
+    async rowClick(row) {
+      this.rowClickData = { orderNo: row.orderNo, id: row.id };
+      this.getInfo(row);
+    },
+    handleClose() {
+      this.addRepairNotesDialog = false;
+      this.rowClickData = {};
+    },
+    submitAdd() {
+      if (!this.rowClickData.id) {
+        return this.$message.warning('请至少选择一条销售订单数据');
+      }
+      if (this.selection.length === 0) {
+        return this.$message.warning('请至少选择一条物品明细数据');
+      }
+      this.$emit('changeParent', {
+        orderCode: this.rowClickData.orderNo,
+        orderId: this.rowClickData.id,
+        tableList: this.selection
+      });
+      this.handleClose();
+    },
+
+    async getInfo(row) {
+      const res = await getSaleOrderDetail(row.id);
+      let list = res.productList.map((el) => {
+        el.categoryCode = el.productCode;
+        el.categoryName = el.productName;
+        el.categoryModel = el.modelType;
+        el.measureQuantity = el.totalCount;
+        el.barcodes = el.carCode;
+        el.packingSpecification = el.specification;
+        el.shipmentDate = row.createTime || null;
+        (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
+          (el.warrantyStatus = this.getTime(row.createTime)[1]);
+        return el;
+      });
+      this.packingList = list;
+    },
+    getTime(createTime) {
+      let date = new Date(createTime);
+      date.setMonth(date.getMonth() + 13); // 月份加13月
+      let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
+      let warrantyStatus =
+        new Date(time).getTime() > new Date().getTime() ? 0 : 1;
+      return [time, warrantyStatus];
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped></style>

+ 5 - 10
src/views/salesServiceManagement/components/sparePartsList.vue

@@ -87,7 +87,7 @@
                 source == '配件回收'
                   ? '配件回收清单名称不能为空'
                   : '项目名称不能为空',
-              trigger: 'change'
+              trigger: ['blur', 'change']
             }"
           >
             <!--:disabled="type == 'view' || scope.row.typeId == 2" -->
@@ -572,20 +572,15 @@ export default {
       }
       this.$set(this.form.tableList, index, obj);
     },
+    // spareParts 组件的 getValidate 方法
     getValidate() {
       return new Promise((resolve, reject) => {
         this.$refs.form.validate((valid, obj) => {
           if (obj) {
-            let messages = Object.keys(obj).map((key) => obj[key][0]);
-            if (messages.length > 0) {
-              this.$message.warning(messages[0].message);
-            }
-          }
-          if (!valid) {
-            reject(false);
-          } else {
-            resolve(true);
+            const messages = Object.keys(obj).map((key) => obj[key][0].message);
+            if (messages.length) this.$message.warning(messages[0]);
           }
+          valid ? resolve(true) : reject(false);
         });
       });
     },

+ 26 - 22
src/views/salesServiceManagement/demandList/components/dispatchDialog.vue

@@ -55,8 +55,8 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item 
-            label="预计售后时长" 
+          <el-form-item
+            label="预计售后时长"
             prop="duration"
             :rules="{
               required: true,
@@ -133,8 +133,8 @@
           </el-form-item>
         </el-col>
         <el-col :span="12">
-          <el-form-item 
-            label="紧急程度" 
+          <el-form-item
+            label="紧急程度"
             prop="urgent"
             :rules="{
               required: true,
@@ -164,7 +164,9 @@
       </el-row>
     </el-form>
     <div slot="footer" class="footer">
-      <el-button type="primary" @click="handleSubmit" :loading="loading">确认</el-button>
+      <el-button type="primary" @click="handleSubmit" :loading="loading"
+        >确认</el-button
+      >
       <el-button @click="handleClose" :loading="loading">取消</el-button>
     </div>
   </ele-modal>
@@ -227,11 +229,14 @@ export default {
       this.submitSource = type === 'add' ? 1 : 2;
       this.dispatchDialog = true;
       submitData = { ...data }; // 深拷贝避免原数据污染
-      
+
       const currentUser = getCurrentUser();
-      if (this.loginChangeGroupVOList && this.loginChangeGroupVOList.length > 0) {
+      if (
+        this.loginChangeGroupVOList &&
+        this.loginChangeGroupVOList.length > 0
+      ) {
         const obj = this.loginChangeGroupVOList.find(
-          el => el.groupId === currentUser.currentGroupId
+          (el) => el.groupId === currentUser.currentGroupId
         );
         this.addForm.executeGroupId = currentUser.currentGroupId || '';
         this.searchDeptNodeClick(currentUser.currentGroupId, {
@@ -274,7 +279,7 @@ export default {
         this.addForm.executeUserName = '';
         return;
       }
-      const user = this.executorList.find(item => item.id === val);
+      const user = this.executorList.find((item) => item.id === val);
       this.addForm.executeUserName = user?.name || '';
     },
     // 处理时长输入(去除前置0)
@@ -285,7 +290,6 @@ export default {
         this.addForm.duration = null;
       }
     },
-    // 转换时长为小时(后端要求)
     calculateDuration() {
       if (this.addForm.duration === null) return null;
       const duration = Number(this.addForm.duration);
@@ -300,24 +304,24 @@ export default {
           return duration;
       }
     },
-    // 提交表单
     handleSubmit() {
       this.$refs.addFormRef.validate(async (valid) => {
         if (valid) {
-          // 构造后端要求的参数结构
-          const planAddPO = {
-            workOrderExecuteUserId: this.addForm.executeUserId ? Number(this.addForm.executeUserId) : null,
+          const submitParams = {
+            ...submitData, // 原有基础数据
+            workOrderExecuteUserId: this.addForm.executeUserId
+              ? Number(this.addForm.executeUserId)
+              : null,
             workOrderExecuteUserName: this.addForm.executeUserName,
-            workOrderExecuteGroupId: this.addForm.executeGroupId ? Number(this.addForm.executeGroupId) : null,
+            workOrderExecuteGroupId: this.addForm.executeGroupId
+              ? Number(this.addForm.executeGroupId)
+              : null,
             workOrderExecuteGroupName: this.addForm.executeGroupName,
-            workOrderUrgent: this.addForm.urgent ? Number(this.addForm.urgent) : null,
+            workOrderUrgent: this.addForm.urgent
+              ? Number(this.addForm.urgent)
+              : null,
             workOrderRemark: this.addForm.remark,
-            duration: this.calculateDuration() // 转换为小时
-          };
-
-          const submitParams = {
-            ...submitData,
-            planAddPO,
+            duration: this.calculateDuration(), // 转换为小时
             submitSource: this.submitSource
           };