| | |
| | | import moment from 'moment' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Button, Modal, notification, message, Drawer, Icon } from 'antd' |
| | | import { Button, Modal, notification, message, Drawer, Switch, Checkbox } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import Utils, { getSysDefaultSql } from '@/utils/utils.js' |
| | |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import { updateForm } from '@/utils/utils-update.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import MkIcon from '@/components/mk-icon' |
| | | // import './index.scss' |
| | | |
| | | const MutilForm = asyncSpinComponent(() => import('@/tabviews/zshare/mutilform')) |
| | |
| | | columns: PropTypes.any, // 字段列 |
| | | setting: PropTypes.any, // 页面通用设置 |
| | | ContainerId: PropTypes.any, // tab页面ID,用于弹窗控制 |
| | | disabled: PropTypes.any, // 行按钮禁用 |
| | | lineId: PropTypes.any, // 行索引+主键值,用于行按钮双击 |
| | | } |
| | | |
| | | state = { |
| | |
| | | disabled: false, |
| | | hidden: false, |
| | | checkParam: null, |
| | | autoMatic: false |
| | | autoMatic: false, |
| | | check: false |
| | | } |
| | | |
| | | moduleParams = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { btn, selectedData } = this.props |
| | | const { btn, selectedData, BData } = this.props |
| | | let disabled = false |
| | | |
| | | if (btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | |
| | | disabled = true |
| | | } |
| | | }) |
| | | this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) |
| | | this.setState({hidden: disabled && btn.control === 'hidden'}) |
| | | } else if (btn.control === 'parent') { |
| | | if (!BData || !BData.hasOwnProperty(btn.controlField)) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | let s = BData[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | this.setState({hidden: false}) |
| | | } |
| | | } |
| | | } |
| | | if (this.props.disabled || disabled) { |
| | | this.setState({disabled: true}) |
| | | } |
| | | |
| | | if (btn.OpenType === 'form') { |
| | | let data = selectedData && selectedData[0] ? selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { btn, selectedData } = this.props |
| | | const { btn, selectedData, BData } = this.props |
| | | |
| | | let disabled = false |
| | | if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) { |
| | | let disabled = false |
| | | |
| | | if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制 |
| | | nextProps.selectedData.forEach(item => { |
| | | let s = item[btn.controlField] + '' |
| | |
| | | } |
| | | }) |
| | | } |
| | | this.setState({disabled, hidden: disabled && btn.control === 'hidden'}) |
| | | this.setState({hidden: disabled && btn.control === 'hidden'}) |
| | | } else if (btn.control === 'parent' && !is(fromJS(nextProps.BData || {}), fromJS(BData || {}))) { |
| | | if (!nextProps.BData || !nextProps.BData.hasOwnProperty(btn.controlField)) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | let s = nextProps.BData[btn.controlField] + '' |
| | | if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) { |
| | | this.setState({hidden: true}) |
| | | } else { |
| | | this.setState({hidden: false}) |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (nextProps.disabled || disabled) { |
| | | this.setState({disabled: true}) |
| | | } else { |
| | | this.setState({disabled: false}) |
| | | } |
| | | |
| | | if (btn.OpenType === 'form') { |
| | | let data = nextProps.selectedData && nextProps.selectedData[0] ? nextProps.selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | | } |
| | | |
| | |
| | | const { Tab, BID, btn, selectedData, setting } = this.props |
| | | const { loading, disabled } = this.state |
| | | |
| | | if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return |
| | | if (loading || disabled) return |
| | | if (triggerId) { |
| | | if (btn.uuid !== triggerId) return |
| | | if (this.props.lineId && record && record[0] && this.props.lineId !== record[0].$$key) { |
| | | return |
| | | } |
| | | } |
| | | |
| | | if (((Tab && Tab.supMenu) || setting.supModule) && !BID) { |
| | | notification.warning({ |
| | |
| | | }, () => { |
| | | this.improveAction() |
| | | }) |
| | | } else if (btn.OpenType === 'form') { |
| | | this.setState({ |
| | | loading: true, |
| | | check: !this.state.check |
| | | }, () => { |
| | | let type = 'text' |
| | | let fieldlen = 50 |
| | | let value = this.state.check ? btn.openVal : btn.closeVal |
| | | |
| | | if (typeof(value) === 'number') { |
| | | type = 'number' |
| | | fieldlen = 0 |
| | | } |
| | | |
| | | let item = { |
| | | type: type, |
| | | readonly: false, |
| | | readin: true, |
| | | writein: true, |
| | | fieldlen: fieldlen, |
| | | key: btn.field, |
| | | value: value |
| | | } |
| | | this.execSubmit(data, () => { this.setState({loading: false})}, [item]) |
| | | }) |
| | | } |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 表单 |
| | | } else if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 表单 |
| | | if (btn.sqlType === 'insert') { // 系统函数添加时,生成uuid |
| | | primaryId = '' |
| | | |
| | |
| | | param[setting.primaryKey] = primaryId // 设置主键参数 |
| | | } |
| | | |
| | | if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') { // 表单 |
| | | if (btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') { // 表单 |
| | | formdata.forEach(_data => { |
| | | param[_data.key] = _data.value |
| | | }) |
| | |
| | | param.BID = this.props.BID |
| | | } |
| | | |
| | | if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit') && formdata) { // 表单 |
| | | if ((btn.OpenType === 'pop' || btn.OpenType === 'formSubmit' || btn.OpenType === 'form') && formdata) { // 表单 |
| | | formdata.forEach(_data => { |
| | | param[_data.key] = _data.value |
| | | }) |
| | |
| | | |
| | | if (btn.execSuccess === 'closetab') { |
| | | MKEmitter.emit('closeTabView', btn.$MenuID) |
| | | } else if (btn.execSuccess === 'closepoptab') { |
| | | MKEmitter.emit('popclose') |
| | | } else if (btn.execSuccess !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, id, this.state.selines) |
| | | } |
| | |
| | | MKEmitter.emit('mkFC', 'focus', btnconfig.setting.errFocus) |
| | | } |
| | | |
| | | if (btn.execError !== 'never') { |
| | | if (btn.execError === 'closepoptab') { |
| | | MKEmitter.emit('popclose') |
| | | } else if (btn.execError !== 'never') { |
| | | MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines) |
| | | } else if (btn.OpenType === 'form') { |
| | | let data = this.props.selectedData && this.props.selectedData[0] ? this.props.selectedData[0] : null |
| | | this.setState({check: data && data[btn.field] === btn.openVal}) |
| | | } |
| | | } |
| | | |
| | |
| | | const { btnconfig, autoMatic } = this.state |
| | | |
| | | if (btnconfig) { |
| | | if (!autoMatic && btnconfig.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && (btnconfig.setting.display === 'prompt' || btnconfig.setting.display === 'exec')) { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | this.setState({ |
| | | btnconfig: _LongParam |
| | | }, () => { |
| | | if (!autoMatic && _LongParam.setting.display === 'prompt') { // 如果表单以是否框展示 |
| | | if (!autoMatic && (_LongParam.setting.display === 'prompt' || _LongParam.setting.display === 'exec')) { // 如果表单以是否框展示 |
| | | this.modelconfirm() |
| | | } else { |
| | | this.setState({ |
| | |
| | | }) |
| | | }) |
| | | |
| | | confirm({ |
| | | title: this.state.dict['main.action.confirm.tip'], |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(selines, resolve, result) |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | _this.setState({ loading: false }) |
| | | } |
| | | }) |
| | | if (btnconfig.setting.display === 'exec') { |
| | | this.execSubmit(selines, () => {}, result) |
| | | } else { |
| | | confirm({ |
| | | title: this.state.dict['main.action.confirm.tip'], |
| | | onOk() { |
| | | return new Promise(resolve => { |
| | | _this.execSubmit(selines, resolve, result) |
| | | }) |
| | | }, |
| | | onCancel() { |
| | | _this.setState({ loading: false }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | if (!btnconfig || !btnconfig.setting) return null |
| | | |
| | | let title = btnconfig.setting.title |
| | | let width = btnconfig.setting.width + 'vw' |
| | | let width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vw' |
| | | let clickouter = btnconfig.setting.clickouter === 'close' |
| | | |
| | | if (btnconfig.setting.display === 'drawer') { |
| | | let height = '100vh' |
| | | if (btnconfig.setting.placement === 'top' || btnconfig.setting.placement === 'bottom') { |
| | | width = '100vw' |
| | | height = btnconfig.setting.width + 'vh' |
| | | height = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + 'vh' |
| | | } |
| | | return ( |
| | | <Drawer |
| | |
| | | (setting.tabType === 'main' && btnconfig.setting.container === 'tab' && this.props.ContainerId) || |
| | | (btnconfig.setting.container === 'tab' && btn.ContainerId) |
| | | ) { |
| | | width = btnconfig.setting.width + '%' |
| | | width = btnconfig.setting.width > 100 ? btnconfig.setting.width : btnconfig.setting.width + '%' |
| | | container = () => document.getElementById(this.props.ContainerId || btn.ContainerId) |
| | | } |
| | | return ( |
| | |
| | | |
| | | render() { |
| | | const { btn, show, style } = this.props |
| | | const { loadingNumber, loading, disabled, hidden } = this.state |
| | | const { loadingNumber, loading, disabled, hidden, check } = this.state |
| | | |
| | | if (hidden) return null |
| | | |
| | | if (show === 'actionList') { |
| | | if (btn.OpenType === 'form') { |
| | | if (btn.formType === 'switch') { |
| | | return <Switch loading={loading} checked={check} disabled={disabled || loading} onChange={(val,e) => {e.stopPropagation();this.actionTrigger()}} style={style} size={btn.size} checkedChildren={btn.openText || ''} unCheckedChildren={btn.closeText || ''}/> |
| | | } else { |
| | | return <Checkbox disabled={disabled || loading} checked={check} onChange={(e) => {e.stopPropagation();this.actionTrigger()}} style={style}></Checkbox> |
| | | } |
| | | } else if (show === 'actionList') { |
| | | return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}> |
| | | <Button |
| | | style={style} |
| | |
| | | label = btn.label |
| | | icon = btn.icon || '' |
| | | } else if (show === 'link') { |
| | | label = <span>{btn.label}{btn.icon ? <Icon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> |
| | | label = <span>{btn.label}{btn.icon ? <MkIcon style={{marginLeft: '8px'}} type={btn.icon}/> : ''}</span> |
| | | icon = '' |
| | | } else if (show === 'icon') { |
| | | icon = btn.icon || '' |
| | | // } else if (show === 'text') { |
| | | } else { |
| | | label = btn.label |
| | | } |