king
2023-05-14 6b72e0d7751fba6af94a64020ac1fb1199612d05
2023-05-14
4个文件已修改
196 ■■■■■ 已修改文件
src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/edit-table/columns/tableIn/index.jsx 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/table/edit-table/columns/editColumn/formconfig.jsx
@@ -259,16 +259,16 @@
        text: '数据源'
      }]
    },
    {
      type: 'select',
      key: 'editField',
      label: '编辑字段',
      initVal: card.editField || '',
      tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。',
      allowClear: true,
      required: false,
      options: fields
    },
    // {
    //   type: 'select',
    //   key: 'editField',
    //   label: '编辑字段',
    //   initVal: card.editField || '',
    //   tooltip: '当值与提示文字不同时,可额外添加编辑字段,作为实际值的录入字段。',
    //   allowClear: true,
    //   required: false,
    //   options: fields
    // },
    {
      type: 'options',
      key: 'options',
src/menu/components/table/edit-table/columns/tableIn/index.jsx
@@ -1,8 +1,8 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
import { StopTwoTone, CheckCircleTwoTone, EditOutlined, ArrowUpOutlined, ArrowDownOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
import { Form, Tabs, Row, Col, Input, Button, Popconfirm, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
import { StopTwoTone, CheckCircleTwoTone, EditOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
import moment from 'moment'
import Api from '@/api'
@@ -160,10 +160,8 @@
        width: '20%',
        dataIndex: 'operation',
        render: (text, record) =>
          (<div>
          (<div style={{textAlign: 'center'}}>
            <span className="operation-btn" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span>
            <span className="operation-btn" onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span>
            <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
            <Popconfirm
              overlayClassName="popover-confirm"
@@ -389,51 +387,6 @@
    })
  }
  handleUpDown = (record, type, direction) => {
    let verify = JSON.parse(JSON.stringify(this.state.verify))
    let index = 0
    if (type === 'unique') {
      verify.uniques = verify.uniques.filter((item, i) => {
        if (item.uuid === record.uuid) {
          index = i
        }
        return item.uuid !== record.uuid
      })
      if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) {
        return
      }
      if (direction === 'up') {
        verify.uniques.splice(index - 1, 0, record)
      } else {
        verify.uniques.splice(index + 1, 0, record)
      }
    } else if (type === 'scripts') {
      verify.scripts = verify.scripts.filter((item, i) => {
        if (item.uuid === record.uuid) {
          index = i
        }
        return item.uuid !== record.uuid
      })
      if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) {
        return
      }
      if (direction === 'up') {
        verify.scripts.splice(index - 1, 0, record)
      } else {
        verify.scripts.splice(index + 1, 0, record)
      }
    }
    this.setState({
      verify: verify
    })
  }
  handleConfirm = () => {
    const { verify } = this.state
    
@@ -634,14 +587,7 @@
              scriptsChange={this.scriptsChange}
              wrappedComponentRef={(inst) => this.scriptsForm = inst}
            />
            <Table
              bordered
              rowKey="uuid"
              className="custom-table"
              dataSource={verify.scripts}
              columns={scriptsColumns}
              pagination={false}
            />
            <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
          </TabPane>
          <TabPane tab="信息提示" key="tip">
            <Form {...formItemLayout}>
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -221,12 +221,12 @@
    }, 50)
    let values = {}
    if (col.editField) {
      values[col.field] = label
      values[col.editField] = val
    } else {
    // if (col.editField) {
    //   values[col.field] = label
    //   values[col.editField] = val
    // } else {
      values[col.field] = val
    }
    // }
    MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
  }
@@ -244,12 +244,12 @@
        })
      }
      if (col.editField) {
        values[col.field] = _option.label
        values[col.editField] = val
      } else {
      // if (col.editField) {
      //   values[col.field] = _option.label
      //   values[col.editField] = val
      // } else {
        values[col.field] = val
      }
      // }
    }
    this.setState({editing: false})
