import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Icon, Tooltip, Modal, notification, Button } from 'antd'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import options from '@/store/options.js'
|
import Utils from '@/utils/utils.js'
|
import DevUtils from '@/utils/devutils.js'
|
import zhCN from '@/locales/zh-CN/model.js'
|
import enUS from '@/locales/en-US/model.js'
|
import { getActionForm } from '@/templates/zshare/formconfig'
|
|
import ActionForm from './actionform'
|
import VerifyCard from '@/templates/zshare/verifycard'
|
import CreateFunc from '@/templates/zshare/createfunc'
|
import CreateInterface from '@/templates/zshare/createinterface'
|
import VerifyPrint from './verifyprint'
|
import VerifyExcelIn from './verifyexcelin'
|
import VerifyExcelOut from './verifyexcelout'
|
import DragElement from './dragaction'
|
import './index.scss'
|
|
const { confirm } = Modal
|
|
class ActionComponent extends Component {
|
static propTpyes = {
|
type: PropTypes.string, // 菜单类型,主表或子表
|
menu: PropTypes.object, // 菜单信息(菜单id,菜单参数,菜单名称)
|
config: PropTypes.object, // 菜单配置信息
|
pasteContent: PropTypes.object, // 粘贴配置信息
|
usefulFields: PropTypes.array, // 自定义函数可用字段
|
tabs: PropTypes.array, // 所有标签
|
setSubConfig: PropTypes.func, // 设置子配置信息
|
updateaction: PropTypes.func // 菜单配置更新
|
}
|
|
state = {
|
dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
card: null, // 编辑中元素
|
formlist: null, // 表单信息
|
actionlist: null, // 按钮组
|
copying: false, // 按钮复制中
|
visible: false, // 模态框控制
|
profVisible: false // 验证信息模态框
|
}
|
|
/**
|
* @description 搜索条件初始化
|
*/
|
UNSAFE_componentWillMount () {
|
this.setState({
|
actionlist: fromJS(this.props.config.action).toJS()
|
})
|
}
|
|
/**
|
* @description 监听到按钮复制时,触发按钮编辑
|
*/
|
UNSAFE_componentWillReceiveProps (nextProps) {
|
const { actionlist } = this.state
|
|
if (nextProps.pasteContent && nextProps.pasteContent.copyType === 'action') {
|
this.setState({actionlist: [...actionlist, nextProps.pasteContent]})
|
this.handleAction(nextProps.pasteContent)
|
} else if (!is(fromJS(nextProps.config.action), fromJS(this.props.config.action)) && !is(fromJS(nextProps.config.action), fromJS(actionlist))) {
|
this.setState({actionlist: fromJS(nextProps.config.action).toJS()})
|
}
|
}
|
|
/**
|
* @description 按钮顺序调整,或拖拽添加
|
*/
|
handleList = (list, card) => {
|
const { config } = this.props
|
|
if (card) {
|
this.setState({actionlist: list})
|
this.handleAction(card)
|
} else {
|
this.setState({actionlist: list}, () => {
|
this.props.updateaction({...config, action: list})
|
})
|
}
|
}
|
|
/**
|
* @description 按钮编辑,获取按钮表单信息
|
*/
|
handleAction = (card) => {
|
const { menu } = this.props
|
let ableField = this.props.usefulFields.join(', ')
|
let functip = <div>
|
<p style={{marginBottom: '5px'}}>{this.state.dict['model.tooltip.func.innerface'].replace('@ableField', ableField)}</p>
|
<p>{this.state.dict['model.tooltip.func.outface']}</p>
|
</div>
|
|
let menulist = []
|
if (menu.fstMenuList) {
|
menulist = menu.fstMenuList.map(item => {
|
return {
|
value: item.MenuID,
|
label: item.text,
|
isLeaf: false
|
}
|
})
|
}
|
|
if (menu.fstMenuList && card.linkmenu && card.linkmenu.length > 0) {
|
let _param = {
|
func: 'sPC_Get_FunMenu',
|
ParentID: card.linkmenu[0],
|
systemType: options.sysType,
|
debug: 'Y'
|
}
|
|
Api.getSystemConfig(_param).then(result => {
|
if (result.status) {
|
menulist = menulist.map(item => {
|
if (item.value === card.linkmenu[0]) {
|
item.children = result.data.map(item => {
|
let submenu = {
|
value: item.ParentID,
|
label: item.MenuNameP,
|
children: item.FunMenu.map(cell => {
|
return {
|
value: cell.MenuID,
|
label: cell.MenuName,
|
MenuID: cell.MenuID,
|
MenuName: cell.MenuName,
|
MenuNo: cell.MenuNo,
|
Ot: cell.Ot,
|
PageParam: cell.PageParam,
|
LinkUrl: cell.LinkUrl,
|
disabled: cell.MenuID === menu.MenuID
|
}
|
})
|
}
|
|
return submenu
|
})
|
}
|
return item
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
|
this.setState({
|
visible: true,
|
card: card,
|
formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist)
|
})
|
})
|
} else {
|
this.setState({
|
visible: true,
|
card: card,
|
formlist: getActionForm(card, functip, this.props.config, this.props.usefulFields, this.props.type, menulist)
|
})
|
}
|
}
|
|
/**
|
* @description 取消保存,如果元素为新添元素,则从序列中删除
|
*/
|
editModalCancel = () => {
|
const { card } = this.state
|
|
if (card.focus) {
|
let actionlist = fromJS(this.state.actionlist).toJS()
|
|
actionlist = actionlist.filter(item => item.uuid !== card.uuid)
|
|
this.setState({
|
card: null,
|
actionlist: actionlist,
|
visible: false
|
})
|
} else {
|
this.setState({
|
card: null,
|
visible: false
|
})
|
}
|
}
|
|
/**
|
* @description 搜索修改后提交保存
|
* 1、去除系统默认搜索条件
|
* 2、字段及提示文字重复校验
|
* 3、更新下拉菜单可选集合
|
* 4、下拉菜单数据源语法验证
|
*/
|
handleSubmit = () => {
|
const { config, menu } = this.props
|
const { card } = this.state
|
let _actionlist = fromJS(this.state.actionlist).toJS()
|
|
this.actionFormRef.handleConfirm().then(btn => {
|
_actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid)
|
|
let labelrepet = false
|
_actionlist = _actionlist.map(item => {
|
if (item.uuid !== btn.uuid && item.label === btn.label) {
|
labelrepet = true
|
}
|
|
if (item.uuid === btn.uuid) {
|
return btn
|
} else {
|
return item
|
}
|
})
|
|
if (labelrepet) {
|
notification.warning({
|
top: 92,
|
message: this.state.dict['model.name.exist'] + ' !',
|
duration: 5
|
})
|
return
|
}
|
|
this.setState({
|
copying: true
|
})
|
|
let copyActionId = '' // 按钮为复制时,记录当前按钮的Id,菜单取消保存时,删除复制按钮配置信息
|
|
/**
|
* @description 按钮保存校验
|
* 1、检查按钮是否为表单或表单标签页,如前后一致,则复制其内容
|
* 2、检查按钮是否为标签页,如前后一致,则复制标签页
|
*/
|
new Promise(resolve => {
|
if (
|
!card.originCard ||
|
(btn.OpenType === 'pop' && card.originCard.OpenType !== 'pop') ||
|
(['tab', 'blank'].includes(btn.OpenType) && !['tab', 'blank'].includes(card.originCard.OpenType)) ||
|
(btn.OpenType === 'popview' && (!btn.createTab || card.originCard.OpenType !== 'popview' || !card.originCard.linkTab))
|
) { // 按钮不是复制,或按钮前后类型不一致时,直接保存
|
resolve('save')
|
} else if (btn.OpenType === 'pop' || btn.OpenType === 'tab' || btn.OpenType === 'blank') {
|
resolve('subconf')
|
} else if (btn.OpenType === 'popview') {
|
resolve('subtab')
|
} else {
|
resolve('save')
|
}
|
}).then(result => { // 查询原按钮配置信息
|
if (result === 'save' || result === 'subtab') return result
|
|
return Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: card.originCard.uuid
|
})
|
}).then(result => { // 复制按钮配置信息,保存至新添加按钮
|
if (result === 'save' || result === 'subtab') return result
|
|
if (result.status && result.LongParam) {
|
let _LongParam = ''
|
|
// 解析配置
|
if (result.LongParam) {
|
try {
|
_LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
_LongParam = ''
|
}
|
}
|
|
let _temp = '' // 配置信息类型
|
|
// 修改模态框标题名称
|
if (btn.OpenType === 'pop' && _LongParam && _LongParam.type === 'Modal') {
|
try {
|
_LongParam.setting.title = btn.label
|
_LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
|
_temp = 'Modal'
|
} catch {
|
console.warn('Stringify Failure')
|
_LongParam = ''
|
_temp = ''
|
}
|
} else if (['tab', 'blank'].includes(btn.OpenType) && _LongParam && _LongParam.type === 'FormTab') {
|
try {
|
_LongParam.action = _LongParam.action.map(_btn => {
|
_btn.uuid = Utils.getuuid()
|
|
return _btn
|
})
|
_LongParam.tabgroups.forEach(_groupId => {
|
_LongParam[_groupId] = _LongParam[_groupId].map(_tab => {
|
_tab.uuid = Utils.getuuid()
|
|
return _tab
|
})
|
})
|
_LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_LongParam)))
|
_temp = 'FormTab'
|
} catch {
|
console.warn('Stringify Failure')
|
_LongParam = ''
|
_temp = ''
|
}
|
}
|
|
if (!_temp) return 'save'
|
|
let param = {
|
func: 'sPC_ButtonParam_AddUpt',
|
ParentID: menu.MenuID,
|
MenuID: btn.uuid,
|
MenuNo: menu.MenuNo,
|
Template: _temp,
|
MenuName: btn.label,
|
PageParam: JSON.stringify({Template: _temp}),
|
LongParam: _LongParam
|
}
|
|
return Api.getSystemConfig(param)
|
} else {
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
return 'save'
|
}
|
}).then(result => {
|
if (result === 'save' || result === 'subtab') return result
|
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
} else {
|
copyActionId = btn.uuid
|
}
|
|
return 'save'
|
}).then(result => { // 查询原按钮关联标签信息
|
if (result === 'save') return result
|
|
return Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: card.originCard.linkTab
|
})
|
}).then(result => { // 标签复制
|
if (result === 'save') return result
|
|
let _LongParam = '' // 标签配置信息
|
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
} else if (result.LongParam) {
|
// 解析标签配置
|
try {
|
_LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
_LongParam = ''
|
}
|
}
|
|
if (!_LongParam) {
|
return 'save'
|
} else {
|
copyActionId = btn.linkTab
|
|
return new Promise(resolve => {
|
this.copytab(btn, _LongParam, resolve)
|
})
|
}
|
}).then(() => {
|
// 判断是否存在操作列
|
let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
|
let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
|
|
if (_gridBtn) {
|
_gridBtn.display = _hasGridbtn
|
} else {
|
_gridBtn = {
|
display: _hasGridbtn,
|
Align: 'center',
|
IsSort: 'false',
|
uuid: Utils.getuuid(),
|
label: this.state.dict['model.form.column.action'],
|
type: 'action',
|
style: 'button',
|
show: 'horizontal',
|
Width: 120
|
}
|
}
|
|
this.setState({
|
actionlist: _actionlist,
|
copying: false,
|
visible: false
|
}, () => {
|
this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, copyActionId)
|
})
|
})
|
})
|
}
|
|
/**
|
* @description 标签复制
|
* 1、保存按钮关联的新标签
|
* 2、保存标签按钮信息
|
* 3、保存新标签中按钮的子配置信息
|
*/
|
copytab = (btn, _tab, _resolve) => {
|
let _LongParam = ''
|
|
_tab.uuid = btn.linkTab
|
_tab.tabName = _tab.tabName + moment().format('YYYY-MM-DD HH:mm:ss')
|
_tab.tabNo = _tab.tabNo + moment().format('YYYY-MM-DD HH:mm:ss')
|
|
let param = {
|
func: 'sPC_Tab_AddUpt',
|
MenuID: _tab.uuid,
|
MenuNo: _tab.tabNo,
|
Template: _tab.Template,
|
MenuName: _tab.tabName,
|
Remark: _tab.Remark,
|
PageParam: JSON.stringify({Template: _tab.Template}),
|
Sort: 0
|
}
|
|
let _oriActions = []
|
|
let btnParam = {
|
func: 'sPC_Button_AddUpt',
|
Type: 40,
|
ParentID: _tab.uuid,
|
MenuNo: _tab.tabNo,
|
Template: _tab.Template,
|
PageParam: '',
|
LongParam: '',
|
LText: ''
|
}
|
|
try {
|
let _linkchange = {}
|
btnParam.LText = []
|
|
_tab.action = _tab.action.map((item, index) => {
|
let uuid = Utils.getuuid()
|
|
if (item.OpenType === 'pop') {
|
_oriActions.push({
|
prebtn: JSON.parse(JSON.stringify(item)),
|
curuuid: uuid,
|
Template: 'Modal'
|
})
|
} else if (item.OpenType === 'popview') {
|
_linkchange[item.linkTab] = Utils.getuuid()
|
|
item.linkTab = _linkchange[item.linkTab]
|
}
|
|
item.uuid = uuid
|
|
btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`)
|
|
return item
|
})
|
|
if (_tab.funcs && _tab.funcs.length > 0) {
|
_tab.funcs = _tab.funcs.map(item => {
|
if (item.type === 'tab') {
|
item.linkTab = _linkchange[item.linkTab]
|
item.menuNo = ''
|
item.subfuncs = []
|
}
|
|
return item
|
})
|
}
|
|
btnParam.LText = btnParam.LText.join(' union all ')
|
btnParam.LText = Utils.formatOptions(btnParam.LText)
|
btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
|
btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
|
|
_LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_tab)))
|
} catch {
|
console.warn('Stringify Failure')
|
_LongParam = ''
|
_resolve('save')
|
return
|
}
|
|
param.LongParam = _LongParam
|
|
new Promise(resolve => {
|
Api.getSystemConfig(param).then(response => {
|
if (response.status) {
|
resolve(true)
|
} else {
|
notification.warning({
|
top: 92,
|
message: response.message,
|
duration: 5
|
})
|
resolve(false)
|
}
|
})
|
}).then(result => {
|
if (!result) return result
|
if (!btnParam.LText) return true
|
|
return Api.getSystemConfig(btnParam)
|
}).then(result => {
|
if (result === false || result === true) return result
|
|
if (result.status) {
|
return true
|
} else {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
return false
|
}
|
}).then(result => {
|
if (!result) return result
|
if (_oriActions.length === 0) return true
|
|
let deffers = _oriActions.map(item => {
|
return new Promise(resolve => {
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: item.prebtn.uuid
|
}).then(response => {
|
if (!response.status || !response.LongParam) {
|
resolve(response)
|
} else {
|
let _param = {
|
func: 'sPC_ButtonParam_AddUpt',
|
ParentID: _tab.uuid,
|
MenuID: item.curuuid,
|
MenuNo: _tab.tabNo,
|
Template: item.Template,
|
MenuName: item.prebtn.label,
|
PageParam: JSON.stringify({Template: item.Template}),
|
LongParam: response.LongParam
|
}
|
Api.getSystemConfig(_param).then(resp => {
|
resolve(resp)
|
})
|
}
|
})
|
})
|
})
|
|
return Promise.all(deffers)
|
}).then(result => {
|
let error = ''
|
|
if (typeof(result) === 'object') {
|
result.forEach(resul => {
|
if (!resul.status && !error) {
|
error = resul
|
}
|
})
|
}
|
|
if (error) {
|
notification.warning({
|
top: 92,
|
message: error.message,
|
duration: 5
|
})
|
}
|
|
_resolve('save')
|
})
|
}
|
|
/**
|
* @description 按钮删除
|
*/
|
deleteElement = (card) => {
|
const { config } = this.props
|
const { dict } = this.state
|
let _this = this
|
|
confirm({
|
content: dict['model.confirm'] + dict['model.delete'] + ` - ${card.label} ?`,
|
onOk() {
|
let _actionlist = fromJS(_this.state.actionlist).toJS()
|
|
_actionlist = _actionlist.filter(item => item.uuid !== card.uuid)
|
|
let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
|
let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
|
|
if (_gridBtn) {
|
_gridBtn.display = _hasGridbtn
|
} else {
|
_gridBtn = {
|
display: _hasGridbtn,
|
Align: 'center',
|
IsSort: 'false',
|
uuid: Utils.getuuid(),
|
label: this.state.dict['model.form.column.action'],
|
type: 'action',
|
style: 'button',
|
show: 'horizontal',
|
Width: 120
|
}
|
}
|
|
let delcard = {
|
type: 'action',
|
card: card
|
}
|
|
_this.setState({
|
actionlist: _actionlist
|
}, () => {
|
_this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn}, '', delcard)
|
})
|
},
|
onCancel() {}
|
})
|
}
|
|
/**
|
* @description 验证信息配置
|
*/
|
profileAction = (element) => {
|
this.setState({
|
profVisible: true,
|
card: element
|
})
|
}
|
|
/**
|
* @description 验证信息保存
|
*/
|
verifySubmit = () => {
|
const { config } = this.props
|
const { card } = this.state
|
|
this.verifyRef.handleConfirm().then(res => {
|
let _actionlist = fromJS(this.state.actionlist).toJS()
|
_actionlist = _actionlist.filter(item => !item.origin || item.uuid === card.uuid)
|
|
_actionlist = _actionlist.map(item => {
|
if (item.uuid === card.uuid) {
|
item.verify = res
|
}
|
|
return item
|
})
|
|
this.setState({
|
actionlist: _actionlist,
|
profVisible: false
|
}, () => {
|
this.props.updateaction({...config, action: _actionlist})
|
})
|
})
|
}
|
|
/**
|
* @description 创建按钮存储过程
|
*/
|
creatFunc = () => {
|
const { config, menu } = this.props
|
let _config = fromJS(this.props.config).toJS()
|
|
this.actionFormRef.handleConfirm().then(res => {
|
let btn = res // 按钮信息
|
let newLText = '' // 创建存储过程sql
|
let DelText = '' // 删除存储过程sql
|
|
let _actionlist = fromJS(this.state.actionlist).toJS()
|
|
_actionlist = _actionlist.filter(item => !item.origin || item.uuid === btn.uuid)
|
|
let labelrepet = false
|
_actionlist = _actionlist.map(item => {
|
if (item.uuid !== btn.uuid && item.label === btn.label) {
|
labelrepet = true
|
}
|
|
if (item.uuid === btn.uuid) {
|
return btn
|
} else {
|
return item
|
}
|
})
|
|
if (labelrepet) {
|
notification.warning({
|
top: 92,
|
message: this.state.dict['model.name.exist'] + ' !',
|
duration: 5
|
})
|
return
|
}
|
|
// 创建存储过程,必须填写内部函数名
|
if (btn.intertype !== 'inner') {
|
notification.warning({
|
top: 92,
|
message: '使用内部函数时,才可以创建存储过程!',
|
duration: 5
|
})
|
return
|
}
|
|
new Promise(resolve => {
|
// 弹窗(表单)类按钮,先获取按钮配置信息,如果尚未配置按钮则会报错并终止。
|
// 获取信息后生成删除和创建存储过程的语句
|
if (btn.OpenType === 'pop') {
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: btn.uuid
|
}).then(res => {
|
let _LongParam = ''
|
if (res.status && res.LongParam) {
|
try {
|
_LongParam = JSON.parse(window.decodeURIComponent(window.atob(res.LongParam)))
|
} catch (e) {
|
console.warn('Parse Failure')
|
_LongParam = ''
|
}
|
}
|
|
if (_LongParam) {
|
let fields = []
|
if (_LongParam.groups.length > 0) {
|
_LongParam.groups.forEach(group => {
|
fields = [...fields, ...group.sublist]
|
})
|
} else {
|
fields = _LongParam.fields
|
}
|
|
let _param = {
|
funcName: btn.innerFunc,
|
name: _config.setting.tableName || '',
|
fields: fields,
|
menuNo: menu.MenuNo
|
}
|
newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
|
DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
|
resolve(true)
|
} else {
|
notification.warning({
|
top: 92,
|
message: '弹窗(表单)按钮,请先配置表单信息!',
|
duration: 5
|
})
|
resolve(false)
|
}
|
})
|
} else if (btn.OpenType === 'excelIn') {
|
if (btn.verify && btn.verify.sheet && btn.verify.columns && btn.verify.columns.length > 0) {
|
let _param = {
|
funcName: btn.innerFunc,
|
menuNo: menu.MenuNo
|
}
|
newLText = Utils.formatOptions(DevUtils.getexcelInfunc(_param, btn, menu))
|
DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
|
resolve(true)
|
} else {
|
notification.warning({
|
top: 92,
|
message: '请完善导入Excel验证信息!',
|
duration: 5
|
})
|
resolve(false)
|
}
|
} else if (btn.OpenType === 'excelOut') {
|
let _param = {
|
innerFunc: btn.innerFunc
|
}
|
|
newLText = Utils.formatOptions(DevUtils.getTableFunc(_param, menu, _config)) // 创建存储过程sql
|
DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
|
|
resolve(true)
|
} else {
|
let _param = {
|
funcName: btn.innerFunc,
|
name: _config.setting.tableName || '',
|
fields: '',
|
menuNo: menu.MenuNo
|
}
|
newLText = Utils.formatOptions(DevUtils.getfunc(_param, btn, menu, _config))
|
DelText = Utils.formatOptions(DevUtils.dropfunc(btn.innerFunc))
|
resolve(true)
|
}
|
}).then(res => {
|
if (!res) return
|
|
this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => {
|
if (result !== 'success') return
|
|
// 判断是否存在操作列
|
let _hasGridbtn = _actionlist.filter(act => act.position === 'grid').length > 0
|
let _gridBtn = config.gridBtn ? fromJS(config.gridBtn).toJS() : null
|
|
if (_gridBtn) {
|
_gridBtn.display = _hasGridbtn
|
} else {
|
_gridBtn = {
|
display: _hasGridbtn,
|
Align: 'center',
|
IsSort: 'false',
|
uuid: Utils.getuuid(),
|
label: this.state.dict['model.form.column.action'],
|
type: 'action',
|
style: 'button',
|
show: 'horizontal',
|
Width: 120
|
}
|
}
|
|
this.setState({
|
actionlist: _actionlist
|
}, () => {
|
this.props.updateaction({...config, action: _actionlist, gridBtn: _gridBtn})
|
})
|
})
|
})
|
})
|
}
|
|
/**
|
* @description 创建按钮接口(写入)
|
*/
|
btnCreatInterface = () => {
|
const { config, type, menu } = this.props
|
|
this.actionFormRef.handleConfirm().then(result => {
|
let _menu = {
|
type: type,
|
MenuID: menu.MenuID,
|
menuName: menu.MenuName,
|
menuNo: menu.MenuNo
|
}
|
|
this.refs.btnCreatInterface.triggerInInterface(result, config, _menu)
|
})
|
}
|
|
/**
|
* @description 按钮双击触发子配置
|
*/
|
btnDoubleClick = (element) => {
|
if (!element.origin && (element.OpenType === 'pop' || element.OpenType === 'popview' || element.OpenType === 'blank' || element.OpenType === 'tab')) {
|
this.props.setSubConfig(element)
|
} else {
|
notification.warning({
|
top: 92,
|
message: '此按钮无子配置项!',
|
duration: 5
|
})
|
}
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { config } = this.props
|
const { actionlist, visible, card, dict, copying, profVisible } = this.state
|
|
return (
|
<div className="model-table-action-list" style={config.charts.length > 1 ? {paddingTop: 25} : null}>
|
<Tooltip placement="bottomLeft" overlayClassName="middle" title={dict['model.tooltip.action.guide']}>
|
<Icon type="question-circle" />
|
</Tooltip>
|
<DragElement
|
list={actionlist}
|
setting={this.props.config.setting}
|
handleList={this.handleList}
|
handleMenu={this.handleAction}
|
deleteMenu={this.deleteElement}
|
profileMenu={this.profileAction}
|
doubleClickCard={this.btnDoubleClick}
|
placeholder={dict['header.form.action.placeholder']}
|
/>
|
{/* 编辑按钮:复制、编辑 */}
|
<Modal
|
title={dict['model.action'] + '-' + (card && card.copyType === 'action' ? dict['model.copy'] : dict['model.edit'])}
|
visible={visible}
|
width={800}
|
maskClosable={false}
|
onCancel={this.editModalCancel}
|
footer={[
|
<CreateInterface key="interface" dict={dict} ref="btnCreatInterface" trigger={this.btnCreatInterface}/>,
|
<CreateFunc key="create" dict={dict} ref="btnCreatFunc" trigger={this.creatFunc}/>,
|
<Button key="cancel" onClick={this.editModalCancel}>{dict['model.cancel']}</Button>,
|
<Button key="confirm" type="primary" loading={copying} onClick={this.handleSubmit}>{dict['model.confirm']}</Button>
|
]}
|
destroyOnClose
|
>
|
<ActionForm
|
dict={dict}
|
card={card}
|
tabs={this.props.tabs}
|
formlist={this.state.formlist}
|
inputSubmit={this.handleSubmit}
|
setting={config.setting}
|
wrappedComponentRef={(inst) => this.actionFormRef = inst}
|
/>
|
</Modal>
|
{/* 按钮使用系统存储过程时,验证信息模态框 */}
|
<Modal
|
wrapClassName="model-table-action-verify-modal"
|
title={'验证信息'}
|
visible={profVisible}
|
width={'75vw'}
|
maskClosable={false}
|
style={{minWidth: '900px', maxWidth: '1200px'}}
|
okText={dict['model.submit']}
|
onOk={this.verifySubmit}
|
onCancel={() => { this.setState({ profVisible: false }) }}
|
destroyOnClose
|
>
|
{card && !card.execMode && card.OpenType !== 'excelIn' && card.OpenType !== 'excelOut' ?
|
<VerifyCard
|
floor={this.props.type}
|
card={card}
|
dict={dict}
|
config={config}
|
columns={config.columns}
|
wrappedComponentRef={(inst) => this.verifyRef = inst}
|
/> : null
|
}
|
{card && card.execMode ?
|
<VerifyPrint
|
card={card}
|
dict={dict}
|
columns={config.columns}
|
wrappedComponentRef={(inst) => this.verifyRef = inst}
|
/> : null
|
}
|
{card && card.OpenType === 'excelIn' ?
|
<VerifyExcelIn
|
card={card}
|
dict={dict}
|
columns={config.columns}
|
wrappedComponentRef={(inst) => this.verifyRef = inst}
|
/> : null
|
}
|
{card && card.OpenType === 'excelOut' ?
|
<VerifyExcelOut
|
card={card}
|
dict={dict}
|
config={config}
|
wrappedComponentRef={(inst) => this.verifyRef = inst}
|
/> : null
|
}
|
</Modal>
|
</div>
|
)
|
}
|
}
|
|
export default ActionComponent
|