import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import {connect} from 'react-redux'
|
import { is, fromJS } from 'immutable'
|
import { DndProvider } from 'react-dnd'
|
import HTML5Backend from 'react-dnd-html5-backend'
|
import { Button, Card, Modal, Collapse, notification, Spin, Select, List, Icon, Empty, Switch, Tooltip } from 'antd'
|
import moment from 'moment'
|
import ActionForm from './actionform'
|
import SettingForm from './settingform'
|
import TabForm from './tabform'
|
import TabDragElement from './tabdragelement'
|
import Api from '@/api'
|
import SearchForm from '@/templates/tableshare/searchform'
|
import ColumnForm from '@/templates/tableshare/columnform'
|
import DragElement from '@/templates/tableshare/dragelement'
|
import ColspanForm from '@/templates/tableshare/colspanform'
|
import GridBtnForm from '@/templates/tableshare/gridbtnform'
|
import EditCard from '@/templates/tableshare/editcard'
|
import VerifyCard from '@/templates/tableshare/verifycard'
|
import MenuForm from '@/templates/tableshare/menuform'
|
import SourceElement from '@/templates/tableshare/dragelement/source'
|
import zhCN from '@/locales/zh-CN/comtable.js'
|
import enUS from '@/locales/en-US/comtable.js'
|
import Utils from '@/utils/utils.js'
|
import Source from './source'
|
import './index.scss'
|
|
const { Panel } = Collapse
|
const { Option } = Select
|
const { confirm } = Modal
|
const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
|
|
class ComTableConfig extends Component {
|
static propTpyes = {
|
type: PropTypes.string,
|
menu: PropTypes.any,
|
reloadmenu: PropTypes.func,
|
handleConfig: PropTypes.func,
|
handleSubConfig: PropTypes.func,
|
supMenuList: PropTypes.array
|
}
|
|
state = {
|
dict: CommonDict, // 字典
|
config: null, // 页面配置
|
visible: false, // 搜索条件、按钮、显示列,模态框显示控制
|
modalTitle: '', // 模态框的标题
|
tableVisible: false, // 数据表字段模态框
|
addType: '', // 添加类型-搜索条件或显示列
|
tableColumns: [], // 表格显示列
|
fields: null, // 搜索条件及显示列,可选字段
|
menuformlist: null, // 基本信息表单字段
|
formlist: null, // 搜索条件、按钮、显示列表单字段
|
formtemp: '', // 表单类型,显示列、按钮、搜索条件
|
card: null, // 编辑元素
|
searchloading: false, // 搜索条件加载中
|
actionloading: false, // 按钮加载中
|
columnsloading: false, // 显示列加载中
|
tabloading: false, // 标签页加载中
|
menuloading: false, // 菜单保存中
|
menucloseloading: false, // 菜单关闭时,选择保存
|
loading: false, // 加载中,页面spin
|
settingVisible: false, // 全局配置模态框
|
closeVisible: false, // 关闭模态框
|
tables: [], // 可用表名
|
selectedTables: [], // 已选表名
|
originMenu: null, // 原始菜单
|
originActions: null, // 原始按钮信息,使用已有用户模板
|
delActions: [], // 删除按钮列表
|
funcLoading: false, // 存储过程创建中
|
showColumnName: false, // 显示列字段名控制
|
tabviews: [], // 所有标签页
|
profileVisible: false // 验证信息模态框
|
}
|
|
/**
|
* @description 数据预处理
|
* 1、设置页面配置信息,新建或无配置信息时(切换模板后无配置信息),使用模板默认配置
|
* 2、设置操作类型、原始菜单信息(每次保存后重置)、已使用表及基本信息表单
|
*/
|
UNSAFE_componentWillMount () {
|
const { menu } = this.props
|
|
let _LongParam = menu.LongParam
|
let _config = ''
|
|
if (!_LongParam) {
|
_config = JSON.parse(JSON.stringify(Source.baseConfig))
|
if (!menu.isSubtable) { // 不是选择主子表时,隐藏标签页
|
_config.tabs = []
|
}
|
} else {
|
_config = _LongParam
|
}
|
|
let _oriActions = []
|
if (_config.type === 'user') {
|
_config.action = _config.action.map(item => {
|
let uuid = Utils.getuuid()
|
|
if (item.OpenType === 'pop') { // 含有子配置项的按钮。。。
|
_oriActions.push({
|
prebtn: JSON.parse(JSON.stringify(item)),
|
curuuid: uuid,
|
Template: 'Modal'
|
})
|
}
|
|
item.uuid = uuid
|
|
return item
|
})
|
}
|
|
_config.tabs = _config.tabs || []
|
_config.tabgroups = _config.tabgroups || ['tabs']
|
_config.setting.subtabs = _config.setting.subtabs || []
|
|
this.setState({
|
config: _config,
|
originActions: _oriActions,
|
originMenu: JSON.parse(JSON.stringify(menu)),
|
selectedTables: _config.tables || [],
|
menuformlist: [
|
{
|
type: 'select',
|
key: 'parentId',
|
label: this.state.dict['header.menu.supMenu'],
|
initVal: menu.ParentID,
|
required: true,
|
readonly: false,
|
options: this.props.supMenuList
|
},
|
{
|
type: 'text',
|
key: 'menuName',
|
label: this.state.dict['header.menu.menuName'],
|
initVal: menu.MenuName,
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'menuNo',
|
label: this.state.dict['header.menu.menuNo'],
|
initVal: menu.MenuNo,
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'opentype',
|
label: this.state.dict['header.menu.openType'],
|
initVal: menu.PageParam.OpenType,
|
required: true,
|
options: [{
|
MenuID: 'newtab',
|
text: this.state.dict['header.form.tab']
|
}, {
|
MenuID: 'newpage',
|
text: this.state.dict['header.form.newpage']
|
}, {
|
MenuID: 'currenttab',
|
text: this.state.dict['header.form.currenttab']
|
}]
|
}
|
]
|
})
|
}
|
|
/**
|
* @description 加载完成后
|
* 1、获取系统可使用表
|
* 2、根据配置信息中已使用表获取相关字段信息
|
* 3、获取所有标签页信息
|
*/
|
componentDidMount () {
|
let param = {
|
func: 'sPC_Get_SelectedList',
|
LText: 'select TbName ,Remark from sDataDictionary where IsKey!=\'\' and Deleted =0',
|
obj_name: 'data',
|
arr_field: 'TbName,Remark'
|
}
|
|
param.LText = Utils.formatOptions(param.LText)
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
|
Api.getSystemConfig(param).then(res => {
|
if (res.status) {
|
this.setState({
|
tables: res.data
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
|
let deffers = this.state.selectedTables.map(item => {
|
return new Promise(resolve => {
|
Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: item.TbName}).then(res => {
|
res.TBName = item.TbName
|
resolve(res)
|
})
|
})
|
})
|
Promise.all(deffers).then(response => {
|
let _columns = []
|
response.forEach(res => {
|
if (res.status) {
|
let tabmsg = {
|
tableName: res.TBName,
|
columns: res.FDName.map(item => {
|
let _type = item.FieldType.toLowerCase()
|
let _decimal = 0
|
if (/^nvarchar/.test(_type)) {
|
_type = 'text'
|
} else if (/^int/.test(_type)) {
|
_type = 'number'
|
} else if (/^decimal/.test(_type)) {
|
_decimal = _type.split(',')[1]
|
_decimal = parseInt(_decimal)
|
if (_decimal > 4) {
|
_decimal = 4
|
}
|
_type = 'number'
|
} else if (/^decimal/.test(_type)) {
|
_decimal = _type.split(',')[1]
|
_decimal = parseInt(_decimal)
|
if (_decimal > 4) {
|
_decimal = 4
|
}
|
_type = 'number'
|
} else if (/^datetime/.test(_type)) {
|
_type = 'datetime'
|
} else if (/^date/.test(_type)) {
|
_type = 'date'
|
} else {
|
_type = 'text'
|
}
|
|
return {
|
field: item.FieldName,
|
label: item.FieldDec,
|
type: _type,
|
datatype: _type,
|
decimal: _decimal
|
}
|
})
|
}
|
_columns.push(tabmsg)
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
|
this.setState({
|
tableColumns: _columns
|
})
|
})
|
|
Api.getSystemConfig({func: 'sPC_Get_UserTemp', TypeCharTwo: 'tab'}).then(res => {
|
if (res.status) {
|
this.setState({
|
tabviews: res.UserTemp.map(temp => {
|
return {
|
uuid: temp.MenuID,
|
value: temp.MenuID,
|
text: temp.MenuName,
|
type: temp.Template,
|
MenuNo: temp.MenuNo
|
}
|
})
|
})
|
}
|
})
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
handleList = (type, list, card) => {
|
const { config } = this.state
|
|
if (type === 'tabs') { // 标签页调整顺序或添加元素
|
if (list.length > config[card.groupId].length) {
|
list = list.filter(item => !item.origin)
|
|
this.setState({
|
tabloading: true,
|
config: {...config, [card.groupId]: list }
|
}, () => {
|
// 刷新对应的配置信息
|
this.setState({
|
tabloading: false
|
})
|
this.handleTab(card)
|
})
|
} else {
|
this.setState({config: {...config, [card.groupId]: list}})
|
}
|
} else {
|
if (list.length > config[type].length) {
|
list = list.filter(item => !item.origin)
|
|
this.setState({
|
[type + 'loading']: true,
|
config: {...config, [type]: list }
|
}, () => {
|
// 刷新对应的配置信息
|
this.setState({
|
[type + 'loading']: false
|
})
|
|
if (type === 'search') {
|
this.handleSearch(card)
|
} else if (type === 'action') {
|
this.handleAction(card)
|
} else if (type === 'columns') {
|
this.handleColumn(card)
|
} else if (type === 'tabs') {
|
this.handleTab(card)
|
}
|
})
|
} else {
|
this.setState({config: {...config, [type]: list}})
|
}
|
}
|
}
|
|
handleSearch = (card) => {
|
this.setState({
|
visible: true,
|
formtemp: 'search',
|
modalTitle: '编辑-搜索条件',
|
card: card,
|
formlist: [
|
{
|
type: 'text',
|
key: 'label',
|
label: this.state.dict['header.form.name'],
|
initVal: card.label || '',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'field',
|
label: this.state.dict['header.form.field'],
|
initVal: card.field || '',
|
tooltip: '字段名可以使用逗号分隔,进行多字段综合搜索,注:综合搜索仅在文本类型时有效',
|
tooltipClass: 'middle',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'type',
|
label: this.state.dict['header.form.type'],
|
initVal: card.type,
|
required: true,
|
options: [{
|
value: 'text',
|
text: this.state.dict['header.form.text']
|
}, {
|
value: 'select',
|
text: this.state.dict['header.form.select']
|
}, {
|
value: 'multiselect',
|
text: this.state.dict['header.form.multiselect']
|
}, {
|
value: 'link',
|
text: this.state.dict['header.form.link']
|
}, {
|
value: 'date',
|
text: this.state.dict['header.form.dateday']
|
}, {
|
value: 'dateweek',
|
text: this.state.dict['header.form.dateweek']
|
}, {
|
value: 'datemonth',
|
text: this.state.dict['header.form.datemonth']
|
}, {
|
value: 'daterange',
|
text: this.state.dict['header.form.daterange']
|
}]
|
},
|
{
|
type: 'text',
|
key: 'initval',
|
label: this.state.dict['header.form.initval'],
|
initVal: card.initval,
|
required: false
|
},
|
{
|
type: 'radio',
|
key: 'resourceType',
|
label: this.state.dict['header.form.resourceType'],
|
initVal: card.resourceType || '0',
|
required: true,
|
options: [{
|
value: '0',
|
text: this.state.dict['header.form.custom']
|
}, {
|
value: '1',
|
text: this.state.dict['header.form.datasource']
|
}]
|
},
|
{
|
type: 'radio',
|
key: 'setAll',
|
label: this.state.dict['header.form.setAll'],
|
initVal: card.setAll || 'false',
|
options: [{
|
value: 'true',
|
text: this.state.dict['header.form.true']
|
}, {
|
value: 'false',
|
text: this.state.dict['header.form.false']
|
}]
|
},
|
{
|
type: 'textarea',
|
key: 'dataSource',
|
label: this.state.dict['header.form.datasource'],
|
initVal: card.dataSource || '',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'options',
|
key: 'options',
|
label: '',
|
initVal: card.options || [],
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'linkField',
|
label: this.state.dict['header.form.linkField'],
|
initVal: card.linkField || '',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'valueField',
|
label: this.state.dict['header.form.valueField'],
|
initVal: card.valueField || '',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'valueText',
|
label: this.state.dict['header.form.valueText'],
|
initVal: card.valueText || '',
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'orderBy',
|
label: this.state.dict['header.form.orderBy'],
|
initVal: card.orderBy || '',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'orderType',
|
label: this.state.dict['header.form.orderType'],
|
initVal: card.orderType || 'asc',
|
options: [{
|
value: 'asc',
|
text: this.state.dict['header.form.asc']
|
}, {
|
value: 'desc',
|
text: this.state.dict['header.form.desc']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'match',
|
label: this.state.dict['header.form.match'],
|
initVal: card.match || 'like',
|
required: true,
|
options: [{
|
value: 'like',
|
text: 'like'
|
}, {
|
value: 'equal',
|
text: 'equal'
|
}, {
|
value: 'greater',
|
text: '>'
|
}, {
|
value: 'less',
|
text: '<'
|
}, {
|
value: 'greaterequal',
|
text: '>='
|
}]
|
},
|
{
|
type: 'select',
|
key: 'display',
|
label: this.state.dict['header.form.display'],
|
initVal: card.display || 'dropdown',
|
required: true,
|
options: [{
|
value: 'dropdown',
|
text: this.state.dict['header.form.dropdown']
|
}, {
|
value: 'button',
|
text: this.state.dict['header.form.button']
|
}]
|
}
|
]
|
})
|
}
|
|
handleAction = (card, type) => {
|
let ableField = this.props.permFuncField.join(', ')
|
this.setState({
|
visible: true,
|
formtemp: 'action',
|
modalTitle: type === 'copy' ? '复制-按钮' : '编辑-按钮',
|
card: card,
|
formlist: [
|
{
|
type: 'text',
|
key: 'label',
|
label: this.state.dict['header.form.name'],
|
initVal: card.label,
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'OpenType',
|
label: this.state.dict['header.form.openType'],
|
initVal: card.OpenType,
|
required: true,
|
options: [{
|
value: 'pop',
|
text: this.state.dict['header.form.popform']
|
}, {
|
value: 'prompt',
|
text: this.state.dict['header.form.prompt']
|
}, {
|
value: 'exec',
|
text: this.state.dict['header.form.exec']
|
}, {
|
value: 'excelIn',
|
text: this.state.dict['header.form.excelIn']
|
}, {
|
value: 'excelOut',
|
text: this.state.dict['header.form.excelOut']
|
}, {
|
value: 'popview',
|
text: this.state.dict['header.form.popview']
|
}, {
|
value: 'tab',
|
text: this.state.dict['header.form.tab']
|
}, {
|
value: 'blank',
|
text: this.state.dict['header.form.blank']
|
}, {
|
value: 'innerpage',
|
text: this.state.dict['header.form.newpage.inner']
|
}, {
|
value: 'outerpage',
|
text: this.state.dict['header.form.newpage.outer']
|
}]
|
}, {
|
type: 'select',
|
key: 'tabType',
|
label: this.state.dict['header.form.tabType'],
|
initVal: card.tabType || 'SubTable',
|
required: true,
|
options: [{
|
value: 'SubTable',
|
text: this.state.dict['header.menu.tab.subtable']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'linkTab',
|
label: '关联标签',
|
initVal: card.linkTab || '',
|
required: false,
|
options: []
|
},
|
{
|
type: 'select',
|
key: 'pageTemplate',
|
label: this.state.dict['header.form.pageTemplate'],
|
initVal: card.pageTemplate || '',
|
required: true,
|
options: []
|
},
|
{
|
type: 'text',
|
key: 'url',
|
label: this.state.dict['header.form.newpage.url'],
|
initVal: card.url || '',
|
required: true
|
},
|
{
|
type: 'radio',
|
key: 'intertype',
|
label: this.state.dict['header.form.intertype'],
|
initVal: card.intertype || 'inner',
|
required: true,
|
options: [{
|
value: 'inner',
|
text: this.state.dict['header.form.interface.inner']
|
}, {
|
value: 'outer',
|
text: this.state.dict['header.form.interface.outer']
|
}]
|
},
|
{
|
type: 'text',
|
key: 'innerFunc',
|
label: this.state.dict['header.form.innerFunc'],
|
initVal: card.innerFunc || '',
|
tooltip: <div>
|
<p>内部接口: 可自定义数据处理函数,函数名称需以{ableField}等字符开始;未设置时会调用系统函数,使用系统函数需完善数据源及操作类型;</p>
|
<p>外部接口: 可自定义数据处理函数,提交数据经过内部函数处理后,传入外部接口,未设置时,数据会直接传入外部接口。</p>
|
</div>,
|
fields: this.props.permFuncField,
|
tooltipClass: 'middle',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'radio',
|
key: 'sysInterface',
|
label: this.state.dict['header.form.sysInterface'],
|
initVal: card.sysInterface || 'false',
|
required: true,
|
options: [{
|
value: 'true',
|
text: this.state.dict['header.form.true']
|
}, {
|
value: 'false',
|
text: this.state.dict['header.form.false']
|
}]
|
},
|
{
|
type: 'text',
|
key: 'outerFunc',
|
label: this.state.dict['header.form.outerFunc'],
|
initVal: card.outerFunc || '',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'interface',
|
label: this.state.dict['header.form.interface'],
|
initVal: card.sysInterface === 'true' ? (window.GLOB.mainSystemApi || window.GLOB.subSystemApi) : (card.interface || ''),
|
required: true,
|
readonly: card.sysInterface === 'true'
|
},
|
{
|
type: 'text',
|
key: 'callbackFunc',
|
label: this.state.dict['header.form.callbackFunc'],
|
initVal: card.callbackFunc || '',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'position',
|
label: this.state.dict['header.form.position'],
|
initVal: card.position || 'toolbar',
|
required: true,
|
options: [{
|
value: 'toolbar',
|
text: this.state.dict['header.form.toolbar']
|
}, {
|
value: 'grid',
|
text: this.state.dict['header.form.grid']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'Ot',
|
label: this.state.dict['header.form.isRequired'],
|
initVal: card.Ot || 'requiredSgl',
|
required: true,
|
options: []
|
},
|
{
|
type: 'select',
|
key: 'tabTemplate',
|
label: '标签模板',
|
initVal: card.tabTemplate || 'formTab',
|
required: true,
|
options: [{
|
value: 'formTab',
|
text: '带标签表单'
|
}]
|
},
|
{
|
type: 'select',
|
key: 'execSuccess',
|
label: this.state.dict['header.form.execSuccess'],
|
initVal: card.execSuccess || 'never',
|
required: true,
|
options: [{
|
value: 'never',
|
text: this.state.dict['header.form.refresh.never']
|
}, {
|
value: 'grid',
|
text: this.state.dict['header.form.refresh.grid']
|
}, {
|
value: 'view',
|
text: this.state.dict['header.form.refresh.view']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'execError',
|
label: this.state.dict['header.form.execError'],
|
initVal: card.execError || 'never',
|
required: true,
|
options: [{
|
value: 'never',
|
text: this.state.dict['header.form.refresh.never']
|
}, {
|
value: 'grid',
|
text: this.state.dict['header.form.refresh.grid']
|
}, {
|
value: 'view',
|
text: this.state.dict['header.form.refresh.view']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'popClose',
|
label: this.state.dict['header.form.popClose'],
|
initVal: card.popClose || 'never',
|
required: true,
|
options: [{
|
value: 'never',
|
text: this.state.dict['header.form.refresh.never']
|
}, {
|
value: 'grid',
|
text: this.state.dict['header.form.refresh.grid']
|
}, {
|
value: 'view',
|
text: this.state.dict['header.form.refresh.view']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'icon',
|
label: this.state.dict['header.form.icon'],
|
initVal: card.icon,
|
required: false,
|
options: []
|
},
|
{
|
type: 'select',
|
key: 'class',
|
label: this.state.dict['header.form.class'],
|
initVal: card.class,
|
required: false,
|
options: []
|
},
|
{
|
type: 'text',
|
key: 'sql',
|
label: this.state.dict['header.form.datasource'],
|
initVal: card.sql || this.state.config.setting.tableName || '',
|
tooltip: this.state.dict['header.form.actionhelp.datasource'],
|
required: false
|
},
|
{
|
type: 'select',
|
key: 'sqlType',
|
label: this.state.dict['header.form.action.type'],
|
initVal: card.sqlType || '',
|
tooltip: this.state.dict['header.form.actionhelp.sqlType'],
|
required: false,
|
options: []
|
}
|
]
|
})
|
}
|
|
handleColumn = (card) => {
|
if (card.type !== 'colspan') {
|
this.setState({
|
visible: true,
|
formtemp: 'columns',
|
modalTitle: '编辑-显示列',
|
card: card,
|
formlist: [
|
{
|
type: 'text',
|
key: 'label',
|
label: this.state.dict['header.form.name'],
|
initVal: card.label,
|
required: true
|
},
|
{
|
type: 'text',
|
key: 'field',
|
label: this.state.dict['header.form.field'],
|
initVal: card.field,
|
required: true,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'type',
|
label: this.state.dict['header.form.type'],
|
initVal: card.type,
|
required: true,
|
options: [{
|
value: 'text',
|
text: this.state.dict['header.form.text']
|
}, {
|
value: 'number',
|
text: this.state.dict['header.form.number']
|
}, {
|
value: 'picture',
|
text: this.state.dict['header.form.picture']
|
}, {
|
value: 'textarea',
|
text: this.state.dict['header.form.textarea']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'Align',
|
label: this.state.dict['header.form.align'],
|
initVal: card.Align,
|
required: true,
|
options: [{
|
value: 'left',
|
text: this.state.dict['header.form.alignLeft']
|
}, {
|
value: 'right',
|
text: this.state.dict['header.form.alignRight']
|
}, {
|
value: 'center',
|
text: this.state.dict['header.form.alignCenter']
|
}]
|
},
|
{
|
type: 'radio',
|
key: 'Hide',
|
label: this.state.dict['header.form.Hide'],
|
initVal: card.Hide,
|
required: true,
|
options: [{
|
value: 'true',
|
text: this.state.dict['header.form.true']
|
}, {
|
value: 'false',
|
text: this.state.dict['header.form.false']
|
}]
|
},
|
{
|
type: 'radio',
|
key: 'IsSort',
|
label: this.state.dict['header.form.IsSort'],
|
initVal: card.IsSort,
|
required: true,
|
options: [{
|
value: 'true',
|
text: this.state.dict['header.form.true']
|
}, {
|
value: 'false',
|
text: this.state.dict['header.form.false']
|
}]
|
},
|
{
|
type: 'number',
|
key: 'Width',
|
min: 1,
|
max: 1000,
|
decimal: 0,
|
label: this.state.dict['header.form.columnWidth'],
|
initVal: card.Width,
|
required: true
|
},
|
{
|
type: 'number',
|
key: 'decimal',
|
min: 0,
|
max: 18,
|
decimal: 0,
|
label: this.state.dict['header.form.decimal'],
|
initVal: card.decimal,
|
required: false
|
},
|
{
|
type: 'select',
|
key: 'format',
|
label: this.state.dict['header.form.format'],
|
initVal: card.format || '',
|
options: [{
|
value: '',
|
text: this.state.dict['header.form.empty']
|
}, {
|
value: 'thdSeparator',
|
text: this.state.dict['header.form.thdSeparator']
|
}],
|
required: false
|
},
|
{
|
type: 'text',
|
key: 'prefix',
|
label: this.state.dict['header.form.prefix'],
|
initVal: card.prefix || '',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'text',
|
key: 'postfix',
|
label: this.state.dict['header.form.postfix'],
|
initVal: card.postfix || '',
|
// tooltip: '后缀值设置为"\\n",表示换行',
|
tooltipClass: 'middle',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'match',
|
label: this.state.dict['header.form.match'],
|
initVal: card.match || '',
|
options: [{
|
value: '',
|
text: this.state.dict['header.form.empty']
|
}, {
|
value: '>',
|
text: '>'
|
}, {
|
value: '<',
|
text: '<'
|
}, {
|
value: '>=',
|
text: '>='
|
}, {
|
value: '<=',
|
text: '<='
|
}],
|
required: false
|
},
|
{
|
type: 'text',
|
key: 'matchVal',
|
min: -Infinity,
|
max: Infinity,
|
decimal: 0,
|
label: this.state.dict['header.form.matchVal'],
|
initVal: card.matchVal || '',
|
required: false,
|
readonly: false
|
},
|
{
|
type: 'select',
|
key: 'color',
|
label: this.state.dict['header.form.color'],
|
initVal: card.color || '',
|
options: [{
|
value: '',
|
text: this.state.dict['header.form.empty']
|
}, {
|
value: 'red',
|
text: '红色(内容)'
|
}, {
|
value: 'redbg',
|
text: '红色(背景)'
|
}, {
|
value: 'orange',
|
text: '橙色(内容)'
|
}, {
|
value: 'orangebg',
|
text: '橙色(背景)'
|
}, {
|
value: 'green',
|
text: '绿色(内容)'
|
}, {
|
value: 'greenbg',
|
text: '绿色(背景)'
|
}],
|
required: false
|
}
|
]
|
})
|
} else {
|
this.setState({
|
visible: true,
|
formtemp: 'columns',
|
modalTitle: '编辑-合并列',
|
card: card
|
})
|
}
|
}
|
|
handleTab = (card) => {
|
const { config } = this.state
|
|
let index = 0 // 筛选下一组
|
config.tabgroups.forEach((groupId, i) => {
|
if (groupId === card.groupId) {
|
index = i
|
}
|
})
|
|
let menus = []
|
let subtabs = card.subtabs || []
|
let nextTabId = config.tabgroups[index + 1]
|
|
if (nextTabId) {
|
let _tabMap = new Map()
|
let _usedTabMap = new Map()
|
|
config[nextTabId].forEach(tab => { // 下级所有的标签
|
menus.push(tab)
|
_tabMap.set(tab.uuid, true)
|
})
|
|
config[card.groupId].forEach(tab => { // 同级标签已选的下级标签
|
if (tab.uuid === card.uuid) return
|
|
tab.subtabs.forEach(subtab => {
|
_usedTabMap.set(subtab, true)
|
})
|
})
|
|
config.setting.subtabs.forEach(subtab => { // 主表已选的下级标签
|
_usedTabMap.set(subtab, true)
|
})
|
|
subtabs = subtabs.filter(tab => _tabMap.has(tab.uuid) && !_usedTabMap.has(tab.uuid))
|
menus = menus.filter(tab => !_usedTabMap.has(tab.uuid))
|
} else {
|
subtabs = []
|
}
|
|
this.setState({
|
visible: true,
|
formtemp: 'tabs',
|
modalTitle: '编辑-标签页',
|
card: card,
|
formlist: [
|
{
|
type: 'text',
|
key: 'label',
|
label: this.state.dict['header.form.name'],
|
initVal: card.label || '',
|
required: true
|
},
|
{
|
type: 'select',
|
key: 'type',
|
label: this.state.dict['header.form.tabType'],
|
initVal: card.type || 'SubTable',
|
required: true,
|
options: [{
|
value: 'SubTable',
|
text: this.state.dict['header.menu.tab.subtable']
|
}]
|
},
|
{
|
type: 'select',
|
key: 'linkTab',
|
label: '关联标签',
|
initVal: card.linkTab || '',
|
required: false,
|
options: []
|
},
|
{
|
type: 'select',
|
key: 'icon',
|
label: this.state.dict['header.menu.icon'],
|
initVal: card.icon || '',
|
required: false,
|
options: [{
|
value: '',
|
text: this.state.dict['header.form.empty']
|
}, {
|
value: 'table',
|
text: 'table'
|
}, {
|
value: 'bar-chart',
|
text: 'bar-chart'
|
}, {
|
value: 'pie-chart',
|
text: 'pie-chart'
|
}, {
|
value: 'line-chart',
|
text: 'line-chart'
|
}]
|
},
|
{
|
type: 'mutilselect',
|
key: 'subtabs',
|
label: '下级标签',
|
initVal: subtabs,
|
required: false,
|
options: menus
|
}
|
]
|
})
|
}
|
|
handleGridBtn = () => {
|
this.setState({
|
visible: true,
|
formtemp: 'gridbtn',
|
modalTitle: '编辑-操作列',
|
})
|
}
|
|
/**
|
* @description 搜索、按钮、显示列修改后提交保存
|
* 1、搜索条件保存,当类型为下拉框且存在数据源时,将查询条件拼接为sql,并用base64转码
|
* 2、按钮包括正常编辑和复制,复制时,按钮列末尾添加
|
* 3、添加或编辑列,保存时,如按钮位置设置为表格,则修改操作列显示状态
|
*/
|
handleSubmit = () => {
|
const { menu } = this.props
|
const { card } = this.state
|
let _config = JSON.parse(JSON.stringify(this.state.config))
|
|
if (this.state.formtemp !== 'gridbtn') {
|
this.formRef.handleConfirm().then(res => {
|
let isupdate = false
|
|
if (res.type === 'action' && card.originCard && res.values.OpenType === 'pop') {
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: card.originCard.uuid
|
}).then(result => {
|
if (result.status && result.LongParam) {
|
let param = {
|
func: 'sPC_ButtonParam_AddUpt',
|
ParentID: menu.MenuID,
|
MenuID: res.values.uuid,
|
MenuNo: menu.MenuNo,
|
Template: 'Modal',
|
MenuName: res.values.label,
|
PageParam: JSON.stringify({Template: 'Modal'}),
|
LongParam: result.LongParam
|
}
|
Api.getSystemConfig(param).then(response => {
|
if (!response.status) {
|
notification.warning({
|
top: 92,
|
message: response.message,
|
duration: 10
|
})
|
}
|
})
|
}
|
})
|
}
|
|
if (res.type !== 'tabs') {
|
_config[res.type] = _config[res.type].map(item => {
|
if (item.uuid === res.values.uuid) {
|
isupdate = true
|
return res.values
|
} else {
|
return item
|
}
|
})
|
_config[res.type] = _config[res.type].filter(item => !item.origin)
|
|
if (!isupdate) { // 操作不是修改,添加元素至列表
|
_config[res.type].push(res.values)
|
}
|
} else { // 标签页的添加与修改
|
_config[res.values.groupId] = _config[res.values.groupId].map(item => {
|
if (item.uuid === res.values.uuid) {
|
isupdate = true
|
return res.values
|
} else {
|
return item
|
}
|
})
|
_config[res.values.groupId] = _config[res.values.groupId].filter(item => !item.origin)
|
|
if (!isupdate) { // 操作不是修改,添加元素至列表
|
_config[res.values.groupId].push(res.values)
|
}
|
}
|
|
|
if (res.type === 'action') {
|
let gridbtn = _config.action.filter(act => act.position === 'grid')
|
let _display = false
|
|
if (gridbtn.length > 0) {
|
_display = true
|
}
|
|
if (_config.gridBtn) {
|
_config.gridBtn.display = _display
|
} else {
|
_config.gridBtn = {
|
display: _display,
|
Align: 'center',
|
IsSort: 'false',
|
uuid: Utils.getuuid(),
|
label: this.state.dict['header.form.column.action'],
|
type: 'action',
|
style: 'button',
|
show: 'horizontal',
|
Width: 120
|
}
|
}
|
}
|
|
this.setState({
|
config: _config,
|
searchloading: true,
|
actionloading: true,
|
columnsloading: true,
|
tabloading: true,
|
visible: false
|
}, () => {
|
this.setState({
|
searchloading: false,
|
actionloading: false,
|
columnsloading: false,
|
tabloading: false
|
})
|
})
|
})
|
} else {
|
this.formRef.handleConfirm().then(res => {
|
_config.gridBtn = res
|
|
this.setState({
|
config: _config,
|
visible: false
|
})
|
})
|
}
|
}
|
|
/**
|
* @description 创建按钮存储过程
|
*/
|
creatFunc = () => {
|
const { menu } = this.props
|
let _config = JSON.parse(JSON.stringify(this.state.config))
|
|
this.formRef.handleConfirm().then(res => {
|
let btn = res.values // 按钮信息
|
let newLText = '' // 创建存储过程sql
|
let DelText = '' // 删除存储过程sql
|
let isExit = false // 存储过程是否存在
|
let sysTVPText = '' // 已有的存储过程语句(云端)
|
let localTVPText = '' // 已有的存储过程语句(本地)
|
|
// 创建存储过程,必须填写内部函数名
|
if (!btn.innerFunc) {
|
notification.warning({
|
top: 92,
|
message: '请填写内部函数!',
|
duration: 10
|
})
|
return
|
}
|
|
// 创建中
|
this.setState({
|
funcLoading: true
|
})
|
|
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) {
|
_LongParam = window.decodeURIComponent(window.atob(res.LongParam))
|
try {
|
_LongParam = JSON.parse(_LongParam)
|
} catch (e) {
|
_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(Utils.getfunc(_param, btn, menu, _config))
|
DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName))
|
resolve(true)
|
} else {
|
resolve(false)
|
notification.warning({
|
top: 92,
|
message: '弹窗(表单)按钮,请先配置表单信息!',
|
duration: 10
|
})
|
}
|
})
|
} else {
|
let _param = {
|
funcName: btn.innerFunc,
|
name: _config.setting.tableName || '',
|
fields: '',
|
menuNo: menu.MenuNo
|
}
|
newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config))
|
DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName))
|
resolve(true)
|
}
|
}).then(res => {
|
// 获取云端及本地,是否已存在该存储过程的信息
|
if (res === false) return res
|
|
let sysDefer = new Promise(resolve => {
|
Api.getSystemConfig({
|
func: 'sPC_Get_TVP', // 云端获取存储结果
|
TVPName: btn.innerFunc
|
}).then(result => {
|
resolve(result)
|
})
|
})
|
|
let localDefer = new Promise(resolve => {
|
let _param = { // 获取本地存储过程信息
|
func: 's_get_userproc',
|
LText: btn.innerFunc
|
}
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
Api.getLocalConfig(_param).then(result => {
|
resolve(result)
|
})
|
})
|
|
return Promise.all([sysDefer, localDefer])
|
}).then(res => {
|
// 云端结果与新语句不同时,更新云端信息
|
if (res === false) return res
|
|
let isError = false
|
|
res.forEach((result, index) => {
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
isError = true
|
} else if (index === 0) {
|
sysTVPText = result.TVPText
|
} else {
|
if (result.Ltext) { // 本地存储过程是否存在
|
isExit = true
|
}
|
localTVPText = Utils.formatOptions(result.Ltext)
|
}
|
})
|
|
if (isError) return false
|
|
if ((newLText === localTVPText) && (newLText === sysTVPText)) {
|
return 'drop'
|
} else if (!localTVPText || (localTVPText === sysTVPText)) {
|
// 本地存储过程不存在,将新的存储过程更新至云端
|
return Api.getSystemConfig({
|
func: 'sPC_TVP_InUp',
|
TVPName: btn.innerFunc,
|
TVPText: newLText,
|
TypeName: 'P'
|
})
|
} else {
|
return new Promise(resolve => {
|
Api.getSystemConfig({ // 添加现有的本地存储过程至云端
|
func: 'sPC_TVP_InUp',
|
TVPName: btn.innerFunc,
|
TVPText: localTVPText,
|
TypeName: 'P'
|
}).then(result => {
|
if (result.status) {
|
Api.getSystemConfig({
|
func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端
|
TVPName: btn.innerFunc,
|
TVPText: newLText,
|
TypeName: 'P'
|
}).then(response => {
|
resolve(response)
|
})
|
} else {
|
resolve(result)
|
}
|
})
|
})
|
}
|
}).then(res => {
|
// 云端信息更新后,判断是删除或是直接新建存储过程
|
if (res === false || res === 'drop') return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else if (isExit) {
|
return 'drop'
|
} else {
|
return 'create'
|
}
|
}).then(res => {
|
// 删除存储过程
|
if (res === false || res === 'create') return res
|
|
let _param = {
|
func: 'sPC_TableData_InUpDe',
|
LText: DelText,
|
TypeCharOne: 'proc' // 删除或创建存储过程
|
}
|
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
return Api.getLocalConfig(_param)
|
}).then(res => {
|
// 根据上述操作结果,判断是否新建存储过程
|
if (res === false || res === 'create') return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else {
|
return 'create'
|
}
|
}).then(res => {
|
// 新建存储过程
|
if (res === false) return res
|
|
let _param = {
|
func: 'sPC_TableData_InUpDe',
|
LText: newLText,
|
TypeCharOne: 'proc' // 删除或创建存储过程
|
}
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
return Api.getLocalConfig(_param)
|
}).then(res => {
|
// 处理新建结果
|
if (res === false) return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else {
|
notification.success({
|
top: 92,
|
message: '创建成功',
|
duration: 2
|
})
|
return true
|
}
|
}).then(res => {
|
// 新建成功后,更新页面按钮信息
|
if (res === false) {
|
this.setState({
|
funcLoading: false
|
})
|
return
|
}
|
|
let isupdate = false
|
_config.action = _config.action.map(item => {
|
if (item.uuid === btn.uuid) {
|
isupdate = true
|
return btn
|
} else {
|
return item
|
}
|
})
|
_config.action = _config.action.filter(item => !item.origin)
|
|
|
if (!isupdate) { // 操作不是修改,添加元素至列表
|
_config.action.push(btn)
|
}
|
|
let gridbtn = _config.action.filter(act => act.position === 'grid')
|
let _display = false
|
|
if (gridbtn.length > 0) {
|
_display = true
|
}
|
|
if (_config.gridBtn) {
|
_config.gridBtn.display = _display
|
} else {
|
_config.gridBtn = {
|
display: _display,
|
Align: 'center',
|
IsSort: 'false',
|
uuid: Utils.getuuid(),
|
label: this.state.dict['header.form.column.action'],
|
type: 'action',
|
style: 'button',
|
show: 'horizontal',
|
Width: 120
|
}
|
}
|
|
this.setState({
|
config: _config,
|
actionloading: true,
|
funcLoading: false
|
}, () => {
|
this.setState({
|
actionloading: false
|
})
|
})
|
})
|
})
|
}
|
|
/**
|
* @description 创建表格存储过程
|
*/
|
tableCreatFunc = () => {
|
const { menu } = this.props
|
let config = JSON.parse(JSON.stringify(this.state.config))
|
|
this.settingRef.handleConfirm().then(res => {
|
const setting = res
|
if (!(setting.interType === 'inner') || !setting.innerFunc) {
|
notification.warning({
|
top: 92,
|
message: '接口类型为-内部,且存在内部函数时,才可以创建存储过程!',
|
duration: 10
|
})
|
return
|
}
|
|
if (setting.dataresource.length > 50 && config.setting.dataresource !== setting.dataresource) {
|
let param = {
|
func: 's_DataSrc_Save',
|
LText: setting.dataresource,
|
MenuID: menu.MenuID
|
}
|
|
param.LText = Utils.formatOptions(param.LText)
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
|
Api.getLocalConfig(param)
|
}
|
|
this.setState({
|
funcLoading: true
|
})
|
|
let newLText = Utils.formatOptions(Utils.getTableFunc(setting, menu, config)) // 创建存储过程sql
|
let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc)) // 删除存储过程sql
|
|
new Promise(resolve => {
|
let sysDefer = new Promise(resolve => {
|
Api.getSystemConfig({
|
func: 'sPC_Get_TVP', // 云端获取存储结果
|
TVPName: setting.innerFunc
|
}).then(result => {
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
resolve(false)
|
} else {
|
resolve(result)
|
}
|
})
|
})
|
|
let localDefer = new Promise(resolve => {
|
let _param = { // 获取本地存储过程信息
|
func: 's_get_userproc',
|
LText: setting.innerFunc
|
}
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
Api.getLocalConfig(_param).then(result => {
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
resolve(false)
|
} else {
|
resolve(result)
|
}
|
})
|
})
|
|
Promise.all([sysDefer, localDefer]).then(result => {
|
resolve(result)
|
})
|
}).then(res => {
|
// 获取云端及本地,是否已存在该存储过程的信息
|
if (res === false) return res
|
if (res[0] === false || res[1] === false) return false
|
|
let cloudfunc = ''
|
let localfunc = ''
|
res.forEach((item, index) => {
|
if (index === 0 && item.TVPText) {
|
cloudfunc = item.TVPText
|
} else if (index === 1 && item.Ltext) {
|
localfunc = Utils.formatOptions(item.Ltext)
|
}
|
})
|
|
if ((newLText === localfunc) && (newLText === cloudfunc)) {
|
return 'drop'
|
} else if (!localfunc || (cloudfunc === localfunc)) {
|
// 本地存储过程不存在,或云端和本地存储过程一致时,将新的存储过程更新至云端
|
return Api.getSystemConfig({
|
func: 'sPC_TVP_InUp',
|
TVPName: setting.innerFunc,
|
TVPText: newLText,
|
TypeName: 'P'
|
})
|
} else {
|
return new Promise(resolve => {
|
Api.getSystemConfig({ // 添加现有的本地存储过程至云端
|
func: 'sPC_TVP_InUp',
|
TVPName: setting.innerFunc,
|
TVPText: localfunc,
|
TypeName: 'P'
|
}).then(result => {
|
if (result.status) {
|
Api.getSystemConfig({
|
func: 'sPC_TVP_InUp', // 添加最新的存储过程至云端
|
TVPName: setting.innerFunc,
|
TVPText: newLText,
|
TypeName: 'P'
|
}).then(response => {
|
resolve(response)
|
})
|
} else {
|
resolve(result)
|
}
|
})
|
})
|
}
|
}).then(res => {
|
// 云端信息更新后,判断是删除或是直接新建存储过程
|
if (res === false || res === 'drop') return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else {
|
return 'create'
|
}
|
}).then(res => {
|
// 删除存储过程
|
if (res === false || res === 'create') return res
|
|
let _param = {
|
func: 'sPC_TableData_InUpDe',
|
LText: DelText,
|
TypeCharOne: 'proc' // 删除或创建存储过程
|
}
|
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
return Api.getLocalConfig(_param)
|
}).then(res => {
|
// 根据上述操作结果,判断是否新建存储过程
|
if (res === false || res === 'create') return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else {
|
return 'create'
|
}
|
}).then(res => {
|
// 新建存储过程
|
if (res === false) return res
|
|
let _param = {
|
func: 'sPC_TableData_InUpDe',
|
LText: newLText,
|
TypeCharOne: 'proc' // 删除或创建存储过程
|
}
|
_param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
_param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
|
|
return Api.getLocalConfig(_param)
|
}).then(res => {
|
// 处理新建结果
|
if (res === false) return res
|
|
if (!res.status) {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
return false
|
} else {
|
notification.success({
|
top: 92,
|
message: '创建成功',
|
duration: 2
|
})
|
return true
|
}
|
}).then(res => {
|
// 新建成功后,更新页面按钮信息
|
if (res === false) {
|
this.setState({
|
funcLoading: false
|
})
|
return
|
}
|
|
this.setState({
|
config: {...config, setting: setting}
|
})
|
})
|
})
|
}
|
|
deleteElement = (element) => {
|
let _this = this
|
confirm({
|
content: `确定删除<<${element.card.label}>>吗?`,
|
okText: this.state.dict['header.confirm'],
|
cancelText: this.state.dict['header.cancel'],
|
onOk() {
|
let _config = JSON.parse(JSON.stringify(_this.state.config))
|
|
if (element.type === 'tabs') {
|
_config[element.card.groupId] = _config[element.card.groupId].filter(item => {
|
if (item.uuid === element.card.uuid) {
|
return false
|
} else {
|
return true
|
}
|
})
|
} else {
|
_config[element.type] = _config[element.type].filter(item => {
|
if (item.uuid === element.card.uuid) {
|
return false
|
} else {
|
return true
|
}
|
})
|
}
|
|
let refreshtype = element.type + 'loading'
|
|
if (/^tab/.test(refreshtype)) {
|
refreshtype = 'tabloading'
|
}
|
|
_this.setState({
|
config: _config,
|
delActions: [..._this.state.delActions, element.card.uuid],
|
[refreshtype]: true
|
}, () => {
|
_this.setState({
|
[refreshtype]: false
|
})
|
})
|
},
|
onCancel() {}
|
})
|
}
|
|
/**
|
* @description 验证信息配置
|
*/
|
profileAction = (element) => {
|
this.setState({
|
profileVisible: true,
|
card: element
|
})
|
}
|
|
/**
|
* @description 验证信息保存
|
*/
|
verifySubmit = () => {
|
const { card } = this.state
|
let config = JSON.parse(JSON.stringify(this.state.config))
|
let _verify = this.verifyRef.state.verify
|
|
config.action = config.action.map(item => {
|
if (item.uuid === card.uuid) {
|
item.verify = _verify
|
}
|
|
return item
|
})
|
|
this.setState({
|
profileVisible: false,
|
config: config,
|
card: '',
|
actionloading: true
|
}, () => {
|
this.setState({
|
actionloading: false
|
})
|
})
|
}
|
|
/**
|
* @description 三级菜单切换模板
|
*/
|
changeTemplate = () => {
|
this.props.handleConfig('template')
|
}
|
|
/**
|
* @description 三级菜单保存
|
*/
|
submitConfig = () => {
|
const { menu } = this.props
|
const { originMenu } = this.state
|
|
let config = JSON.parse(JSON.stringify(this.state.config))
|
|
this.menuformRef.handleConfirm().then(res => {
|
|
if (config.search[0] && config.search[0].origin) {
|
config.search = config.search.filter(item => !item.origin)
|
}
|
if (config.action[0] && config.action[0].origin) {
|
config.action = config.action.filter(item => !item.origin)
|
}
|
if (config.columns[0] && config.columns[0].origin) {
|
config.columns = config.columns.filter(item => !item.origin)
|
}
|
if (config.tabs[0] && config.tabs[0].origin) {
|
config.tabs = config.tabs.filter(item => !item.origin)
|
}
|
|
let _LongParam = ''
|
let _config = {...config, tables: this.state.selectedTables}
|
let _pageParam = {...menu.PageParam, OpenType: res.opentype}
|
|
// 未设置数据源或标签不合法时,启用状态为false
|
if (_config.setting.interType === 'inner' && !_config.setting.innerFunc && !_config.setting.dataresource) {
|
_config.enabled = false
|
} else if (_config.tabgroups.length > 1) {
|
_config.tabgroups.forEach(group => {
|
if (_config[group].length === 0) {
|
_config.enabled = false
|
}
|
})
|
}
|
|
// 保存时删除配置类型,system 、user
|
delete _config.type
|
|
try {
|
_LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
|
} catch (e) {
|
notification.warning({
|
top: 92,
|
message: '编译错误',
|
duration: 10
|
})
|
return
|
}
|
|
let btnParam = { // 添加菜单按钮
|
func: 'sPC_Button_AddUpt',
|
ParentID: menu.MenuID,
|
MenuNo: res.menuNo,
|
Template: menu.PageParam.Template || '',
|
PageParam: '',
|
LongParam: '',
|
LText: config.action.map((item, index) => {
|
return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`
|
})
|
}
|
|
btnParam.LText = btnParam.LText.join(' union all ')
|
btnParam.LText = Utils.formatOptions(btnParam.LText)
|
btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
|
|
let tabParam = { // 添加菜单tab页
|
func: 'sPC_sMenusTab_AddUpt',
|
MenuID: menu.MenuID,
|
LText: config.tabs.map((item, index) => {
|
return `select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`
|
})
|
}
|
tabParam.LText = tabParam.LText.join(' union all ')
|
tabParam.LText = Utils.formatOptions(tabParam.LText)
|
tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
|
|
let param = {
|
func: 'sPC_TrdMenu_AddUpt',
|
ParentID: res.parentId,
|
MenuID: menu.MenuID,
|
MenuNo: res.menuNo,
|
Template: menu.PageParam.Template || '',
|
MenuName: res.menuName,
|
Sort: (this.props.supMenuList.length + 1) * 10,
|
PageParam: JSON.stringify(_pageParam),
|
LongParam: _LongParam
|
}
|
|
if (this.state.closeVisible) { // 显示关闭对话框时,模态框中保存按钮,显示保存中状态
|
this.setState({
|
menucloseloading: true
|
})
|
} else {
|
this.setState({
|
menuloading: true
|
})
|
}
|
|
Api.getSystemConfig(param).then(response => {
|
if (response.status) {
|
this.setState({
|
config: _config,
|
originMenu: {
|
...originMenu,
|
LongParam: _config,
|
PageParam: _pageParam,
|
MenuName: res.menuName,
|
MenuNo: res.menuNo,
|
ParentID: res.parentId
|
},
|
searchloading: true,
|
actionloading: true,
|
columnsloading: true
|
}, () => {
|
this.setState({
|
searchloading: false,
|
actionloading: false,
|
columnsloading: false
|
})
|
})
|
|
this.props.reloadmenu()
|
|
this.submitAction(btnParam, tabParam)
|
} else {
|
this.setState({
|
menuloading: false,
|
menucloseloading: false
|
})
|
notification.warning({
|
top: 92,
|
message: response.message,
|
duration: 10
|
})
|
}
|
})
|
}, () => {
|
notification.warning({
|
top: 92,
|
message: this.state.dict['header.menu.basemsg'],
|
duration: 10
|
})
|
})
|
}
|
|
/**
|
* @description 保存或修改菜单按钮
|
*/
|
submitAction = (btnParam, tabParam) => {
|
const { config } = this.state
|
new Promise(resolve => {
|
// 内部请求
|
if (this.state.delActions.length > 0) {
|
let deffers = this.state.delActions.map(item => {
|
let _param = {
|
func: 'sPC_MainMenu_Del',
|
MenuID: item
|
}
|
return new Promise(resolve => {
|
Api.getSystemConfig(_param).then(res => {
|
resolve(res)
|
})
|
})
|
})
|
Promise.all(deffers).then(result => {
|
let error = false
|
result.forEach(res => {
|
if (!res.status) {
|
error = res
|
}
|
})
|
|
if (error) {
|
notification.warning({
|
top: 92,
|
message: error.message,
|
duration: 10
|
})
|
resolve(false)
|
} else {
|
this.setState({
|
delActions: []
|
})
|
resolve(true)
|
}
|
})
|
} else if (this.state.delActions.length === 0) {
|
resolve(true)
|
}
|
}).then(res => {
|
if (res === false) return res
|
|
if (tabParam.LText) {
|
Api.getSystemConfig(tabParam).then(result => {
|
if (!result.status) {
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
})
|
}
|
if (btnParam.LText) {
|
return Api.getSystemConfig(btnParam)
|
} else {
|
return 'copy'
|
}
|
}).then(response => {
|
if (response === false || response === 'copy') return response
|
|
if (response.status) {
|
return 'copy'
|
} else {
|
notification.warning({
|
top: 92,
|
message: response.message,
|
duration: 10
|
})
|
return false
|
}
|
}).then(response => {
|
if (response === false) return response
|
|
let oriActions = []
|
this.state.originActions.forEach(item => {
|
let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 查看初始化按钮是否存在
|
if (!curBtn) return
|
if (curBtn.OpenType !== item.prebtn.OpenType) return
|
|
oriActions.push({
|
prebtn: item.prebtn,
|
curBtn: curBtn
|
})
|
})
|
|
if (oriActions.length === 0) return 'true'
|
|
oriActions.forEach(action => {
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: action.prebtn ? action.prebtn.uuid : ''
|
}).then(result => {
|
if (result.status && result.LongParam) {
|
let _LongParam = ''
|
|
if (result.LongParam) {
|
_LongParam = window.decodeURIComponent(window.atob(result.LongParam))
|
try {
|
_LongParam = JSON.parse(_LongParam)
|
} catch (e) {
|
_LongParam = ''
|
}
|
}
|
|
if (_LongParam) {
|
let param = {
|
func: 'sPC_ButtonParam_AddUpt',
|
ParentID: this.props.menu.MenuID,
|
MenuID: action.curBtn.uuid,
|
MenuNo: this.props.menu.MenuNo,
|
Template: _LongParam.type,
|
MenuName: action.curBtn.label,
|
PageParam: JSON.stringify({Template: _LongParam.type}),
|
LongParam: result.LongParam
|
}
|
Api.getSystemConfig(param).then(() => {})
|
}
|
}
|
})
|
})
|
return 'true'
|
}).then(response => {
|
if (response === 'true') {
|
notification.success({
|
top: 92,
|
message: '保存成功',
|
duration: 2
|
})
|
if (this.state.closeVisible) {
|
this.props.handleConfig('')
|
} else {
|
this.setState({
|
menuloading: false,
|
menucloseloading: false
|
})
|
}
|
} else {
|
this.setState({
|
menuloading: false,
|
menucloseloading: false
|
})
|
}
|
})
|
}
|
|
cancelConfig = () => {
|
const { menu } = this.props
|
const { config, originMenu } = this.state
|
|
let _this = this
|
let isAdd = false
|
|
if (
|
(config.search[0] && config.search[0].origin) ||
|
(config.action[0] && config.action[0].origin) ||
|
(config.columns[0] && config.columns[0].origin) ||
|
(config.tabs[0] && config.tabs[0].origin)
|
) {
|
isAdd = true
|
}
|
|
if (isAdd) {
|
confirm({
|
content: '菜单尚未提交,确定放弃保存吗?',
|
okText: this.state.dict['header.confirm'],
|
cancelText: this.state.dict['header.cancel'],
|
onOk() {
|
_this.props.handleConfig('')
|
},
|
onCancel() {}
|
})
|
} else {
|
this.menuformRef.handleConfirm().then(res => {
|
let _config = {...config, tables: this.state.selectedTables}
|
let _pageParam = {...menu.PageParam, OpenType: res.opentype}
|
let _originMenu = {
|
...originMenu,
|
LongParam: _config,
|
PageParam: _pageParam,
|
MenuName: res.menuName,
|
MenuNo: res.menuNo,
|
ParentID: res.parentId
|
}
|
|
if (!is(fromJS(originMenu), fromJS(_originMenu))) {
|
this.setState({
|
closeVisible: true
|
})
|
} else {
|
this.props.handleConfig('')
|
}
|
}, () => {
|
this.setState({
|
closeVisible: true
|
})
|
})
|
}
|
}
|
|
queryField = (type) => {
|
const {selectedTables, tableColumns, config} = this.state
|
// 判断是否已选择表名
|
if (selectedTables.length === 0) {
|
notification.warning({
|
top: 92,
|
message: '请选择表名!',
|
duration: 10
|
})
|
return
|
}
|
|
// 表字段集转为map数据
|
let columns = new Map()
|
tableColumns.forEach(table => {
|
table.columns.forEach(column => {
|
columns.set(column.field, column)
|
})
|
})
|
|
if (type === 'search') {
|
// 添加搜索条件,字段集中存在搜索条件字段,使用搜索条件对象替换字段集,设置数据类型
|
config.search.forEach(item => {
|
if (columns.has(item.field)) {
|
let _datatype = columns.get(item.field).datatype
|
columns.set(item.field, {...item, selected: true, datatype: _datatype})
|
}
|
})
|
} else if (type === 'columns') {
|
// 添加显示列,字段集中存在显示列字段,使用显示列对象替换字段集,设置数据类型
|
config.columns.forEach(item => {
|
if (columns.has(item.field)) {
|
let _datatype = columns.get(item.field).datatype
|
columns.set(item.field, {...item, selected: true, datatype: _datatype})
|
}
|
})
|
}
|
|
// 显示字段集弹窗
|
this.setState({
|
addType: type,
|
tableVisible: true,
|
fields: [...columns.values()]
|
})
|
}
|
|
addFieldSubmit = () => {
|
// 字段集为空,关闭弹窗
|
if (!this.state.fields || this.state.fields.length === 0) {
|
this.setState({
|
tableVisible: false,
|
addType: ''
|
})
|
}
|
|
const {addType, config} = this.state
|
const textmatch = { // 选择text时匹配规则
|
text: 'like',
|
number: 'like',
|
datetime: 'like',
|
date: 'like'
|
}
|
const selectmatch = { // 选择select时匹配规则
|
text: '=',
|
number: '=',
|
datetime: '=',
|
date: '='
|
}
|
const datematch = { // 选择dateRange时匹配规则
|
text: 'between',
|
number: 'between',
|
datetime: 'between',
|
date: 'between'
|
}
|
|
// 获取已选字段集合
|
let cards = this.refs.searchcard.state.selectCards
|
let columnsMap = new Map()
|
cards.forEach(card => {
|
columnsMap.set(card.field, card)
|
})
|
|
let items = []
|
if (addType === 'search') {
|
config.search.forEach(item => {
|
if (columnsMap.has(item.field)) {
|
let cell = columnsMap.get(item.field)
|
|
if (cell.selected && cell.type === item.type) { // 数据未修改
|
items.push(item)
|
} else if (cell.selected) { // 数据类型修改
|
if (cell.type === 'text') {
|
item.match = textmatch[cell.datatype]
|
} else if (cell.type === 'select') {
|
item.match = selectmatch[cell.datatype]
|
} else if (cell.type === 'daterange') {
|
item.match = datematch[cell.datatype]
|
} else {
|
cell.type = 'text'
|
item.match = textmatch[cell.datatype]
|
}
|
|
item.type = cell.type
|
item.initval = ''
|
items.push(item)
|
}
|
columnsMap.delete(item.field)
|
} else if (!item.origin) {
|
items.push(item)
|
}
|
})
|
|
let _columns = [...columnsMap.values()]
|
|
_columns.forEach(item => {
|
if (item.selected) {
|
let _match = ''
|
if (item.type === 'text') {
|
_match = textmatch[item.datatype]
|
} else if (item.type === 'select') {
|
_match = selectmatch[item.datatype]
|
} else if (item.type === 'daterange') {
|
_match = datematch[item.datatype]
|
} else {
|
item.type = 'text'
|
_match = textmatch[item.datatype]
|
}
|
|
let newcard = {
|
uuid: Utils.getuuid(),
|
label: item.label,
|
field: item.field,
|
initval: '',
|
type: item.type,
|
resourceType: '0',
|
setAll: 'false',
|
options: [],
|
dataSource: '',
|
linkField: '',
|
valueField: '',
|
valueText: '',
|
orderBy: '',
|
orderType: 'asc',
|
match: _match,
|
display: 'dropdown'
|
}
|
|
items.push(newcard)
|
}
|
})
|
} else {
|
config.columns.forEach(item => {
|
if (columnsMap.has(item.field)) {
|
let cell = columnsMap.get(item.field)
|
|
if (cell.selected) {
|
items.push(item)
|
}
|
columnsMap.delete(item.field)
|
} else if (!item.origin) {
|
items.push(item)
|
}
|
})
|
|
let _columns = [...columnsMap.values()]
|
|
_columns.forEach(item => {
|
if (item.selected) {
|
let newcard = {
|
uuid: Utils.getuuid(),
|
Align: 'left',
|
label: item.label,
|
field: item.field,
|
Hide: 'false',
|
IsSort: item.type === 'picture' ? 'false' : 'true',
|
type: item.type,
|
Width: 120
|
}
|
|
items.push(newcard)
|
}
|
})
|
}
|
|
this.setState({
|
[addType + 'loading']: true,
|
config: {...config, [addType]: items}
|
}, () => {
|
notification.success({
|
top: 92,
|
message: '操作成功',
|
duration: 2
|
})
|
this.setState({
|
[addType + 'loading']: false
|
})
|
})
|
}
|
|
onTableChange = (value) => {
|
const {tables, selectedTables, tableColumns} = this.state
|
|
let _table = tables.filter(item => item.TbName === value)[0]
|
let isSelected = !!selectedTables.filter(cell => cell.TbName === value)[0]
|
if (!isSelected) {
|
this.setState({
|
selectedTables: [...selectedTables, _table]
|
})
|
Api.getSystemConfig({func: 'sPC_Get_FieldName', TBName: value}).then(res => {
|
if (res.status) {
|
let tabmsg = {
|
tableName: _table.name,
|
columns: res.FDName.map(item => {
|
let _type = item.FieldType.toLowerCase()
|
let _decimal = 0
|
if (/^nvarchar/.test(_type)) {
|
_type = 'text'
|
} else if (/^int/.test(_type)) {
|
_type = 'number'
|
} else if (/^decimal/.test(_type)) {
|
_decimal = _type.split(',')[1]
|
_decimal = parseInt(_decimal)
|
_type = 'number'
|
} else if (/^datetime/.test(_type)) {
|
_type = 'datetime'
|
} else if (/^date/.test(_type)) {
|
_type = 'date'
|
} else {
|
_type = 'text'
|
}
|
|
return {
|
field: item.FieldName,
|
label: item.FieldDec,
|
type: _type,
|
datatype: _type,
|
decimal: _decimal
|
}
|
})
|
}
|
this.setState({
|
tableColumns: [...tableColumns, tabmsg]
|
})
|
} else {
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
}
|
}
|
|
deleteTable = (table) => {
|
const {selectedTables, tableColumns} = this.state
|
|
this.setState({
|
selectedTables: selectedTables.filter(item => item.TbName !== table.TbName),
|
tableColumns: tableColumns.filter(item => item.tableName !== table.TbName)
|
})
|
}
|
|
changeSetting = () => {
|
this.setState({
|
settingVisible: true
|
})
|
}
|
|
settingSave = () => {
|
const { menu } = this.props
|
const {config} = this.state
|
|
this.settingRef.handleConfirm().then(res => {
|
if (
|
res.interType === 'inner' &&
|
!res.innerFunc &&
|
res.dataresource.length > 50 &&
|
config.setting.dataresource !== res.dataresource
|
) {
|
let param = {
|
func: 's_DataSrc_Save',
|
LText: res.dataresource,
|
MenuID: menu.MenuID
|
}
|
|
param.LText = Utils.formatOptions(param.LText)
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
|
Api.getLocalConfig(param)
|
}
|
|
this.setState({
|
config: {...config, setting: res},
|
settingVisible: false,
|
columnsloading: true,
|
tabloading: true
|
}, () => {
|
this.setState({
|
columnsloading: false,
|
tabloading: false
|
})
|
})
|
})
|
}
|
|
/**
|
* @description 设置可配置按钮
|
*/
|
setSubConfig = (btn, type) => {
|
const { menu } = this.props
|
const { config, originMenu } = this.state
|
|
let isAdd = false
|
|
if (
|
(config.search[0] && config.search[0].origin) ||
|
(config.action[0] && config.action[0].origin) ||
|
(config.columns[0] && config.columns[0].origin) ||
|
(config.tabs[0] && config.tabs[0].origin)
|
) {
|
isAdd = true
|
}
|
|
if (isAdd) {
|
notification.warning({
|
top: 92,
|
message: '菜单尚未保存,请保存菜单配置!',
|
duration: 10
|
})
|
} else {
|
this.menuformRef.handleConfirm().then(res => {
|
let _config = {...config, tables: this.state.selectedTables}
|
let _pageParam = {...menu.PageParam, OpenType: res.opentype}
|
let _originMenu = {
|
...originMenu,
|
LongParam: _config,
|
PageParam: _pageParam,
|
MenuName: res.menuName,
|
MenuNo: res.menuNo,
|
ParentID: res.parentId
|
}
|
|
if (!is(fromJS(originMenu), fromJS(_originMenu))) {
|
notification.warning({
|
top: 92,
|
message: '菜单配置已修改,请保存!',
|
duration: 10
|
})
|
} else {
|
this.setState({
|
loading: true
|
})
|
|
let uuid = ''
|
let _type = type
|
if (type === 'button' && btn.OpenType === 'popview') {
|
_type = 'tab'
|
} else if (type === 'button' && (btn.OpenType === 'tab' || btn.OpenType === 'blank')) {
|
_type = 'tabview'
|
}
|
|
if (_type === 'tab') {
|
uuid = btn.linkTab
|
} else {
|
uuid = btn.uuid
|
}
|
|
Api.getSystemConfig({
|
func: 'sPC_Get_LongParam',
|
MenuID: uuid
|
}).then(res => {
|
if (res.status) {
|
this.setState({
|
loading: false
|
})
|
let _LongParam = ''
|
if (res.LongParam) {
|
_LongParam = window.decodeURIComponent(window.atob(res.LongParam))
|
try {
|
_LongParam = JSON.parse(_LongParam)
|
} catch (e) {
|
_LongParam = ''
|
}
|
}
|
|
if (_type === 'tab' && !_LongParam) {
|
_LongParam = {
|
...btn,
|
uuid: btn.linkTab,
|
create: true
|
}
|
}
|
|
this.props.handleSubConfig(btn, originMenu, _LongParam, _type)
|
} else {
|
this.setState({
|
loading: false
|
})
|
notification.warning({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
}
|
}, () => {
|
notification.warning({
|
top: 92,
|
message: '菜单基本信息已修改,请保存!',
|
duration: 10
|
})
|
})
|
}
|
}
|
|
onEnabledChange = (val, e) => {
|
const { config } = this.state
|
|
let tabinvalid = true
|
if (config.tabgroups.length > 1) {
|
config.tabgroups.forEach(group => {
|
if (config[group].length === 0) {
|
tabinvalid = false
|
}
|
})
|
}
|
|
if (config.setting.interType === 'inner' && !config.setting.innerFunc && !config.setting.dataresource) {
|
notification.warning({
|
top: 92,
|
message: '菜单尚未设置数据源,不可启用!',
|
duration: 10
|
})
|
} else if (!tabinvalid) {
|
notification.warning({
|
top: 92,
|
message: '菜单标签页设置错误(多行标签内,行标签不可为空),不可启用!',
|
duration: 10
|
})
|
} else {
|
this.setState({
|
config: {...config, enabled: !config.enabled}
|
})
|
}
|
}
|
|
onColumnNameChange = () => {
|
const { showColumnName } = this.state
|
|
this.setState({
|
showColumnName: !showColumnName
|
})
|
}
|
|
addTabGroup = () => {
|
let _this = this
|
let _config = JSON.parse(JSON.stringify(this.state.config))
|
|
confirm({
|
content: `确定新建标签组吗?`,
|
okText: this.state.dict['header.confirm'],
|
cancelText: this.state.dict['header.cancel'],
|
onOk() {
|
let newgroup = 'tabs' + Utils.getuuid()
|
|
_config.tabgroups.push(newgroup)
|
_config[newgroup] = []
|
|
_this.setState({
|
config: _config,
|
tabloading: true
|
}, () => {
|
_this.setState({
|
tabloading: false
|
})
|
})
|
},
|
onCancel() {}
|
})
|
}
|
|
delTabGroup = (groupId) => {
|
let _this = this
|
let _config = JSON.parse(JSON.stringify(this.state.config))
|
|
confirm({
|
content: `确定删除标签组吗?`,
|
okText: this.state.dict['header.confirm'],
|
cancelText: this.state.dict['header.cancel'],
|
onOk() {
|
|
_config.tabgroups = _config.tabgroups.filter(group => group !== groupId)
|
delete _config[groupId]
|
|
_this.setState({
|
config: _config,
|
tabloading: true
|
}, () => {
|
_this.setState({
|
tabloading: false
|
})
|
})
|
},
|
onCancel() {}
|
})
|
}
|
|
render () {
|
const configAction = this.state.config.action.filter(_action =>
|
!_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab')
|
)
|
|
let configTabs = []
|
this.state.config.tabgroups.forEach(group => {
|
configTabs.push(...this.state.config[group])
|
})
|
|
return (
|
<div className="common-table-board">
|
<DndProvider backend={HTML5Backend}>
|
{/* 工具栏 */}
|
<div className="tools">
|
<Collapse accordion defaultActiveKey="0" bordered={false}>
|
{/* 基本信息 */}
|
<Panel header={this.state.dict['header.menu.basedata']} key="0" id="common-basedata">
|
{/* 菜单信息 */}
|
<MenuForm
|
dict={this.state.dict}
|
formlist={this.state.menuformlist}
|
wrappedComponentRef={(inst) => this.menuformRef = inst}
|
/>
|
{/* 表名添加 */}
|
<div className="ant-col ant-form-item-label">
|
<label>
|
<Tooltip placement="topLeft" title="此处可以添加配置相关的常用表,在添加搜索条件和显示列时,可通过工具栏中的添加按钮,批量添加表格相关字段。">
|
<Icon type="question-circle" />
|
{this.state.dict['header.menu.table.add']}
|
</Tooltip>
|
</label>
|
</div>
|
<Select
|
showSearch
|
className="tables"
|
style={{ width: '100%' }}
|
optionFilterProp="children"
|
value={this.state.dict['header.menu.table.placeholder']}
|
onChange={this.onTableChange}
|
showArrow={false}
|
getPopupContainer={() => document.getElementById('common-basedata')}
|
filterOption={(input, option) => {
|
return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
|
option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
}}
|
>
|
{this.state.tables.map((table, index) => (
|
<Option key={index} title={table.TbName} value={table.TbName}>{table.Remark}</Option>
|
))}
|
</Select>
|
{this.state.selectedTables.length > 0 && <List
|
size="small"
|
bordered
|
dataSource={this.state.selectedTables}
|
renderItem={(item, index) => <List.Item key={index} title={item.Remark + ' (' + item.TbName + ')'}>
|
{item.Remark + ' (' + item.TbName + ')'}
|
<Icon type="close" onClick={() => this.deleteTable(item)}/>
|
<div className="bottom-mask"></div>
|
</List.Item>}
|
/>}
|
</Panel>
|
{/* 搜索条件添加 */}
|
<Panel header={this.state.dict['header.menu.search']} key="1">
|
<div className="search-element">
|
{Source.searchItems.map((item, index) => {
|
return (<SourceElement key={index} content={item}/>)
|
})}
|
</div>
|
<Button type="primary" block onClick={() => this.queryField('search')}>{this.state.dict['header.menu.search.add']}</Button>
|
</Panel>
|
{/* 按钮添加 */}
|
<Panel header={this.state.dict['header.menu.action']} key="2">
|
<div className="search-element">
|
{Source.actionItems.map((item, index) => {
|
return (<SourceElement key={index} content={item}/>)
|
})}
|
</div>
|
{configAction.length > 0 ?
|
<p className="config-btn-title">
|
<Tooltip placement="topLeft" title="点击按钮,可完成或查看按钮配置信息。">
|
<Icon type="question-circle" />
|
</Tooltip>
|
{this.state.dict['header.menu.action.configurable']}
|
</p> : null
|
}
|
{configAction.map((item, index) => {
|
return (
|
<div key={index}>
|
<Button
|
icon={item.icon}
|
style={{marginBottom: '10px'}}
|
className={'config-button mk-btn mk-' + item.class}
|
onClick={() => this.setSubConfig(item, 'button')}
|
>{item.label}</Button>
|
</div>
|
)
|
})}
|
</Panel>
|
{/* 添加显示列 */}
|
<Panel header={this.state.dict['header.menu.column']} key="3">
|
<div className="search-element">
|
{Source.columnItems.map((item, index) => {
|
return (<SourceElement key={index} content={item}/>)
|
})}
|
</div>
|
<Button type="primary" block onClick={() => this.queryField('columns')}>{this.state.dict['header.menu.column.add']}</Button>
|
</Panel>
|
{/* 添加标签 */}
|
<Panel header={this.state.dict['header.menu.tab']} key="4">
|
<div className="search-element">
|
{Source.tabItems.map((item, index) => {
|
return (<SourceElement key={index} content={item}/>)
|
})}
|
</div>
|
{configTabs.length > 0 ?
|
<p className="config-btn-title">
|
<Tooltip placement="topLeft" title="点击按钮,可完成或查看标签配置信息。">
|
<Icon type="question-circle" />
|
</Tooltip>
|
{this.state.dict['header.menu.tab.configurable']}
|
</p> : null
|
}
|
{configTabs.map((item, index) => {
|
return (
|
<div key={index}>
|
<Button
|
className="config-button"
|
icon={item.icon}
|
style={{marginBottom: '10px'}}
|
onClick={() => this.setSubConfig(item, 'tab')}
|
>{item.label}</Button>
|
</div>
|
)
|
})}
|
</Panel>
|
</Collapse>
|
</div>
|
<div className="setting">
|
<Card title={this.state.dict['header.menu.page.configurable']} bordered={false} extra={
|
<div>
|
<Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} />
|
<Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button>
|
<Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button>
|
<Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button>
|
</div>
|
} style={{ width: '100%' }}>
|
<Icon type="setting" onClick={this.changeSetting} />
|
<div className="search-list">
|
<Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《搜索》中,选择对应搜索框拖至此处添加;或点击按钮《添加搜索条件》批量添加,选择批量添加时,需提前选择使用表。">
|
<Icon type="question-circle" />
|
</Tooltip>
|
{!this.state.searchloading ?
|
<DragElement
|
type="search"
|
list={this.state.config.search}
|
handleList={this.handleList}
|
handleMenu={this.handleSearch}
|
deleteMenu={this.deleteElement}
|
placeholder={this.state.dict['header.form.search.placeholder']}
|
/> : null
|
}
|
</div>
|
<div className="action-list">
|
<Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《按钮》中,选择对应类型的按钮拖至此处添加,如选择按钮类型为表单、新标签页等含有配置页面的按钮,可在左侧工具栏-按钮-可配置按钮处,点击按钮完成相关配置。注:当设置按钮显示位置为表格时,显示列会增加操作列。">
|
<Icon type="question-circle" />
|
</Tooltip>
|
{!this.state.actionloading ?
|
<DragElement
|
type="action"
|
list={this.state.config.action}
|
handleList={this.handleList}
|
handleMenu={this.handleAction}
|
copyElement={(val) => this.handleAction(val, 'copy')}
|
deleteMenu={this.deleteElement}
|
profileMenu={this.profileAction}
|
placeholder={this.state.dict['header.form.action.placeholder']}
|
/> : null
|
}
|
</div>
|
{/* 显示列 */}
|
<div className="column-list">
|
<Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《显示列》中,选择对应类型的显示列拖至此处添加;或点击《添加显示列》按钮批量添加,选择批量添加时,需提前选择使用表。注:添加合并列时,需设置可选列。">
|
<Icon type="question-circle" />
|
</Tooltip>
|
<Switch checkedChildren="开" unCheckedChildren="关" defaultChecked={this.state.showColumnName} onChange={this.onColumnNameChange} />
|
{!this.state.columnsloading ?
|
<DragElement
|
type="columns"
|
list={this.state.config.columns}
|
setting={this.state.config.setting}
|
gridBtn={this.state.config.gridBtn}
|
handleList={this.handleList}
|
handleMenu={this.handleColumn}
|
deleteMenu={this.deleteElement}
|
handleGridBtn={this.handleGridBtn}
|
showfield={this.state.showColumnName}
|
placeholder={this.state.dict['header.form.column.placeholder']}
|
/> : null
|
}
|
</div>
|
{/* 标签组 */}
|
{!this.state.tabloading && this.state.config.tabgroups.map((groupId, index) => {
|
return (
|
<div key={index} className="tab-list">
|
{index === 0 ? <Tooltip placement="bottomLeft" overlayClassName="middle" title="在左侧工具栏《标签页》中,选择对应类型的标签页拖至此处添加。">
|
<Icon type="question-circle" />
|
</Tooltip> : null}
|
{index === 0 ? <Icon type="plus" onClick={this.addTabGroup} /> : null}
|
{index !== 0 ? <Icon type="delete" onClick={() => {this.delTabGroup(groupId)}} /> : null}
|
<TabDragElement
|
type="tabs"
|
groupId={groupId}
|
list={this.state.config[groupId]}
|
handleList={this.handleList}
|
handleMenu={this.handleTab}
|
deleteMenu={this.deleteElement}
|
placeholder={this.state.dict['header.form.tab.placeholder']}
|
/>
|
</div>)
|
})}
|
</Card>
|
</div>
|
</DndProvider>
|
{/* 编辑搜索条件、按钮、显示列 */}
|
<Modal
|
title={this.state.modalTitle}
|
visible={this.state.visible}
|
width={700}
|
onCancel={() => { this.setState({ visible: false }) }}
|
footer={[
|
this.state.formtemp === 'action' ?
|
<Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null,
|
<Button key="cancel" onClick={() => { this.setState({ visible: false }) }}>{this.state.dict['header.cancel']}</Button>,
|
<Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
|
]}
|
destroyOnClose
|
>
|
{this.state.formtemp === 'search' ?
|
<SearchForm
|
dict={this.state.dict}
|
formlist={this.state.formlist}
|
card={this.state.card}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
{this.state.formtemp === 'action' ?
|
<ActionForm
|
dict={this.state.dict}
|
card={this.state.card}
|
tabs={this.state.tabviews}
|
formlist={this.state.formlist}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
{this.state.formtemp === 'columns' && this.state.card.type !== 'colspan' ?
|
<ColumnForm
|
dict={this.state.dict}
|
card={this.state.card}
|
formlist={this.state.formlist}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
{this.state.formtemp === 'columns' && this.state.card.type === 'colspan' ?
|
<ColspanForm
|
dict={this.state.dict}
|
card={this.state.card}
|
columns={this.state.config.columns}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
{this.state.formtemp === 'gridbtn' ?
|
<GridBtnForm
|
dict={this.state.dict}
|
card={this.state.config.gridBtn}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
{this.state.formtemp === 'tabs' ?
|
<TabForm
|
type="tabs"
|
tabs={this.state.tabviews}
|
dict={this.state.dict}
|
card={this.state.card}
|
formlist={this.state.formlist}
|
wrappedComponentRef={(inst) => this.formRef = inst}
|
/> : null
|
}
|
</Modal>
|
{/* 根据字段名添加显示列及搜索条件 */}
|
<Modal
|
wrapClassName="common-table-fields-modal"
|
title={this.state.dict['header.edit']}
|
visible={this.state.tableVisible}
|
width={'65vw'}
|
style={{minWidth: '900px', maxWidth: '1200px'}}
|
cancelText={this.state.dict['header.close']}
|
onOk={this.addFieldSubmit}
|
onCancel={() => { // 取消添加
|
this.setState({
|
tableVisible: false,
|
addType: ''
|
})
|
}}
|
destroyOnClose
|
>
|
{this.state.addType && this.state.fields.length > 0 ?
|
<EditCard data={this.state.fields} ref="searchcard" type={this.state.addType} dict={this.state.dict} /> : null
|
}
|
{(!this.state.fields || this.state.fields.length === 0) &&
|
<Empty />
|
}
|
</Modal>
|
{/* 按钮使用系统存储过程时,验证信息模态框 */}
|
<Modal
|
wrapClassName="common-table-fields-modal"
|
title={'验证信息'}
|
visible={this.state.profileVisible}
|
width={'75vw'}
|
style={{minWidth: '900px', maxWidth: '1200px'}}
|
onOk={this.verifySubmit}
|
onCancel={() => { this.setState({ profileVisible: false }) }}
|
destroyOnClose
|
>
|
<VerifyCard card={this.state.card} columns={this.state.config.columns} wrappedComponentRef={(inst) => this.verifyRef = inst} dict={this.state.dict} />
|
</Modal>
|
{/* 设置全局配置及列表数据源 */}
|
<Modal
|
title={this.state.dict['header.edit']}
|
visible={this.state.settingVisible}
|
width={700}
|
// onOk={this.settingSave}
|
onCancel={() => { // 取消修改
|
this.setState({
|
settingVisible: false
|
})
|
}}
|
footer={[
|
<Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>,
|
<Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>,
|
<Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button>
|
]}
|
destroyOnClose
|
>
|
<SettingForm
|
dict={this.state.dict}
|
menu={this.props.menu}
|
config={this.state.config}
|
data={this.state.config.setting}
|
columns={this.state.config.columns}
|
usefulFields={this.props.permFuncField}
|
wrappedComponentRef={(inst) => this.settingRef = inst}
|
/>
|
</Modal>
|
<Modal
|
bodyStyle={{textAlign: 'center', color: '#000000', fontSize: '16px'}}
|
closable={false}
|
visible={this.state.closeVisible}
|
onCancel={() => { this.setState({closeVisible: false}) }}
|
footer={[
|
<Button key="save" className="mk-btn mk-green" loading={this.state.menucloseloading} onClick={this.submitConfig}>{this.state.dict['header.save']}</Button>,
|
<Button key="confirm" className="mk-btn mk-yellow" onClick={() => {this.props.handleConfig('')}}>{this.state.dict['header.notsave']}</Button>,
|
<Button key="cancel" onClick={() => { this.setState({closeVisible: false}) }}>{this.state.dict['header.cancel']}</Button>
|
]}
|
destroyOnClose
|
>
|
{this.state.dict['header.menu.config.placeholder']}
|
</Modal>
|
{this.state.loading && <Spin size="large" />}
|
</div>
|
)
|
}
|
}
|
|
const mapStateToProps = (state) => {
|
return {
|
permFuncField: state.permFuncField
|
}
|
}
|
|
const mapDispatchToProps = () => {
|
return {}
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ComTableConfig)
|