@@ -292,6 +292,10 @@
        content = `${record[col.field]}`
      }
      if (col.editType === 'select' && col.options.length > 0) {
        content = col.map.get(content) || content
      }
      if (content !== '') {
        if (col.textFormat === 'YYYY-MM-DD' && /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])/.test(content)) {
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)}`
@@ -330,21 +334,21 @@
            </td>)
          } else if (col.editType === 'switch') {
            let _value = ''
            if (col.editField) {
              _value = record[col.editField] !== undefined ? record[col.editField] : ''
            } else {
            // if (col.editField) {
            //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
            // } else {
              _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 {
            // if (col.editField) {
            //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
            // } else {
              _value = record[col.field] !== undefined ? record[col.field] : ''
            }
            // }
            return (<td className="editing_table_cell">
              <Select
                showSearch
@@ -637,12 +641,12 @@
    }, 50)
    let values = {}
    if (col.editField) {
      values[col.field] = label
      values[col.editField] = val
    } else {
    // if (col.editField) {
    //   values[col.field] = label
    //   values[col.editField] = val
    // } else {
      values[col.field] = val
    }
    // }
    MKEmitter.emit('changeRecord', col.tableId, {...record, ...values})
  }
@@ -660,12 +664,12 @@
        })
      }
      if (col.editField) {
        values[col.field] = _option.label
        values[col.editField] = val
      } else {
      // if (col.editField) {
      //   values[col.field] = _option.label
      //   values[col.editField] = val
      // } else {
        values[col.field] = val
      }
      // }
    }
    setTimeout(() => {
@@ -703,11 +707,11 @@
    if (col.type === 'text') {
      if (col.editable === 'true' && !disabled) {
        let _value = ''
        if (col.editField) {
          _value = record[col.editField] !== undefined ? record[col.editField] : ''
        } else {
        // if (col.editField) {
        //   _value = record[col.editField] !== undefined ? record[col.editField] : ''
        // } else {
          _value = record[col.field] !== undefined ? record[col.field] : ''
        }
        // }
        
        if (!col.editType || col.editType === 'text') {
          children = (<>
@@ -736,6 +740,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 !== '') {
@@ -967,17 +975,24 @@
              item.ctrlValue = item.ctrlValue.split(',')
            }
            
            if (item.type === 'text' && item.editType === 'select' && item.resourceType === '1') {
              let _option = Utils.getSelectQueryOptions(item)
              if (/@BID@/ig.test(_option.sql)) {
                hasBid = true
            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 = _option.sql
              item.arr_field = _option.field
              deForms.push(item)
            }
          }
    
@@ -1234,7 +1249,7 @@
  }
  resetFormList = (result) => {
    const { columns } = this.state
    const { columns, edData } = this.state
    let _edColumns = []
@@ -1242,7 +1257,6 @@
    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()}
@@ -1259,8 +1273,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 => {
@@ -1277,7 +1291,7 @@
        item.options = options
        reCols[item.uuid] = item
        reCols[item.uuid] = fromJS(item).toJS()
      }
    })
@@ -1292,8 +1306,8 @@
      return item
    })
    this.setState({columns: []}, () => {
      this.setState({columns: _edColumns})
    this.setState({columns: [], edData: []}, () => {
      this.setState({columns: _edColumns, edData: edData})
    })
  }
  
src/utils/utils.js
@@ -808,6 +808,8 @@
    }
    if (['select', 'radio', 'link', 'checkcard'].includes(item.type) && item.linkSubField && item.linkSubField.length > 0) {
      arrfield.push(...item.linkSubField)
    } else if (item.type === 'text' && item.editType === 'select' && item.linkSubField && item.linkSubField.length > 0) { // 可编辑表
      arrfield.push(...item.linkSubField)
    }
    if (item.disableField) {
      arrfield.push(item.disableField)