Browse Source

feat:处理默认值为已审核逻辑,并在无缓存时主动触发查询

xieyong 2 days ago
parent
commit
d23b8fb865

+ 17 - 0
src/components/common/seekPage.vue

@@ -100,6 +100,20 @@
           if (!Array.isArray(val)) return;
           this.seekListRow = val.slice(0, this.maxLength);
           this.deboListRow = val.slice(this.maxLength);
+          // 初始化默认值
+          const defaults = {};
+          val.forEach((item) => {
+            if (
+              item.defaultValue !== undefined &&
+              item.defaultValue !== null &&
+              item.defaultValue !== ''
+            ) {
+              defaults[item.value] = item.defaultValue;
+            }
+          });
+          if (Object.keys(defaults).length) {
+            this.defaultWhere = { ...defaults, ...this.defaultWhere };
+          }
         }
       },
       defaultWhere: {
@@ -120,6 +134,9 @@
       if (cache) {
         this.defaultWhere = JSON.parse(cache);
         this.search();
+      } else if (Object.keys(this.defaultWhere).length) {
+        // 无缓存但有默认值(如 approvalStatus 默认 2),主动触发一次查询
+        this.search();
       }
     },
 

+ 3 - 1
src/components/selectionDialog/processRoute.vue

@@ -12,7 +12,7 @@
     :maxable="true"
   >
     <el-card shadow="never">
-      <route-search @search="reload"></route-search>
+      <route-search :key="routeSearchKey" @search="reload"></route-search>
 
       <ele-pro-table
         ref="table"
@@ -49,6 +49,7 @@
     data() {
       return {
         visible: false,
+        routeSearchKey: 0,
         columns: [
           {
             action: 'action',
@@ -147,6 +148,7 @@
         if (item) {
           this.radio = item.id;
         }
+        this.routeSearchKey++;
         this.visible = true;
       },
 

+ 2 - 1
src/components/selectionDialog/routeSearch.vue

@@ -54,7 +54,8 @@
             value: 'approvalStatus',
             type: 'select',
             placeholder: '请选择',
-            planList: this.approvalStatus
+            planList: this.approvalStatus,
+            defaultValue: 2
           },
           {
             label: '所属工厂:',