king
2022-10-17 e8edfdadb561cd83bf6e1c3e00d55b8cc2aee6d5
src/templates/sharecomponent/actioncomponent/verifyexcelout/index.jsx
@@ -22,7 +22,6 @@
class VerifyCard extends Component {
  static propTpyes = {
    dict: PropTypes.object,    // 字典项
    config: PropTypes.object,
    card: PropTypes.object,
  }
@@ -34,46 +33,50 @@
    defaultscript: '', // 自定义脚本
    excelColumns: [
      {
        title: this.props.dict['model.form.field'],
        title: '字段',
        dataIndex: 'Column',
        inputType: 'input',
        editable: true,
        unique: true,
        width: '20%'
        width: '17%'
      },
      {
        title: this.props.dict['model.name'],
        title: '名称',
        dataIndex: 'Text',
        inputType: 'input',
        editable: true,
        width: '20%'
        unique: true,
        width: '17%'
      },
      {
        title: this.props.dict['model.form.columnWidth'],
        title: '列宽',
        dataIndex: 'Width',
        inputType: 'number',
        min: 5,
        max: 200,
        editable: true,
        width: '14%',
        width: '12%',
        render: (text) => text || 20
      },
      {
        title: '类型',
        dataIndex: 'type',
        inputType: 'radio',
        inputType: 'select',
        editable: true,
        required: false,
        width: '18%',
        width: '14%',
        render: (text) => {
          if (text === 'image') {
            return '图片'
          } else if (text === 'number') {
            return '数值'
          } else {
            return '文本'
          }
        },
        options: [
          {value: 'text', text: '文本'},
          {value: 'number', text: '数值'},
          {value: 'image', text: '图片'}
        ]
      },
@@ -95,6 +98,16 @@
          {value: 'true', text: '是'},
          {value: 'false', text: '否'}
        ]
      },
      {
        title: '小数位',
        dataIndex: 'decimal',
        inputType: 'number',
        min: 0,
        max: 18,
        editable: true,
        required: false,
        width: '12%'
      },
      {
        title: '导出',
@@ -173,11 +186,11 @@
        dataIndex: 'operation',
        render: (text, record) =>
          (<div style={{textAlign: 'center'}}>
            <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
            <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
            <span className="operation-btn" title="编辑" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
            <span className="operation-btn" title="状态切换" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
            <Popconfirm
              overlayClassName="popover-confirm"
              title={this.props.dict['model.query.delete']}
              title="确定删除吗?"
              onConfirm={() => this.handleDelete(record, 'scripts')
            }>
              <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
@@ -280,6 +293,17 @@
  }
  componentDidMount () {
    this.getsysScript()
  }
  getsysScript = () => {
    if (sessionStorage.getItem('mk_sys_scripts')) {
      this.setState({
        systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts'))
      })
      return
    }
    let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from  s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`
    _scriptSql = Utils.formatOptions(_scriptSql)
@@ -293,18 +317,21 @@
    
    _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
    _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 云端数据验证
    
    Api.getSystemConfig(_sParam).then(res => {
      if (res.status) {
        let _scripts = res.data.map(item => {
          return {
            name: item.funcname,
            value: window.decodeURIComponent(window.atob(item.longparam))
          }
        })
        sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts))
        this.setState({
          systemScripts: res.data.map(item => {
            return {
              name: item.funcname,
              value: window.decodeURIComponent(window.atob(item.longparam))
            }
          })
          systemScripts: _scripts
        })
      } else {
        notification.warning({
@@ -317,11 +344,13 @@
  }
  handleEdit = (record, type) => {
    let node = null
    if (type === 'scripts') {
      this.scriptsForm.edit(record)
      node = document.getElementById('mk-exout-script')
    }
    let node = document.getElementById('verify-excelout-box-tab').parentNode
    if (node && node.scrollTop) {
      let inter = Math.ceil(node.scrollTop / 10)
@@ -657,7 +686,7 @@
        this.setState({
          loading: true
        })
        Api.getLocalConfig(param).then(res => {
        Api.genericInterface(param).then(res => {
          this.setState({
            loading: false
          })
@@ -703,7 +732,7 @@
      if (fields.includes(item.field) || !item.field) return
      fields.push(item.field)
      columns.push({
      let cell = {
        Column: item.field,
        Text: item.label,
        Width: 20,
@@ -711,7 +740,14 @@
        output: 'true',
        type: 'text',
        uuid: Utils.getuuid()
      })
      }
      if (item.type === 'number') {
        cell.type = 'number'
        cell.decimal = item.decimal
      }
      columns.push(cell)
    })
    this.setState({
@@ -740,7 +776,7 @@
  changeColumns = (columns) => {
    const { verify } = this.state
    if (columns[0] && (columns[0].type !== 'image' && columns[0].type !== 'text')) {
    if (columns[0] && (columns[0].type !== 'image' && columns[0].type !== 'text' && columns[0].type !== 'number')) {
      columns = columns.map(col => {
        let _cell = {
          uuid: Utils.getuuid(),
@@ -877,6 +913,11 @@
  sqlverify = (_resolve, _reject, scripts) => {
    const { searches, verify } = this.state
    if (verify.dataType !== 'custom') {
      _resolve()
      return
    }
    let timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    let sql = SettingUtils.getDebugSql(verify, scripts, searches, Utils, timestamp)
    let param = {
@@ -888,7 +929,7 @@
    param.timestamp = timestamp
    param.secretkey = Utils.encrypt('', timestamp)
    Api.getLocalConfig(param).then(result => {
    Api.genericInterface(param).then(result => {
      if (result.status) {
        _resolve()
      } else {
@@ -920,7 +961,8 @@
    }
    return (
      <div id="verify-excelout-box-tab">
      <div className="verify-excelout-box-tab">
        {card.label ? <div className="mk-com-name">{card.label} - 验证信息</div> : null}
        {loading && <Spin size="large" />}
        <Tabs activeKey={activeKey} className="excelout-verify-card-box" onChange={this.tabchange}>
          {card.intertype === 'system' ? <TabPane tab="基础验证" key="setting">
@@ -932,14 +974,14 @@
              {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null}
            </span>
          } key="columns">
            <ColumnForm dict={this.props.dict} columnChange={this.columnChange}/>
            <ColumnForm columnChange={this.columnChange}/>
            <Button className="excel-col-add mk-green" title="添加显示列字段" onClick={this.columnFieldInput}>
              同步显示列
            </Button>
            <Button className="excel-col-add mk-red" title="清空Excel列" onClick={this.clearField}>
              清空Excel列
            </Button>
            <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>如需导出序号,请使用字段 $Index。</div>
            <div style={{color: '#959595', fontSize: '13px', paddingLeft: '10px'}}>如需导出序号,请使用字段 $Index;数值类型导出时可进行数据处理(取绝对值、保留小数位)。</div>
            <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" wrappedComponentRef={(inst) => this.columnRef = inst} data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
          </TabPane>
          {card.intertype === 'system' ? <TabPane tab={
@@ -947,7 +989,7 @@
              自定义脚本
              {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
            </span>
          } key="scripts" disabled={verify.dataType !== 'custom'}>
          } key="scripts" disabled={verify.dataType !== 'custom'} id="mk-exout-script">
            <CustomScript
              btn={card}
              sheet={verify.tableName}
@@ -983,7 +1025,7 @@
                      rules: [
                        {
                          required: true,
                          message: this.props.dict['form.required.input'] + 'sql!'
                          message: '请输入sql!'
                        }
                      ]
                    })(<CodeMirror />)}