From 08cce3334a2dc81d690b518136b0aaea64e48b0b Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 14 六月 2023 09:55:50 +0800
Subject: [PATCH] 2023-06-14

---
 src/tabviews/custom/components/table/edit-table/normalTable/index.jsx | 1119 +++++++++++++++++++++++++++-------------------------------
 1 files changed, 513 insertions(+), 606 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 8c85c47..a38bb09 100644
--- a/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1,23 +1,20 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Table, Typography, Switch, Modal, Input, InputNumber, Tooltip, Button, notification, message, Select } from 'antd'
-import { ExclamationCircleOutlined, EditOutlined, PlusOutlined, PlusCircleOutlined, DeleteOutlined } from '@ant-design/icons'
+import { Table, Typography, Modal, Input, InputNumber, Button, notification, message, Select } from 'antd'
+import { EditOutlined, QuestionCircleOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Api from '@/api'
 import asyncComponent from '@/utils/asyncComponent'
 import Utils, { getEditTableSql, getMark } from '@/utils/utils.js'
-import MkIcon from '@/components/mk-icon'
 import MKEmitter from '@/utils/events.js'
-import zhCN from '@/locales/zh-CN/main.js'
-import enUS from '@/locales/en-US/main.js'
 import CusSwitch from './cusSwitch'
 import Encrypts from '@/components/encrypts'
 import './index.scss'
 
 const { Paragraph } = Typography
-const { confirm } = Modal
+const MkIcon = asyncComponent(() => import('@/components/mk-icon'))
 const CardCellComponent = asyncComponent(() => import('@/tabviews/custom/components/card/cardcellList'))
 
 class BodyRow extends React.Component {
@@ -99,17 +96,12 @@
 class BodyCell extends React.Component {
   state = {
     editing: false,
-    err: null
+    err: null,
+    value: ''
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props.record), fromJS(nextProps.record)) ||
-      nextState.editing !== this.state.editing ||
-      nextState.err !== this.state.err
-  }
-
-  componentDidMount () {
-    MKEmitter.addListener('tdFocus', this.tdFocus)
+    return !is(fromJS(this.props.record), fromJS(nextProps.record)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
   /**
@@ -119,14 +111,6 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('tdFocus', this.tdFocus)
-  }
-
-  tdFocus = (id) => {
-    const { col, record } = this.props
-
-    if (id !== col.uuid + record.$$uuid) return
-    this.focus()
   }
 
   enterPress = () => {
@@ -135,12 +119,13 @@
 
     this.setState({editing: false})
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+        node && node.click()
       }
     }, 50)
 
@@ -151,6 +136,8 @@
 
   focus = () => {
     const { col, record } = this.props
+
+    if (col.ctrlField && col.ctrlValue.includes(record[col.ctrlField])) return
 
     if (col.editType === 'switch' || col.editType === 'select') {
       this.setState({editing: true}, () => {
@@ -211,6 +198,7 @@
     } else if (col.required === 'true' && !val) {
       err = '璇峰~鍐�' + col.label
     }
+    
     this.setState({value: val, err})
   }
 
@@ -220,24 +208,17 @@
     this.setState({editing: false})
 
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+        node && node.click()
       }
     }, 50)
 
-    let values = {}
-    if (col.editField) {
-      values[col.field] = label
-      values[col.editField] = val
-    } else {
-      values[col.field] = val
-    }
-
-    MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
+    MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val})
   }
 
   onSelectChange = (val, option) => {
@@ -253,23 +234,19 @@
         })
       }
 
-      if (col.editField) {
-        values[col.field] = _option.label
-        values[col.editField] = val
-      } else {
-        values[col.field] = val
-      }
+      values[col.field] = val
     }
 
     this.setState({editing: false})
 
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+        node && node.click()
       }
     }, 50)
 
@@ -288,11 +265,20 @@
 
     if (!col) return (<td {...resProps} className={className} style={style}/>)
 
+    let disabled = false
+    if (col.ctrlField) {
+      disabled = col.ctrlValue.includes(record[col.ctrlField])
+    }
+
     let children = null
     if (col.type === 'text') {
       let content = ''
       if (record[col.field] !== undefined) {
         content = `${record[col.field]}`
+      }
+
+      if (col.editType === 'select' && col.options.length > 0) {
+        content = col.map.get(content) || content
       }
 
       if (content !== '') {
@@ -325,30 +311,21 @@
         }
       }
 
-      if (col.editable === 'true') {
+      if (col.editable === 'true' && !disabled) {
         if (editing) {
           if (!col.editType || col.editType === 'text') {
             return (<td className="editing_table_cell">
-              <Input id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
-              {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null}
+              <Input className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
             </td>)
           } else if (col.editType === 'switch') {
-            let _value = ''
-            if (col.editField) {
-              _value = record[col.editField] !== undefined ? record[col.editField] : ''
-            } else {
-              _value = record[col.field] !== undefined ? record[col.field] : ''
-            }
+            let _value = record[col.field] !== undefined ? record[col.field] : ''
+
             return (<td className="editing_table_cell">
               <CusSwitch config={col} defaultValue={_value} autoFocus={true} onChange={this.onSwitchChange} onBlur={this.switchBlur}/>
             </td>)
           } else {
-            let _value = ''
-            if (col.editField) {
-              _value = record[col.editField] !== undefined ? record[col.editField] : ''
-            } else {
-              _value = record[col.field] !== undefined ? record[col.field] : ''
-            }
+            let _value = record[col.field] !== undefined ? record[col.field] : ''
+
             return (<td className="editing_table_cell">
               <Select
                 showSearch
@@ -366,9 +343,7 @@
           }
         } else {
           return (<td className={className + ' pointer'} style={style}>
-            {col.addable ? <PlusCircleOutlined onClick={() => MKEmitter.emit('addRecord', col.tableId, {...record})} className="mk-editable mk-plus"/> : null}
-            <div className="mk-mask" onClick={this.focus}></div>{content}
-            {col.delable ? <DeleteOutlined onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})} className="mk-editable mk-del"/> : null}
+            <div className="mk-mask" id={col.uuid + record.$$uuid} onClick={this.focus}></div>{content}
           </td>)
         }
       } else {
@@ -379,6 +354,9 @@
       try {
         content = parseFloat(record[col.field])
         if (isNaN(content)) {
+          content = ''
+        }
+        if (col.noValue === 'hide' && content === 0) {
           content = ''
         }
       } catch (e) {
@@ -421,17 +399,18 @@
         }
       }
 
-      if (col.editable === 'true') {
+      if (col.editable === 'true' && !disabled) {
         if (editing) {
+          let val = value
+          if (col.noValue === 'hide' && value === 0) {
+            val = ''
+          }
           return (<td className="editing_table_cell">
-            <InputNumber id={col.uuid + record.$$uuid} defaultValue={value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
-            {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null}
+            <InputNumber className={err ? 'has-error' : ''} precision={col.decimal || 0} title={err} id={col.uuid + record.$$uuid} defaultValue={val} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
           </td>)
         } else {
           return (<td className={className + ' pointer'} style={style}>
-            {col.addable ? <PlusCircleOutlined onClick={() => MKEmitter.emit('addRecord', col.tableId, {...record})} className="mk-editable mk-plus"/> : null}
-            <div className="mk-mask" onClick={this.focus}></div>{content}
-            {col.delable ? <DeleteOutlined onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})} className="mk-editable mk-del"/> : null}
+            <div className="mk-mask" id={col.uuid + record.$$uuid} onClick={this.focus}></div>{content}
           </td>)
         }
       } else {
@@ -464,19 +443,29 @@
           // eslint-disable-next-line
           content = eval(content)
         } catch (e) {
+          if (window.debugger) {
+            console.info(content)
+            console.warn(e)
+          }
           content = ''
         }
       }
 
       content = content === undefined ? '' : content
 
+      if (col.noValue === 'hide' && content === 0) {
+        content = ''
+      }
+
+      if (col.round && typeof(content) === 'number') {
+        content = Math.round(content * col.round) / col.round
+        content = content.toFixed(col.decimal)
+      }
+
       if (content !== '') {
         content = `${col.prefix || ''}${content}${col.postfix || ''}`
-
-        if (col.eval === 'false') {
-          content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
-          content = <span dangerouslySetInnerHTML={{__html: content}}></span>
-        }
+        content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
+        content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       }
 
       if (col.marks) {
@@ -505,38 +494,37 @@
       children = (
         <CardCellComponent data={record} cards={config} elements={col.elements}/>
       )
-    } else if (col.type === 'action') {
-      style.padding = '0px'
-      if (col.style) {
-        style = {...style, ...col.style}
-      }
-      children = (
-        <CardCellComponent data={record} cards={config} elements={col.elements}/>
-      )
-    } else if (col.type === 'operation') {
-      style.padding = '0px 5px'
-      children = (
-        <Button type="link" style={{color: 'rgb(255, 77, 79)', backgroundColor: 'transparent'}} onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})}>鍒犻櫎</Button>
-      )
     }
 
-    return (<td className={className} style={style}>{col.addable ? <PlusCircleOutlined onClick={() => MKEmitter.emit('addRecord', col.tableId, {...record})} className="mk-editable mk-plus"/> : null}{children}{col.delable ? <DeleteOutlined onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})} className="mk-editable mk-del"/> : null}</td>)
-    // return (<td className={className} style={style}>{children}</td>)
+    return (<td className={className} style={style}>{children}</td>)
   }
 }
 
 class BodyAllCell extends React.Component {
   state = {
-    err: null
+    err: null,
+    value: ''
   }
 
   shouldComponentUpdate (nextProps, nextState) {
-    return !is(fromJS(this.props.record), fromJS(nextProps.record)) ||
-      nextState.err !== this.state.err
+    return !is(fromJS(this.props.record), fromJS(nextProps.record)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
-  componentDidMount () {
-    MKEmitter.addListener('tdFocus', this.tdFocus)
+  UNSAFE_componentWillMount() {
+    const { col } = this.props
+
+    if (col && col.editable === 'true') {
+      this.setState({value: this.props.record[col.field]})
+    }
+  }
+
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    const { col } = this.props
+    const { value } = this.state
+
+    if (col && col.editable === 'true' && nextProps.record[col.field] !== value) {
+      this.setState({value: nextProps.record[col.field]})
+    }
   }
 
   /**
@@ -546,65 +534,48 @@
     this.setState = () => {
       return
     }
-    MKEmitter.removeListener('tdFocus', this.tdFocus)
-  }
-
-  tdFocus = (id) => {
-    const { col, record } = this.props
-
-    if (id !== col.uuid + record.$$uuid) return
-    this.focus()
   }
 
   enterPress = () => {
     const { col, record } = this.props
 
+    this.onBlur()
+
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+
+        if (node) {
+          if (col.triType === 'click') {
+            node.click()
+          } else {
+            node.select && node.select()
+          }
+        }
       }
     }, 50)
   }
-
-  focus = () => {
-    const { col, record } = this.props
-
-    if (col.editType === 'switch' || col.editType === 'select') {
-      let node = document.getElementById(col.uuid + record.$$uuid)
-      node && node.click()
-    } else {
-      let err = null
-      let val = record[col.field] !== undefined ? record[col.field] : ''
-  
-      if (col.type === 'number') {
-        val = +val
-        if (isNaN(val)) {
-          val = 0
-        }
-        if (typeof(col.max) === 'number' && val > col.max) {
-          err = col.label + '鏈�澶т负' + col.max
-        } else if (typeof(col.min) === 'number' && val < col.min) {
-          err = col.label + '鏈�灏忎负' + col.min
-        }
-      } else if (col.required === 'true' && !val) {
-        err = '璇峰~鍐�' + col.label
-      }
-  
-      this.setState({err}, () => {
-        let node = document.getElementById(col.uuid + record.$$uuid)
-        node && node.select()
-      })
-    }
-  }
   
   onChange = (val) => {
+    const { col } = this.props
+
+    if (col.noValue === 'hide' && val === null) {
+      this.setState({value: 0})
+    } else {
+      this.setState({value: val})
+    }
+  }
+
+  onBlur = () => {
     const { col, record } = this.props
+    const { value } = this.state
     
     let err = null
+    let val = value
 
     if (col.type === 'number') {
       val = +val
@@ -619,32 +590,35 @@
     } else if (col.required === 'true' && !val) {
       err = '璇峰~鍐�' + col.label
     }
+
     this.setState({err})
-    MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val})
+
+    if (value !== record[col.field]) {
+      MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val})
+    }
   }
 
   onSwitchChange = (val, label) => {
     const { col, record } = this.props
 
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+        if (node) {
+          if (col.triType === 'click') {
+            node.click()
+          } else {
+            node.select && node.select()
+          }
+        }
       }
     }, 50)
 
-    let values = {}
-    if (col.editField) {
-      values[col.field] = label
-      values[col.editField] = val
-    } else {
-      values[col.field] = val
-    }
-
-    MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
+    MKEmitter.emit('changeRecord', col.tableId, {...record, [col.field]: val})
   }
 
   onSelectChange = (val, option) => {
@@ -660,21 +634,23 @@
         })
       }
 
-      if (col.editField) {
-        values[col.field] = _option.label
-        values[col.editField] = val
-      } else {
-        values[col.field] = val
-      }
+      values[col.field] = val
     }
 
     setTimeout(() => {
-      if (col.enter === '$next') {
+      if (/\$next/.test(col.enter)) {
         MKEmitter.emit('nextLine', col, record.$$uuid)
       } else if (col.enter === '$sub') {
         MKEmitter.emit('subLine', col, record)
       } else if (col.enter !== '$noAct') {
-        MKEmitter.emit('tdFocus', col.enter + record.$$uuid)
+        let node = document.getElementById(col.enter + record.$$uuid)
+        if (node) {
+          if (col.triType === 'click') {
+            node.click()
+          } else {
+            node.select && node.select()
+          }
+        }
       }
     }, 50)
 
@@ -682,23 +658,24 @@
   }
 
   render() {
-    let { col, config, record, style, className } = this.props
+    let { col, config, record, style, className, ...resProps } = this.props
     const { err } = this.state
+
+    if (!col) return (<td {...resProps} className={className} style={style}/>)
+
+    let disabled = false
+    if (col.ctrlField) {
+      disabled = col.ctrlValue.includes(record[col.ctrlField])
+    }
 
     let children = null
     if (col.type === 'text') {
-      if (col.editable === 'true') {
-        let _value = ''
-        if (col.editField) {
-          _value = record[col.editField] !== undefined ? record[col.editField] : ''
-        } else {
-          _value = record[col.field] !== undefined ? record[col.field] : ''
-        }
+      if (col.editable === 'true' && !disabled) {
+        let _value = record[col.field] !== undefined ? record[col.field] : ''
         
         if (!col.editType || col.editType === 'text') {
           children = (<>
-            <Input id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
-            {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null}
+            <Input className={err ? 'has-error' : ''} title={err} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(e) => this.onChange(e.target.value)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
           </>)
         } else if (col.editType === 'switch') {
           children = (
@@ -723,6 +700,10 @@
         let content = ''
         if (record[col.field] !== undefined) {
           content = `${record[col.field]}`
+        }
+
+        if (col.editType === 'select' && col.options.length > 0) {
+          content = col.map.get(content) || content
         }
 
         if (content !== '') {
@@ -754,20 +735,32 @@
             content = <span style={mark.innerStyle}>{content}</span>
           }
         }
+
+        if (col.editable === 'true' && disabled) {
+          content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span>
+        }
+
         children = content
       }
     } else if (col.type === 'number') {
-      if (col.editable === 'true') {
+      if (col.editable === 'true' && !disabled) {
         let _value = record[col.field] !== undefined ? record[col.field] : ''
+
+        if (col.noValue === 'hide' && _value === 0) {
+          _value = ''
+        }
+
         children = (<>
-          <InputNumber id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress}/>
-          {err ? <Tooltip title={err}><ExclamationCircleOutlined /></Tooltip> : null}
+          <InputNumber className={err ? 'has-error' : ''} title={err} precision={col.decimal || 0} id={col.uuid + record.$$uuid} defaultValue={_value} onChange={(val) => this.onChange(val)} onPressEnter={this.enterPress} onBlur={this.onBlur}/>
         </>)
       } else {
         let content = ''
         try {
           content = parseFloat(record[col.field])
           if (isNaN(content)) {
+            content = ''
+          }
+          if (col.noValue === 'hide' && content === 0) {
             content = ''
           }
         } catch (e) {
@@ -809,6 +802,11 @@
             content = <span style={mark.innerStyle}>{content}</span>
           }
         }
+
+        if (col.editable === 'true' && disabled) {
+          content = <span style={{display: 'inline-block', padding: '0 6px'}}>{content}</span>
+        }
+
         children = content
       }
     } else if (col.type === 'textarea') {
@@ -838,19 +836,29 @@
           // eslint-disable-next-line
           content = eval(content)
         } catch (e) {
+          if (window.debugger) {
+            console.info(content)
+            console.warn(e)
+          }
           content = ''
         }
       }
 
       content = content === undefined ? '' : content
 
+      if (col.noValue === 'hide' && content === 0) {
+        content = ''
+      }
+
+      if (col.round && typeof(content) === 'number') {
+        content = Math.round(content * col.round) / col.round
+        content = content.toFixed(col.decimal)
+      }
+
       if (content !== '') {
         content = `${col.prefix || ''}${content}${col.postfix || ''}`
-
-        if (col.eval === 'false') {
-          content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
-          content = <span dangerouslySetInnerHTML={{__html: content}}></span>
-        }
+        content = content.replace(/\n/ig, '<br/>').replace(/\s/ig, '&nbsp;')
+        content = <span dangerouslySetInnerHTML={{__html: content}}></span>
       }
 
       if (col.marks) {
@@ -879,20 +887,14 @@
       children = (
         <CardCellComponent data={record} cards={config} elements={col.elements}/>
       )
-    } else if (col.type === 'operation') {
-      style.padding = '0px 5px'
-      children = (
-        <Button type="link" style={{color: 'rgb(255, 77, 79)', backgroundColor: 'transparent'}} onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})}>鍒犻櫎</Button>
-      )
     }
 
-    return (<td className={'editing_all_table_cell ' + className} style={style}>{col.addable ? <PlusCircleOutlined onClick={() => MKEmitter.emit('addRecord', col.tableId, {...record})} className="mk-editable mk-plus"/> : null}{children}{col.delable ? <DeleteOutlined onClick={() => MKEmitter.emit('delRecord', col.tableId, {...record})} className="mk-editable mk-del"/> : null}</td>)
+    return (<td className={'editing_all_table_cell ' + className} style={style}>{children}</td>)
   }
 }
 
 class NormalTable extends Component {
   static propTpyes = {
-    statFValue: PropTypes.any,       // 鍚堣瀛楁鏁版嵁
     MenuID: PropTypes.string,        // 鑿滃崟Id
     setting: PropTypes.object,       // 琛ㄦ牸鍏ㄥ眬璁剧疆锛歵ableType锛堣〃鏍兼槸鍚﹀彲閫夈�佸崟閫夈�佸閫夛級銆乤ctionfixed锛堟寜閽浐瀹氾級
     columns: PropTypes.array,        // 琛ㄦ牸鍒�
@@ -902,37 +904,33 @@
     total: PropTypes.any,            // 鎬绘暟
     loading: PropTypes.bool,         // 琛ㄦ牸鍔犺浇涓�
     refreshdata: PropTypes.func,     // 琛ㄦ牸涓帓搴忓垪銆侀〉鐮佺殑鍙樺寲鏃跺埛鏂�
-    changeLock: PropTypes.func,
     chgSelectData: PropTypes.func,
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
-    data: [],
     edData: [],
-    edColumns: [],
     selectedRowKeys: [],  // 琛ㄦ牸涓�変腑琛�
     tableId: '',          // 琛ㄦ牸ID
     pageIndex: 1,         // 鍒濆椤甸潰绱㈠紩
     pageSize: 10,         // 姣忛〉鏁版嵁鏉℃暟
     columns: null,        // 鏄剧ず鍒�
     forms: [],
-    pickup: false,        // 鏀惰捣鏈�夋嫨椤�
     orderfields: {},      // 鎺掑簭id涓巉ield杞崲
     loading: false,
-    editable: false,
-    pageOptions: []
+    pageOptions: [],
+    deForms: null,
+    visible: false,
+    midData: null
   }
 
   UNSAFE_componentWillMount () {
-    const { setting, fields, columns } = this.props
+    const { setting, fields, columns, BID } = this.props
     let orderfields = {}
-    let initEditLine = null
-    let edColumns = []
 
     let _columns = []
     let deForms = []
     let _forms = {}
+    let hasBid = false
 
     let getColumns = (cols) => {
       return cols.map(item => {
@@ -944,22 +942,30 @@
         } else {
           if (item.editable === 'true') {
             _forms[item.field] = item
-            if (!initEditLine) {
-              initEditLine = item
+
+            if (item.ctrlField) {
+              item.ctrlValue = item.ctrlValue.split(',')
             }
-          }
-    
-          if (item.type === 'text' && item.editable === 'true' && item.editType === 'select' && item.resourceType === '1') {
-            let _option = Utils.getSelectQueryOptions(item)
-    
-            if (window.GLOB.debugger === true || window.debugger === true) {
-              console.info(_option.sql)
+            
+            if (item.type === 'text' && item.editType === 'select') {
+              item.map = new Map()
+              if (item.resourceType === '1') {
+                let _option = Utils.getSelectQueryOptions(item)
+  
+                if (/@BID@/ig.test(_option.sql)) {
+                  hasBid = true
+                }
+        
+                item.base_sql = _option.sql
+                item.arr_field = _option.field
+        
+                deForms.push(item)
+              } else {
+                item.options.forEach(cell => {
+                  item.map.set(cell.value, cell.label)
+                })
+              }
             }
-    
-            item.base_sql = window.btoa(window.encodeURIComponent(_option.sql))
-            item.arr_field = _option.field
-    
-            deForms.push(item)
           }
     
           if (item.field) {
@@ -969,14 +975,14 @@
           cell = {
             align: item.Align,
             dataIndex: item.uuid,
-            title: item.label,
+            title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label,
             sorter: !!(item.field && item.IsSort === 'true'),
             width: item.Width || 120,
             $type: item.type,
             onCell: record => ({
               record,
               col: item,
-              config: item.type === 'custom' || item.type === 'action' ? {setting, columns: fields} : null,
+              config: item.type === 'custom' ? {setting, columns: fields} : null,
             })
           }
         }
@@ -984,6 +990,7 @@
         return cell
       })
     }
+
     _columns = getColumns(columns)
 
     let forms = []
@@ -996,32 +1003,6 @@
         forms.push(item)
       }
     })
-
-    _columns.forEach(item => {
-      if (item.$type === 'action') return
-
-      let _copy = fromJS(item).toJS()
-      _copy.sorter = false
-
-      if (item.editable === 'true') {
-        _copy.title = <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span>
-      }
-      edColumns.push(_copy)
-    })
-
-    if (setting.delable !== 'false' && setting.operType !== 'buoyMode') {
-      edColumns.push({
-        align: 'center',
-        dataIndex: 'mkoperation',
-        title: '鎿嶄綔',
-        sorter: false,
-        width: 100,
-        onCell: record => ({
-          record,
-          col: {type: 'operation', tableId: setting.tableId},
-        })
-      })
-    }
 
     let size = (setting.pageSize || 10) + ''
     let pageOptions = ['10', '25', '50', '100', '500', '1000']
@@ -1036,14 +1017,15 @@
       pageSize: setting.pageSize || 10,
       pageOptions,
       columns: _columns,
-      edColumns,
       tableId: setting.tableId,
-      orderfields,
-      initEditLine,
-      editable: setting.editable === 'true'
+      orderfields
     }, () => {
       if (deForms.length > 0) {
-        this.improveActionForm(deForms)
+        if (hasBid && setting.supModule && !BID) {
+          this.setState({ deForms })
+        } else {
+          this.improveActionForm(deForms, BID)
+        }
       }
 
       const element = document.getElementById(setting.tableId)
@@ -1058,10 +1040,19 @@
     return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
   }
 
+  UNSAFE_componentWillReceiveProps(nextProps) {
+    const { BID } = this.props
+    const { deForms } = this.state
+
+    if (deForms && nextProps.BID !== BID) {
+      this.improveActionForm(deForms, nextProps.BID)
+    }
+  }
+
   componentDidMount () {
     MKEmitter.addListener('subLine', this.subLine)
     MKEmitter.addListener('nextLine', this.nextLine)
-    MKEmitter.addListener('addRecord', this.addLine)
+    MKEmitter.addListener('addRecord', this.addRecord)
     MKEmitter.addListener('delRecord', this.delRecord)
     MKEmitter.addListener('resetTable', this.resetTable)
     MKEmitter.addListener('transferData', this.transferData)
@@ -1077,7 +1068,7 @@
     }
     MKEmitter.removeListener('subLine', this.subLine)
     MKEmitter.removeListener('nextLine', this.nextLine)
-    MKEmitter.removeListener('addRecord', this.addLine)
+    MKEmitter.removeListener('addRecord', this.addRecord)
     MKEmitter.removeListener('delRecord', this.delRecord)
     MKEmitter.removeListener('resetTable', this.resetTable)
     MKEmitter.removeListener('transferData', this.transferData)
@@ -1085,24 +1076,20 @@
   }
 
   transferData = (menuid, data, type) => {
-    if (menuid !== this.props.MenuID) return
+    const { MenuID } = this.props
+    const { edData } = this.state
+
+    if (menuid !== MenuID) return
 
     if (type !== 'line') {
-      this.setState({data: data || []})
+      let index = edData.findIndex(item => !item.$origin && !item.$forbid)
 
-      if (this.state.editable && !this.state.pickup) {
-        setTimeout(() => {
-          this.pickupChange()
-        }, 200)
+      if (index > -1) {
+        this.setState({visible: true, midData: data})
+      } else {
+        this.updateMutil(data)
       }
-    } else if (type === 'line' && data.$$uuid) {
-      let _data = this.state.data.map(item => {
-        if (item.$$uuid === data.$$uuid) {
-          return data
-        } else {
-          return item
-        }
-      })
+    } else if (type === 'line') {
       let _edData = this.state.edData.map(item => {
         if (item.$$uuid === data.$$uuid) {
           return data
@@ -1111,24 +1098,66 @@
         }
       })
 
-      this.setState({edData: _edData, data: _data})
+      this.setState({edData: _edData})
     }
-    this.setState({editable: false})
   }
 
-  improveActionForm = (deForms) => {
-    const { BID, setting } = this.props
+  updateMutil = (data) => {
+    const { setting } = this.props
+
+    if (setting.editType === 'multi' && data.length > 0) {
+      this.setState({edData: []}, () => {
+        this.setState({edData: data, visible: false, midData: null})
+      })
+    } else {
+      this.setState({edData: data, visible: false, midData: null})
+    }
+
+    if (setting.addable && data.length === 0) {
+      setTimeout(() => {
+        this.plusLine(true)
+      }, 10)
+    }
+  }
+
+  improveActionForm = (deForms, BID) => {
+    const { setting } = this.props
 
     let deffers = []
     let mainItems = []  // 浜戠鎴栧崟鐐规暟鎹�
     let localItems = [] // 鏈湴鏁版嵁
     let cache = setting.cache !== 'false'
+    let debug = window.GLOB.debugger === true || window.debugger === true
+    let _sql = `Declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)  select @mk_departmentcode='${sessionStorage.getItem('departmentcode') || ''}',@mk_organization='${sessionStorage.getItem('organization') || ''}',@mk_user_type='${sessionStorage.getItem('mk_user_type') || ''}'\n`
+    let _sso = _sql
 
     deForms.forEach(item => {
       if (item.database === 'sso') {
-        mainItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`)
+        let sql = _sso + item.base_sql
+        _sso = ''
+
+        sql = sql.replace(/@BID@/ig, `'${BID}'`)
+
+        if (debug) {
+          console.info(sql)
+        }
+
+        sql = sql.replace(/%/ig, ' mpercent ')
+
+        mainItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${window.btoa(window.encodeURIComponent(sql))}' as LText`)
       } else {
-        localItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${item.base_sql}' as LText`)
+        let sql = _sql + item.base_sql
+        _sql = ''
+
+        sql = sql.replace(/@BID@/ig, `'${BID}'`)
+
+        if (debug) {
+          console.info(sql)
+        }
+
+        sql = sql.replace(/%/ig, ' mpercent ')
+        
+        localItems.push(`select '${item.uuid}' as obj_name,'${item.arr_field}' as arr_field,'${window.btoa(window.encodeURIComponent(sql))}' as LText`)
       }
     })
 
@@ -1211,16 +1240,14 @@
   }
 
   resetFormList = (result) => {
-    const { columns } = this.props
-    const { edColumns } = this.state
+    const { columns, edData } = this.state
 
     let _edColumns = []
 
     let reCols = {}
-    columns.forEach(item => {
+    this.props.columns.forEach(item => {
       if (item.resourceType === '1' && result[item.uuid] && result[item.uuid].length > 0) {
         let options = []
-        let _map = new Map()
         let all = false
         result[item.uuid].forEach(cell => {
           let _cell = {key: Utils.getuuid()}
@@ -1237,8 +1264,8 @@
             }
           }
 
-          if (_map.has(_cell.value)) return
-          _map.set(_cell.value, 0)
+          if (item.map.has(_cell.value)) return
+          item.map.set(_cell.value, _cell.label)
 
           if (item.linkSubField) {
             item.linkSubField.forEach(m => {
@@ -1255,11 +1282,11 @@
 
         item.options = options
 
-        reCols[item.uuid] = item
+        reCols[item.uuid] = fromJS(item).toJS()
       }
     })
 
-    _edColumns = edColumns.map(item => {
+    _edColumns = columns.map(item => {
       if (reCols[item.dataIndex]) {
         item.onCell = record => ({
           record,
@@ -1270,29 +1297,39 @@
       return item
     })
 
-    if (this.state.pickup) {
-      this.setState({
-        pickup: false
-      }, () => {
-        this.setState({pickup: true, edColumns: _edColumns})
-      })
-    } else {
-      this.setState({edColumns: _edColumns})
-    }
+    this.setState({columns: [], edData: []}, () => {
+      this.setState({columns: _edColumns, edData: edData})
+    })
   }
   
   nextLine = (col, uuid) => {
     const { setting } = this.props
-    const { edData, initEditLine, tableId } = this.state
+    const { edData, tableId } = this.state
 
     if (col.tableId !== tableId) return
 
     let index = edData.findIndex(item => item.$$uuid === uuid)
     let next = edData[index + 1] || null
-
-    if (next && initEditLine) {
-      MKEmitter.emit('tdFocus', initEditLine.uuid + next.$$uuid)
-    } else if (setting.addable === 'true') {
+    
+    if (next) {
+      let nextId = setting.initId + next.$$uuid
+      if (/^\$next_/.test(col.enter)) {
+        nextId = col.enter.split('_')[1] + next.$$uuid
+      }
+      
+      let node = document.getElementById(nextId)
+      if (node) {
+        if (setting.editType === 'multi') {
+          if (setting.triType === 'click') {
+            node.click()
+          } else {
+            node.select && node.select()
+          }
+        } else {
+          node.click()
+        }
+      }
+    } else if (setting.addable) {
       setTimeout(() => {
         this.plusLine()
       }, 10)
@@ -1304,83 +1341,31 @@
   }
 
   subLine = (col, record) => {
-    const { tableId, forms, edData } = this.state
+    const { tableId, edData } = this.state
 
     if (col && col.tableId !== tableId) return
 
-    if (edData.filter(item => !item.$origin).length > 1) {
-      setTimeout(() => {
-        this.submit(edData)
-      }, 10)
-      return
-    }
-
-    setTimeout(() => {
-      let item = fromJS(record).toJS()
-      let line = []
-      forms.forEach(col => {
-        if (col.editable !== 'true' || item.$deleted) {
-          if (col.type === 'number') {
-            item[col.field] = +item[col.field]
-            if (isNaN(item[col.field])) {
-              item[col.field] = 0
-            }
-          } else {
-            item[col.field] = item[col.field] !== undefined ? (item[col.field] + '') : ''
-          }
-          return
-        }
-        if (col.type === 'text') {
-          let val = item[col.field] !== undefined ? (item[col.field] + '') : ''
-          if (col.required === 'true' && !val) {
-            line.push(`${col.label}涓嶅彲涓虹┖`)
-          }
-          item[col.field] = val
-        } else if (col.type === 'number') {
-          let val = item[col.field]
-          if (!val && val !== 0) {
-            line.push(`${col.label}涓嶅彲涓虹┖`)
-            return
-          }
-          val = +val
-          if (isNaN(val)) {
-            line.push(`${col.label}鏁版嵁鏍煎紡閿欒`)
-            return
-          }
-
-          val = +val.toFixed(col.decimal || 0)
-          
-          if (typeof(col.max) === 'number' && val > col.max) {
-            line.push(`${col.label}涓嶅彲澶т簬${col.max}`)
-          } else if (typeof(col.min) === 'number' && val < col.min) {
-            line.push(`${col.label}涓嶅彲灏忎簬${col.min}`)
-          }
-
-          item[col.field] = val
-        }
-      })
-
-      let err = line.join('锛�')
-
-      if (err) {
-        notification.warning({
-          top: 92,
-          message: err,
-          duration: 5
-        })
-      } else {
-        this.submit([item], 'simple')
+    let _data = edData.map(item => {
+      if (item.$$uuid === record.$$uuid) {
+        item.$origin = false
       }
-    }, 10)
+      return item
+    })
+
+    this.setState({edData: _data}, () => {
+      this.submit()
+    })
   }
 
-  plusLine = () => {
-    const { edData, forms, initEditLine } = this.state
+  plusLine = (auto) => {
+    const { setting } = this.props
+    const { edData, forms } = this.state
 
-    let item = {...edData[edData.length - 1]}
+    let item = edData.length > 0 ? {...edData[edData.length - 1]} : {}
 
     item.$$uuid = Utils.getguid()
     item.$type = 'add'
+    item.$forbid = true
     item.$Index = ''
 
     forms.forEach(col => {
@@ -1399,7 +1384,18 @@
     })
 
     this.setState({edData: [...edData, item]}, () => {
-      MKEmitter.emit('tdFocus', initEditLine.uuid + item.$$uuid)
+      let node = document.getElementById(setting.initId + item.$$uuid)
+      if (node && !auto) {
+        if (setting.editType === 'multi') {
+          if (setting.triType === 'click') {
+            node.click()
+          } else {
+            node.select && node.select()
+          }
+        } else {
+          node.click()
+        }
+      }
     })
   }
 
@@ -1408,118 +1404,112 @@
     const { tableId, edData } = this.state
 
     if (id !== tableId) return
-
-    let _data = []
-
+    
     if (record.$type === 'add') {
-      _data = edData.filter(item => item.$$uuid !== record.$$uuid)
+      let _data = edData.filter(item => item.$$uuid !== record.$$uuid)
+      this.setState({edData: _data})
     } else {
-      _data = edData.map(item => {
+      let _data = fromJS(edData).toJS().map(item => {
         if (item.$$uuid === record.$$uuid) {
-          record.$deleted = true
-          record.$origin = false
-          record.$type = 'del'
-          return record
-        } else {
-          return item
+          item.$deleted = true
+          item.$origin = false
+          item.$type = 'del'
         }
+
+        return item
       })
 
-      if (setting.commit === 'simple' && record.$deleted) {
-        this.subLine(null, record)
-      }
+      this.setState({edData: _data}, () => {
+        if (setting.commit === 'simple') {
+          this.submit()
+        }
+      })
     }
-
-    this.setState({edData: _data})
   }
 
   changeRecord = (id, record) => {
+    const { setting } = this.props
     const { tableId } = this.state
 
     if (id !== tableId) return
 
+    let lock = record.$lock
+
     let _data = this.state.edData.map(item => {
       if (item.$$uuid === record.$$uuid) {
         record.$origin = false
+        record.$lock = true
+
+        delete record.$forbid
+
         return record
       } else {
         return item
       }
     })
 
-    this.setState({edData: _data})
+    this.setState({edData: _data}, () => {
+      if (setting.tableType && setting.hasAction && !lock && this.state.selectedRowKeys.includes(record.$$uuid)) {
+        this.selectdata(this.state.selectedRowKeys)
+      }
+    })
   }
 
-  addLine = (id, record) => {
+  addRecord = (id, record) => {
     const { BID } = this.props
     const { edData, forms, tableId } = this.state
 
-    if (id) {
-      if (id !== tableId) return
-      let _edData = fromJS(edData).toJS()
-      let index = _edData.findIndex(item => record.$$uuid === item.$$uuid)
+    if (id !== tableId) return
 
-      let item = {}
+    let _edData = fromJS(edData).toJS()
+    let item = {}
+    let index = null
+    let copy = edData.length > 0 ? {...edData[edData.length - 1]} : null
 
-      item.$$uuid = Utils.getguid()
-      item.$type = 'add'
-      item.$Index = ''
-      item.$$BID = BID || ''
-  
-      forms.forEach(col => {
-        if (col.initval !== '$copy') {
-          item[col.field] = col.initval
-        }
-        if (col.type === 'number') {
-          item[col.field] = +item[col.field]
-          if (isNaN(item[col.field])) {
-            item[col.field] = 0
-          }
-        }
-  
-        if (item[col.field] === undefined) {
-          item[col.field] = ''
-        }
-      })
+    if (record) {
+      index = _edData.findIndex(item => record.$$uuid === item.$$uuid)
+      index = index === -1 ? null : index
 
-      _edData.splice(index, 0, item)
-
-      this.setState({edData: _edData})
-    } else {
-      let item = {}
-      if (edData.length > 0) {
-        item = {...edData[edData.length - 1]}
-        item.$$uuid = Utils.getguid()
-        item.$type = 'add'
-        item.$Index = ''
-      } else {
-        item.$$uuid = Utils.getguid()
-        item.$type = 'add'
-        item.$Index = ''
-        item.$$BID = BID || ''
-      }
-  
-      forms.forEach(col => {
-        if (col.initval !== '$copy') {
-          item[col.field] = col.initval
-        }
-        if (col.type === 'number') {
-          item[col.field] = +item[col.field]
-          if (isNaN(item[col.field])) {
-            item[col.field] = 0
-          }
-        }
-  
-        if (item[col.field] === undefined) {
-          item[col.field] = ''
-        }
-      })
-  
-      this.setState({edData: [...edData, item]})
+      copy = {...record}
     }
+
+    if (copy) {
+      item = {...copy}
+    }
+
+    item.$$uuid = Utils.getguid()
+    item.$type = 'add'
+    item.$Index = ''
+    item.$forbid = true
+    item.$$BID = BID || ''
+
+    forms.forEach(col => {
+      if (col.initval !== '$copy') {
+        item[col.field] = col.initval
+      }
+      if (col.type === 'number') {
+        item[col.field] = +item[col.field]
+        if (isNaN(item[col.field])) {
+          item[col.field] = 0
+        }
+      }
+
+      if (item[col.field] === undefined) {
+        item[col.field] = ''
+      }
+    })
+
+    if (index === null) {
+      _edData.push(item)
+    } else {
+      _edData.splice(index, 0, item)
+    }
+
+    this.setState({edData: _edData})
   }
 
   checkData = () => {
+    const { setting } = this.props
     const { edData, forms } = this.state
 
     if (edData.length === 0) {
@@ -1528,11 +1518,28 @@
         message: '鎻愪氦鏁版嵁涓嶅彲涓虹┖锛�',
         duration: 5
       })
-      return
+      return null
     }
+
+    let data = fromJS(edData).toJS()
+
+    data = data.filter(item => !item.$forbid)
+    if (setting.commit === 'change' || setting.commit === 'simple') {
+      data = data.filter(item => !item.$origin)
+    }
+
+    if (data.length === 0) {
+      notification.warning({
+        top: 92,
+        message: '鏁版嵁鏈慨鏀癸紝涓嶅彲鎻愪氦锛�',
+        duration: 5
+      })
+      return null
+    }
+
     let err = ''
     let Index = 1
-    let data = fromJS(edData).toJS().map(item => {
+    data = data.map(item => {
       let line = []
       forms.forEach(col => {
         if (col.editable !== 'true' || item.$deleted) {
@@ -1554,7 +1561,9 @@
           item[col.field] = val
         } else if (col.type === 'number') {
           let val = item[col.field]
-          if (!val && val !== 0) {
+          if (col.noValue === 'hide' && !val) {
+            val = 0
+          } else if (!val && val !== 0) {
             line.push(`${col.label}涓嶅彲涓虹┖`)
             return
           }
@@ -1592,27 +1601,32 @@
         message: err,
         duration: 5
       })
-    } else {
-      this.submit(data)
+
+      return null
     }
+
+    return data
   }
 
-  submit = (data, type) => {
+  submit = () => {
     const { submit, BID, setting } = this.props
     const { forms } = this.state
 
-    if (type !== 'simple' && (setting.commit === 'change' || setting.commit === 'simple')) {
-      data = data.filter(item => !item.$origin)
-    }
+    this.setState({visible: false, midData: null})
 
-    if (data.length === 0) {
+    if (setting.supModule && !BID) {
       notification.warning({
         top: 92,
-        message: '鏁版嵁鏈慨鏀癸紝涓嶅彲鎻愪氦锛�',
+        message: '闇�瑕佷笂绾т富閿�硷紒',
         duration: 5
       })
+
       return
     }
+
+    let data = this.checkData()
+
+    if (!data) return
 
     let result = getEditTableSql(submit, data, forms)
 
@@ -1653,12 +1667,7 @@
 
       Api.genericInterface(param).then((res) => {
         if (res.status) {
-          if (type === 'simple') {
-            this.updataLine(data[0])
-            this.execSuccess(res, type)
-          } else {
-            this.execSuccess(res)
-          }
+          this.execSuccess(res)
         } else {
           this.execError(res)
         }
@@ -1670,12 +1679,7 @@
 
       Api.genericInterface(param).then((res) => {
         if (res.status) {
-          if (type === 'simple') {
-            this.updataLine(data[0])
-            this.execSuccess(res, type)
-          } else {
-            this.execSuccess(res)
-          }
+          this.execSuccess(res)
         } else {
           this.execError(res)
         }
@@ -1685,55 +1689,47 @@
     }
   }
 
-  updataLine = (item) => {
-    if (item.$type === 'del') {
-      let _data = this.state.edData.filter(m => m.$$uuid !== item.$$uuid)
-
-      this.setState({edData: _data})
-    } else {
-      let _data = this.state.edData.map(m => {
-        if (m.$$uuid === item.$$uuid) {
-          item.$origin = true
-          return item
-        }
-        return m
-      })
-
-      this.setState({edData: _data})
-    }
-    MKEmitter.emit('reloadData', this.props.MenuID, item.$$uuid, item)
-  }
-
-  execSuccess = (res, type) => {
+  execSuccess = (res) => {
     const { submit } = this.props
+    const { edData } = this.state
 
     if (res && res.ErrCode === 'S') { // 鎵ц鎴愬姛
       notification.success({
         top: 92,
-        message: res.ErrMesg || this.state.dict['main.action.confirm.success'],
+        message: res.ErrMesg || '鎵ц鎴愬姛',
         duration: submit.stime ? submit.stime : 2
       })
     } else if (res && res.ErrCode === 'Y') { // 鎵ц鎴愬姛
       Modal.success({
-        title: res.ErrMesg || this.state.dict['main.action.confirm.success']
+        title: res.ErrMesg || '鎵ц鎴愬姛'
       })
     } else if (res && res.ErrCode === '-1') { // 瀹屾垚鍚庝笉鎻愮ず
 
     }
 
-    this.setState({
-      loading: false
+    let _edData = fromJS(edData).toJS()
+
+    _edData = _edData.map(item => {
+      if (!item.$forbid) {
+        item.$origin = true
+      }
+      return item
     })
 
-    if (type === 'simple') return
+    this.setState({
+      loading: false,
+      edData: _edData
+    })
 
     if (submit.closetab === 'true') {
       MKEmitter.emit('popclose')
     }
+
     if (submit.execSuccess !== 'never') {
-      this.repick()
       MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execSuccess, submit)
     }
+
+    submit.syncComponentId && MKEmitter.emit('reloadData', submit.syncComponentId)
   }
 
   execError = (res) => {
@@ -1765,33 +1761,12 @@
     })
 
     if (submit.execError !== 'never') {
-      this.repick()
       MKEmitter.emit('refreshByButtonResult', submit.$menuId, submit.execError, submit)
     }
   }
 
-  repick = () => {
-    const { setting } = this.props
-    const { data } = this.state
-
-    if (setting.submittal === 'true') {
-      this.setState({editable: true})
-    }
-
-    this.props.changeLock(false)
-    this.setState({
-      data: [],
-      edData: [],
-      pickup: false,
-    }, () => {
-      this.setState({
-        data: data,
-      })
-    })
-  }
-
   /**
-   * 
+   * @description 閫変腑琛�
    */
   onSelectChange = selectedRowKeys => {
     this.setState({ selectedRowKeys })
@@ -1807,28 +1782,28 @@
   /**
    * @description 鐐瑰嚮鏁磋锛岃Е鍙戝垏鎹紝 鍒ゆ柇鏄惁鍙�夛紝鍗曢�夋垨澶氶�夛紝杩涜瀵瑰簲鎿嶄綔
    */
-  changeRow = (index) => {
+  changeRow = (id) => {
     const { setting } = this.props
 
-    if (!setting.tableType || this.state.pickup) return
+    if (!setting.tableType) return
     
     let newkeys = fromJS(this.state.selectedRowKeys).toJS()
 
     let activeId = ''
     if (setting.tableType === 'radio') {
-      activeId = index
-      newkeys = [index]
+      activeId = id
+      newkeys = [id]
       this.setState({ selectedRowKeys: newkeys })
     } else {
-      if (newkeys.includes(index)) {
-        newkeys = newkeys.filter(item => item !== index)
+      if (newkeys.includes(id)) {
+        newkeys = newkeys.filter(item => item !== id)
 
         if (newkeys.length > 0) {
           activeId = newkeys.slice(-1)[0]
         }
       } else {
-        activeId = index
-        newkeys.push(index)
+        activeId = id
+        newkeys.push(id)
       }
 
       this.setState({ selectedRowKeys: newkeys })
@@ -1840,21 +1815,21 @@
 
   changedata = (id) => {
     const { MenuID } = this.props
-    const { data } = this.state
+    const { edData } = this.state
 
     let _data = ''
 
     if (id) {
-      _data = data.filter(item => item.$$uuid === id)[0] || ''
+      _data = edData.filter(item => item.$$uuid === id)[0] || ''
     }
 
     MKEmitter.emit('resetSelectLine', MenuID, id, _data)
   }
 
   selectdata = (keys) => {
-    const { data } = this.state
+    const { edData } = this.state
 
-    let _data = data.filter(item => keys.includes(item.$$uuid))
+    let _data = edData.filter(item => keys.includes(item.$$uuid))
 
     this.props.chgSelectData(_data)
   }
@@ -1890,96 +1865,22 @@
     }
   }
 
-  pickupChange = () => {
-    const { submit, MenuID, setting } = this.props
-    const { data } = this.state
-
-    let pickup = !this.state.pickup
-
-    if (!submit.sheet) {
-      notification.warning({
-        top: 92,
-        message: '鎻愪氦鎸夐挳灏氭湭璁剧疆锛屼笉鍙紪杈戯紒',
-        duration: 5
-      })
-      return
-    }
-
-    if (!pickup && this.state.edData.filter(item => !item.$origin).length > 0) {
-      const _this = this
-      confirm({
-        title: '鏁版嵁宸蹭慨鏀癸紝纭畾鏀惧純淇濆瓨鍚楋紵',
-        onOk() {
-          _this.setState({
-            data: [],
-            edData: [],
-            pickup
-          }, () => {
-            _this.setState({
-              data: data,
-              edData: pickup ? fromJS(data).toJS() : []
-            })
-          })
-        },
-        onCancel() {}
-      })
-    } else {
-      pickup && MKEmitter.emit('resetSelectLine', MenuID, '', '')
-      pickup && this.props.chgSelectData([])
-      let keys = this.state.selectedRowKeys
-      this.setState({
-        data: [],
-        edData: [],
-        selectedRowKeys: [],
-        pickup,
-        loading: false,
-        editable: false
-      }, () => {
-        if (pickup && setting.tableType === 'checkbox' && keys.length > 0) {
-          this.setState({
-            data: data,
-            edData: fromJS(data).toJS().filter(item => {
-              item.$origin = false
-              
-              return keys.includes(item.$$uuid)
-            })
-          })
-        } else {
-          this.setState({
-            data: data,
-            edData: pickup ? fromJS(data).toJS() : []
-          })
-        }
-      })
-
-    }
-    this.props.changeLock(pickup)
-  }
-
   render() {
-    const { setting, statFValue, lineMarks, submit } = this.props
-    const { pickup, tableId, data, edData, columns, edColumns, loading, pageOptions, selectedRowKeys } = this.state
+    const { setting, lineMarks, submit } = this.props
+    const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData } = this.state
 
     const components = {
       body: {
         row: BodyRow,
-        cell: setting.editType !== 'multi' || !pickup ? BodyCell : BodyAllCell
+        cell: setting.editType !== 'multi' ? BodyCell : BodyAllCell
       }
     }
 
-    // 鏁版嵁鏀惰捣鏃讹紝杩囨护宸查�夋暟鎹�
-    let _data = data
-    let _columns = columns
-
-    if (pickup) {
-      _data = edData
-      _data = _data.filter(item => !item.$deleted)
-      _columns = edColumns
-    }
+    let _data = edData.filter(item => !item.$deleted)
 
     // 璁剧疆琛ㄦ牸閫夋嫨灞炴�э細鍗曢�夈�佸閫夈�佷笉鍙��
     let rowSelection = null
-    if (setting.tableType && !pickup) {
+    if (setting.tableType) {
       rowSelection = {
         selectedRowKeys,
         type: (setting.tableType === 'radio') ? 'radio' : 'checkbox',
@@ -1988,49 +1889,42 @@
     }
 
     let _pagination = false
-    if (!pickup && setting.laypage !== 'false' && setting.laypage !== false) {
+    if (setting.laypage) {
       _pagination = {
         current: this.state.pageIndex,
         pageSize: this.state.pageSize,
         pageSizeOptions: pageOptions,
         showSizeChanger: true,
         total: this.props.total || 0,
-        showTotal: (total, range) => `${range[0]}-${range[1]} ${this.state.dict['main.pagination.of']} ${total} ${this.state.dict['main.pagination.items']}`
+        showTotal: (total, range) => `${range[0]}-${range[1]} 鍏� ${total} 鏉
       }
     }
 
-    let _footer = ''
-
-    if (!pickup && statFValue && statFValue.length > 0) {
-      _footer = statFValue.map(f => `${f.label}(鍚堣)锛�${f.value}`).join('锛�')
-    }
-
     let height = setting.height || false
+    if (height && height <= 100) {
+      height = height + 'vh'
+    }
 
     return (
       <>
-        {submit.hasAction && pickup ? <div className="edit-custom-table-leftbtn-wrap">
-          <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button>
+        {setting.hasSubmit ? <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>
         </div> : null}
-        <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}>
-          {!submit.hasAction && pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">鎻愪氦</Button> : null}
-          {setting.switchable !== 'false' ? <Switch title="缂栬緫" className="main-pickup" checkedChildren="寮�" unCheckedChildren="鍏�" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} /> : null}
-        </div>
-        <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}>
+        <div className={`edit-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''} table-vertical-${setting.vertical || ''} mk-edit-${setting.editType || 'simple'}`} id={tableId}>
           <Table
             rowKey="$$uuid"
             components={components}
-            // style={setting.style}
             size={setting.size || 'middle'}
             bordered={setting.bordered !== 'false'}
             rowSelection={rowSelection}
-            columns={_columns}
+            columns={columns}
             dataSource={_data}
             loading={this.props.loading}
             scroll={{ x: '100%', y: height }}
             onRow={(record, index) => {
               return {
                 lineMarks,
+                title: setting.tipField ? record[setting.tipField] : '',
                 data: record,
                 onClick: () => {this.changeRow(record.$$uuid)},
               }
@@ -2038,10 +1932,23 @@
             onChange={this.changeTable}
             pagination={_pagination}
           />
-          {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null}
-          {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null}
-          {pickup && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 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">鎻愪氦</Button> : null}
         </div>
+        <Modal
+          className="mk-user-confirm"
+          visible={visible}
+          width={450}
+          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>
+          ]}
+          destroyOnClose
+        >
+          <div><QuestionCircleOutlined />琛ㄦ牸涓湁鏁版嵁灏氭湭鎻愪氦</div>
+        </Modal>
       </>
     )
   }

--
Gitblit v1.8.0