From 9282e645d0205f85bf0d424a0b2f5c42c2aae1d9 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 21 五月 2025 11:40:32 +0800
Subject: [PATCH] 2025-05-21

---
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx |  592 +++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 452 insertions(+), 140 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
index 57dba86..8415ed3 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -20,7 +20,6 @@
 
 class MkSwitch extends Component {
   static propTpyes = {
-    autoFocus: PropTypes.bool,
     defaultValue: PropTypes.any,
     config: PropTypes.object,
     onChange: PropTypes.func
@@ -78,12 +77,10 @@
     if (config.$ctrl) {
       MKEmitter.emit('colBlur' + config.tableId, lineId, config.uuid)
     }
-
-    this.props.onBlur && this.props.onBlur()
   }
 
   render() {
-    const { config, autoFocus } = this.props
+    const { config } = this.props
     const { status } = this.state
 
     return (
@@ -91,7 +88,6 @@
         ref={ref => this.node = ref}
         checkedChildren={config.openText}
         checked={status}
-        autoFocus={autoFocus}
         onFocus={this.onFocus}
         onBlur={this.onBlur}
         unCheckedChildren={config.closeText}
@@ -562,6 +558,10 @@
 
       if (config.noValue === 'hide' && !value) {
         value = 0
+      }
+
+      if (config.required === 'true' && !value) {
+        err = `${config.label}涓嶅彲涓�${config.noValue === 'hide' ? '绌�' : '0'}`
       } else {
         if (typeof(config.max) === 'number' && value > config.max) {
           err = config.label + '鏈�澶т负' + config.max
@@ -582,19 +582,34 @@
     const { config } = this.props
     const { value, err } = this.state
 
-    return (
-      <InputNumber
-        title={err}
-        className={err ? 'has-error' : ''}
-        ref={ref => this.node = ref}
-        precision={config.decimal || 0}
-        value={value}
-        onChange={(value) => this.onChange(value)}
-        onPressEnter={this.enterPress}
-        onFocus={this.onFocus}
-        onBlur={this.onBlur}
-      />
-    )
+    if (!config.decimal && config.decimal !== 0) {
+      return (
+        <InputNumber
+          title={err}
+          className={err ? 'has-error' : ''}
+          ref={ref => this.node = ref}
+          value={value}
+          onChange={(value) => this.onChange(value)}
+          onPressEnter={this.enterPress}
+          onFocus={this.onFocus}
+          onBlur={this.onBlur}
+        />
+      )
+    } else {
+      return (
+        <InputNumber
+          title={err}
+          className={err ? 'has-error' : ''}
+          ref={ref => this.node = ref}
+          precision={config.decimal}
+          value={value}
+          onChange={(value) => this.onChange(value)}
+          onPressEnter={this.enterPress}
+          onFocus={this.onFocus}
+          onBlur={this.onBlur}
+        />
+      )
+    }
   }
 }
 
@@ -727,7 +742,7 @@
   }
 
   render() {
-    let { col, config, record, style, className, ...resProps } = this.props
+    let { col, record, style, className, ...resProps } = this.props
     const { editing } = this.state
 
     if (!col) return (<td {...resProps} className={className} style={style}/>)
@@ -744,13 +759,17 @@
         content = `${record[col.field]}`
       }
 
-      if (col.editType === 'select' && col.options.length > 0) {
+      if (col.editType === 'select' && col.showValue !== 'value' && col.options.length > 0) {
         content = col.map.get(content) || content
       } else if (col.editType === 'switch') {
-        if (content === config.openVal) {
-          content = config.openText
-        } else if (content === config.closeVal) {
-          content = config.closeText
+        if (content === col.openVal) {
+          content = col.openText
+        } else if (content === col.closeVal) {
+          content = col.closeText
+        }
+      } else if (col.editType === 'popSelect') {
+        if (col.showField) {
+          content = record[col.showField] || content
         }
       }
 
@@ -761,6 +780,10 @@
           content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
         } else if (col.textFormat === 'encryption') {
           content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
+        }
+
+        if (col.noValue === 'hide' && content < '1949-10-02') {
+          content = ''
         }
 
         if (col.textFormat !== 'encryption') {
@@ -793,24 +816,30 @@
       }
 
       if (col.editable === 'true' && !disabled) {
-        if (editing) {
+        if (col.editType === 'switch') {
+          let _value = record[col.field] !== undefined ? record[col.field] : ''
+          return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
+            <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/>
+          </td>)
+        } else if (editing) {
           let _value = record[col.field] !== undefined ? record[col.field] : ''
 
           if (!col.editType || col.editType === 'text') {
             return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
               <MkInput config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
             </td>)
-          } else if (col.editType === 'switch') {
-            return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
-              <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
-            </td>)
           } else if (col.editType === 'date') {
             return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
               <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
             </td>)
           } else if (col.editType === 'popSelect') {
+            let showValue = ''
+            if (col.showField) {
+              showValue = record[col.showField] || ''
+            }
+
             return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
-              <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
+              <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={true} onChange={this.onColChange} onBlur={() => this.setState({editing: false})}/>
             </td>)
           } else {
             return (<td onClick={(e) => e.stopPropagation()} className="editing_table_cell">
@@ -845,6 +874,9 @@
         }
         if (col.format === 'percent') {
           content = content * 100
+          if (!col.round) {
+            content = +content.toFixed(2)
+          }
         } else if (col.format === 'abs') {
           content = Math.abs(content)
         }
@@ -853,6 +885,7 @@
         }
   
         if (col.format === 'thdSeparator') {
+          content = content + ''
           content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
         }
   
@@ -928,6 +961,15 @@
           content = ''
         }
       } else {
+        if (col.eval === 'false' && col.noValue === 'hide') { // 绌哄�奸殣钘�
+          Object.keys(record).forEach(key => {
+            if (/^\$/.test(key)) return
+            if (record[key]) return
+
+            content = content.replace(new RegExp('[^@]*@' + key + '@', 'ig'), '')
+          })
+        }
+
         Object.keys(record).forEach(key => {
           let reg = new RegExp('@' + key + '@', 'ig')
           content = content.replace(reg, record[key])
@@ -938,7 +980,7 @@
             // eslint-disable-next-line
             content = eval(content)
           } catch (e) {
-            console.info(content)
+            window.mkInfo(content)
             console.warn(e)
             content = ''
           }
@@ -960,7 +1002,12 @@
         content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       } else if (content !== '') {
         content = `${col.prefix || ''}${content}${col.postfix || ''}`
-        content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
+        if (!col.evalchars || col.evalchars.includes('enter')) {
+          content = content.replace(/\n/ig, '<br/>')
+        }
+        if (!col.evalchars || col.evalchars.includes('space')) {
+          content = content.replace(/\s/ig, '&nbsp;')
+        }
         content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       }
 
@@ -996,7 +1043,7 @@
       }
 
       children = (
-        <CardCellComponent data={record} cards={config} elements={col.elements}/>
+        <CardCellComponent data={record} cards={col.config} elements={col.elements}/>
       )
     }
 
