From 0c68b446cc11c62a34afe382058ec5630e684750 Mon Sep 17 00:00:00 2001
From: 田源 <lastanimals@163.com>
Date: 星期四, 21 十二月 2023 15:36:40 +0800
Subject: [PATCH] 参照对话框关闭后,选中状态未取消

---
 Source/UBCS-WEB/src/components/refer/vciWebReferTable.vue |   87 +++++++++++++++++++++++++++++++------------
 1 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/refer/vciWebReferTable.vue b/Source/UBCS-WEB/src/components/refer/vciWebReferTable.vue
index 70ccbae..fc86c35 100644
--- a/Source/UBCS-WEB/src/components/refer/vciWebReferTable.vue
+++ b/Source/UBCS-WEB/src/components/refer/vciWebReferTable.vue
@@ -5,7 +5,9 @@
                :visible.sync="visible"
                top="0"
                class="avue-dialog avue-dialog--top"
-               :width="options.width|| '80%'">
+               :width="options.width|| '80%'"
+               :height="options.height|| 'auto'"
+               @close="dialogClose"	>
       <avue-crud :option="option"
                  :table-loading="loading"
                  :data="data"
@@ -26,14 +28,12 @@
       </avue-crud>
       <div class="avue-dialog__footer">
         <div class="avue-dialog__footer--left valueInfo">{{ valueInfo }} </div>
-        <el-button @click="visible=false">鍙� 娑�</el-button>
+        <el-button @click="escHandler">鍙� 娑�</el-button>
         <el-button @click="setValue" type="primary">纭� 瀹�</el-button>
       </div>
     </el-dialog>
 
-    <avue-input v-model="text" :disabled="disabled" :placeholder="title" @click="!disabled && (visible=true)"></avue-input>
-    <!--<avue-input-table ref="referTable"  :props="props"  :column="column" :on-load="onLoad" v-model="value"  :placeholder="title" ></avue-input-table>
-  -->
+    <avue-input v-model="text" :disabled="disabled" :readonly="true" :placeholder="title" @click="!disabled && (visible=true)"></avue-input>
   </div>
 </template>
 
