Kaynağa Gözat

限制必填项隐藏

yusheng 8 ay önce
ebeveyn
işleme
7ce6e2755c

+ 17 - 23
src/BIZComponents/inventoryTable.vue

@@ -137,9 +137,7 @@
         </el-form-item>
       </template>
       <template v-slot:headerCustomerMark="{ column }">
-        <span :class="isCustomerMark ? 'is-required' : ''">{{
-          column.label
-        }}</span>
+        <span class="is-required">{{ column.label }}</span>
       </template>
       <template v-slot:customerMark="{ row, $index }">
         <el-form-item
@@ -209,7 +207,7 @@
         <span :class="{ 'is-required': isTotalCount }">{{ column.label }}</span>
       </template>
       <template v-slot:headerTaxRate="{ column }">
-        <span :class="{ 'is-required': isTaxRate == 1 }">{{ column.label }}</span>
+        <span class="is-required">{{ column.label }}</span>
       </template>
       <template v-slot:totalPrice="scope">
         <el-form-item :prop="'datasource.' + scope.$index + '.totalPrice'">
@@ -242,11 +240,6 @@
           ></el-input>
         </el-form-item>
       </template>
-      <template v-slot:headerGuaranteePeriod="{ column }">
-        <span :class="{ 'is-required': contractBookType == 1 }">{{
-          column.label
-        }}</span>
-      </template>
 
       <template v-slot:guaranteePeriod="scope">
         <div class="period">
@@ -273,7 +266,6 @@
               dictName="质保期单位"
               clearable
               v-model="scope.row.guaranteePeriodUnitCode"
-              
               @change="
                 setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
               "
@@ -336,7 +328,7 @@
       </template> -->
 
       <template v-slot:taxRate="scope">
-        <el-form-item 
+        <el-form-item
           :prop="'datasource.' + scope.$index + '.taxRate'"
           :rules="{
             required: isTaxRate == 1 ? true : false,
@@ -445,7 +437,7 @@
       </template>
       <template v-slot:customerExpectDeliveryDeadline="scope">
         <el-form-item
-          v-if="scope.row.arrivalWay == 1||!scope.row.arrivalWay"
+          v-if="scope.row.arrivalWay == 1 || !scope.row.arrivalWay"
           :rules="{
             required: isDate == 1 ? true : false,
             message:
@@ -611,9 +603,7 @@
         </el-form-item>
       </template>
       <template v-slot:headerBatchNo="{ column }">
-        <span :class="isBatchNo == 1 ? 'is-required' : ''">{{
-          column.label
-        }}</span>
+        <span class="is-required">{{ column.label }}</span>
       </template>
 
       <template v-slot:orderNo="{ row, $index }">
@@ -1055,7 +1045,7 @@
             prop: 'customerMark',
             label: this.contractBookType == 1 ? '客户代号' : '供应商代号',
             slot: 'customerMark',
-            headerSlot: 'headerCustomerMark',
+            headerSlot: this.isCustomerMark ? 'headerCustomerMark' : '',
             align: 'center'
           },
           {
@@ -1089,7 +1079,7 @@
             prop: 'saleCount',
             label: '数量',
             slot: 'saleCount',
-            headerSlot: 'headerTotalCount',
+            headerSlot: this.isTotalCount ? 'headerTotalCount' : '',
             align: 'center'
           },
           {
@@ -1150,7 +1140,7 @@
             prop: 'singlePrice',
             label: '单价',
             slot: 'singlePrice',
-            headerSlot: 'headerSinglePrice',
+            headerSlot: this.isSinglePrice ? 'headerSinglePrice' : '',
             align: 'center'
           },
           {
@@ -1159,7 +1149,7 @@
             label: '税率',
             slot: 'taxRate',
             align: 'center',
-            headerSlot: 'headerTaxRate',
+            headerSlot: this.isTaxRate == 1 ? 'headerTaxRate' : ''
           },
           {
             width: 180,
@@ -1214,7 +1204,7 @@
             prop: 'batchNo',
             label: '批次号',
             slot: 'batchNo',
-            headerSlot: 'headerBatchNo',
+            headerSlot: this.isBatchNo ? 'headerBatchNo' : '',
             align: 'center'
           },
           {
@@ -1318,7 +1308,8 @@
             prop: 'customerExpectDeliveryDeadline',
             label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
             slot: 'customerExpectDeliveryDeadline',
-            headerSlot: 'headerCustomerExpectDeliveryDeadline',
+            headerSlot:
+              this.isDate == 1 ? 'headerCustomerExpectDeliveryDeadline' : '',
             align: 'center'
           },
 
@@ -1328,7 +1319,10 @@
                 prop: 'produceDeliveryDeadline',
                 label: '生产交付交期',
                 slot: 'produceDeliveryDeadline',
-                headerSlot: 'headerProduceDeliveryDeadline',
+                headerSlot:
+                  this.isDate == 1 && this.isProduceDeliveryDeadline
+                    ? 'headerProduceDeliveryDeadline'
+                    : '',
                 show: this.contractBookType == 1,
                 align: 'center'
               }
@@ -1513,7 +1507,7 @@
             .map((item) => item.productId);
           if (categoryIds.length > 0) {
             return await contactQueryByCategoryIdsAPI({
-              categoryIds,
+              categoryIds
             });
           } else {
             return Promise.resolve({});

+ 27 - 0
src/mixins/tableColumnsMixin.js

@@ -9,6 +9,7 @@ export default {
   created() {
     //从服务器获取缓存列表配置
     this.getTabColumns();
+
     // 创建防抖函数并绑定this
     this.debouncedHandleColumnChange = this.debounce(
       this.handleColumnChangeImpl,
@@ -30,6 +31,32 @@ export default {
 
     // 列表变化回调
     handleColumnChange() {
+      const list = this.getStorage(this.cacheKeyUrl + 'Cols');
+
+      if (list) {
+        let requireList = [];
+        let currentList = this.getColumns()
+          .filter((item) => item.headerSlot)
+          .map((item) => item.prop);
+        list.forEach((item) => {
+          if (currentList.includes(item.prop) && !item.checked) {
+            requireList.push(item.label);
+            item.checked = true;
+          }
+        });
+        if (requireList.length) {
+          this.setStorage(this.cacheKeyUrl + 'Cols', list);
+          if ('columns' in this.$options.computed) {
+            this.columnsVersion++;
+          } else {
+            this.columns = [...this.columns];
+          }
+          this.$message.warning(
+            `${requireList.toString()} 为必填项,无法隐藏!`
+          );
+          return;
+        }
+      }
       this.debouncedHandleColumnChange();
     },
 

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

@@ -474,7 +474,8 @@
         form: {
           datasource: []
         },
-        rules: {}
+        rules: {},
+        columnsVersion: 1
       };
     },
     created() {
@@ -497,7 +498,6 @@
       },
       columns() {
         let columnsVersion = this.columnsVersion;
-
         return [
           {
             width: 60,