@@ -1027,7 +1074,7 @@
   }
 
   render() {
-    let { col, config, record, style, className, ...resProps } = this.props
+    let { col, record, style, className, ...resProps } = this.props
 
     if (!col) return (<td {...resProps} className={className} style={style}/>)
 
@@ -1049,15 +1096,20 @@
           )
         } else if (col.editType === 'switch') {
           children = (
-            <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} autoFocus={false} onChange={this.onColChange}/>
+            <MkSwitch config={col} lineId={record.$$uuid} defaultValue={_value} onChange={this.onColChange}/>
           )
         } else if (col.editType === 'date') {
           children = (
             <MkDatePicker config={col} lineId={record.$$uuid} defaultValue={_value || null} autoFocus={false} onChange={this.onColChange}/>
           )
         } else if (col.editType === 'popSelect') {
+          let showValue = ''
+          if (col.showField) {
+            showValue = record[col.showField] || ''
+          }
+          
           children = (
-            <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/>
+            <MKPopSelect config={col} lineId={record.$$uuid} defaultValue={_value} showValue={showValue} BID={record.$$BID} autoFocus={false} onChange={this.onColChange}/>
           )
         } else {
           children = (
@@ -1070,13 +1122,17 @@
           content = `${record[col.field]}`
         }
 
-        if (col.editType === 'select' && col.options.length > 0) {
+        if (col.editType === 'select' && col.showValue !== 'value' && col.options.length > 0) {
           content = col.map.get(content) || content
         } else if (col.editType === 'switch') {
-          if (content === config.openVal) {
-            content = config.openText
-          } else if (content === config.closeVal) {
-            content = config.closeText
+          if (content === col.openVal) {
+            content = col.openText
+          } else if (content === col.closeVal) {
+            content = col.closeText
+          }
+        } else if (col.editType === 'popSelect') {
+          if (col.showField) {
+            content = record[col.showField] || content
           }
         }
 
@@ -1087,6 +1143,10 @@
             content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
           } else if (col.textFormat === 'encryption') {
             content = <span>{col.prefix || ''}<Encrypts value={content} />{col.postfix || ''}</span>
+          }
+
+          if (col.noValue === 'hide' && content < '1949-10-02') {
+            content = ''
           }
 
           if (col.textFormat !== 'encryption') {
@@ -1156,6 +1216,9 @@
           }
           if (col.format === 'percent') {
             content = content * 100
+            if (!col.round) {
+              content = +content.toFixed(2)
+            }
           } else if (col.format === 'abs') {
             content = Math.abs(content)
           }
@@ -1164,6 +1227,7 @@
           }
     
           if (col.format === 'thdSeparator') {
+            content = content + ''
             content = content.replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
           }
     
@@ -1228,6 +1292,15 @@
           content = ''
         }
       } else {
+        if (col.eval === 'false' && col.noValue === 'hide') { // 绌哄�奸殣钘�
+          Object.keys(record).forEach(key => {
+            if (/^\$/.test(key)) return
+            if (record[key]) return
+
+            content = content.replace(new RegExp('[^@]*@' + key + '@', 'ig'), '')
+          })
+        }
+        
         Object.keys(record).forEach(key => {
           let reg = new RegExp('@' + key + '@', 'ig')
           content = content.replace(reg, record[key])
@@ -1238,7 +1311,7 @@
             // eslint-disable-next-line
             content = eval(content)
           } catch (e) {
-            console.info(content)
+            window.mkInfo(content)
             console.warn(e)
             content = ''
           }
@@ -1260,7 +1333,12 @@
         content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       } else if (content !== '') {
         content = `${col.prefix || ''}${content}${col.postfix || ''}`
-        content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
+        if (!col.evalchars || col.evalchars.includes('enter')) {
+          content = content.replace(/\n/ig, '<br/>')
+        }
+        if (!col.evalchars || col.evalchars.includes('space')) {
+          content = content.replace(/\s/ig, '&nbsp;')
+        }
         content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       }
 
@@ -1296,7 +1374,7 @@
       }
 
       children = (
-        <CardCellComponent data={record} cards={config} elements={col.elements}/>
+        <CardCellComponent data={record} cards={col.config} elements={col.elements}/>
       )
     }
 
