From 4d6b9f8a2d7b316633e43b489eae9ada949c07b5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 九月 2024 10:18:08 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx |  193 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 133 insertions(+), 60 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx
index e99578c..7c1cc56 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/mkPopSelect/index.jsx
@@ -41,61 +41,127 @@
       loading: true
     })
 
-    let param = {
-      func: 'sPC_Get_TableData',
-      obj_name: 'data',
-      exec_type: 'y',
-      arr_field: config.arr_field,
-      default_sql: 'true',
-      custom_script: '',
-      menuname: config.label
-    }
+    let param = null
+    if (window.backend && window.GLOB.CacheData.has('sql_' + config.uuid)) {
+      let ex = window.GLOB.CacheData.get('sql_' + config.uuid)
+      let sysvals = {
+        time_id: Utils.getguid(),
+        mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+        mk_organization: sessionStorage.getItem('organization') || '',
+        mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+        id: ID || '',
+        bid: BID || '',
+        datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+        orderby: orderBy || config.order || '',
+        pagesize: config.laypage === 'true' ? pageSize : '9999',
+        pageindex: pageIndex
+      }
+      if (window.GLOB.externalDatabase !== null) {
+        sysvals.db = window.GLOB.externalDatabase
+      }
 
-    let sql = ''
-    let DateCount = ''
-    let _search = ''
-    let _orderBy = orderBy || config.order || ''
-    let _datasource = config.dataSource
+      let exps = []
 
-    if (config.searchKey && searchKey) {
-      let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`)
-      _search = 'where ' + fields.join(' OR ')
-    }
+      if (config.searchKey) {
+        if (!searchKey) {
+          exps.push({
+            key: 'mk_search',
+            value: []
+          })
+        } else {
+          exps.push({
+            key: 'mk_search',
+            value: [{
+              key: config.searchKey,
+              match: '01',
+              type: /,/.test(config.searchKey) ? 'text_or' : 'text',
+              value: searchKey
+            }]
+          })
+        }
+        config.searchKey.split(',').forEach(key => {
+          sysvals[key.toLowerCase()] = searchKey || ''
+        })
+      }
 
-    _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`)
-    _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`)
-
-    if (config.laypage === 'true') {
-      sql = `/*system_query*/select top ${pageSize} ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows `
-      DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}`
-    } else if (_orderBy) {
-      sql = `/*system_query*/select ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows `
-    } else {
-      sql = `/*system_query*/select ${config.arr_field} from ${_datasource} ${_search}  `
-    }
-
-    let departmentcode = sessionStorage.getItem('departmentcode') || ''
-    let organization = sessionStorage.getItem('organization') || ''
-    let mk_user_type = sessionStorage.getItem('mk_user_type') || ''
+      ex.reps.forEach(n => {
+        let key = n.toLowerCase()
+        if (sysvals.hasOwnProperty(key)) {
+          exps.push({
+            key: n,
+            value: sysvals[key]
+          })
+        }
+      })
     
