From 1a11f7115e61c548f9ffc77d0a9e504307ca71b2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 24 八月 2021 18:37:20 +0800
Subject: [PATCH] 2021-08-24

---
 src/tabviews/custom/components/table/normal-table/index.jsx |   63 +++++++++++++------------------
 1 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/src/tabviews/custom/components/table/normal-table/index.jsx b/src/tabviews/custom/components/table/normal-table/index.jsx
index 2547788..cd57cff 100644
--- a/src/tabviews/custom/components/table/normal-table/index.jsx
+++ b/src/tabviews/custom/components/table/normal-table/index.jsx
@@ -75,7 +75,7 @@
         item.key = index
         item.$$uuid = item[_config.setting.primaryKey] || ''
         item.$$BID = BID || ''
-        item.$Index = index + 1
+        item.$Index = index + 1 + ''
         return item
       })
     }
@@ -138,7 +138,7 @@
    */
   async loadmaindata (reset, repage) {
     const { mainSearch } = this.props
-    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state
+    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state
 
     if (setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
       this.setState({
@@ -148,11 +148,14 @@
       })
       MKEmitter.emit('resetSelectLine', config.uuid, '', '') // 骞挎挱鏁版嵁鍒囨崲
       reset && MKEmitter.emit('resetTable', config.uuid, repage) // 鍒楄〃閲嶇疆
+      if (setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
       return
     }
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -161,11 +164,8 @@
       })
     }
 
-    let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
+    let requireFields = searches.filter(item => item.required && item.value === '')
     if (requireFields.length > 0) {
-      this.setState({
-        loading: false
-      })
       return
     }
 
@@ -175,10 +175,6 @@
 
     let _orderBy = orderBy || setting.order
     let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
-
-    if (param.func === 'sPC_Get_TableData') {
-      param.menuname = config.name || ''
-    }
 
     let result = await Api.genericInterface(param)
     if (result.status) {
@@ -195,13 +191,17 @@
           item.key = index
           item.$$uuid = item[setting.primaryKey] || ''
           item.$$BID = BID || ''
-          item.$Index = start + index
+          item.$$BData = BData || ''
+          item.$Index = start + index + ''
           return item
         }),
         selectedData: [],
         total: result.total,
         loading: false
       })
+      if (setting.$hasSyncModule) {
+        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
+      }
     } else {
       this.setState({
         loading: false
@@ -219,10 +219,10 @@
    */ 
   async loadmainLinedata (id) {
     const { mainSearch } = this.props
-    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize } = this.state
+    const { setting, config, arr_field, search, orderBy, BID, pageIndex, pageSize, BData } = this.state
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -238,10 +238,6 @@
     let _orderBy = orderBy || setting.order
     let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
 
-    if (param.func === 'sPC_Get_TableData') {
-      param.menuname = config.name || ''
-    }
-
     let result = await Api.genericInterface(param)
     if (result.status) {
       let data = fromJS(this.state.data).toJS()
@@ -250,6 +246,7 @@
         let _data = result.data[0] || {}
         _data.$$uuid = _data[setting.primaryKey] || ''
         _data.$$BID = BID || ''
+        _data.$$BData = BData || ''
         try {
           data = data.map(item => {
             if (item.$$uuid === _data.$$uuid) {
@@ -305,7 +302,7 @@
     if (config.statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
 
     let searches = fromJS(search).toJS()
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -313,17 +310,13 @@
         }
       })
     }
-    let requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
+    let requireFields = searches.filter(item => item.required && item.value === '')
     if (requireFields.length > 0) {
       return
     }
 
     let _orderBy = orderBy || setting.order
     let param = UtilsDM.getStatQueryDataParams(setting, config.statFields, searches, _orderBy, BID, this.props.menuType)
-
-    if (param.func === 'sPC_Get_TableData') {
-      param.menuname = config.name || ''
-    }
 
     Api.genericInterface(param).then(res => {
       if (res.status) {
@@ -426,14 +419,14 @@
   /**
    * @description 瀵煎嚭Excel鏃讹紝鑾峰彇椤甸潰鎼滅储鎺掑簭绛夊弬鏁�
    */
-  getexceloutparam = (menuId, btnId) => {
+  queryModuleParam = (menuId, btnId) => {
     const { mainSearch } = this.props
     const { arr_field, config, orderBy, search, setting} = this.state
 
     if (config.uuid !== menuId) return
 
     let searches = search ? fromJS(search).toJS() : []
-    if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
+    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢
       let keys = searches.map(item => item.key.toLowerCase())
       mainSearch.forEach(item => {
         if (!keys.includes(item.key.toLowerCase())) {
@@ -442,7 +435,7 @@
       })
     }
 
-    MKEmitter.emit('execExcelout', config.uuid, btnId, {
+    MKEmitter.emit('returnModuleParam', config.uuid, btnId, {
       arr_field: arr_field,
       orderBy: orderBy || setting.order,
       search: searches,
@@ -516,17 +509,15 @@
         item.key = index
         item.$$uuid = item[config.setting.primaryKey] || ''
         item.$$BID = BID || ''
-        item.$Index = index + 1
+        item.$Index = index + 1 + ''
         return item
       })
 
       this.setState({sync: false, data: _data})
-    } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
-      if (config.setting.syncRefresh === 'true') {
-        this.setState({pageIndex: 1}, () => {
-          this.reloadtable()
-        })
-      }
+    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
+      this.setState({pageIndex: 1}, () => {
+        this.reloadtable()
+      })
     }
   }
 
@@ -537,7 +528,7 @@
   componentDidMount () {
     MKEmitter.addListener('reloadData', this.reloadData)
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
-    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 
@@ -550,7 +541,7 @@
     }
     MKEmitter.removeListener('reloadData', this.reloadData)
     MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
-    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
+    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
     MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
   }
 

--
Gitblit v1.8.0