@@ -1341,7 +1419,8 @@
     allColumns: null,
     checkForms: [],
     allForms: [],
-    reseting: false
+    reseting: false,
+    dict: window.GLOB.dict
   }
 
   timer = null
@@ -1357,7 +1436,6 @@
     let deForms = []
     let _forms = {}
     let hasBid = false
-    let index = 0
     let checkForms = []
     let allForms = []
 
@@ -1370,25 +1448,12 @@
           cell.children = getColumns(item.subcols, sk || item.uuid)
         } else {
           if (item.editable === 'true') {
-            item.$sort = index
-            index++
             _forms[item.field] = item
 
             allForms.push({uuid: sk || item.uuid, field: item.field})
             checkForms.push(item.field)
 
-            if (item.ctrlField) {
-              item.ctrlValue = item.ctrlValue.split(',')
-            }
-            
-            if (item.type === 'number' && item.clearField) {
-              fields.forEach(cell => {
-                if (cell.field === item.clearField) {
-                  item.clearName = cell.label
-                }
-              })
-            } else if (item.type === 'text' && item.editType === 'select') {
-              item.map = new Map()
+            if (item.type === 'text' && item.editType === 'select') {
               if (item.resourceType === '1') {
                 let _option = Utils.getSelectQueryOptions(item)
   
@@ -1400,20 +1465,6 @@
                 item.arr_field = _option.field
         
                 deForms.push(item)
-              } else {
-                item.options.forEach(cell => {
-                  item.map.set(cell.value, cell.label)
-                })
-              }
-            } else if (item.type === 'text' && item.editType === 'date') {
-              item.format = 'YYYY-MM-DD'
-  
-              if (item.precision === 'hour') {
-                item.format = 'YYYY-MM-DD HH'
-              } else if (item.precision === 'minute') {
-                item.format = 'YYYY-MM-DD HH:mm'
-              } else if (item.precision === 'second') {
-                item.format = 'YYYY-MM-DD HH:mm:ss'
               }
             }
           }
@@ -1433,8 +1484,7 @@
             $key: item.uuid,
             onCell: record => ({
               record,
-              col: item,
-              config: item.type === 'custom' ? {setting, columns: fields} : null,
+              col: item
             })
           }
         }
@@ -1455,6 +1505,9 @@
           _item.datatype = _item.declareType || 'datetime'
         } else {
           _item.datatype = item.datatype
+        }
+        if (_item.type === 'number' && item.type === 'number') {
+          _item.decimal = item.decimal || 0
         }
 
         forms.push(_item)
@@ -1501,7 +1554,11 @@
       deForms: hasBid ? deForms : null
     }, () => {
       if (deForms.length > 0 && (!hasBid || BID)) {
-        this.improveActionForm(deForms, BID)
+        if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) {
+          this.improveBackActionForm(deForms, BID)
+        } else {
+          this.improveActionForm(deForms, BID)
+        }
       }
     })
   }
