Explorar el Código

fix(销售服务管理): 优化订单选择逻辑并添加清空表单功能

yusheng hace 6 meses
padre
commit
6dd009b951

+ 8 - 6
src/views/salesServiceManagement/components/info.vue

@@ -1780,7 +1780,7 @@ export default {
         this.$refs.form.validateField('supplierName');
       });
     },
-    async contactDetail(id, type) {
+    async contactDetail(id, type,clear) {
       if (!id) {
         this.contractInfo = {};
         return;
@@ -1807,7 +1807,7 @@ export default {
             return item;
           })
         );
-        if (this.form.associationType != '3') {
+        if (this.form.associationType != '3'&&!clear) {
           this.$set(this.form, 'orderCode', '');
           this.$set(this.form, 'orderId', '');
           this.$set(this.form, 'tableList', []);
@@ -1923,10 +1923,10 @@ export default {
       this.$refs.form.resetFields();
     },
     saleorderDialogOpen() {
-      if (!this.form?.contractInfo?.id) {
-        this.$message.warning('请先选择客户名称!');
-        return;
-      }
+      // if (!this.form?.contractInfo?.id) {
+      //   this.$message.warning('请先选择客户名称!');
+      //   return;
+      // }
       this.form.tableList = [];
       if (this.type != 'view') {
         let obj = {
@@ -1938,6 +1938,7 @@ export default {
       }
     },
     saleorderChange(data) {
+      console.log(data,'data')
       this.$set(this.form, 'orderCode', data.orderCode);
       this.$set(this.form, 'orderId', data.orderId);
       let list = JSON.parse(JSON.stringify(data.tableList));
@@ -1951,6 +1952,7 @@ export default {
       } else {
         this.$set(this.form, 'faultDetailList', []);
       }
+     this.contactDetail(data.contactId,'',true)
     },
     customersDialogOpen() {
       this.$refs.productDialogRef.open();

+ 276 - 274
src/views/salesServiceManagement/components/saleorderDialog.vue

@@ -106,292 +106,294 @@
 </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;
+              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];
+            }
           }
-        },
-        {
-          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];
+        ],
+        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
           }
+        ],
+        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) {
+        console.log(row,'row')
+        this.rowClickData = { orderNo: row.orderNo, id: row.id,partaId:row.partaId };
+        this.getInfo(row);
+      },
+      handleClose() {
+        this.addRepairNotesDialog = false;
+        this.rowClickData = {};
+      },
+      submitAdd() {
+        if (!this.rowClickData.id) {
+          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
+        if (this.selection.length === 0) {
+          return this.$message.warning('请至少选择一条物品明细数据');
         }
-      ],
-      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.$emit('changeParent', {
+          orderCode: this.rowClickData.orderNo,
+          orderId: this.rowClickData.id,
+          contactId: this.rowClickData.partaId,
+          tableList: this.selection
         });
-        this.reload();
-      });
-    },
+        this.handleClose();
+      },
 
-    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('请至少选择一条物品明细数据');
+      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;
+        console.log(this.packingList);
+      },
+      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];
       }
-      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;
-      console.log(this.packingList)
-    },
-    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>