king
2025-03-21 fdce913ce7b9d55c34a2abd7a94ee377a4869b9a
2025-03-21
5个文件已修改
2个文件已添加
540 ■■■■■ 已修改文件
src/menu/components/share/pastecomponent/index.jsx 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/pasteforms/index.jsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/actioncomponent/index.jsx 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/sharecomponent/searchcomponent/index.jsx 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/transystem/index.jsx 430 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/transystem/index.scss 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/pastecomponent/index.jsx
@@ -121,9 +121,44 @@
    return item
  }
  extra = (res) => {
    let config = fromJS(this.props.config).toJS()
    if (res.copyType === 'mk_actions') {
      config.action = res.action
      this.props.updateConfig(config)
      setTimeout(() => {
        MKEmitter.emit('revertBtn', config.uuid)
      }, 30)
    } else if (res.copyType === 'mk_searches') {
      config.search = res.search
      this.props.updateConfig(config)
      setTimeout(() => {
        MKEmitter.emit('revert', config.uuid, 'search')
      }, 30)
    } else if (res.copyType === 'mk_fields') {
      config.columns = res.columns
      this.props.updateConfig(config)
    } else if (res.copyType === 'mk_cols') {
      config.cols = res.cols
      this.props.updateConfig(config)
    } else if (res.copyType === 'mk_setting') {
      config.setting = res.setting
      this.props.updateConfig(config)
    }
    console.log(config)
    this.setState({visible: false})
  }
  pasteSubmit = () => {
    const { options } = this.props
    this.pasteFormRef.handleConfirm().then(res => {
      if (/^mk_/.test(res.copyType)) { // dms-trans
        this.extra(res)
        return
      }
      if (!options.includes(res.copyType)) {
        notification.warning({ top: 92, message: '配置信息格式错误!', duration: 5 })
        return
src/menu/components/share/pasteforms/index.jsx
@@ -26,6 +26,12 @@
    const { config } = this.props
    this.pasteFormRef.handleConfirm().then(res => {
      if (res.copyType === 'mk_forms') { // dms-trans
        this.props.update(res.fields, res)
        this.setState({visible: false})
        return
      }
      if (res.copyType === 'search' && ['text', 'select', 'multiselect', 'link', 'checkcard', 'date', 'datemonth'].includes(res.type)) {
        res.copyType = 'form'
      }
src/router/index.js
@@ -27,6 +27,7 @@
// const SystemCheck = asyncLoadComponent(() => import('@/views/syscheck'))
const MkIframe = asyncLoadComponent(() => import('@/views/mkiframe'))
// const MkAi = asyncLoadComponent(() => import('@/views/mkai'))
const TranSystem = asyncLoadComponent(() => import('@/views/transystem'))
const routers = [
  {path: '/login', name: 'login', component: Login},
@@ -56,6 +57,7 @@
  {path: '/view/:menuId', name: 'iframe', component: MkIframe},
  {path: '/view/:menuId/:bid', name: 'iframe', component: MkIframe},
  {path: '/interface', name: 'interface', component: Interface},
  {path: '/trans', name: 'trans', component: TranSystem},
  // {path: '/ai', name: 'ai', component: MkAi},
  // {path: '/syscheck', name: 'syscheck', component: SystemCheck}
]
src/templates/sharecomponent/actioncomponent/index.jsx
@@ -53,15 +53,17 @@
  componentDidMount () {
    this.getBillPrintTemp()
    // MKEmitter.addListener('revert', this.revert)
    MKEmitter.addListener('revert', this.revert)
    MKEmitter.addListener('pasteButton', this.pasteButton)
  }
  // dms-trans
  revert = (id, type) => {
    if (id !== this.props.config.uuid || type !== 'action') return
  // revert = () => {
  //   this.setState({
  //     actionlist: fromJS(this.props.config.action).toJS()
  //   })
  // }
    this.setState({
      actionlist: fromJS(this.props.config.action).toJS()
    })
  }
  pasteButton = (MenuId, btn) => {
    const { config } = this.props
@@ -384,7 +386,7 @@
    this.setState = () => {
      return
    }
    // MKEmitter.removeListener('revert', this.revert)
    MKEmitter.removeListener('revert', this.revert)
    MKEmitter.removeListener('pasteButton', this.pasteButton)
  }
src/templates/sharecomponent/searchcomponent/index.jsx
@@ -42,12 +42,15 @@
  componentDidMount () {
    MKEmitter.addListener('plusSearch', this.plusSearch)
    // MKEmitter.addListener('revert', this.revert)
    MKEmitter.addListener('revert', this.revert)
  }
  // revert = () => {
  //   this.setState({searchlist: fromJS(this.props.config.search).toJS()})
  // }
   // dms-trans
  revert = (id, type) => {
    if (id !== this.props.config.uuid || type !== 'search') return
    this.setState({searchlist: fromJS(this.props.config.search).toJS()})
  }
  plusSearch = (MenuId, item, type) => {
    const { config } = this.props
@@ -319,7 +322,7 @@
    this.setState = () => {
      return
    }
    // MKEmitter.removeListener('revert', this.revert)
    MKEmitter.removeListener('revert', this.revert)
    MKEmitter.removeListener('plusSearch', this.plusSearch)
  }
src/views/transystem/index.jsx
New file
@@ -0,0 +1,430 @@
import React, { Component } from 'react'
import { Input, Button, message } from 'antd'
import Utils from '@/utils/utils.js'
import './index.scss'
const { TextArea } = Input
class MkTrans extends Component {
  state = {
    type: '',
    value: null,
    textInput: ''
  }
  changeVal = (e) => {
    this.setState({textInput: e.target.value})
  }
  changeType = (type) => {
    if (!this.state.type) {
      this.setState({type: type, value: null})
    } else {
      this.setState({type: type, textInput: '', value: null})
    }
  }
  trans = () => {
    const { type, textInput } = this.state
    if (!type) {
      message.error('请选择转化类型!')
      return
    }
    let result = ''
    if (type === 'mk_searches') {
      let list = JSON.parse(textInput)
      if (list.rows) {
        list = list.rows
      }
      result = []
      list.forEach(item => {
        let cell = {
          uuid: Utils.getuuid(),
          label: item.Label,
          match: ['like', 'not like', '=', '>', '<', '>=', '<='].includes(item.Op) ? item.Op : '',
          field: item.FieldName.toLowerCase(),
          initval: '',
          ratio: 6,
          type: 'text'
        }
        // options
        // resourceType
        // orderType
        result.push(cell)
      })
      result = JSON.stringify(result)
    } else if (type === 'mk_actions') {
      let list = JSON.parse(textInput)
      if (list.rows) {
        list = list.rows
      }
      result = []
      list.forEach(item => {
        if (item.IsButton !== '1') return
        let cell = {
          uuid: Utils.getuuid(),
          label: item.MenuName,
          show: 'button',
          execError: 'never',
          execSuccess: 'grid',
          Ot: 'required',
          class: 'primary',
          verify: null
        }
        // if (item.ReloadForm === 'grid') {
        //   cell.execSuccess = 'grid'
        // }
        if (/添加/.test(cell.label)) {
          cell.Ot = 'notRequired'
          cell.class = 'green'
        } else if (/修改/.test(cell.label)) {
          cell.Ot = 'requiredSgl'
          cell.class = 'purple'
        } else if (/删除/.test(cell.label)) {
          cell.class = 'danger'
        } else if (/导入/.test(cell.label)) {
          cell.Ot = 'notRequired'
          cell.class = 'border-dgreen'
        } else if (/导出/.test(cell.label)) {
          cell.Ot = 'requiredOnce'
          cell.class = 'dgreen'
        }
        if (item.Action === 'PopDlg') {
          cell.OpenType = 'pop'
        }
        if (item.TableName) {
          cell.sql = item.TableName
        }
        if (['pop', 'prompt', 'exec'].includes(cell.OpenType)) {
          if (/添加/.test(cell.label)) {
            cell.sqlType = 'insert'
          } else if (/修改/.test(cell.label)) {
            cell.sqlType = 'update'
          } else if (/删除/.test(cell.label)) {
            cell.sqlType = 'LogicDelete'
          }
          if (!cell.sqlType) {
            if (cell.OpenType === 'pop') {
              cell.sqlType = 'audit'
            } else {
              cell.sqlType = 'custom'
            }
          }
        }
        if (cell.class) {
          let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#E7E7EF', default: 'rgba(0, 0, 0, 0.65)' }
          let _c = cell.class.replace('border-', '')
          if (cell.class === 'default') {
            cell.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: '#fff', borderColor: '#d9d9d9', marginRight: '15px'}
          } else if (cell.class.indexOf('border') > -1) {
            cell.style = {color: color[_c], backgroundColor: '#fff', borderColor: color[_c], marginRight: '15px'}
          } else if (cell.class === 'gray') {
            cell.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: color[_c], borderColor: color[_c], marginRight: '15px'}
          } else {
            cell.style = {color: '#fff', backgroundColor: color[_c], borderColor: color[_c], marginRight: '15px'}
          }
        }
        result.push(cell)
      })
      result = JSON.stringify(result)
    } else if (type === 'mk_setting') {
      let list = JSON.parse(textInput)
      let data = list.rows[0]
      let tb = data.QueryFrom
      let id = data.TableID ? data.TableID.toLowerCase() : 'id'
      let order = ''
      if (data.SortName) {
        order = data.SortName.toLowerCase() + ' ' + (data.SortOrder || 'desc')
      }
      if (/^[a-zA-Z0-9_]+$/.test(data.QueryFrom)) {
        tb = 'select * from @db@' + data.QueryFrom
      }
      if (tb && data.AppendWhere) {
        tb += ` where ${data.AppendWhere.replace(/^\s*\(|\)\s*$/g, '')}`
      }
      result = {
        tableName: '@db@' + data.TableName,
        interType: 'system',
        queryType: 'query',
        execute: 'true',
        laypage: 'true',
        pageSize: 10,
        supModule: ['empty'],
        primaryKey: id,
        order: order,
        sync: 'false',
        useMSearch: 'false',
        onload: 'true',
        dataresource: tb
      }
      result = JSON.stringify(result)
    } else if (type === 'mk_fields') {
      let list = JSON.parse(textInput)
      if (list.rows) {
        list = list.rows
        list.reverse()
      }
      result = []
      list.forEach(item => {
        let cell = {
          uuid: Utils.getuuid(),
          label: item.Label,
          field: item.FieldName.toLowerCase(),
          datatype: 'Nvarchar(50)',
        }
        if (item.Type === 'text') {
          if (cell.field === 'description') {
            cell.datatype = 'Nvarchar(100)'
          } else if (['remark', 'address'].includes(cell.field)) {
            cell.datatype = 'Nvarchar(256)'
          }
        } else if (item.Type === 'number') {
          cell.datatype = 'Int'
        }
        if (/int/ig.test(cell.datatype)) {
          cell.type = 'number'
          cell.decimal = 0
        } else {
          cell.type = 'text'
          cell.fieldlength = +cell.datatype.replace(/^Nvarchar\(/ig, '').replace(/\)/ig, '')
        }
        result.push(cell)
      })
      result = JSON.stringify(result)
    } else if (type === 'mk_cols') {
      let list = JSON.parse(textInput)
      if (list.rows) {
        list = list.rows
        list.reverse()
      }
      result = []
      list.forEach(item => {
        if (item.Hide === 'true') return
        let cell = {
          uuid: Utils.getuuid(),
          label: item.Label,
          field: item.FieldName.toLowerCase(),
          Hide: 'false',
          Align: item.Align || 'left',
          IsSort: item.IsSort || 'false',
          type: 'text',
          Width: 120
        }
        if (item.Type === 'text') {
          cell.textFormat = 'none'
        } else if (item.Type === 'number') {
          cell.type = 'number'
          cell.Width = 80
          cell.decimal = 0
          cell.format = 'none'
        }
        result.push(cell)
      })
      result = JSON.stringify(result)
    } else if (type === 'mk_forms') {
      let list = JSON.parse(textInput)
      if (list.rows) {
        list = list.rows
        // list.reverse()
      }
      result = []
      list.forEach(item => {
        let cell = {
          uuid: Utils.getuuid(),
          label: item.Label,
          field: item.FieldName.toLowerCase(),
          initval: item.DefaultVal || '',
          type: 'text',
          span: 12,
          labelwidth: 33.3,
          decimal: 0,
          fieldlength: 50,
          readonly: 'false',
          required: 'true',
          hidden: 'false',
          readin: 'top'
        }
        if (cell.field === 'description') {
          cell.fieldlength = 100
        } else if (['remark', 'address'].includes(cell.field)) {
          cell.fieldlength = 256
        }
        if (item.Hide === 'true') {
          cell.hidden = 'true'
        }
        if (item.ReadOnly === 'true') {
          cell.readonly = 'true'
        }
        if (item.InputType === 'text') {
          if (item.Validate && /required:\s?true/.test(item.Validate)) {
            cell.required = 'true'
          } else {
            cell.required = 'false'
          }
        } else if (item.InputType === 'select') {
          if (item.Validate && /required:\s?true/.test(item.Validate)) {
            cell.required = 'true'
          } else {
            cell.required = 'false'
          }
          cell.type = 'select'
          cell.resourceType = '1'
          cell.valueField = item.IdField
          cell.valueText = item.TextField
          cell.dataSource = item.FromField
          cell.orderBy = item.OrderField || ''
          cell.orderType = 'asc'
          cell.options = []
          if (cell.dataSource) {
            cell.dataSource = `select * from @db@${cell.dataSource}`
            if (item.WhereField) {
              cell.dataSource += ' where ' + item.WhereField.replace(/^\s*\(|\)\s*$/g, '')
            }
          }
          if (item.Multi === 'true') {
            cell.type = 'multiselect'
          }
        }
        result.push(cell)
      })
      result = JSON.stringify(result)
    } else if (type === 'mk_func') {
      let res = JSON.parse(textInput)
      result = ''
      if (res.getproc) {
        result = res.getproc[0].Ltext
      }
      result = result.replace(/mchr13k/g, '\n')
      result = result.replace(/\t|\v/g, ' ')
      result = result.replace(/--[^\n]+\n/g, (w) => {
        w = w.replace(/-{2,10}/, '/* ')
        w = w.replace(/\n/, ' */\n')
        return w
      })
      // result = result.replace(/\n+/g, '\n')
    }
    this.setState({value: result})
  }
  copy = () => {
    const { type, value } = this.state
    if (!type || !value) return
    if (type === 'mk_func') {
      try {
        navigator.clipboard.writeText(value)
        message.success('复制成功。')
      } catch (err) {
        console.error('Failed to copy: ', err)
        message.error('复制失败!')
      }
      return
    }
    let val = {copyType: type}
    let vals = JSON.parse(value)
    if (type === 'mk_setting') {
      val.setting = vals
    } else if (type === 'mk_searches') {
      val.search = vals
    } else if (type === 'mk_actions') {
      val.action = vals
    } else if (type === 'mk_forms') {
      val.fields = vals
    } else if (type === 'mk_fields') {
      val.columns = vals
    } else if (type === 'mk_cols') {
      val.cols = vals
    }
    try {
      navigator.clipboard.writeText(window.btoa(window.encodeURIComponent(JSON.stringify(val))))
      message.success('复制成功。')
    } catch (err) {
      console.error('Failed to copy: ', err)
      message.error('复制失败!')
    }
  }
  render () {
    const { textInput, value, type } = this.state
    return (
      <div className="mk-trans-wrap">
        <div className="mk-trans-type">
          <Button className={type === 'mk_searches' ? 'active' : ''} onClick={() => this.changeType('mk_searches')}>搜索条件</Button>
          <Button className={type === 'mk_actions' ? 'active' : ''} onClick={() => this.changeType('mk_actions')}>按钮</Button>
          <Button className={type === 'mk_forms' ? 'active' : ''} onClick={() => this.changeType('mk_forms')}>表单</Button>
          <Button className={type === 'mk_fields' ? 'active' : ''} onClick={() => this.changeType('mk_fields')}>字段集</Button>
          <Button className={type === 'mk_cols' ? 'active' : ''} onClick={() => this.changeType('mk_cols')}>显示列</Button>
          <Button className={type === 'mk_setting' ? 'active' : ''} onClick={() => this.changeType('mk_setting')}>数据源</Button>
          <Button className={type === 'mk_func' ? 'active' : ''} onClick={() => this.changeType('mk_func')}>存储过程</Button>
        </div>
        <div className="input-wrap">
          <Button onClick={this.trans}>转换</Button>
          <TextArea value={textInput} autoSize={{minRows: 10, maxRows: 10}} onChange={this.changeVal}/>
        </div>
        <div className="result-wrap">
          <Button onClick={this.copy}>复制</Button>
          <div className="result">{value}</div>
        </div>
      </div>
    )
  }
}
export default MkTrans
src/views/transystem/index.scss
New file
@@ -0,0 +1,38 @@
.mk-trans-wrap {
  padding: 30px 10vw 0px;
  .mk-trans-type {
    margin-bottom: 20px;
    .ant-btn {
      margin-right: 20px;
    }
    .ant-btn.active {
      margin-right: 20px;
      color: #ffffff;
      border: 1px solid #1890ff;
      background-color: #1890ff;
    }
  }
  .input-wrap {
    text-align: right;
    margin-bottom: 20px;
    .ant-btn {
      margin-bottom: 10px;
    }
    .ant-input {
      text-align: left;
    }
  }
  .result-wrap {
    text-align: right;
    .ant-btn {
      margin-bottom: 10px;
    }
    .result {
      text-align: left;
      border: 1px solid #1890ff;
      min-height: 200px;
      padding: 5px;
    }
  }
}