king
3 天以前 80deba0c2dcffd9e6b6f07815c7c52199309ce42
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}
@@ -627,6 +623,10 @@
    let style = {}
    let className = ''
    if (data && data.$disabled) {
      className = className + ' mk-disabled '
    }
    lineMarks && lineMarks.some(mark => {
      let originVal = data[mark.field[0]] + ''
      let contrastVal = ''
@@ -763,7 +763,7 @@
        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 === col.openVal) {
@@ -820,16 +820,17 @@
      }
      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">
@@ -1099,7 +1100,7 @@
          )
        } 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 = (
@@ -1125,7 +1126,7 @@
          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 === col.openVal) {
@@ -2140,6 +2141,12 @@
      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)
    })
  }
@@ -2505,7 +2512,7 @@
    if (setting.supModule && !BID) {
      notification.warning({
        top: 92,
        message: dict['sup_key_req'] || '需要上级主键值!',
        message: setting.supModTip || dict['sup_key_req'] || '需要上级主键值!',
        duration: 5
      })
@@ -2541,7 +2548,7 @@
        this.execError({})
      })
    } else if (submit.intertype === 'system') { // 系统存储过程
      let result = getEditTableSql(submit, data, forms)
      let result = getEditTableSql(submit, data, forms, setting)
      let param = {}
      param.func = 'sPC_TableData_InUpDe'
@@ -2570,7 +2577,7 @@
        this.execError({})
      })
    } else if (submit.intertype === 'inner' && submit.innerFunc) { // 自定义存储过程
      let result = getEditTableSql(submit, data, forms)
      let result = getEditTableSql(submit, data, forms, setting)
      let param = {}
      param.func = submit.innerFunc
@@ -2625,7 +2632,11 @@
    let lines = data.map(item => {
      let vals = []
      forms.forEach(col => {
        vals.push(item[col.field])
        if (typeof(item[col.field]) === 'number') {
          vals.push(item[col.field] + '')
        } else {
          vals.push(item[col.field])
        }
      })
  
      vals.push(item.$$uuid)
@@ -2763,24 +2774,48 @@
  /**
   * @description 选中行
   */
  onSelectChange = selectedRowKeys => {
    this.setState({ selectedRowKeys })
  onSelectChange = (selectedRowKeys, keys) => {
    const { setting } = this.props
    let activeId = ''
    if (selectedRowKeys.length > 0) {
      activeId = selectedRowKeys.slice(-1)[0]
    if (setting.controlField && selectedRowKeys.length > 0) {
      let newkeys = keys.filter(item => !item.$disabled).map(item => item.$$uuid)
      this.setState({ selectedRowKeys: newkeys })
      let activeId = ''
      if (newkeys.length > 0) {
        activeId = newkeys.slice(-1)[0]
      }
      this.changedata(activeId)
      this.selectdata(newkeys)
    } else {
      this.setState({ selectedRowKeys })
      let activeId = ''
      if (selectedRowKeys.length > 0) {
        activeId = selectedRowKeys.slice(-1)[0]
      }
      this.changedata(activeId)
      this.selectdata(selectedRowKeys)
    }
    this.changedata(activeId)
    this.selectdata(selectedRowKeys)
    // this.setState({ selectedRowKeys })
    // let activeId = ''
    // if (selectedRowKeys.length > 0) {
    //   activeId = selectedRowKeys.slice(-1)[0]
    // }
    // this.changedata(activeId)
    // this.selectdata(selectedRowKeys)
  }
  /**
   * @description 点击整行,触发切换, 判断是否可选,单选或多选,进行对应操作
   */
  changeRow = (id) => {
  changeRow = (record) => {
    const { setting } = this.props
    if (!setting.tableType) return
    if (!setting.tableType || record.$disabled) return
    let id = record.$$uuid
    
    let newkeys = fromJS(this.state.selectedRowKeys).toJS()
@@ -2920,7 +2955,7 @@
        {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">{dict['submit'] || '提交'}</Button>
        </div> : null}
        <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'}`} 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}
@@ -2931,12 +2966,12 @@
            dataSource={_data}
            loading={this.props.loading}
            scroll={{ x: '100%', y: height }}
            onRow={(record, index) => {
            onRow={(record, _) => {
              return {
                lineMarks,
                title: setting.tipField ? record[setting.tipField] : '',
                data: record,
                onClick: () => {this.changeRow(record.$$uuid)},
                onClick: () => {this.changeRow(record)},
              }
            }}
            onChange={this.changeTable}