| | |
| | | import { is, fromJS } from 'immutable' |
| | | import { DndProvider } from 'react-dnd' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { Button, Card, Modal, Collapse, notification, Spin, Icon, Switch } from 'antd' |
| | | import { Button, Card, Modal, Collapse, notification, Spin, Switch } from 'antd' |
| | | import { RedoOutlined } from '@ant-design/icons' |
| | | import moment from 'moment' |
| | | |
| | | import Api from '@/api' |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import Utils from '@/utils/utils.js' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import SearchComponent from '@/templates/sharecomponent/searchcomponent' |
| | | |
| | | import MenuForm from '@/templates/comtableconfig/menuform' |
| | | import EditComponent from '@/templates/zshare/editcomponent' |
| | | import SourceElement from '@/templates/zshare/dragsource' |
| | | import Source from './source' |
| | | import './index.scss' |
| | |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | |
| | | const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent')) |
| | | const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent')) |
| | | const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcalcomponent')) |
| | | const TabComponent = asyncComponent(() => import('./tabcomponent')) |
| | | const CalComponent = asyncComponent(() => import('./calcomponent')) |
| | |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 字典 |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 字典 |
| | | config: null, // 页面配置 |
| | | visible: false, // 搜索条件、按钮、显示列,模态框显示控制 |
| | | tableFields: [], // 已选表字段集 |
| | | fields: null, // 搜索条件及显示列,可选字段 |
| | | formlist: null, // 搜索条件、按钮、显示列表单字段 |
| | | menuloading: false, // 菜单保存中 |
| | |
| | | originConfig: null, // 原配置 |
| | | tabviews: [], // 所有标签页 |
| | | activeKey: '0', // 默认展开基本信息 |
| | | pasteContent: null, // 粘贴内容 |
| | | openEdition: '', // 编辑版本标记,防止多人操作 |
| | | mockdata: [], // 测试数据 |
| | | } |
| | |
| | | |
| | | getFuncNames = (data, funcNames, tableNames) => { |
| | | data.forEach(item => { |
| | | if (item.subfuncs) { |
| | | this.getFuncNames(item.subfuncs, funcNames, tableNames) |
| | | } else { |
| | | if (item.tableName) { |
| | | tableNames.push(item.tableName) |
| | | } |
| | | if (item.innerFunc) { |
| | | funcNames.push({func: item.innerFunc, label: item.label || ''}) |
| | | } |
| | | // if (item.subfuncs) { |
| | | // this.getFuncNames(item.subfuncs, funcNames, tableNames) |
| | | // return |
| | | // } |
| | | |
| | | if (item.callbackFunc) { |
| | | funcNames.push({func: item.callbackFunc, label: item.label || ''}) |
| | | } |
| | | if (item.tableName) { |
| | | tableNames.push(item.tableName) |
| | | } |
| | | if (item.innerFunc) { |
| | | funcNames.push({func: item.innerFunc, label: item.label || ''}) |
| | | } |
| | | |
| | | if (item.callbackFunc) { |
| | | funcNames.push({func: item.callbackFunc, label: item.label || ''}) |
| | | } |
| | | }) |
| | | |
| | |
| | | } |
| | | |
| | | new Promise(resolve => { |
| | | if (_config.tab) { |
| | | Api.getSystemConfig({ |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: _config.tab.linkTab |
| | | }).then(result => { |
| | | if (result.status && result.LongParam) { |
| | | let _LongParam = '' |
| | | // if (_config.tab) { |
| | | // Api.getSystemConfig({ |
| | | // func: 'sPC_Get_LongParam', |
| | | // MenuID: _config.tab.linkTab |
| | | // }).then(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 = '' |
| | | } |
| | | } |
| | | // if (result.LongParam) { |
| | | // try { |
| | | // _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | // } catch (e) { |
| | | // console.warn('Parse Failure') |
| | | // _LongParam = '' |
| | | // } |
| | | // } |
| | | |
| | | if (_LongParam) { |
| | | _config.funcs[1].menuNo = _LongParam.tabNo || '' |
| | | _config.funcs[1].subfuncs = _LongParam.funcs || [] |
| | | } |
| | | } |
| | | resolve() |
| | | }) |
| | | } else { |
| | | resolve() |
| | | } |
| | | // if (_LongParam) { |
| | | // _config.funcs[1].menuNo = _LongParam.tabNo || '' |
| | | // _config.funcs[1].subfuncs = _LongParam.funcs || [] |
| | | // } |
| | | // } |
| | | // resolve() |
| | | // }) |
| | | // } else { |
| | | // resolve() |
| | | // } |
| | | resolve() |
| | | }).then(() => { |
| | | let reload = _config.isAdd |
| | | |
| | | // 保存时删除配置类型,system 、user |
| | | delete _config.type |
| | | delete _config.isAdd |
| | |
| | | config: _config, |
| | | openEdition: response.open_edition || '', |
| | | originMenu: fromJS(_config).toJS() |
| | | }, () => { |
| | | reload && MKEmitter.emit('revert') |
| | | }) |
| | | |
| | | this.props.reloadmenu() |
| | |
| | | } |
| | | }) |
| | | |
| | | let calvaild = true |
| | | if (!cols.includes(config.calendar.startfield)) { |
| | | calvaild = false |
| | | } else if (!cols.includes(config.calendar.endfield)) { |
| | | calvaild = false |
| | | } else if (!cols.includes(config.calendar.colorfield)) { |
| | | calvaild = false |
| | | } else if (!cols.includes(config.calendar.remarkfield)) { |
| | | calvaild = false |
| | | } |
| | | |
| | | if (config.setting.interType === 'system' && config.setting.default !== 'false' && !config.setting.dataresource) { |
| | | return '菜单尚未设置数据源,不可启用!' |
| | | } else if (config.columns.length === 0) { |
| | | return '菜单尚未设置数据字段,不可启用!' |
| | | } else if (!calvaild) { |
| | | return '菜单尚未设置字段集,不可启用!' |
| | | } else if (!config.calendar.startfield) { |
| | | return '日历关联字段未设置,不可启用!' |
| | | } else if (!cols.includes(config.calendar.startfield)) { |
| | | return '开始时间字段已删除,不可启用!' |
| | | } else if (!cols.includes(config.calendar.endfield)) { |
| | | return '结束时间字段已删除,不可启用!' |
| | | } else if (config.calendar.colorfield && !cols.includes(config.calendar.colorfield)) { |
| | | return '颜色字段已删除,不可启用!' |
| | | } else if (!cols.includes(config.calendar.remarkfield)) { |
| | | return '信息字段已删除,不可启用!' |
| | | } else { |
| | | return true |
| | | } |
| | |
| | | config: res.config |
| | | }) |
| | | } else if (res.type === 'paste') { |
| | | this.setState({ |
| | | pasteContent: res.content |
| | | }, () => { |
| | | this.setState({ |
| | | pasteContent: null |
| | | }) |
| | | }) |
| | | this.setState({config: res.config}) |
| | | } |
| | | } |
| | | |
| | |
| | | updateconfig = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 更新常用表信息,快捷添加后更新配置信息 |
| | | */ |
| | | updatetable = (config, fields) => { |
| | | const { tableFields } = this.state |
| | | |
| | | this.setState({ |
| | | config: config, |
| | | tableFields: fields ? fields : tableFields |
| | | }) |
| | | } |
| | | |
| | |
| | | dict={this.state.dict} |
| | | updatemenu={this.updateconfig} |
| | | /> |
| | | {config ? <UrlFieldComponent |
| | | config={config} |
| | | updateConfig={this.updateconfig} |
| | | /> : null} |
| | | {/* 表名添加 */} |
| | | <TableComponent |
| | | config={config} |
| | | containerId="subtable-basedata" |
| | | updatetable={this.updatetable} |
| | | updatetable={this.updateconfig} |
| | | /> |
| | | </Panel> |
| | | {/* 搜索条件添加 */} |
| | |
| | | return (<SourceElement key={index} content={item}/>) |
| | | })} |
| | | </div> |
| | | <FieldsComponent |
| | | config={config} |
| | | type="search" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | <FieldsComponent config={config} type="search" /> |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | |
| | | <Card title={ |
| | | <div> |
| | | 日历页面配置 |
| | | <Icon type="redo" style={{marginLeft: '10px'}} title="刷新标签列表" onClick={() => this.reloadTab(true)} /> |
| | | <RedoOutlined style={{marginLeft: '10px'}} title="刷新标签列表" onClick={() => this.reloadTab(true)} /> |
| | | </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | <EditComponent dict={this.state.dict} type="calendar" config={this.state.config} refresh={this.updateConfig}/> |
| | | <EditComponent dict={this.state.dict} type="table" options={['search', 'form']} config={this.state.config}/> |
| | | <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} /> |
| | | <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button> |
| | | <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button> |
| | |
| | | <SettingComponent |
| | | config={config} |
| | | MenuID={menu.MenuID} |
| | | tableFields={this.state.tableFields} |
| | | permFuncField={this.props.permFuncField} |
| | | updateConfig={this.updateconfig} |
| | | /> |
| | | <SearchComponent |
| | | menu={{MenuID: menu.MenuID, MenuName: config.MenuName}} |
| | | config={config} |
| | | pasteContent={this.state.pasteContent} |
| | | sysRoles={this.props.sysRoles} |
| | | updatesearch={this.updatesearch} |
| | | /> |
| | | <div className="calendar-wrap"> |
| | |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | sysRoles: state.sysRoles, |
| | | permFuncField: state.permFuncField, |
| | | memberLevel: state.memberLevel |
| | | } |
| | | } |