-    sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
-      Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}'
-      ${sql}`
-
-    // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
-    if (window.GLOB.debugger === true) {
-      console.info(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n'))
-      DateCount && console.info(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n'))
+      param = {
+        $backend: true,
+        data: [{
+          id: ex.id,
+          exps: exps,
+          menuname: '',
+          md5_id: ''
+        }]
+      }
+    } else {
+      param = {
+        func: 'sPC_Get_TableData',
+        obj_name: 'data',
+        exec_type: window.GLOB.execType || 'y',
+        arr_field: config.arr_field,
+        default_sql: 'true',
+        custom_script: '',
+        menuname: config.label
+      }
+  
+      let sql = ''
+      let DateCount = ''
+      let _search = ''
+      let _orderBy = orderBy || config.order || ''
+      let _datasource = config.dataSource
+  
+      if (config.searchKey && searchKey) {
+        let fields = config.searchKey.split(',').map(field => field + ` like '%${searchKey}%'`)
+        _search = 'where ' + fields.join(' OR ')
+      }
+  
+      _datasource = _datasource.replace(/@BID@/ig, `'${BID || ''}'`)
+      _datasource = _datasource.replace(/@ID@/ig, `'${ID || ''}'`)
+  
+      if (config.laypage === 'true') {
+        sql = `/*system_query*/select top ${pageSize} ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows `
+        DateCount = `/*system_query*/select count(1) as total from ${_datasource} ${_search}`
+      } else if (_orderBy) {
+        sql = `/*system_query*/select ${config.arr_field} from (select ${config.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_datasource} ${_search}) tmptable order by tmptable.rows `
+      } else {
+        sql = `/*system_query*/select ${config.arr_field} from ${_datasource} ${_search}  `
+      }
+  
+      let departmentcode = sessionStorage.getItem('departmentcode') || ''
+      let organization = sessionStorage.getItem('organization') || ''
+      let mk_user_type = sessionStorage.getItem('mk_user_type') || ''
+      
+      sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
+        Select @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}'
+        ${sql}`
+  
+      // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞
+      if (window.GLOB.debugger === true) {
+        window.mkInfo(`/*${config.label} 鏁版嵁婧�*/\n` + sql.replace(/\n\s{6}/ig, '\n'))
+        DateCount && window.mkInfo(`/*${config.label} 鎬绘暟鏌ヨ*/\n` + DateCount.replace(/\n\s{6}/ig, '\n'))
+      }
+  
+      param.LText = Utils.formatOptions(sql, param.exec_type)
+      param.DateCount = Utils.formatOptions(DateCount, param.exec_type)
+  
+      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+      param.secretkey = Utils.encrypt('', param.timestamp)
+  
+      param.username = sessionStorage.getItem('User_Name') || ''
+      param.fullname = sessionStorage.getItem('Full_Name') || ''
     }
-
-    param.LText = Utils.formatOptions(sql)
-    param.DateCount = Utils.formatOptions(DateCount)
-
-    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    param.secretkey = Utils.encrypt('', param.timestamp)
-
-    param.username = sessionStorage.getItem('User_Name') || ''
-    param.fullname = sessionStorage.getItem('Full_Name') || ''
 
     Api.getSystemCacheConfig(param, config.cache === 'true').then(result => {
       if (result.status) {
@@ -234,6 +300,7 @@
     
     this.state = {
       value: props.defaultValue,
+      showValue: props.showValue,
       visible: false
     }
   }
@@ -275,6 +342,10 @@
     const { config, lineId } = this.props
 
     let values = {[config.field]: record.$$uuid}
+    let showValue = ''
+    if (config.showField) {
+      showValue = record[config.showField] || ''
+    }
 
     if (config.linkSubField) {
       config.linkSubField.forEach((m, i) => {
@@ -284,7 +355,7 @@
 
     this.props.onChange(values, record.$$uuid)
 
-    this.setState({visible: false})
+    this.setState({visible: false, value: record.$$uuid, showValue})
 
     if (config.$ctrl) {
       MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid)
@@ -292,13 +363,15 @@
 
     this.props.onBlur && this.props.onBlur()
 
-    if (config.enter === '$noAct') return
+    if (/\$noAct/.test(config.enter)) return
 
-    if (/\$next/.test(config.enter)) {
-      MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', ''))
-    } else {
-      MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter)
-    }
+    setTimeout(() => {
+      if (/\$next/.test(config.enter)) {
+        MKEmitter.emit('nextLine' + config.tableId, lineId, config.enter.replace('$next_', ''))
+      } else {
+        MKEmitter.emit('setFocus' + config.tableId, lineId, config.enter)
+      }
+    }, 10)
   }
 
   trigger = (e) => {
@@ -327,7 +400,7 @@
     }
 
     this.props.onChange(values, '')
-    this.setState({value: ''})
+    this.setState({value: '', showValue: ''})
 
     if (config.$ctrl) {
       MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid)
@@ -348,12 +421,12 @@
 
   render() {
     const { autoFocus, BID, lineId, config } = this.props
-    const { value, visible } = this.state
+    const { showValue, value, visible } = this.state
     
     return <>
       {autoFocus ? <div className="mk-pop-select-mask" onClick={this.trigger}></div> : null}
       <div className="mk-pop-select-wrap" onClick={this.trigger}>
-        {value}
+        {showValue || value}
         {value && !autoFocus ? <CloseCircleFilled onClick={this.clear} /> : null}
         <TableOutlined onClick={this.trigger}/>
       </div>

--
Gitblit v1.8.0