From cc3682641685022d2f0400b30408cf3cb5a0a93d Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期一, 18 十二月 2023 17:31:04 +0800
Subject: [PATCH] 主数据管理:高级查询,状态查询,快速查询,当查询出多页时,点击分页的页码能够保留上一次的查询条件进行分页,点击分类树节点时则置空查询条件。

---
 Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue     |   20 +++++-
 Source/UBCS-WEB/src/views/MasterData/items.vue                  |   10 ++
 Source/UBCS-WEB/src/components/advanced-query/advancedQuery.vue |  107 +++++++++++++++++++----------------
 3 files changed, 83 insertions(+), 54 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
index 51e6949..420cd25 100644
--- a/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
+++ b/Source/UBCS-WEB/src/components/MasterCrud/VciMasterCrud.vue
@@ -348,6 +348,7 @@
       fileOptions: {},
       result: '',
       elapsedTime: '',
+      conditionMap: [],
     };
   },
   computed: {
@@ -428,7 +429,7 @@
 
           if (_index == 0) {
             this.keyWordFind = record.queryField;
-            console.log(record)
+            //console.log(record)
           }
         })
         this.tableHeadFindDatas = newval;
@@ -480,11 +481,15 @@
     },
   },
   methods: {
+    // 缃┖鏌ヨ鏉′欢
+    resetConditionMap() {
+      this.conditionMap = {};
+    },
+
     CodeLinkHandler(row) {
       this.LinkObject = row;
       this.LinkVisible = true;
       this.LinkList = Object.keys(row).map(property => property)
-
     },
     //鐘舵�佹悳绱�
     cellSelectHandler(row) {
@@ -496,6 +501,7 @@
     },
     cellStatusFind(lcstatus) {
       this.isLoading = true;
+      this.conditionMap["conditionMap[lcstatus]"] = lcstatus;
       TableData({
         templateOid: this.templateOid,
         codeClassifyOid: this.codeClassifyOid,
@@ -855,6 +861,7 @@
         codeClassifyOid: this.codeClassifyOid,
         page: this.page.currentPage,
         limit: this.page.pageSize,
+        ...this.conditionMap, /**甯︿笂鍒嗛〉鏌ヨ鏉′欢 */
       });
       const endTime = performance.now();
       this.elapsedTime = Math.floor(endTime - startTime) * 1;
@@ -916,7 +923,7 @@
         });
       });
     },
-    // 灏嗘鍦ㄧ紪杈戠殑琛岀殑鐘舵�佸彉涓� null 锛屽嵆閫�鍑虹紪杈戠姸鎬�
+    //灏嗘鍦ㄧ紪杈戠殑琛岀殑鐘舵�佸彉涓� null 锛屽嵆閫�鍑虹紪杈戠姸鎬�
     saveRow() {
       this.editingRow = null;
     },
@@ -940,6 +947,7 @@
           sort: val.prop,
           page: this.page.currentPage,
           limit: this.page.pageSize,
