Przeglądaj źródła

库存表格优化:重构条件列显示逻辑,使用三元表达式替代show属性

yusheng 10 miesięcy temu
rodzic
commit
8923b59900

+ 86 - 58
src/BIZComponents/inventoryTable.vue

@@ -1054,14 +1054,18 @@
             align: 'center'
           },
 
-          {
-            minWidth: 120,
-            prop: 'entrustedEnterpriseId',
-            label: '受托企业',
-            slot: 'entrustedEnterpriseId',
-            show: this.isCustomerMark,
-            align: 'center'
-          },
+          this.isCustomerMark
+            ? {
+                minWidth: 120,
+                prop: 'entrustedEnterpriseId',
+                label: '受托企业',
+                slot: 'entrustedEnterpriseId',
+                show: this.isCustomerMark,
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
           {
             width: 150,
             prop: 'saleCount',
@@ -1145,18 +1149,22 @@
             slot: 'notaxSinglePrice',
             align: 'center'
           },
-          {
-            width: 160,
-            prop: 'discountSinglePrice',
-            label: '折让单价',
-            align: 'center',
-            show: this.isDiscount,
-            formatter: (_row, _column, cellValue) => {
-              return _row.discountSinglePrice
-                ? Number(_row.discountSinglePrice).toFixed(2)
-                : '';
-            }
-          },
+          this.isDiscount
+            ? {
+                width: 160,
+                prop: 'discountSinglePrice',
+                label: '折让单价',
+                align: 'center',
+                show: this.isDiscount,
+                formatter: (_row, _column, cellValue) => {
+                  return _row.discountSinglePrice
+                    ? Number(_row.discountSinglePrice).toFixed(2)
+                    : '';
+                }
+              }
+            : {
+                width: 1
+              },
           {
             width: 120,
             prop: 'totalPrice',
@@ -1165,18 +1173,22 @@
             align: 'center'
           },
 
-          {
-            width: 160,
-            prop: 'discountTotalPrice',
-            label: '折让合计',
-            align: 'center',
-            show: this.isDiscount,
-            formatter: (_row, _column, cellValue) => {
-              return _row.discountTotalPrice
-                ? Number(_row.discountTotalPrice).toFixed(2)
-                : '';
-            }
-          },
+          this.isDiscount
+            ? {
+                width: 160,
+                prop: 'discountTotalPrice',
+                label: '折让合计',
+                align: 'center',
+                show: this.isDiscount,
+                formatter: (_row, _column, cellValue) => {
+                  return _row.discountTotalPrice
+                    ? Number(_row.discountTotalPrice).toFixed(2)
+                    : '';
+                }
+              }
+            : {
+                width: 1
+              },
 
           {
             width: 110,
@@ -1256,14 +1268,18 @@
             }
           },
 
-          {
-            width: 160,
-            prop: 'arrivalWay',
-            label: '到货方式',
-            slot: 'arrivalWay',
-            align: 'center',
-            show: this.isArrivalWay
-          },
+          this.isArrivalWay
+            ? {
+                width: 160,
+                prop: 'arrivalWay',
+                label: '到货方式',
+                slot: 'arrivalWay',
+                align: 'center',
+                show: this.isArrivalWay
+              }
+            : {
+                width: 1
+              },
           {
             width: 160,
             prop: 'customerExpectDeliveryDeadline',
@@ -1273,15 +1289,19 @@
             align: 'center'
           },
 
