| | |
| | | state = { |
| | | dict: CommonDict, // 字典 |
| | | config: null, // 页面配置 |
| | | visible: false, // 搜索条件、按钮、显示列,模态框显示控制 |
| | | modalTitle: '', // 模态框的标题 |
| | | tableVisible: false, // 数据表字段模态框 |
| | | addType: '', // 添加类型-搜索条件或显示列 |
| | | tableColumns: [], // 表格显示列 |
| | |
| | | originMenu: null, // 原始菜单 |
| | | originActions: null, // 原始按钮信息,使用已有用户模板 |
| | | delActions: [], // 删除按钮列表 |
| | | copyActions: [], // 删除按钮列表 |
| | | copyActions: [], // 复制按钮组 |
| | | funcLoading: false, // 存储过程创建中 |
| | | showColumnName: false, // 显示列字段名控制 |
| | | tabviews: [], // 所有标签页 |
| | |
| | | this.setState({ |
| | | modaltype: type === 'copy' ? 'actionCopy' : 'actionEdit', |
| | | card: card, |
| | | formlist: getActionForm(card, functip, this.state.config, this.props.permFuncField) |
| | | formlist: getActionForm(card, functip, this.state.config, this.props.permFuncField, 'main') |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 显示列与合并列编辑,获取表单信息 |
| | | */ |
| | | handleColumn = (card) => { |
| | | if (card.type !== 'colspan') { |
| | | this.setState({ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 标签编辑,筛选可选的下级标签与已关联的下级标签 |
| | | */ |
| | | handleTab = (card) => { |
| | | const { config } = this.state |
| | | |
| | |
| | | let _tabMap = new Map() |
| | | let _usedTabMap = new Map() |
| | | |
| | | config[nextTabId].forEach(tab => { // 下级所有的标签 |
| | | config[nextTabId].forEach(tab => { // 下级所有的标签 |
| | | menus.push(tab) |
| | | _tabMap.set(tab.uuid, true) |
| | | }) |
| | | |
| | | config[card.groupId].forEach(tab => { // 同级标签已选的下级标签 |
| | | config[card.groupId].forEach(tab => { // 同级标签已选的下级标签 |
| | | if (tab.uuid === card.uuid) return |
| | | |
| | | tab.subtabs.forEach(subtab => { |
| | |
| | | _usedTabMap.set(subtab, true) |
| | | }) |
| | | |
| | | subtabs = subtabs.filter(tab => _tabMap.has(tab.uuid) && !_usedTabMap.has(tab.uuid)) |
| | | subtabs = subtabs.filter(tabId => _tabMap.has(tabId) && !_usedTabMap.has(tabId)) |
| | | menus = menus.filter(tab => !_usedTabMap.has(tab.uuid)) |
| | | } else { |
| | | subtabs = [] |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 操作列编辑 |
| | | */ |
| | | handleGridBtn = () => { |
| | | this.setState({ |
| | | modaltype: 'gridbtn' |
| | |
| | | * @description 搜索、按钮、显示列修改后提交保存 |
| | | * 1、搜索条件保存 |
| | | * 2、按钮包括正常编辑和复制,复制时,末尾添加,如按钮为表单(保存至数据库),复制按钮id存于复制列表(点击不保存时删除) |
| | | * 3、添加或编辑列,保存时,如按钮位置设置为表格,则修改操作列显示状态 |
| | | * 3、如按钮位置设置为表格,则修改操作列显示状态 |
| | | */ |
| | | handleSubmit = () => { |
| | | const { menu } = this.props |
| | |
| | | |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 |
| | | let _gridBtn = {...config.gridBtn} |
| | | let _gridBtn = config.gridBtn |
| | | |
| | | if (_gridBtn) { |
| | | _gridBtn.display = _hasGridbtn |
| | |
| | | }) |
| | | } else if (modaltype === 'tabs') { |
| | | this.tabsFormRef.handleConfirm().then(res => { |
| | | let isupdate = false |
| | | let _tabgroup = config[res.values.groupId].map(item => { |
| | | if (item.uuid === res.values.uuid) { |
| | | isupdate = true |
| | | return res.values |
| | | } else { |
| | | return item |
| | | } |
| | | }) |
| | | _tabgroup = _tabgroup.filter(item => !item.origin) |
| | | |
| | | if (!isupdate) { // 操作不是修改,添加元素至列表 |
| | | _tabgroup.push(res.values) |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, [res.values.groupId]: _tabgroup}, |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 取消保存,如果元素为新添元素,则从序列中删除 |
| | | */ |
| | | editModalCancel = () => { |
| | | const { config, card, modaltype } = this.state |
| | | |
| | |
| | | } else if (modaltype === 'columns' || modaltype === 'colspan') { |
| | | let _columns = config.columns.filter(item => item.uuid !== card.uuid) |
| | | _config = {...config, columns: _columns} |
| | | } else if (modaltype === 'tabs') { |
| | | let _tabgroup = config[card.groupId].filter(item => item.uuid !== card.uuid) |
| | | _config = {...config, [card.groupId]: _tabgroup} |
| | | } else { |
| | | _config = config |
| | | } |
| | |
| | | */ |
| | | creatFunc = () => { |
| | | const { menu } = this.props |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | | const { config } = this.state |
| | | |
| | | this.actionFormRef.handleConfirm().then(res => { |
| | | let btn = res // 按钮信息 |
| | |
| | | |
| | | let _param = { |
| | | funcName: btn.innerFunc, |
| | | name: _config.setting.tableName || '', |
| | | name: config.setting.tableName || '', |
| | | fields: fields, |
| | | menuNo: menu.MenuNo |
| | | } |
| | | newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config)) |
| | | newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, config)) |
| | | DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName)) |
| | | resolve(true) |
| | | } else { |
| | |
| | | } else { |
| | | let _param = { |
| | | funcName: btn.innerFunc, |
| | | name: _config.setting.tableName || '', |
| | | name: config.setting.tableName || '', |
| | | fields: '', |
| | | menuNo: menu.MenuNo |
| | | } |
| | | newLText = Utils.formatOptions(Utils.getfunc(_param, btn, menu, _config)) |
| | | 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 |
| | | if (res !== false) return false |
| | | |
| | | let sysDefer = new Promise(resolve => { |
| | | Api.getSystemConfig({ |
| | |
| | | return |
| | | } |
| | | |
| | | let isupdate = false |
| | | _config.action = _config.action.map(item => { |
| | | let _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) |
| | | _action = _action.filter(item => !item.origin) |
| | | |
| | | // 判断是否存在操作列 |
| | | let _hasGridbtn = _action.filter(act => act.position === 'grid').length > 0 |
| | | let _gridBtn = config.gridBtn |
| | | |
| | | 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 |
| | | if (_gridBtn) { |
| | | _gridBtn.display = _hasGridbtn |
| | | } else { |
| | | _config.gridBtn = { |
| | | display: _display, |
| | | _gridBtn = { |
| | | display: _hasGridbtn, |
| | | Align: 'center', |
| | | IsSort: 'false', |
| | | uuid: Utils.getuuid(), |
| | |
| | | } |
| | | |
| | | this.setState({ |
| | | config: _config, |
| | | config: {...config, action: _action, gridBtn: _gridBtn}, |
| | | funcLoading: false |
| | | }) |
| | | }) |
| | |
| | | } |
| | | |
| | | deleteElement = (element) => { |
| | | const { config } = this.state |
| | | 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)) |
| | | let _config = null |
| | | |
| | | if (element.type === 'tabs') { |
| | | _config[element.card.groupId] = _config[element.card.groupId].filter(item => { |
| | | let _tabgroup = config[element.card.groupId].filter(item => { |
| | | if (item.uuid === element.card.uuid) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | _config = {...config, [element.card.groupId]: _tabgroup} |
| | | } else { |
| | | _config[element.type] = _config[element.type].filter(item => { |
| | | let list = config[element.type].filter(item => { |
| | | if (item.uuid === element.card.uuid) { |
| | | return false |
| | | } else { |
| | | return true |
| | | } |
| | | }) |
| | | |
| | | _config = {...config, [element.type]: list} |
| | | |
| | | // 删除按钮时判断是否存在操作列 |
| | | if (element.type === 'action' && _config.gridBtn) { |
| | | _config.gridBtn.display = _config.action.filter(act => act.position === 'grid').length > 0 |
| | | } |
| | | } |
| | | |
| | | _this.setState({ |
| | |
| | | return |
| | | } |
| | | |
| | | let btnParam = { // 添加菜单按钮 |
| | | let btnParam = { // 添加菜单按钮 |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮 |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: menu.MenuID, |
| | | MenuNo: res.menuNo, |
| | | Template: menu.PageParam.Template || '', |
| | |
| | | } |
| | | |
| | | /** |
| | | * @description 保存或修改菜单按钮 |
| | | * @description 保存或修改菜单按钮集 |
| | | */ |
| | | submitAction = (btnParam, tabParam) => { |
| | | const { config } = this.state |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 点击返回时,判断配置保存状态 |
| | | */ |
| | | cancelConfig = () => { |
| | | const { menu } = this.props |
| | | const { config, originMenu } = this.state |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 筛选可用字段集 |
| | | */ |
| | | queryField = (type) => { |
| | | const {selectedTables, tableColumns, config} = this.state |
| | | // 判断是否已选择表名 |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 添加字段集 |
| | | */ |
| | | addFieldSubmit = () => { |
| | | const {addType, config} = this.state |
| | | |
| | | // 字段集为空,关闭弹窗 |
| | | if (!this.state.fields || this.state.fields.length === 0) { |
| | | this.setState({ |
| | |
| | | }) |
| | | } |
| | | |
| | | const {addType, config} = this.state |
| | | const textmatch = { // 选择text时匹配规则 |
| | | text: 'like', |
| | | number: 'like', |
| | |
| | | |
| | | // 获取已选字段集合 |
| | | let cards = this.refs.searchcard.state.selectCards |
| | | |
| | | if (cards.length === 0) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请选择添加字段', |
| | | duration: 10 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | let columnsMap = new Map() |
| | | cards.forEach(card => { |
| | | columnsMap.set(card.field, card) |
| | | }) |
| | | |
| | | let items = [] |
| | | if (addType === 'search') { |
| | | config.search.forEach(item => { |
| | | let _search = config.search.filter(item => !item.origin) |
| | | |
| | | // 重置原有搜素条件 |
| | | _search = _search.map(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') { |
| | | if (cell.type !== item.type) { // 数据类型修改 |
| | | if (cell.type === 'select') { |
| | | item.match = selectmatch[cell.datatype] |
| | | } else if (cell.type === 'daterange') { |
| | | item.match = datematch[cell.datatype] |
| | |
| | | |
| | | item.type = cell.type |
| | | item.initval = '' |
| | | items.push(item) |
| | | } |
| | | columnsMap.delete(item.field) |
| | | } else if (!item.origin) { |
| | | items.push(item) |
| | | } |
| | | return 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) |
| | | let _match = '' |
| | | if (item.type === 'select') { |
| | | _match = selectmatch[item.datatype] |
| | | } else if (item.type === 'daterange') { |
| | | _match = datematch[item.datatype] |
| | | } else { |
| | | _match = textmatch[item.datatype] |
| | | } |
| | | |
| | | let newcard = { |
| | | uuid: Utils.getuuid(), |
| | | label: item.label, |
| | | field: item.field, |
| | | initval: '', |
| | | type: item.type || 'text', |
| | | resourceType: '0', |
| | | setAll: 'false', |
| | | options: [], |
| | | orderType: 'asc', |
| | | match: _match, |
| | | display: 'dropdown' |
| | | } |
| | | |
| | | _search.push(newcard) |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: {...config, search: _search} |
| | | }) |
| | | } else { |
| | | config.columns.forEach(item => { |
| | | let _columns = config.columns.filter(item => !item.origin) |
| | | |
| | | // 重置原有显示列类型 |
| | | _columns = _columns.map(item => { |
| | | if (columnsMap.has(item.field)) { |
| | | let cell = columnsMap.get(item.field) |
| | | |
| | | if (cell.selected) { |
| | | items.push(item) |
| | | if (cell.type) { |
| | | item.type = cell.type |
| | | } |
| | | |
| | | columnsMap.delete(item.field) |
| | | } else if (!item.origin) { |
| | | items.push(item) |
| | | } |
| | | return item |
| | | }) |
| | | |
| | | let _columns = [...columnsMap.values()] |
| | | let _cols = [...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) |
| | | // 添加显示列 |
| | | _cols.forEach(item => { |
| | | 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 |
| | | } |
| | | |
| | | _columns.push(newcard) |
| | | }) |
| | | |
| | | this.setState({ |
| | | config: {...config, columns: _columns} |
| | | }) |
| | | } |
| | | |
| | | this.setState({ |
| | | [addType + 'loading']: true, |
| | | config: {...config, [addType]: items} |
| | | }, () => { |
| | | notification.success({ |
| | | top: 92, |
| | | message: '操作成功', |
| | | duration: 2 |
| | | }) |
| | | this.setState({ |
| | | [addType + 'loading']: false |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '操作成功', |
| | | duration: 2 |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 表名切换时,添加表名,新增时查询表相关字段 |
| | | */ |
| | | onTableChange = (value) => { |
| | | const {tables, selectedTables, tableColumns} = this.state |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 删除表名以及表相关字段 |
| | | */ |
| | | deleteTable = (table) => { |
| | | const {selectedTables, tableColumns} = this.state |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 页面配置信息模态框显示 |
| | | */ |
| | | changeSetting = () => { |
| | | this.setState({ |
| | | settingVisible: true |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 保存页面配置信息 |
| | | */ |
| | | settingSave = () => { |
| | | const { menu } = this.props |
| | | const {config} = this.state |
| | |
| | | } |
| | | } |
| | | |
| | | onEnabledChange = (val, e) => { |
| | | /** |
| | | * @description 页面启用停止切换 |
| | | */ |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | | let tabinvalid = true |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @description 显示隐藏显示列字段名 |
| | | */ |
| | | onColumnNameChange = () => { |
| | | const { showColumnName } = this.state |
| | | |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 增加标签页分组 |
| | | */ |
| | | addTabGroup = () => { |
| | | let _this = this |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 删除标签页分组 |
| | | */ |
| | | delTabGroup = (groupId) => { |
| | | let _this = this |
| | | let _config = JSON.parse(JSON.stringify(this.state.config)) |
| | |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 选择不保存时,如有复制按钮,则删除 |
| | | */ |
| | | notsave = () => { |
| | | this.state.copyActions.forEach(item => { |
| | | let _param = { |
| | |
| | | render () { |
| | | const { modaltype } = this.state |
| | | const configAction = this.state.config.action.filter(_action => |
| | | !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') |
| | | !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview') |
| | | // !_action.origin && (_action.OpenType === 'pop' || _action.OpenType === 'popview' || _action.OpenType === 'blank' || _action.OpenType === 'tab') |
| | | ) |
| | | |
| | | let configTabs = [] |
| | |
| | | wrappedComponentRef={(inst) => this.columnFormRef = inst} |
| | | /> |
| | | </Modal> |
| | | {/* 合并列编辑 */} |
| | | {/* 操作列编辑 */} |
| | | <Modal |
| | | title={this.state.dict['header.modal.gridbtn.edit']} |
| | | visible={modaltype === 'gridbtn'} |