king
2020-10-29 944730f2794b87aa053f53084f0d082d4af6fd41
src/tabviews/custom/components/card/cardcellList/index.jsx
@@ -1,19 +1,31 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Button, Icon, Col, Tooltip } from 'antd'
import { Icon, Col, Tooltip, notification } from 'antd'
import zhCN from '@/locales/zh-CN/model.js'
import enUS from '@/locales/en-US/model.js'
import asyncComponent from './asyncButtonComponent'
import './index.scss'
const NormalButton = asyncComponent(() => import('@/tabviews/zshare/actionList/normalbutton'))
const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton'))
const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton'))
const PopupButton = asyncComponent(() => import('@/tabviews/zshare/actionList/popupbutton'))
const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
const ChangeUserButton = asyncComponent(() => import('@/tabviews/zshare/actionList/changeuserbutton'))
const PrintButton = asyncComponent(() => import('@/tabviews/zshare/actionList/printbutton'))
class CardCellComponent extends Component {
  static propTpyes = {
    BID: PropTypes.any,              // 上级ID
    cards: PropTypes.object,         // 菜单配置信息
    cardCell: PropTypes.object,
    data: PropTypes.object,
    elements: PropTypes.array,       // 元素集
    updateStatus: PropTypes.func,    // 状态更新
  }
  state = {
@@ -46,8 +58,38 @@
    }
  }
  openNewView = (card, url) => {
    const { cardCell, data, cards } = this.props
    if (!url) {
      notification.warning({
        top: 92,
        message: '地址链接不可为空!',
        duration: 5
      })
      return
    }
    let Id = ''
    let con = '?'
    if (/\?/ig.test(url)) {
      con = '&'
    }
    if (cards.subtype === 'propcard') {
      Id = cardCell.setting.primaryId || ''
    } else {
      Id = data[cards.setting.primaryKey] || ''
    }
    if (card.joint === 'true') {
      url = url + `${con}id=${Id}&appkey=${window.GLOB.appkey}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID') || ''}`
    }
    window.open(url)
  }
  getContent = (card) => {
    const { data } = this.props
    const { data, BID, cards } = this.props
    if (card.eleType === 'text' || card.eleType === 'number') {
      let val = ''
@@ -64,7 +106,29 @@
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>{val}</div>
          <div style={card.style}>
            <div className={'ant-mk-text line' + card.height} style={{height: card.innerHeight || 21}}>{val}</div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'link') {
      let url = ''
      if (card.datatype === 'static') {
        url = card.value
      } else if (data.hasOwnProperty(card.field)) {
        url = data[card.field]
      }
      let val = card.label || url
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div className={'ant-mk-text line' + card.height} style={{height: card.innerHeight || 21}}>
              <span style={{cursor: 'pointer'}} onClick={(e) => {e.stopPropagation(); this.openNewView(card, url)}}>{val}</span>
            </div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'icon') {
@@ -154,41 +218,140 @@
      return (
        <Col key={card.uuid} span={card.width}>
          <div style={card.style}>
            <div className="ant-mk-splitline" style={{backgroundColor: card.color}}></div>
            <div className="ant-mk-splitline" style={{borderColor: card.color}}></div>
          </div>
        </Col>
      )
    } else if (card.eleType === 'button') {
      if (card.show === 'icon') {
      if (['exec', 'prompt', 'pop'].includes(card.OpenType)) {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <Button className={'mk-link mk-' + card.class} style={card.btnstyle} type="link"><Icon type={card.icon}/></Button>
            </div>
          </Col>
        )
      } else if (card.show === 'link') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <Button className={'mk-link mk-' + card.class} style={card.btnstyle} type="link">{card.label}{card.icon ? <Icon type={card.icon}/> : null}</Button>
            </div>
          </Col>
        )
      } else {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <Button
                className={'mk-btn mk-' + card.class}
                icon={card.icon}
              <NormalButton
                BID={BID}
                btn={card}
                show={card.show}
                style={card.btnstyle}
              >
                {card.label}
              </Button>
                setting={cards.setting}
                columns={cards.columns}
                selectedData={[data]}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'excelIn') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <ExcelInButton
                BID={BID}
                btn={card}
                show={card.show}
                style={card.btnstyle}
                setting={cards.setting}
                selectedData={[data]}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'excelOut') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <ExcelOutButton
                BID={BID}
                btn={card}
                show={card.show}
                style={card.btnstyle}
                setting={cards.setting}
                // getexceloutparam={getexceloutparam}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'popview') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <PopupButton
                BID={BID}
                btn={card}
                show={card.show}
                style={card.btnstyle}
                setting={cards.setting}
                selectedData={[data]}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'tab') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <TabButton
                btn={card}
                show={card.show}
                style={card.btnstyle}
                setting={cards.setting}
                selectedData={[data]}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'innerpage') {
        return (
          <Col key={card.uuid} span={card.width}>
            <div style={card.style}>
              <NewPageButton
                btn={card}
                show={card.show}
                style={card.btnstyle}
                setting={cards.setting}
                selectedData={[data]}
                updateStatus={this.props.updateStatus}
              />
            </div>
          </Col>
        )
      } else if (card.OpenType === 'funcbutton') {
        if (card.funcType === 'changeuser') {
          return (
            <Col key={card.uuid} span={card.width}>
              <div style={card.style}>
                <ChangeUserButton
                  BID={BID}
                  btn={card}
                  show={card.show}
                  style={card.btnstyle}
                  setting={cards.setting}
                  selectedData={[data]}
                  updateStatus={this.props.updateStatus}
                />
              </div>
            </Col>
          )
        } else if (card.funcType === 'print') {
          return (
            <Col key={card.uuid} span={card.width}>
              <div style={card.style}>
                <PrintButton
                  BID={BID}
                  btn={card}
                  show={card.show}
                  style={card.btnstyle}
                  setting={cards.setting}
                  selectedData={[data]}
                  updateStatus={this.props.updateStatus}
                />
              </div>
            </Col>
          )
        }
      }
    }
  }