-          {
-            width: 160,
-            prop: 'produceDeliveryDeadline',
-            label: '生产交付交期',
-            slot: 'produceDeliveryDeadline',
-            headerSlot: 'headerProduceDeliveryDeadline',
-            show: this.contractBookType == 1,
-            align: 'center'
-          },
+          this.contractBookType == 1
+            ? {
+                width: 160,
+                prop: 'produceDeliveryDeadline',
+                label: '生产交付交期',
+                slot: 'produceDeliveryDeadline',
+                headerSlot: 'headerProduceDeliveryDeadline',
+                show: this.contractBookType == 1,
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
 
           {
             width: 200,
@@ -1291,14 +1311,18 @@
             // headerSlot: 'headerGuaranteePeriod',
             align: 'center'
           },
-          {
-            width: 200,
-            prop: 'guaranteePeriodDeadline',
-            label: '有效期截止日期',
-            slot: 'guaranteePeriodDeadline',
-            show: this.isGuaranteePeriod,
-            align: 'center'
-          },
+          this.isGuaranteePeriod
+            ? {
+                width: 200,
+                prop: 'guaranteePeriodDeadline',
+                label: '有效期截止日期',
+                slot: 'guaranteePeriodDeadline',
+                show: this.isGuaranteePeriod,
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
           {
             width: 120,
             prop: 'imgCode',
@@ -1893,7 +1917,11 @@
             this.$set(parasm, 'goodsPriceId', goodsPriceList.id);
             this.$set(parasm, 'goodsPriceType', goodsPriceList.priceType);
             this.$set(parasm, 'singlePrice', goodsPriceList.unitPrice);
-            this.$set(parasm, 'notaxSinglePrice', goodsPriceList.excludeTaxPrice);
+            this.$set(
+              parasm,
+              'notaxSinglePrice',
+              goodsPriceList.excludeTaxPrice
+            );
             this.$set(parasm, 'taxRate', goodsPriceList.taxRate);
             this.$set(parasm, 'discountSinglePrice', goodsPriceList.unitPrice);
             this.$set(parasm, 'totalCount', '');

+ 103 - 79
src/BIZComponents/inventoryTableDetails.vue

@@ -270,22 +270,26 @@
             label: '生产编号',
             align: 'center'
           },
-          {
-            minWidth: 120,
-            prop: 'entrustedEnterpriseId',
-            label: '受托企业',
-            slot: 'entrustedEnterpriseId',
-            show: this.isCustomerMark,
-            align: 'center',
-            showOverflowTooltip: true,
-            formatter: (row, column) => {
-              return (
-                this.supplierObj[row.productId]?.find(
-                  (item) => item.id === row.entrustedEnterpriseId
-                )?.name || ''
-              );
-            }
-          },
+          this.isCustomerMark
+            ? {
+                minWidth: 120,
+                prop: 'entrustedEnterpriseId',
+                label: '受托企业',
+                slot: 'entrustedEnterpriseId',
+                show: this.isCustomerMark,
+                align: 'center',
+                showOverflowTooltip: true,
+                formatter: (row, column) => {
+                  return (
+                    this.supplierObj[row.productId]?.find(
+                      (item) => item.id === row.entrustedEnterpriseId
+                    )?.name || ''
+                  );
+                }
+              }
+            : {
+                width: 1
+              },
           {
             width: 150,
             prop: 'saleCount',
@@ -325,22 +329,28 @@
             align: 'center'
           },
           wmsColumn,
-          {
-            minWidth: 110,
-            prop: 'sendTotalCount',
-            label: '已发货数量',
-            slot: 'sendTotalCount',
-            show: this.pageName == 'send',
-            align: 'center'
-          },
-          {
-            minWidth: 110,
-            prop: 'notSendTotalCount',
-            label: '未发货数量',
-            slot: 'notSendTotalCount',
-            show: this.pageName == 'send',
-            align: 'center'
-          },
+          this.pageName == 'send'
+            ? {
+                minWidth: 110,
+                prop: 'sendTotalCount',
+                label: '已发货数量',
+                slot: 'sendTotalCount',
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
+          this.pageName == 'send'
+            ? {
+                minWidth: 110,
+                prop: 'notSendTotalCount',
+                label: '未发货数量',
+                slot: 'notSendTotalCount',
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
 
           {
             width: 120,
@@ -413,18 +423,22 @@
             slot: 'notaxSinglePrice',
             align: 'center'
           },
-          {
-            width: 160,
-            prop: 'discountSinglePrice',
-            label: '折让单价',
-            align: 'center',
-            show: this.isDiscount,
-            formatter: (_row, _column, cellValue) => {
-              return _row.discountSinglePrice
-                ? Number(_row.discountSinglePrice).toFixed(2)
-                : '';
-            }
-          },
+          this.isDiscount
+            ? {
+                width: 160,
+                prop: 'discountSinglePrice',
+                label: '折让单价',
+                align: 'center',
+                show: this.isDiscount,
+                formatter: (_row, _column, cellValue) => {
+                  return _row.discountSinglePrice
+                    ? Number(_row.discountSinglePrice).toFixed(2)
+                    : '';
+                }
+              }
+            : {
+                width: 1
+              },
           {
             width: 120,
             prop: 'totalPrice',
@@ -432,18 +446,22 @@
             slot: 'totalPrice',
             align: 'center'
           },
-          {
-            width: 160,
-            prop: 'discountTotalPrice',
-            label: '折让合计',
-            align: 'center',
-            show: this.isDiscount,
-            formatter: (_row, _column, cellValue) => {
-              return _row.discountTotalPrice
-                ? Number(_row.discountTotalPrice).toFixed(2)
-                : '';
-            }
-          },
+          this.isDiscount
+            ? {
+                width: 160,
+                prop: 'discountTotalPrice',
+                label: '折让合计',
+                align: 'center',
+                show: this.isDiscount,
+                formatter: (_row, _column, cellValue) => {
+                  return _row.discountTotalPrice
+                    ? Number(_row.discountTotalPrice).toFixed(2)
+                    : '';
+                }
+              }
+            : {
+                width: 1
+              },
           {
             minWidth: 120,
             prop: 'goodsLevel',
@@ -529,20 +547,23 @@
           //   label: '包装规格',
           //   showOverflowTooltip: true
           // },
-          {
-            width: 160,
-            prop: 'arrivalWay',
-            label: '到货方式',
-            align: 'center',
-            formatter: (_row, _column, cellValue) => {
-              return _row.arrivalWay == 1
-                ? '一次性到货'
-                : _row.arrivalWay == 2
-                ? '分批到货'
-                : '';
-            },
-            show: this.isArrivalWay
-          },
+          this.isArrivalWay
+            ? {
+                width: 160,
+                prop: 'arrivalWay',
+                label: '到货方式',
+                align: 'center',
+                formatter: (_row, _column, cellValue) => {
+                  return _row.arrivalWay == 1
+                    ? '一次性到货'
+                    : _row.arrivalWay == 2
+                    ? '分批到货'
+                    : '';
+                }
+              }
+            : {
+                width: 1
+              },
           {
             width: 160,
             prop: 'customerExpectDeliveryDeadline',
@@ -550,15 +571,18 @@
             slot: 'customerExpectDeliveryDeadline',
             align: 'center'
           },
-          {
-            width: 160,
-            prop: 'produceDeliveryDeadline',
-            label: '生产交付交期',
-            slot: 'produceDeliveryDeadline',
-            headerSlot: 'headerProduceDeliveryDeadline',
-            show: this.contractBookType == 1,
-            align: 'center'
-          },
+          this.contractBookType == 1
+            ? {
+                width: 160,
+                prop: 'produceDeliveryDeadline',
+                label: '生产交付交期',
+                slot: 'produceDeliveryDeadline',
+                headerSlot: 'headerProduceDeliveryDeadline',
+                align: 'center'
+              }
+            : {
+                width: 1
+              },
 
           {
             width: 200,

+ 20 - 20
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -506,7 +506,6 @@
         isWarehouseId: 0,
         blockCountColumn: {},
         clientEnvironmentId: '',
-        columns: [],
         form: {
           datasource: []
         },
@@ -528,26 +527,9 @@
     computed: {
       canHandl() {
         return this.form.datasource.length;
-      }
-    },
-    mounted() {
-      this.clientEnvironmentId =
-        this.$store.state.user.info.clientEnvironmentId;
-    },
-    methods: {
-      downloadFile(file) {
-        getFile({ objectName: file.storePath }, file.name);
       },
-      //发货明细选择
-      stockLedgerSelect(row, index) {
-        this.curIndex = index;
-        this.stockLedgerDialogFlag = true;
-        this.$nextTick(() => {
-          this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
-        });
-      },
-      getColumns() {
-        this.columns = [
+      columns() {
+        return [
           {
             width: 45,
             type: 'index',
@@ -929,7 +911,25 @@
             showOverflowTooltip: true
           }
         ];
+      }
+    },
+    mounted() {
+      this.clientEnvironmentId =
+        this.$store.state.user.info.clientEnvironmentId;
+    },
+    methods: {
+      downloadFile(file) {
+        getFile({ objectName: file.storePath }, file.name);
       },
+      //发货明细选择
+      stockLedgerSelect(row, index) {
+        this.curIndex = index;
+        this.stockLedgerDialogFlag = true;
+        this.$nextTick(() => {
+          this.$refs.stockLedgerDialogRef.init(row.sendProductDetail, row);
+        });
+      },
+
       // changeCount1(row, index) {
       //   this.tableHandleKeyUp(row, index, 'sum');
       //   this.changeCount(row, index);