@@ -42,7 +42,7 @@
 import {getList,getLazyList,getTableDefinedUrl} from "@/api/refer/table";
 export default {
   name: "vciWebReferTable",
-  props:["referConfig","value","text","title","disabled"],
+  props:["referConfig","value","text","title","disabled","referType"],
   data() {
     return {
       visible: false,
@@ -58,6 +58,7 @@
       query: {},
       loading: false,
       page: {
+        layout: this.referType === "master" ? "total,pager,prev, next,jumper" : "total,pager,prev, next,jumper,sizes",
         pageSize: 10,
         currentPage: 1,
         total: this.referConfig.options.data?this.referConfig.options.data.length :0
@@ -66,6 +67,7 @@
       selectionList: [],
       option: {
         addBtn: false,
+        columnBtn:false,
         height: this.referConfig.options.height ? this.referConfig.options.height : 475,
         calcHeight: 30,
         tip: false,
@@ -87,15 +89,15 @@
   },
   created() {
     this.getParams();
-
-    // console.log('referConfig:')
-    // console.log(this.referConfig)
   },
   mounted() {
-    console.log('referrTable')
-    if(this.referConfig.options.page){
-      this.page.pageSize=this.referConfig.options.page.limit || this.referConfig.options.page.pageSize;
-      this.page.currentPage=this.referConfig.options.page.page || this.referConfig.options.page.currentPage;
+    if (this.referConfig.options.tableConfig && this.referConfig.options.tableConfig.page) {
+      this.page.pageSize = this.referConfig.options.tableConfig.page.limit || this.referConfig.options.tableConfig.page.pageSize;
+      this.page.currentPage = this.referConfig.options.tableConfig.page.page || this.referConfig.options.tableConfig.page.currentPage;
+    } else if (!validatenull(this.referConfig.options.limit)) {
+      this.page.pageSize = this.referConfig.options.limit;
+    } else if (this.referConfig.options.tableConfig && !validatenull(this.referConfig.options.tableConfig.limit)) {
+      this.page.pageSize = this.referConfig.options.tableConfig.limit;
     }
     this.$nextTick(() => {
       this.$refs.referCrud.doLayout()
@@ -108,6 +110,14 @@
     }
   },
   methods: {
+    escHandler(){
+      this.visible = false;
+      this.$refs.referDefalutCrud.refreshTable()
+    },
+    dialogClose(){
+      this.visible = false;
+      this.$refs.referDefalutCrud.refreshTable()
+    },
     getParams:function (){
       var queryParams = {};
       if(this.options.extraParams){
@@ -131,9 +141,15 @@
         queryParams['referBo'] = this.options['referBo'] || this.options['referType'];
       }
       queryParams['referType']= queryParams['referBo']
-      if (this.options.remoteSort && this.options.initSort) {
+      if (this.options.initSort) {
         queryParams['order'] = this.options.initSort.type;//鏂规硶
         queryParams['sort'] = this.options.initSort.field;//瀛楁
+      }
+      if(this.options.sortField){
+        queryParams['sort'] = this.options.sortField;//瀛楁
+      }
+      if(this.options.sortType){
+        queryParams['order'] = this.options.sortType;//鏂规硶
       }
       if (this.options.conditionParams) {
         //璇存槑鏄墿灞曞睘鎬�
@@ -240,7 +256,6 @@
         if(!tableConfig){
           this.$message.error( '娌℃湁瀹氫箟鍙傜収鐨勮〃鏍奸厤缃�');
         }
-        this.page.pageSize=tableConfig.page.limit || 10;
         if(!paramsData){
           paramsData = {
             currentUserReferModelKey:this.options.currentUserReferModelKey,
@@ -305,25 +320,48 @@
       this.selectionList.forEach((item,_index) =>{
         if(isMutiValue){
           var valueFieldArray = _that.props.value.split(",");
-          valueFieldArray.forEach((_itemField,_indexFiel)=>{
-            value.push( (item[_itemField] || item['data'][_itemField]) + (_that.referConfig.valueSep?_that.referConfig.valueSep:' '));
+          valueFieldArray.forEach((_itemField,_indexField)=>{
+            let itemValue=item[_itemField];
+            if(itemValue==undefined || itemValue == null){
+              itemValue=item['data'][_itemField]
+            }
+            value.push( itemValue + (_that.referConfig.valueSep?_that.referConfig.valueSep:' '));
           })
         }else {
-          value.push(item[_that.props.value] || item['data'][_that.props.value]);
+          let itemValue=item[_that.props.value];
+          if(itemValue==undefined || itemValue == null){
+            itemValue=item['data'][_that.props.value]
+          }
+          value.push(itemValue);
         }
         if(isMutiRaw) {
           var rawFieldArray = _that.props.label.split(",");
           rawFieldArray.forEach((_itemField,_indexField)=>{
-            text.push((item[_itemField] || item['data'][_itemField]) + (_that.referConfig.textSep?_that.referConfig.textSep:' ')) ;
+            let itemText=item[_itemField];
+            if(itemText==undefined || itemText == null){
+              itemText=item['data'][_itemField]
+            }
+            text.push(itemText + (_that.referConfig.textSep?_that.referConfig.textSep:' ')) ;
           })
         }else{
-          text.push(item[_that.props.label] || item['data'][_that.props.label]);
+          let itemText=item[_that.props.label];
+          if(itemText==undefined || itemText == null){
+            itemText=item['data'][_that.props.label]
+          }
+          text.push(itemText);
         }
       })
+      let mapFields =this.referConfig.fieldMap || {};
+      try {
+        if(!validatenull(this.options.mapFields)){
+          mapFields =Object.assign(this.referConfig.fieldMap,JSON.parse(this.options.mapFields)) ;
+        }
+      }catch (e) {
 
+      }
       this.value=value.join(',');
       this.text=text.join(',')
-      this.$emit("setValue", {field:this.referConfig.field,showField:this.referConfig.showField,value:this.value,text:this.text,rawData:this.selectionList,fieldMap:this.referConfig.fieldMap});
+      this.$emit("setValue", {field:this.referConfig.field,showField:this.referConfig.showField,value:this.value,text:this.text,rawData:this.selectionList,fieldMap:mapFields});
       this.visible=false;
     },
     searchReset() {
@@ -371,14 +409,15 @@
           }
         }
         getList(Object.assign(params,this.params,this.query, query),page.currentPage, page.pageSize, this.url).then(res => {
+          let data=[]
           if(res.data.records){
-            this.data = res.data.records
+            data = res.data.records
             this.page.total=res.data.total ;
           }else{
-            this.data = res.data.data.records;
+            data = res.data.data.records;
             this.page.total=res.data.data.total;
           }
-          this.data=this.data.map(item => {
+          this.data=data.map(item => {
             item.data=item.data || {}
             return {
               ...item

--
Gitblit v1.9.3