| | |
| | | import { is, fromJS } from 'immutable' |
| | | import moment from 'moment' |
| | | import HTML5Backend from 'react-dnd-html5-backend' |
| | | import { Icon, notification, Modal, Collapse } from 'antd' |
| | | import { ConfigProvider, notification, Modal, Collapse, Card, Switch, Button } from 'antd' |
| | | import html2canvas from 'html2canvas' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import zhCN from '@/locales/zh-CN/mob.js' |
| | | import enUS from '@/locales/en-US/mob.js' |
| | | import antdEnUS from 'antd/es/locale/en_US' |
| | | import antdZhCN from 'antd/es/locale/zh_CN' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import { modifyCustomMenu, initPermission } from '@/store/action' |
| | | |
| | | import './index.scss' |
| | | |
| | | // const { TabPane } = Tabs |
| | | const { Panel } = Collapse |
| | | const { confirm } = Modal |
| | | const _locale = localStorage.getItem('lang') !== 'en-US' ? antdZhCN : antdEnUS |
| | | |
| | | const MenuForm = asyncComponent(() => import('./menuform')) |
| | | const HomeForm = asyncComponent(() => import('./homeform')) |
| | | const PrintMenuForm = asyncComponent(() => import('./printmenuform')) |
| | | const Header = asyncComponent(() => import('@/menu/header')) |
| | | const MenuForm = asyncComponent(() => import('@/menu/menuform')) |
| | | // const Controller = asyncComponent(() => import('@/mob/controller')) |
| | | const SourceWrap = asyncComponent(() => import('@/mob/modelsource')) |
| | | // const DataSource = asyncComponent(() => import('@/mob/datasource')) |
| | | const SourceWrap = asyncComponent(() => import('@/menu/modelsource')) |
| | | const MenuShell = asyncComponent(() => import('@/menu/menushell')) |
| | | const BgController = asyncComponent(() => import('@/menu/bgcontroller')) |
| | | const PaddingController = asyncComponent(() => import('@/menu/padcontroller')) |
| | | const StyleController = asyncComponent(() => import('@/menu/stylecontroller')) |
| | | const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller')) |
| | | const TableComponent = asyncComponent(() => import('@/templates/sharecomponent/tablecomponent')) |
| | | |
| | | class Mobile extends Component { |
| | | sessionStorage.setItem('isEditState', 'true') |
| | | sessionStorage.setItem('delButtons', JSON.stringify([])) |
| | | |
| | | class MenuDesign extends Component { |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | MenuId: this.props.match.params.MenuId, |
| | | MenuType: '', |
| | | MenuId: '', |
| | | ParentId: '', |
| | | MenuName: '', |
| | | MenuNo: '', |
| | | tableFields: [], |
| | | activeKey: 'basedata', |
| | | menuloading: false, |
| | | oriConfig: null, |
| | | parentId: '', |
| | | openEdition: '', |
| | | saveIng: false, |
| | | config: null, |
| | | editElem: null |
| | | } |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | this.getMenuParam() |
| | | // this.testFunc() |
| | | try { |
| | | let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param))) |
| | | |
| | | this.setState({ |
| | | MenuType: param.MenuType, |
| | | MenuId: param.MenuId, |
| | | ParentId: param.ParentId || '', |
| | | MenuName: param.MenuName || '', |
| | | MenuNo: param.MenuNo || '', |
| | | }, () => { |
| | | this.getMenuParam() |
| | | }) |
| | | } catch { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '菜单信息解析错误!', |
| | | duration: 5 |
| | | }) |
| | | } |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | closeView = () => { |
| | | const { oriConfig, config } = this.state |
| | | const _this = this |
| | | |
| | | if (!is(fromJS(oriConfig), fromJS(config))) { |
| | | let _config = fromJS(config).toJS() |
| | | delete _config.fstMenuList |
| | | delete _config.permFuncField |
| | | delete _config.sysRoles |
| | | delete _config.tableFields |
| | | |
| | | if (!is(fromJS(oriConfig), fromJS(_config))) { |
| | | confirm({ |
| | | title: '配置已修改,放弃保存吗?', |
| | | content: '', |
| | | okText: _this.state.dict['mob.confirm'], |
| | | cancelText: _this.state.dict['mob.cancel'], |
| | | onOk() { |
| | | window.close() |
| | | }, |
| | |
| | | } |
| | | } |
| | | |
| | | triggerSave = () => { |
| | | const { config, openEdition, parentId } = this.state |
| | | |
| | | this.setState({ |
| | | saveIng: true |
| | | }) |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | ParentID: parentId, |
| | | MenuID: config.uuid, |
| | | MenuNo: config.MenuNo, |
| | | EasyCode: '', |
| | | Template: '', |
| | | MenuName: '', |
| | | PageParam: '', |
| | | LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(config))), |
| | | // LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`), |
| | | // LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`), |
| | | TypeCharOne: 'mob' |
| | | } |
| | | |
| | | let _LText = '' |
| | | // _LText = _LText.join(' union all ') |
| | | let _LTexttb = '' |
| | | // _LTexttb = _LTexttb.join(' union all ') |
| | | |
| | | param.LText = Utils.formatOptions(_LText) |
| | | param.LTexttb = Utils.formatOptions(_LTexttb) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (openEdition) { // 版本管理 |
| | | param.open_edition = openEdition |
| | | } |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | oriConfig: fromJS(config).toJS(), |
| | | openEdition: response.open_edition || '', |
| | | saveIng: false |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | testFunc = () => { |
| | | let datas = [{ |
| | | name: 'a', |
| | | arr_field: 'MapCode,Country', |
| | | par_tablename: '', |
| | | type: '', |
| | | primaryKey: 'MapCode', |
| | | foreign_key: '', |
| | | sql: `select MapCode,Country from @tc1`, |
| | | script: `declare @tc1 table (MapCode nvarchar(50),Country nvarchar(50)) insert into @tc1 (MapCode,Country) select MapCode,Country from sMap where Province=''` |
| | | }, { |
| | | name: 'b', |
| | | arr_field: 'MapCode,Province,ParMapCode', |
| | | par_tablename: 'a', |
| | | type: 'array', |
| | | primaryKey: 'MapCode', |
| | | foreign_key: 'ParMapCode', |
| | | sql: `select MapCode,Province,ParMapCode from @tc2`, |
| | | script: `declare @tc2 table (MapCode nvarchar(50),Province nvarchar(50),ParMapCode nvarchar(50)) insert into @tc2 (MapCode,Province,ParMapCode) select MapCode,Province,ParMapCode from sMap where Province!='' and City=''` |
| | | }, { |
| | | name: 'c', |
| | | arr_field: 'MapCode,City,ParMapCode', |
| | | par_tablename: 'b', |
| | | type: 'array', |
| | | primaryKey: 'MapCode', |
| | | foreign_key: 'ParMapCode', |
| | | sql: `select MapCode,City,ParMapCode from @tc3`, |
| | | script: `declare @tc3 table (MapCode nvarchar(50),City nvarchar(50),ParMapCode nvarchar(50)) insert into @tc3 (MapCode,City,ParMapCode) select MapCode,City,ParMapCode from sMap where City!='' and Area=''` |
| | | }, { |
| | | name: 'd', |
| | | arr_field: 'MapCode,Area,ParMapCode', |
| | | par_tablename: 'c', |
| | | type: 'array', |
| | | primaryKey: 'MapCode', |
| | | foreign_key: 'ParMapCode', |
| | | sql: `select MapCode,Area,ParMapCode from sMap where Area!=''`, |
| | | script: `` |
| | | }] |
| | | |
| | | let LText = datas.map((item, index) => { |
| | | // item.par_tablename = '' |
| | | // item.foreign_key = '' |
| | | |
| | | let _orderBy = 'MapCode desc' |
| | | let _search = '' |
| | | let _sql = `select top 1000 ${item.arr_field} from (select ${item.arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from (${item.sql}) tb ${_search}) tmptable order by tmptable.rows ` |
| | | |
| | | return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(item.script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` |
| | | }) |
| | | |
| | | let LText_field = [] |
| | | datas.forEach(item => { |
| | | item.arr_field.split(',').forEach(cell => { |
| | | LText_field.push(`Select '${item.name}' as tablename,'${cell}' as fieldname,'nvarchar(50)' as field_type`) |
| | | }) |
| | | }) |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_structured_data', |
| | | LText: LText.join(' union all '), |
| | | LText_field: LText_field.join(' union all ') |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.LText_field = Utils.formatOptions(param.LText_field) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | Api.getLocalConfig(param) |
| | | } |
| | | |
| | | getMenuParam = () => { |
| | | Api.getSystemConfig({ |
| | | const { MenuId, ParentId, MenuName, MenuNo, MenuType } = this.state |
| | | |
| | | let param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: this.props.match.params.MenuId |
| | | }).then(result => { |
| | | MenuID: MenuId |
| | | } |
| | | |
| | | Api.getSystemConfig(param).then(result => { |
| | | if (result.status) { |
| | | let config = null |
| | | |
| | | if (result.LongParam) { |
| | | try { |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = null |
| | | } |
| | | try { |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = null |
| | | } |
| | | |
| | | if (!config) { |
| | | config = { |
| | | version: 1.0, |
| | | uuid: this.props.match.params.MenuId, |
| | | uuid: MenuId, |
| | | MenuID: MenuId, |
| | | parentId: ParentId, |
| | | Template: 'CustomPage', |
| | | easyCode: '', |
| | | enabled: false, |
| | | MenuName: this.props.match.params.MenuName, |
| | | MenuNo: this.props.match.params.MenuNo, |
| | | MenuName: MenuName, |
| | | MenuNo: MenuNo, |
| | | tables: [], |
| | | components: [] |
| | | components: [], |
| | | style: { |
| | | backgroundColor: '#ffffff', backgroundImage: '', |
| | | paddingTop: '16px', paddingBottom: '80px', paddingLeft: '16px', paddingRight: '16px' |
| | | }, |
| | | MenuType: MenuType |
| | | } |
| | | if (MenuType === 'billPrint') { |
| | | config.style.paddingTop = '50px' |
| | | config.style.paddingBottom = '50px' |
| | | config.style.paddingLeft = '30px' |
| | | config.style.paddingRight = '30px' |
| | | } |
| | | } else { |
| | | config.uuid = MenuId |
| | | config.MenuID = MenuId |
| | | config.MenuType = config.MenuType || MenuType |
| | | } |
| | | |
| | | if (MenuType === 'billPrint') { |
| | | config.fstMenuId = 'BillPrintTemp' |
| | | config.parentId = 'BillPrintTemp' |
| | | config.MenuName = MenuName |
| | | config.MenuNo = MenuNo |
| | | config.firstCount = config.firstCount || 5 |
| | | config.everyPCount = config.everyPCount || 5 |
| | | config.lastCount = config.lastCount || '' |
| | | } |
| | | |
| | | this.setState({ |
| | | oriConfig: config, |
| | | config: fromJS(config).toJS(), |
| | | openEdition: result.open_edition || '', |
| | | }) |
| | | |
| | | this.getRoleFields() |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | |
| | | }) |
| | | } |
| | | |
| | | deleteCard = (id) => { |
| | | let _this = this |
| | | let config = fromJS(this.state.config).toJS() |
| | | |
| | | confirm({ |
| | | title: '确定删除元素吗?', |
| | | content: '', |
| | | okText: this.state.dict['mob.confirm'], |
| | | cancelText: this.state.dict['mob.cancel'], |
| | | onOk() { |
| | | config.components = config.components.filter(item => item.uuid !== id) |
| | | |
| | | _this.setState({ |
| | | config: config |
| | | }) |
| | | }, |
| | | onCancel() {} |
| | | }) |
| | | } |
| | | |
| | | editCard = (element) => { |
| | | this.setState({ |
| | | editElem: element |
| | | }) |
| | | } |
| | | |
| | | updateStyle = (proper) => { |
| | | getMenuMessage = () => { |
| | | const { config } = this.state |
| | | let buttons = [] |
| | | let _sort = 1 |
| | | |
| | | config.components = config.components.map(component => { |
| | | if (component.uuid === proper.componentId) { |
| | | Object.keys(component).forEach(key => { |
| | | let _uuid = component[key].uuid |
| | | if (_uuid && (_uuid === proper.uuid || _uuid === proper.classId)) { |
| | | if (component[key].substyle) { |
| | | let traversal = (components) => { |
| | | components.forEach(item => { |
| | | if (item.type === 'tabs') { |
| | | item.subtabs.forEach(tab => { |
| | | traversal(tab.components) |
| | | }) |
| | | } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) { |
| | | item.subcards.forEach(card => { |
| | | card.elements && card.elements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | } else { |
| | | component[key].style = {...component[key].style, ...proper.style} |
| | | // eslint-disable-next-line |
| | | for (let index in component[key].style) { |
| | | if (component[key].style[index] === '') { |
| | | delete component[key].style[index] |
| | | } |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | card.backElements && card.backElements.forEach(cell => { |
| | | if (cell.eleType !== 'button') return |
| | | |
| | | buttons.push(`select '${cell.uuid}' as menuid, '${item.name + '-' + cell.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | }) |
| | | } else if (item.type === 'line' || item.type === 'bar') { |
| | | item.action && item.action.forEach(btn => { |
| | | buttons.push(`select '${btn.uuid}' as menuid, '${item.name + '-' + btn.label}' as menuname, '${_sort * 10}' as Sort`) |
| | | _sort++ |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | traversal(config.components) |
| | | |
| | | return buttons |
| | | } |
| | | |
| | | submitConfig = () => { |
| | | const { config, openEdition } = this.state |
| | | |
| | | if (config.MenuType === 'billPrint' && (!config.firstCount || !config.everyPCount)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (config.MenuType === 'home' && (config.cacheUseful === 'true' && !config.cacheTime)) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } else if (config.MenuType === 'custom' && (!config.MenuName || !config.MenuNo || !config.fstMenuId || !config.parentId || (config.cacheUseful === 'true' && !config.cacheTime))) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '请完善菜单基本信息!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (config.enabled && this.verifyConfig()) { |
| | | config.enabled = false |
| | | } |
| | | |
| | | let _config = fromJS(config).toJS() |
| | | delete _config.fstMenuList |
| | | delete _config.permFuncField |
| | | delete _config.sysRoles |
| | | delete _config.tableFields |
| | | |
| | | let param = { |
| | | func: 'sPC_TrdMenu_AddUpt', |
| | | FstID: _config.fstMenuId || '', |
| | | SndID: _config.parentId, |
| | | ParentID: _config.parentId, |
| | | MenuID: _config.uuid, |
| | | MenuNo: _config.MenuNo || '', |
| | | EasyCode: _config.easyCode || '', |
| | | Template: 'CustomPage', |
| | | MenuName: _config.MenuName || '', |
| | | PageParam: JSON.stringify({Template: 'CustomPage', OpenType: 'newtab'}), |
| | | LongParam: window.btoa(window.encodeURIComponent(JSON.stringify(_config))), |
| | | LText: '', |
| | | LTexttb: '' |
| | | } |
| | | |
| | | param.LText = Utils.formatOptions(param.LText) |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | |
| | | if (openEdition) { // 版本管理 |
| | | param.open_edition = openEdition |
| | | } |
| | | |
| | | let btnParam = { // 添加菜单按钮 |
| | | func: 'sPC_Button_AddUpt', |
| | | Type: 40, // 添加菜单下的按钮type为40,按钮下的按钮type为60 |
| | | ParentID: _config.uuid, |
| | | MenuNo: _config.MenuNo, |
| | | Template: 'CustomPage', |
| | | PageParam: '', |
| | | LongParam: '', |
| | | LText: [] |
| | | } |
| | | |
| | | if (config.MenuType !== 'billPrint') { |
| | | btnParam.LText = this.getMenuMessage() |
| | | |
| | | btnParam.LText = btnParam.LText.join(' union all ') |
| | | btnParam.LText = Utils.formatOptions(btnParam.LText) |
| | | btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp) |
| | | } else { |
| | | btnParam.LText = '' |
| | | } |
| | | |
| | | this.setState({ |
| | | menuloading: true |
| | | }, () => { |
| | | new Promise(resolve => { |
| | | if (config.MenuType === 'billPrint') { |
| | | html2canvas(document.getElementById('menu-shell-inner')).then(canvas => { |
| | | let img = canvas.toDataURL('image/png') // 获取生成的图片 |
| | | Api.fileuploadbase64(img, 'cloud').then(result => { |
| | | if (result.status) { |
| | | Api.getSystemConfig({ |
| | | func: 's_PrintTemplateMSub', |
| | | ID: _config.uuid, |
| | | Images: Utils.getcloudurl(result.Images), |
| | | Remark: '', |
| | | temp_type: 'billprint', |
| | | }).then(response => { |
| | | if (response.status) { |
| | | resolve(true) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | resolve(false) |
| | | } |
| | | }) |
| | | } else { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: result.ErrMesg, |
| | | duration: 5 |
| | | }) |
| | | this.setState({ |
| | | menuloading: false |
| | | }) |
| | | resolve(false) |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | resolve(true) |
| | | } |
| | | }).then(res => { |
| | | if (!res) return |
| | | |
| | | Api.getSystemConfig(param).then(response => { |
| | | if (response.status) { |
| | | this.setState({ |
| | | oriConfig: fromJS(_config).toJS(), |
| | | openEdition: response.open_edition || '', |
| | | menuloading: false |
| | | }) |
| | | notification.success({ |
| | | top: 92, |
| | | message: '保存成功', |
| | | duration: 2 |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | | openEdition: response.open_edition || '', |
| | | menuloading: false |
| | | }) |
| | | notification.warning({ |
| | | top: 92, |
| | | message: response.message, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | return component |
| | | }) |
| | | }) |
| | | this.setState({config}) |
| | | } |
| | | |
| | | getRoleFields = () => { |
| | | Api.getSystemConfig({func: 'sPC_Get_Roles_sModular'}).then(res => { |
| | | if (res.status) { |
| | | let _permFuncField = [] |
| | | let _sysRoles = [] |
| | | |
| | | if (res.Roles && res.Roles.length > 0) { |
| | | _sysRoles = res.Roles.map(role => { |
| | | return { |
| | | uuid: Utils.getuuid(), |
| | | value: role.RoleID, |
| | | text: role.RoleName |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (res.sModular && res.sModular.length > 0) { |
| | | res.sModular.forEach(field => { |
| | | if (field.ModularNo) { |
| | | _permFuncField.push(field.ModularNo) |
| | | } |
| | | }) |
| | | _permFuncField = _permFuncField.sort() |
| | | } |
| | | |
| | | let config = {...this.state.config, sysRoles: _sysRoles, permFuncField: _permFuncField} |
| | | |
| | | this.setState({config}) |
| | | this.props.modifyCustomMenu(config) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | initMenuList = (msg) => { |
| | | let config = {...this.state.config, ...msg} |
| | | |
| | | this.setState({config}) |
| | | this.props.modifyCustomMenu(config) |
| | | } |
| | | |
| | | onEnabledChange = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config.enabled && this.verifyConfig(true)) { |
| | | return |
| | | } |
| | | |
| | | this.setState({ |
| | | config: {...config, enabled: !config.enabled} |
| | | }) |
| | | } |
| | | |
| | | verifyConfig = (show) => { |
| | | const { config } = this.state |
| | | let error = '' |
| | | |
| | | config.components.forEach(item => { |
| | | if (error) return |
| | | if (item.subtype === 'propcard' && item.wrap.datatype === 'static') return |
| | | |
| | | if (item.setting) { |
| | | if (item.setting.interType === 'system' && item.setting.execute !== 'false' && !item.setting.dataresource) { |
| | | error = `组件《${item.name}》未设置数据源!` |
| | | } else if (item.setting.interType === 'system' && item.setting.execute === 'false' && item.scripts.length === 0) { |
| | | error = `组件《${item.name}》未设置数据源!` |
| | | } else if (item.setting.interType && !item.setting.primaryKey && config.MenuType !== 'billPrint') { |
| | | error = `组件《${item.name}》未设置主键!` |
| | | } |
| | | } |
| | | if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') { |
| | | if (!item.plot.Xaxis) { |
| | | error = `组件《${item.name}》图表字段尚未设置!` |
| | | } |
| | | } |
| | | }) |
| | | |
| | | if (show && error) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: error, |
| | | duration: 5 |
| | | }) |
| | | } |
| | | |
| | | return error |
| | | } |
| | | |
| | | // 更新配置信息 |
| | | updateConfig = (config) => { |
| | | this.setState({ |
| | | config: config |
| | | }) |
| | | } |
| | | updatetable = (config) => { |
| | | // this.setState({ |
| | | // config: config |
| | | // }) |
| | | |
| | | this.props.modifyCustomMenu(config) |
| | | } |
| | | |
| | | save = () => { |
| | | html2canvas(document.getElementById('view')).then(canvas => { |
| | | let imgUri = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream'); // 获取生成的图片的url |
| | | window.location.href = imgUri; // 下载图片 |
| | | /** |
| | | * @description 更新常用表信息,快捷添加后更新配置信息 |
| | | */ |
| | | updatetable = (config, fields) => { |
| | | const { tableFields } = this.state |
| | | |
| | | config.tableFields = fields ? fields : tableFields |
| | | |
| | | this.setState({ |
| | | tableFields: fields ? fields : tableFields, |
| | | config |
| | | }) |
| | | |
| | | this.props.modifyCustomMenu(config) |
| | | } |
| | | |
| | | render () { |
| | | const { activeKey, saveIng, dict, MenuId, config } = this.state |
| | | const { activeKey, MenuType, dict, MenuId, config, ParentId, MenuName, MenuNo, menuloading } = this.state |
| | | |
| | | return ( |
| | | <div className="pc-menu-view" id="view"> |
| | | <Header view="design" closeView={this.closeView} triggerSave={this.triggerSave} saveIng={saveIng} /> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="menu-body"> |
| | | <div className="menu-setting"> |
| | | <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> |
| | | {/* 基本信息 */} |
| | | <Panel header={dict['mob.basemsg']} key="basedata"> |
| | | {/* 菜单信息 */} |
| | | <MenuForm |
| | | dict={dict} |
| | | config={config} |
| | | MenuId={MenuId} |
| | | parentId={this.props.match.params.ParentId} |
| | | MenuName={this.props.match.params.MenuName} |
| | | MenuNo={this.props.match.params.MenuNo} |
| | | updateConfig={this.updateConfig} |
| | | /> |
| | | {/* 表名添加 */} |
| | | {config ? <TableComponent |
| | | config={config} |
| | | // containerId="main-basedata" |
| | | updatetable={this.updatetable} |
| | | /> : null} |
| | | </Panel> |
| | | {/* 搜索条件添加 */} |
| | | {/* <Panel header={dict['mob.component']} key="component"> |
| | | <div className="search-element"> |
| | | {Source.searchItems.map((item, index) => (<SourceElement key={index} content={item}/>))} |
| | | </div> |
| | | <FieldsComponent |
| | | config={config} |
| | | type="search" |
| | | tableFields={this.state.tableFields} |
| | | updatefield={this.updateconfig} |
| | | /> |
| | | </Panel> */} |
| | | |
| | | </Collapse> |
| | | {/* <Tabs defaultActiveKey="1" animated={false} size="small"> |
| | | <TabPane tab="配置" key="1"> |
| | | <Controller editElem={editElem} updateStyle={this.updateStyle} /> |
| | | </TabPane> |
| | | <TabPane tab="数据源" key="2"> |
| | | <DataSource config={config} updateConfig={this.updateConfig} /> |
| | | </TabPane> |
| | | </Tabs> */} |
| | | </div> |
| | | <div className="menu-tool"> |
| | | <div className="menu-tool-content"> |
| | | <div className="plus-content"> |
| | | <Icon type="plus-circle" />添 加 组 件 |
| | | </div> |
| | | <div className="useable-component"> |
| | | <SourceWrap appType="Menu" /> |
| | | </div> |
| | | <ConfigProvider locale={_locale}> |
| | | <div className="pc-menu-view" id="view"> |
| | | <Header /> |
| | | <DndProvider backend={HTML5Backend}> |
| | | <div className="menu-body"> |
| | | <div className="menu-setting"> |
| | | <Collapse accordion activeKey={activeKey} bordered={false} onChange={(key) => this.setState({activeKey: key})}> |
| | | {/* 基本信息 */} |
| | | <Panel header={dict['mob.basemsg']} key="basedata"> |
| | | {/* 菜单信息 */} |
| | | {config && MenuType === 'custom' ? <MenuForm |
| | | dict={dict} |
| | | config={config} |
| | | MenuId={MenuId} |
| | | parentId={ParentId} |
| | | MenuName={MenuName} |
| | | MenuNo={MenuNo} |
| | | initMenuList={this.initMenuList} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {config && MenuType === 'home' ? <HomeForm |
| | | dict={dict} |
| | | config={config} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {config && MenuType === 'billPrint' ? <PrintMenuForm |
| | | dict={dict} |
| | | config={config} |
| | | updateConfig={this.updateConfig} |
| | | /> : null} |
| | | {/* 表名添加 */} |
| | | {config ? <TableComponent config={config} updatetable={this.updatetable}/> : null} |
| | | </Panel> |
| | | {/* 组件添加 */} |
| | | <Panel header={dict['mob.component']} key="component"> |
| | | <SourceWrap MenuType={MenuType} /> |
| | | </Panel> |
| | | <Panel header={'背景'} key="background"> |
| | | {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null} |
| | | </Panel> |
| | | <Panel header={'内边距'} key="padding"> |
| | | {config ? <PaddingController config={config} updateConfig={this.updateConfig} /> : null} |
| | | </Panel> |
| | | </Collapse> |
| | | </div> |
| | | <div className="menu-tool-other"></div> |
| | | <div className={'menu-view ' + (menuloading ? 'saving' : '')}> |
| | | <Card title={ |
| | | <div> {config && config.MenuName} </div> |
| | | } bordered={false} extra={ |
| | | <div> |
| | | {config ? <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config.enabled} onChange={this.onEnabledChange} /> : null} |
| | | <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button> |
| | | <Button type="default" onClick={this.closeView}>{dict['mob.return']}</Button> |
| | | </div> |
| | | } style={{ width: '100%' }}> |
| | | {config && config.components ? <MenuShell menu={config} handleList={this.updateConfig} /> : null} |
| | | </Card> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </DndProvider> |
| | | </div> |
| | | </DndProvider> |
| | | <StyleController /> |
| | | <ModalController /> |
| | | </div> |
| | | </ConfigProvider> |
| | | ) |
| | | } |
| | | } |
| | |
| | | return {} |
| | | } |
| | | |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | const mapDispatchToProps = (dispatch) => { |
| | | return { |
| | | modifyCustomMenu: (customMenu) => dispatch(modifyCustomMenu(customMenu)), |
| | | initPermission: (sysRoles, permFuncField) => dispatch(initPermission(sysRoles, permFuncField)) |
| | | } |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(Mobile) |
| | | export default connect(mapStateToProps, mapDispatchToProps)(MenuDesign) |