king
2024-04-10 8a1ee7d651500f848a3c2f05c7fe3be2b7114a43
src/menu/components/card/cardcellcomponent/index.jsx
@@ -1,15 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Modal, Button, notification } from 'antd'
import { Modal, Button } from 'antd'
import moment from 'moment'
import Api from '@/api'
import asyncComponent from '@/utils/asyncComponent'
import { getCardCellForm } from './formconfig'
import { queryPrintSql } from '@/utils/option.js'
import { getActionForm, getBaseTableActionForm } from '@/menu/components/share/actioncomponent/formconfig'
import Utils, { FuncUtils } from '@/utils/utils.js'
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
import ElementForm from './elementform'
@@ -27,11 +24,12 @@
class CardCellComponent extends Component {
  static propTpyes = {
    cards: PropTypes.object,         // 菜单配置信息
    cards: PropTypes.object,
    cardCell: PropTypes.object,
    side: PropTypes.string,
    elements: PropTypes.array,       // 元素集
    updateElement: PropTypes.func    // 菜单配置更新
    timestamp: PropTypes.any,
    elements: PropTypes.array,
    updateElement: PropTypes.func
  }
  state = {
@@ -77,7 +75,7 @@
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    if (this.props.side !== nextProps.side && nextProps.side) {
    if (this.props.timestamp !== nextProps.timestamp && nextProps.timestamp) {
      this.setState({
        elements: fromJS(nextProps.elements).toJS()
      })
@@ -172,7 +170,7 @@
      options = ['padding', 'margin']
    }
    if (element.eleType !== 'button') {
    if (element.eleType !== 'button' && element.eleType !== 'tag') {
      options.push('position')
    }
@@ -248,6 +246,10 @@
    } else if (_card.eleType === 'picture') {
      _card.style = style
      delete _card.style.backgroundImage
      delete _card.style.paddingTop
      delete _card.style.paddingBottom
      delete _card.style.paddingLeft
      delete _card.style.paddingRight
    } else {
      _card.style = style
    }
@@ -313,67 +315,25 @@
        supId = ''
      }
    }
    let menu = window.GLOB.customMenu
    let modules = MenuUtils.getSubModules(window.GLOB.customMenu.components, cards.uuid, supId)
    let modules = MenuUtils.getSubModules(menu.components, cards.uuid, supId, menu.interfaces || null)
    this.checkPrintTemp().then(() => {
      if (cards.subtype === 'basetable') {
        this.setState({
          actvisible: true,
          card: card,
          formlist: getBaseTableActionForm(card, functip, cards, usefulFields, modules)
        })
      } else {
        let anchors = MenuUtils.getAnchors(window.GLOB.customMenu.components, cards.uuid) || []
        this.setState({
          actvisible: true,
          card: card,
          formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors, side)
        })
      }
    })
  }
    if (cards.subtype === 'basetable') {
      this.setState({
        actvisible: true,
        card: card,
        formlist: getBaseTableActionForm(card, functip, cards, usefulFields, modules, 'line')
      })
    } else {
      let anchors = MenuUtils.getAnchors(menu.components, cards.uuid) || []
  checkPrintTemp = () => {
    return new Promise(resolve => {
      if (!window.GLOB.printTemps) {
        let param = {
          func: 'sPC_Get_SelectedList',
          LText: Utils.formatOptions(queryPrintSql),
          obj_name: 'data',
          arr_field: 'PN,ID,Images'
        }
        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
        param.secretkey = Utils.encrypt(param.LText, param.timestamp)
        param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
        Api.getCloudConfig(param).then(res => {
          if (!res.status) {
            notification.warning({
              top: 92,
              message: res.message,
              duration: 5
            })
          }
          let temps = (res.data || []).map(temp => {
            return {
              value: temp.ID,
              text: temp.PN
            }
          })
          window.GLOB.printTemps = temps
          resolve()
        }, () => {
          resolve()
        })
      } else {
        resolve()
      }
    })
      this.setState({
        actvisible: true,
        card: card,
        formlist: getActionForm(card, functip, cards, usefulFields, modules, anchors, side, 'line')
      })
    }
  }
  /**
@@ -460,6 +420,25 @@
            res.innerHeight = res.barHeight + (res.displayValue === 'true' ? fontSize + 2 : 0)
          } else if (res.eleType === 'picture') {
            delete res.style.backgroundImage
            delete res.style.paddingTop
            delete res.style.paddingBottom
            delete res.style.paddingLeft
            delete res.style.paddingRight
          } else if (res.eleType === 'tag') {
            delete res.style.position
            if (cell.eleType !== 'tag') {
              res.style = {
                backgroundColor: 'var(--mk-sys-color1)',
                color: 'var(--mk-sys-color)',
                borderColor: 'var(--mk-sys-color)',
                borderWidth: '1px',
                borderRadius: '4px',
                paddingLeft: '7px',
                paddingRight: '7px',
                marginRight: '8px',
                marginBottom: '8px',
              }
            }
          }
          
          return res
@@ -484,6 +463,13 @@
    let color = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#666666', default: 'rgba(0, 0, 0, 0.65)' }
    this.actionFormRef.handleConfirm().then(res => {
      if (res.width % 0.5) {
        res.width = parseInt(res.width / 0.5) * 0.5
      }
      if (res.width % 1) {
        res.width = (res.width + '').replace(/.5/, 'x')
      }
      let _elements = elements.map(cell => {
        if (cell.uuid === res.uuid) {
          res.eleType = cell.eleType || null
@@ -494,25 +480,38 @@
            if (cell.OpenType !== 'form') {
              res.style = {}
            }
          } else if (res.class !== cell.class || res.show !== cell.show || !res.style) {
            let cl = res.class.replace('border-', '')
            let style = {}
            if (res.show === 'link' || res.show === 'icon') {
              style.color = color[cl]
              style.backgroundColor = 'transparent'
            } else if (res.class === 'default') {
              style.color = 'rgba(0, 0, 0, 0.65)'
              style.backgroundColor = '#fff'
              style.borderColor = '#d9d9d9'
            } else if (res.class.indexOf('border') > -1) {
              style.color = color[cl]
              style.backgroundColor = '#fff'
              style.borderColor = color[cl]
          // } else if (res.class !== cell.class || res.show !== cell.show || !res.style) {
          } else if (res.class !== cell.class || !res.style) {
            if (res.class) {
              let cl = res.class.replace('border-', '')
              let style = {}
              if (res.class === 'default') {
                style.color = 'rgba(0, 0, 0, 0.65)'
                style.backgroundColor = 'transparent'
                style.borderColor = '#d9d9d9'
              } else if (res.class.indexOf('border') > -1) {
                style.color = color[cl]
                style.backgroundColor = 'transparent'
                style.borderColor = color[cl]
              } else {
                style.color = '#ffffff'
                style.backgroundColor = color[cl]
              }
              res.style = {...res.style, ...style}
            } else {
              style.color = '#ffffff'
              style.backgroundColor = color[cl]
              res.style = res.style || {}
            }
            res.style = {...res.style, ...style}
          }
          if (res.width === 0 && cell.width !== 0) {
            res.style = res.style || {}
            res.style.paddingLeft = '15px'
            res.style.paddingRight = '15px'
            res.style.marginRight = '15px'
            res.style.width = 'auto'
            delete res.style.marginLeft
          }
          res.updateTime = moment().format('YYYY-MM-DD HH:mm')
@@ -705,47 +704,47 @@
   * @description 创建按钮存储过程
   */
  creatFunc = () => {
    const { cards } = this.props
    const menu = window.GLOB.customMenu
    let _config = fromJS(this.props.cards).toJS()
    this.actionFormRef.handleConfirm().then(res => {
      let btn = res         // 按钮信息
      let newLText = ''     // 创建存储过程sql
      let DelText = ''      // 删除存储过程sql
    return new Promise((resolve) => {
      this.actionFormRef.handleConfirm().then(res => {
        let btn = fromJS(res).toJS()
        let _config = fromJS(cards).toJS()
      if (btn.intertype !== 'inner') return
        if (btn.OpenType === 'excelIn') {
          btn.func = btn.innerFunc
          btn.menuNo = menu.MenuNo
          btn.MenuName = menu.MenuName + _config.name
          btn.$type = 'excelIn'
      if (btn.OpenType === 'pop') {
        let _param = {
          funcName: btn.innerFunc,
          name: _config.setting.tableName || '',
          fields: btn.modal ? btn.modal.fields : [],
          menuNo: menu.MenuNo
          resolve(btn)
        } else if (btn.OpenType === 'excelOut') {
          _config.MenuName = menu.MenuName + '-' + _config.name
          _config.menuNo = menu.MenuNo
          _config.MenuID = menu.MenuID
          _config.func = btn.innerFunc
          _config.$type = 'table'
          resolve(_config)
        } else {
          btn.func = btn.innerFunc
          btn.name = _config.setting.tableName || ''
          btn.menuNo = menu.MenuNo
          btn.MenuID = menu.MenuID
          btn.MenuName = menu.MenuName + _config.name
          btn.fields = []
          btn.columns = _config.columns
          btn.primaryKey = _config.setting.primaryKey || 'ID'
          btn.$type = 'btn'
          if (btn.OpenType === 'pop') {
            btn.fields = btn.modal ? btn.modal.fields : []
          }
          resolve(btn)
        }
        newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config))
        DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
      } else if (btn.OpenType === 'excelIn') {
        let _param = {
          funcName: btn.innerFunc,
          menuNo: menu.MenuNo
        }
        newLText = Utils.formatOptions(FuncUtils.getexcelInfunc(_param, btn, menu))
        DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
      } else if (btn.OpenType === 'excelOut') {
        newLText = Utils.formatOptions(FuncUtils.getTableFunc(btn.innerFunc, menu, _config)) // 创建存储过程sql
        DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
      } else {
        let _param = {
          funcName: btn.innerFunc,
          name: _config.setting.tableName || '',
          fields: '',
          menuNo: menu.MenuNo
        }
        newLText = Utils.formatOptions(FuncUtils.getfunc(_param, btn, menu, _config))
        DelText = Utils.formatOptions(FuncUtils.dropfunc(btn.innerFunc))
      }
      this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText)
      })
    })
  }
@@ -832,7 +831,7 @@
            maskClosable={false}
            onCancel={this.editModalCancel}
            footer={[
              record && record.intertype === 'inner' && cards.subtype === 'dualdatacard' ? <CreateFunc key="create" ref="btnCreatFunc" trigger={this.creatFunc}/> : null,
              record && record.intertype === 'inner' && cards.subtype === 'dualdatacard' ? <CreateFunc key="create" getMsg={this.creatFunc}/> : null,
              <Button key="cancel" onClick={this.editModalCancel}>取消</Button>,
              <Button key="confirm" type="primary" onClick={this.handleActionSubmit}>确定</Button>
            ]}