@@ -1511,11 +1568,48 @@
   }
 
   UNSAFE_componentWillReceiveProps(nextProps) {
-    const { BID } = this.props
+    const { BID, parCtrl } = this.props
     const { deForms } = this.state
 
     if (deForms && nextProps.BID !== BID) {
-      this.improveActionForm(deForms, nextProps.BID)
+      if (window.backend && window.GLOB.CacheData.has('sql_' + deForms[0].uuid)) {
+        this.improveBackActionForm(deForms, nextProps.BID)
+      } else {
+        this.improveActionForm(deForms, nextProps.BID)
+      }
+    }
+    if (parCtrl && !is(fromJS(this.props.columns), fromJS(nextProps.columns))) {
+      let getColumns = (cols, sk) => {
+        return cols.map(item => {
+          let cell = null
+    
+          if (item.type === 'colspan') {
+            cell = { title: item.label, align: item.Align, $key: item.uuid }
+            cell.children = getColumns(item.subcols, sk || item.uuid)
+          } else {
+            cell = {
+              align: item.Align,
+              dataIndex: item.uuid,
+              title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label,
+              sorter: (item.field || item.sortField) && item.IsSort === 'true',
+              width: item.Width || 120,
+              $key: item.uuid,
+              onCell: record => ({
+                record,
+                col: item
+              })
+            }
+          }
+    
+          return cell
+        })
+      }
+  
+      let _columns = getColumns(nextProps.columns)
+
+      this.setState({
+        columns: _columns
+      })
     }
   }
 