+          ...this.conditionMap
         });
         this.data = data.data;
       } finally {
@@ -949,7 +957,6 @@
     //鍒嗛〉鍒锋柊
     async onLoad(val) {
       this.isLoading = true;
-
       try {
         let conditionMap = {};
         if (this.statusSelect !== 'all') {
@@ -1002,11 +1009,14 @@
     },
     // 楂樼骇鏌ヨ
     async echoContion(val) {
+      this.conditionMap = val;
       try {
         const res = await FindData({
           templateOid: this.templateOid,
           codeClassifyOid: this.codeClassifyOid,
           ...val,
+          page: this.page.currentPage = 1,/** 姣忔鐐瑰嚮楂樼骇鏌ヨ閮藉簲璇ヤ粠绗竴椤靛紑濮�*/
+          limit: this.page.pageSize
         });
         this.tableData = res.data.data;
         this.page.total = res.data.total
@@ -1089,6 +1099,8 @@
     tableFindInp() {
       this.isLoading = true;
       try {
+        // 瀛樺偍鏌ヨ鏉′欢锛屼富瑕佹槸涓轰簡鐐瑰嚮椤电爜鏃跺甫涓婅繖涓潯浠�
+        this.conditionMap["conditionMap[" + this.keyWordFind + "]"] = '*' + this.WupinFindValue + '*';
         TableData({
           templateOid: this.templateOid,
           codeClassifyOid: this.codeClassifyOid,
diff --git a/Source/UBCS-WEB/src/components/advanced-query/advancedQuery.vue b/Source/UBCS-WEB/src/components/advanced-query/advancedQuery.vue
index fa4fa40..f928c61 100644
--- a/Source/UBCS-WEB/src/components/advanced-query/advancedQuery.vue
+++ b/Source/UBCS-WEB/src/components/advanced-query/advancedQuery.vue
@@ -104,6 +104,7 @@
 
 <script>
 import { getDictionary } from "@/api/omd/enum";
+import moment from 'moment';
 import vciWebRefer from '../refer/vciWebRefer.vue';
 export default {
   components: { vciWebRefer },
@@ -204,57 +205,55 @@
             const data = JSON.stringify(this.options);
             this.initOptions = JSON.parse(data);
             //console.log(this.initOptions);
-                if(this.initOptions.length > 0){
-                    let array = [];
-                    this.initOptions.forEach((item,index) => {
-                        if(item.fieldType==='combox') {
-                            let enumCach = item.data || JSON.parse(localStorage.getItem(item.comboxKey));
-                            if(enumCach != null && enumCach.length > 0) {
-                                item.data = enumCach;
-                            }else {
-                                getDictionary({code: item.comboxKey}).then(res=>{
-                                    item.data = res.data.data;
-                                    localStorage.setItem(item.comboxKey,JSON.stringify(res.data.data));
-                                })
-                            }
-                        }else if(item.fieldType==='refer'){
-                            this.$set(item,"referConfigData",{
-                                title: item.title,
-                                showField: item.showField || item.field,
-                                field: item.field,
-                                placeholder: item.inputTip || '',
-                                options: Object.assign(item.referConfig,{width:"80%"}),
-                            })
-                            //console.log(item.referConfigData.options);
-                            //console.log(item);
-                        }
-                        // TODO: 杩欏効淇敼涓�涓嬪弬鐓х殑鏌ヨ鏉′欢
-                        let conditions = [];
-                        if(item.fieldType==='text'){
-                            conditions = this.searchConditions;
-                        }else if (item.fieldType==='combox'|| item.fieldType==='truefalse'){
-                          conditions = this.switchSearchConditions;
-                        }else if (item.fieldType==='datetime') {
-                          conditions = this.dateConditions;
+            if(this.initOptions.length > 0){
+                let array = [];
+                this.initOptions.forEach((item,index) => {
+                    if(item.fieldType==='combox') {
+                        let enumCach = item.data || JSON.parse(localStorage.getItem(item.comboxKey));
+                        if(enumCach != null && enumCach.length > 0) {
+                            item.data = enumCach;
                         }else {
-                            conditions = this.referSearchConditions;
+                            getDictionary({code: item.comboxKey}).then(res=>{
+                                item.data = res.data.data;
+                                localStorage.setItem(item.comboxKey,JSON.stringify(res.data.data));
+                            })
                         }
-                        // console.log(conditions);
-                        this.$set(item,"conditions",conditions)
+                    }else if(item.fieldType==='refer'){
+                        this.$set(item,"referConfigData",{
+                            title: item.title,
+                            showField: item.showField || item.field,
+                            field: item.field,
+                            placeholder: item.inputTip || '',
+                            options: Object.assign(item.referConfig,{width:"80%"}),
+                        })
+                        //console.log(item.referConfigData.options);
+                        //console.log(item);
+                    }
+                    let conditions = [];
+                    if(item.fieldType==='text'){
+                        conditions = this.searchConditions;
+                    }else if (item.fieldType==='combox'|| item.fieldType==='truefalse'){
+                        conditions = this.switchSearchConditions;
+                    }else if (item.fieldType==='datetime' || item.fieldType==='date') {
+                        conditions = this.dateConditions;
+                    }else {
+                        conditions = this.referSearchConditions;
+                    }
+                    // console.log(conditions);
+                    this.$set(item,"conditions",conditions)
 
-                        let add = {
-                            queryField: String(item.queryField),
-                            condition: item.fieldType==='text' ? String("_like"):String("_equal"),
-                            fieldValue: item.fieldType==='truefalse' ? Boolean(false):String(''),
-                        }
-                        array.push(add)
-                    });
-                    this.searchFormArrays = array;
+                    let add = {
+                        queryField: String(item.queryField),
+                        condition: item.fieldType==='text' ? String("_like"):String("_equal"),
+                        fieldValue: item.fieldType==='truefalse' ? Boolean(false):String(''),
+                    }
+                    array.push(add)
+                });
+                this.searchFormArrays = array;
             }
             //console.log(this.initOptions);
             //console.log(this.searchFormArrays);
         },
-
         /** 涓哄弬鐓х被鍨嬫椂鍊奸�夋嫨涔嬪悗鐨勫鐞� */
         setReferValue(data,index){
             if(data.field) {
@@ -313,15 +312,27 @@
                     // 瀛樺湪鐩稿悓鐨勬煡璇㈡潯浠�
                     if(condtionParam['conditionMap['+searchConditions[index].queryField+']']+'' != 'undefined' ) {
                         this.$message.warning("瀛樺湪閲嶅鏌ヨ鏉′欢锛岃浠旂粏鏍稿!");
-                        console.log(condtionParam['conditionMap['+searchConditions[index].queryField+']']);
+                        //console.log(condtionParam['conditionMap['+searchConditions[index].queryField+']']);
                         return false;
                     }
-                    //鎷兼帴鎴恗ap瀵硅薄锛屽皢鏌ヨ瀵硅薄鍜宑ondition鎷兼帴鍦ㄤ竴璧凤紝缁勬垚楂樼骇鏌ヨmap鐨刱ey
-                    condtionParam['conditionMap['+searchConditions[index].queryField+searchConditions[index].condition+']'] = searchConditions[index].fieldValue;
+                    let fieldType = this.initOptions[index].fieldType;
+                    // 褰撳嚭鐜版煡璇㈡棩鏈熺殑鏍煎紡鏃�,闇�瑕佸鏃ユ湡鏍煎紡杩涜澶勭悊
+                    if(fieldType==='datetime' || fieldType==='date'){
+                        // 灏嗘椂闂磋浆鎹负鏈湴鏃堕棿
+                        let localTime = moment.utc(searchConditions[index].fieldValue).local();
+                        // 鏍煎紡鍖栨椂闂翠负鎮ㄦ兂瑕佺殑鏍煎紡
+                        let formattedTime = localTime.format('YYYY-MM-DD HH:mm:ss');
+                        condtionParam['conditionMap['+searchConditions[index].queryField+searchConditions[index].condition+']'] = formattedTime;
+                        //console.log(formattedTime);
+                    }else{
+                        //鎷兼帴鎴恗ap瀵硅薄锛屽皢鏌ヨ瀵硅薄鍜宑ondition鎷兼帴鍦ㄤ竴璧凤紝缁勬垚楂樼骇鏌ヨmap鐨刱ey
+                        condtionParam['conditionMap['+searchConditions[index].queryField+searchConditions[index].condition+']'] = searchConditions[index].fieldValue;
+                    }
                 }
+                
             }
             // 鏌ヨ鏉′欢娌℃湁鍑虹幇閲嶅灞炴�э紝骞朵笖杩囨护鎺変簡绌哄�硷紝灏变紶閫掔粰鐖剁粍浠�
-            console.log(condtionParam);
+            //console.log(condtionParam);
             this.$emit('echoContion',condtionParam)
             this.isShowDialog = false;
         },
diff --git a/Source/UBCS-WEB/src/views/MasterData/items.vue b/Source/UBCS-WEB/src/views/MasterData/items.vue
index 2ee09cf..fc9d781 100644
--- a/Source/UBCS-WEB/src/views/MasterData/items.vue
+++ b/Source/UBCS-WEB/src/views/MasterData/items.vue
@@ -40,6 +40,7 @@
         :nodeClickList="this.nodeClickList"
         @currentPage="currentPages"
         @pageSize="pageSizes"
+        ref="vciMasterCrud"
       >
       </VciMasterCrud>
     </el-main>
@@ -55,7 +56,7 @@
       page: {
         total: 0,
         currentPage: 1,
-        pageSize: 10,
+        pageSize: 100,
         pageSizes: [10, 30, 50, 100, 200],
       },
       pageSize: "100",
@@ -79,6 +80,12 @@
   methods: {
     nodeClickLists(val){
       this.nodeClickList=val;
+      // 鐐瑰嚮鏍戣妭鐐规椂閲嶇疆褰撳墠椤靛拰椤垫暟
+      this.page.pageSize = 100;
+      this.page.currentPage = 1;
+      // 閲嶇疆淇濆瓨鐨勯珮绾ф煡璇㈡煡璇㈡潯浠跺拰蹇�熸煡璇㈡潯浠�
+      const childComponent = this.$refs.vciMasterCrud;
+      childComponent.conditionMap = {}; // 淇敼瀛愮粍浠剁殑data涓殑灞炴��
     },
     TreeValueEmit(val) {
       this.TreeValue = val;
@@ -112,7 +119,6 @@
     },
     nodeClickTem(val) {
       this.templateOid = val;
-
     },
     tableHeadBttoms(val) {
       this.masterVrBtnList = val;

--
Gitblit v1.9.3