@@ -1579,7 +1673,7 @@
   }
 
   checkLine = () => {
-    const { edData, forms, checkForms } = this.state
+    const { edData, forms, checkForms, dict } = this.state
 
     let data = edData.filter(item => item.$$uuid === this.blurId)[0]
 
@@ -1622,7 +1716,7 @@
       if (col.type === 'text') {
         let val = record[col.field] !== undefined ? (record[col.field] + '') : ''
         if (col.required === 'true' && !val) {
-          err = `${col.label}涓嶅彲涓虹┖`
+          err = `${col.label}${dict['not_empty'] || '涓嶅彲涓虹┖'}`
         } else if (col.datatype === 'datetime' && !val) {
           val = '1949-10-01'
         }
@@ -1630,26 +1724,28 @@
       } else if (col.type === 'number') {
         let val = record[col.field]
 
-        if (col.noValue === 'hide' && !val) {
+        if (col.required === 'true' && !val) {
+          err = `${col.label}${col.noValue === 'hide' ? (dict['not_empty'] || '涓嶅彲涓虹┖') : dict['not_zero'] || '涓嶅彲涓�0'}`
+        } else if (col.noValue === 'hide' && !val) {
           if (col.clearField && checkForms.includes(col.clearField) && !record[col.clearField]) {
-            err = `璇峰~鍐� ${col.label} 鎴� ${col.clearName}`
+            err = `${dict['input_tip'] || '璇峰~鍐� '}${col.label} ${dict['or'] || '鎴�'} ${col.clearName}`
           }
           val = 0
         } else if (!val && val !== 0) {
-          err = `${col.label}涓嶅彲涓虹┖`
+          err = `${col.label}${dict['not_empty'] || '涓嶅彲涓虹┖'}`
         } else {
           val = +val
           if (isNaN(val)) {
-            err = `${col.label}鏁版嵁鏍煎紡閿欒`
+            err = `${col.label} ${dict['data_format'] || '鏁版嵁鏍煎紡閿欒'}`
             return
           }
   
           val = +val.toFixed(col.decimal || 0)
           
           if (typeof(col.max) === 'number' && val > col.max) {
-            err = `${col.label}涓嶅彲澶т簬${col.max}`
+            err = `${col.label}${dict['max_limit'] || ' 涓嶅彲澶т簬 '}${col.max}`
           } else if (typeof(col.min) === 'number' && val < col.min) {
-            err = `${col.label}涓嶅彲灏忎簬${col.min}`
+            err = `${col.label}${dict['less_limit'] || ' 涓嶅彲灏忎簬 '}${col.min}`
           }
         }
 
@@ -1682,6 +1778,9 @@
         result = originVal === contrastVal
       } else if (item.match === '!=') {
         result = originVal !== contrastVal
+      } else if (item.match === 'regexp') {
+        let reg = new RegExp(item.contrastValue, 'ig')
+        result = reg.test(originVal)
       } else {
         originVal = isNaN(originVal) ? originVal : +originVal
         contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
@@ -1719,7 +1818,10 @@
   transferData = (data, type) => {
     const { edData, tableId } = this.state
 
-    if (type === 'delete') {
+    if (type === 'clear') {
+      this.setState({edData: [], midData: []})
+      return
+    } else if (type === 'delete') {
 
     } else if (type === 'line') {
       let value = ''
@@ -1837,7 +1939,7 @@
         sql = sql.replace(/@BID@/ig, `'${BID}'`)
 
         if (debug) {
-          console.info(sql)
+          window.mkInfo(sql)
         }
 
         sql = sql.replace(/%/ig, ' mpercent ')
@@ -1850,7 +1952,7 @@
         sql = sql.replace(/@BID@/ig, `'${BID}'`)
 
         if (debug) {
-          console.info(sql)
+          window.mkInfo(sql)
         }
 
         sql = sql.replace(/%/ig, ' mpercent ')
@@ -1870,14 +1972,18 @@
     }
 
     if (param.LText) {
-      param.LText = Utils.formatOptions(param.LText)
+      if (window.GLOB.execType === 'x') {
+        param.exec_type = 'x'
+      }
+      
+      param.LText = Utils.formatOptions(param.LText, param.exec_type)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+      param.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : param.LText, param.timestamp)
 
       deffers.push(
         new Promise(resolve => {
           Api.getSystemCacheConfig(param, false).then(res => {
-            if (!res.status) {
+            if (!res.status && res.ErrCode !== '-2') {
               notification.warning({
                 top: 92,
                 message: res.message,
@@ -1901,9 +2007,13 @@
     }
 
     if (mainparam.LText) {
-      mainparam.LText = Utils.formatOptions(mainparam.LText)
+      if (window.GLOB.execType === 'x') {
+        mainparam.exec_type = 'x'
+      }
+
+      mainparam.LText = Utils.formatOptions(mainparam.LText, mainparam.exec_type)
       mainparam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      mainparam.secretkey = Utils.encrypt(mainparam.LText, mainparam.timestamp)
+      mainparam.secretkey = Utils.encrypt(window.GLOB.execType === 'x' ? '' : mainparam.LText, mainparam.timestamp)
 
       if (window.GLOB.mainSystemApi) {
         mainparam.rduri = window.GLOB.mainSystemApi
@@ -1912,7 +2022,7 @@
       deffers.push(
         new Promise(resolve => {
           Api.getSystemCacheConfig(mainparam, false).then(res => {
-            if (!res.status) {
+            if (!res.status && res.ErrCode !== '-2') {
               notification.warning({
                 top: 92,
                 message: res.message,
@@ -1932,6 +2042,106 @@
       delete result.ErrMesg
       delete result.message
       delete result.status
+
+      this.resetFormList(result)
+    })
+  }
+
+  improveBackActionForm = (deForms, BID) => {
+    let sysvals = {
+      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+      mk_organization: sessionStorage.getItem('organization') || '',
+      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+      bid: BID || '',
+      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
+    }
+    if (window.GLOB.externalDatabase !== null) {
+      sysvals.db = window.GLOB.externalDatabase
+    }
+
+    let deffers = []
+    let mainItems = []  // 浜戠鎴栧崟鐐规暟鎹�
+    let localItems = [] // 鏈湴鏁版嵁
+
+    deForms.forEach(item => {
+      let ex = window.GLOB.CacheData.get('sql_' + item.uuid)
+      
+      if (!ex) return
+      
+      let exps = []
+      ex.reps.forEach(n => {
+        let key = n.toLowerCase()
+        if (sysvals.hasOwnProperty(key)) {
+          exps.push({
+            key: n,
+            value: sysvals[key]
+          })
+        }
+      })
+
+      let cell = {
+        id: ex.id,
+        menuname: item.label + '锛堣〃鍗曪級',
+        exps: exps,
+        md5_id: ''
+      }
+
+      if (item.database === 'sso' && window.GLOB.mainSystemApi) {
+        mainItems.push(cell)
+      } else {
+        localItems.push(cell)
+      }
+    })
+
+    if (localItems.length) {
+      deffers.push({
+        $backend: true,
+        $type: 's_Get_SelectedList',
+        data: localItems
+      })
+    }
+
+    if (mainItems.length) {
+      deffers.push({
+        $backend: true,
+        $type: 's_Get_SelectedList',
+        data: mainItems,
+        rduri: window.GLOB.mainSystemApi
+      })
+    }
+
+    if (!deffers.length) return
+
+    deffers = deffers.map(item => {
+      return new Promise(resolve => {
+        Api.getSystemCacheConfig(item, false).then(res => {
+          if (!res.status && res.ErrCode !== '-2') {
+            notification.warning({
+              top: 92,
+              message: res.message,
+              duration: 5
+            })
+          }
+          resolve(res)
+        })
+      })
+    })
+
+    Promise.all(deffers).then(response => {
+      let result = {...response[0], ...(response[1] || {})}
+
+      delete result.ErrCode
+      delete result.ErrMesg
+      delete result.message
+      delete result.status
+
+      this.props.columns.forEach(item => {
+        if (item.arr_field && result[item.field]) {
+          result[item.uuid] = result[item.field]
+        }
+      })
 
       this.resetFormList(result)
     })
@@ -2168,7 +2378,7 @@
 
   checkData = () => {
     const { setting } = this.props
-    const { edData, forms, checkForms, selectedRowKeys } = this.state
+    const { edData, forms, checkForms, selectedRowKeys, dict } = this.state
 
     let data = fromJS(edData).toJS()
 
@@ -2182,7 +2392,7 @@
       if (data.length === 0) {
         notification.warning({
           top: 92,
-          message: '璇烽�夋嫨闇�瑕佹彁浜ょ殑鏁版嵁锛�',
+          message: dict['select_row'] || '璇烽�夋嫨闇�瑕佹彁浜ょ殑鏁版嵁锛�',
           duration: 5
         })
         return null
@@ -2192,7 +2402,7 @@
     if (data.length === 0) {
       notification.warning({
         top: 92,
-        message: '鏁版嵁鏈慨鏀癸紝涓嶅彲鎻愪氦锛�',
+        message: dict['un_modified'] || '鏁版嵁鏈慨鏀癸紝涓嶅彲鎻愪氦锛�',
         duration: 5
       })
       return null
@@ -2226,37 +2436,39 @@
         if (col.type === 'text') {
           let val = item[col.field] !== undefined ? (item[col.field] + '') : ''
           if (col.required === 'true' && !val) {
-            line.push(`${col.label}涓嶅彲涓虹┖`)
+            line.push(`${col.label}${dict['not_empty'] || '涓嶅彲涓虹┖'}`)
           } else if (col.datatype === 'datetime' && !val) {
             val = '1949-10-01'
           }
           item[col.field] = val
         } else if (col.type === 'number') {
           let val = item[col.field]
-          if (col.noValue === 'hide' && !val) {
+          if (col.required === 'true' && !val) {
+            err = `${col.label}${col.noValue === 'hide' ? (dict['not_empty'] || '涓嶅彲涓虹┖') : dict['not_zero'] || '涓嶅彲涓�0'}`
+          } else if (col.noValue === 'hide' && !val) {
             if (col.clearField && checkForms.includes(col.clearField) && !item[col.clearField]) {
-              let msg = `璇峰~鍐� ${col.label} 鎴� ${col.clearName}`
+              let msg = `${dict['input_tip'] || '璇峰~鍐� '}${col.label} ${dict['or'] || '鎴�'} ${col.clearName}`
               if (!line.includes(msg)) {
                 line.push(msg)
               }
             }
             val = 0
           } else if (!val && val !== 0) {
-            line.push(`${col.label}涓嶅彲涓虹┖`)
+            line.push(`${col.label}${dict['not_empty'] || '涓嶅彲涓虹┖'}`)
             return
           } else {
             val = +val
             if (isNaN(val)) {
-              line.push(`${col.label}鏁版嵁鏍煎紡閿欒`)
+              line.push(`${col.label} ${dict['data_format'] || '鏁版嵁鏍煎紡閿欒'}`)
               return
             }
   
             val = +val.toFixed(col.decimal || 0)
             
             if (typeof(col.max) === 'number' && val > col.max) {
-              line.push(`${col.label}涓嶅彲澶т簬${col.max}`)
+              line.push(`${col.label}${dict['max_limit'] || ' 涓嶅彲澶т簬 '}${col.max}`)
             } else if (typeof(col.min) === 'number' && val < col.min) {
-              line.push(`${col.label}涓嶅彲灏忎簬${col.min}`)
+              line.push(`${col.label}${dict['less_limit'] || ' 涓嶅彲灏忎簬 '}${col.min}`)
             }
           }
 
@@ -2265,7 +2477,7 @@
       })
 
       if (line.length > 0) {
-        err += `绗�${Index}琛岋細` + line.join('锛�') + '锛�'
+        err += (dict['line'] ? `${dict['line']} ${Index}锛歚 : `绗�${Index}琛岋細`) + line.join('锛�') + '锛�'
       }
       if (!item.$deleted) {
         Index++
@@ -2289,14 +2501,14 @@
 
   submit = (record) => {
     const { submit, BID, setting } = this.props
-    const { forms } = this.state
+    const { forms, dict } = this.state
 
     this.setState({visible: false, midData: null})
 
     if (setting.supModule && !BID) {
       notification.warning({
         top: 92,
-        message: '闇�瑕佷笂绾т富閿�硷紒',
+        message: setting.supModTip || dict['sup_key_req'] || '闇�瑕佷笂绾т富閿�硷紒',
         duration: 5
       })
 
@@ -2312,24 +2524,34 @@
 
     if (!data) return
 
-    let result = getEditTableSql(submit, data, forms)
-
-    let param = {
-      excel_in: result.lines,
-      BID: BID || ''
-    }
-
     this.setState({
       loading: true
     })
 
-    if (submit.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼
-      param.func = 'sPC_TableData_InUpDe'
-      
-      delete param.excel_in
+    if (submit.intertype === 'system' && window.backend && window.GLOB.CacheData.has('sql_submit_' + submit.$menuId)) {
+      let ex = window.GLOB.CacheData.get('sql_submit_' + submit.$menuId)
+      let param = this.getExps(ex, submit, data, forms)
 
-      param.exec_type = 'y'
-      param.LText = Utils.formatOptions(result.sql)
+      Api.genericInterface(param).then((res) => {
+        if (res.status) {
+          this.execSuccess(res, record)
+        } else {
+          this.execError(res, record)
+        }
+      }, (error) => {
+        if (error && error.ErrCode === 'LoginError') return
+
+        this.execError({})
+      })
+    } else if (submit.intertype === 'system') { // 绯荤粺瀛樺偍杩囩▼
+      let result = getEditTableSql(submit, data, forms, setting)
+      let param = {}
+
+      param.func = 'sPC_TableData_InUpDe'
+      param.BID = BID || ''
+      
+      param.exec_type = window.GLOB.execType || 'y'
+      param.LText = Utils.formatOptions(result.sql, param.exec_type)
       param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
       param.secretkey = Utils.encrypt('', param.timestamp)
 
@@ -2351,7 +2573,12 @@
         this.execError({})
       })
     } else if (submit.intertype === 'inner' && submit.innerFunc) { // 鑷畾涔夊瓨鍌ㄨ繃绋�
+      let result = getEditTableSql(submit, data, forms, setting)
+      let param = {}
+
       param.func = submit.innerFunc
+      param.BID = BID || ''
+      param.excel_in = result.lines
 
       if (submit.recordUser === 'true') {
         param.username = sessionStorage.getItem('User_Name') || ''
@@ -2372,19 +2599,96 @@
     }
   }
 
+  getExps = (ex, btn, data, forms) => {
+    const { BID } = this.props
+
+    let exps = []
+    let values = {
+      time_id: Utils.getguid(),
+      roleid: sessionStorage.getItem('role_id') || '',
+      mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
+      mk_organization: sessionStorage.getItem('organization') || '',
+      mk_user_type: sessionStorage.getItem('mk_user_type') || '',
+      mk_nation: sessionStorage.getItem('nation') || '',
+      mk_province: sessionStorage.getItem('province') || '',
+      mk_city: sessionStorage.getItem('city') || '',
+      mk_district: sessionStorage.getItem('district') || '',
+      mk_address: sessionStorage.getItem('address') || '',
+      bid: BID || '',
+      typename: 'admin',
+      datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+      datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
+    }
+
+    if (window.GLOB.externalDatabase !== null) {
+      values.db = window.GLOB.externalDatabase
+    }
+
+    let lines = data.map(item => {
+      let vals = []
+      forms.forEach(col => {
+        if (typeof(item[col.field]) === 'number') {
+          vals.push(item[col.field] + '')
+        } else {
+          vals.push(item[col.field])
+        }
+      })
+  
+      vals.push(item.$$uuid)
+      vals.push(item.$type || 'upt')
+      vals.push(BID)
+  
+      return vals
+    })
+
+    ex.reps.forEach(n => {
+      let key = n.toLowerCase()
+      if (values.hasOwnProperty(key)) {
+        exps.push({
+          key: n,
+          value: values[key]
+        })
+      }
+    })
+
+    exps.push({
+      key: 'mk_excel_data',
+      value: lines
+    })
+
+    let md5_id = ''
+    if (window.GLOB.probation) {
+      md5_id = md5(ex.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
+      md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
+    }
+
+    return {
+      $backend: true,
+      $type: 's_TableData_InUpDe',
+      data: [{
+        id: ex.id,
+        menuname: btn.logLabel || '',
+        exps: exps,
+        md5_id: md5_id
+      }]
+    }
+  }
+
   execSuccess = (res, record) => {
     const { submit } = this.props
-    const { edData } = this.state
+    const { edData, dict } = this.state
 
     if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.message || '鎵ц鎴愬姛',
+        message: res.message || dict['exc_success'] || '鎵ц鎴愬姛',
         duration: submit.stime ? submit.stime : 2
       })
     } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.message || '鎵ц鎴愬姛'
+        title: res.message || dict['exc_success'] || '鎵ц鎴愬姛',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
       })
     } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
@@ -2430,26 +2734,28 @@
 
   execError = (res, record) => {
     const { submit } = this.props
+    const { dict } = this.state
 
     if (res.ErrCode === 'E') {
       Modal.error({
-        title: res.message || '鎵ц澶辫触锛�',
+        title: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
+        okText: dict['got_it'] || '鐭ラ亾浜�'
       })
     } else if (res.ErrCode === 'N') {
       notification.error({
         top: 92,
-        message: res.message || '鎵ц澶辫触锛�',
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         duration: submit.ntime ? submit.ntime : 10
       })
     } else if (res.ErrCode === 'F') {
       notification.error({
         className: 'notification-custom-error',
         top: 92,
-        message: res.message || '鎵ц澶辫触锛�',
+        message: res.message || dict['exc_fail'] || '鎵ц澶辫触锛�',
         duration: submit.ftime ? submit.ftime : 10
       })
     } else if (res.ErrCode === 'NM') {
-      message.error(res.message || '鎵ц澶辫触锛�')
+      message.error(res.message || dict['exc_fail'] || '鎵ц澶辫触锛�')
     }
     
     this.setState({
@@ -2563,7 +2869,7 @@
 
   render() {
     const { setting, lineMarks, submit } = this.props
-    const { edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state
+    const { edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting, dict } = this.state
 
     if (reseting) return null
 
@@ -2594,13 +2900,19 @@
         pageSizeOptions: pageOptions,
         showSizeChanger: true,
         total: this.props.total || 0,
-        showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉
+        showTotal: (total, range) => `${range[0]}-${range[1]} ${dict['of'] || '鍏�'} ${total} ${dict['items'] || '鏉�'}`
       }
     }
 
     let height = setting.height || false
-    if (height && height <= 100) {
-      height = height + 'vh'
+    if (height) {
+      if (height <= 100) {
+        if (height < 0) {
+          height = `calc(100vh - ${-height}px)`
+        } else {
+          height = height + 'vh'
+        }
+      }
     }
 
     let style = {
@@ -2613,9 +2925,9 @@
     return (
       <>
         {setting.hasSubmit && edData.length > 0 ? <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}>
-          <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button>
+          <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-table" type="link">{dict['submit'] || '鎻愪氦'}</Button>
         </div> : null}
-        <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} style={style}>
+        <div className={`edit-custom-table ${setting.tableHeader || ''} ${setting.parity === 'true' ? 'mk-parity' : ''} ${height ? 'fixed-table-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'} ${setting.empSign === 'hidden' ? 'mk-empty-hide' : ''}`} style={style}>
           <Table
             rowKey="$$uuid"
             components={components}
@@ -2637,7 +2949,7 @@
             onChange={this.changeTable}
             pagination={_pagination}
           />
-          {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">鎻愪氦</Button> : null}
+          {setting.hasSubmit && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.submit()}, 10)} loading={loading} className="submit-footer-table" type="link">{dict['submit'] || '鎻愪氦'}</Button> : null}
         </div>
         <Modal
           className="mk-user-confirm"
@@ -2646,13 +2958,13 @@
           maskClosable={false}
           closable={false}
           footer={[
-            <Button key="cancel" onClick={() => { this.setState({ visible: false, midData: null }) }}>鍙栨秷</Button>,
-            <Button key="refresh" className="table-refresh" onClick={() => { midData && this.updateMutil(midData) }}>鍒锋柊琛ㄦ牸</Button>,
-            <Button key="confirm" type="primary" onClick={() => setTimeout(() => {this.submit()}, 10)}>鎻愪氦鏁版嵁</Button>
+            <Button key="cancel" onClick={() => { this.setState({ visible: false, midData: null }) }}>{dict['cancel'] || '鍙栨秷'}</Button>,
+            <Button key="refresh" className="table-refresh" onClick={() => { midData && this.updateMutil(midData) }}>{dict['refresh'] || '鍒锋柊琛ㄦ牸'}</Button>,
+            <Button key="confirm" type="primary" onClick={() => setTimeout(() => {this.submit()}, 10)}>{dict['submit'] || '鎻愪氦鏁版嵁'}</Button>
           ]}
           destroyOnClose
         >
-          <div><QuestionCircleOutlined />琛ㄦ牸涓湁鏁版嵁灏氭湭鎻愪氦</div>
+          <div><QuestionCircleOutlined />{dict['data_not_sub'] || '琛ㄦ牸涓湁鏁版嵁灏氭湭鎻愪氦'}</div>
         </Modal>
       </>
     )

--
Gitblit v1.8.0