From 98ad33fac8e0a0f7c3cfbc78c333792a2cfa428f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 七月 2020 18:46:22 +0800 Subject: [PATCH] 2020-07-21 --- src/views/mobdesign/index.jsx | 99 ++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 85 insertions(+), 14 deletions(-) diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx index b63b496..daa9099 100644 --- a/src/views/mobdesign/index.jsx +++ b/src/views/mobdesign/index.jsx @@ -1,11 +1,13 @@ import React, { Component } from 'react' import { connect } from 'react-redux' import { DndProvider } from 'react-dnd' -import { fromJS } from 'immutable' +import { is, fromJS } from 'immutable' +import moment from 'moment' import HTML5Backend from 'react-dnd-html5-backend' import { Icon, Tabs, notification, Modal } from 'antd' 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 asyncComponent from '@/utils/asyncComponent' @@ -26,7 +28,11 @@ dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, appId: this.props.match.params.appId, appType: this.props.match.params.appType, - appConfig: null, + appCode: this.props.match.params.appCode, + appName: this.props.match.params.appName, + oriConfig: null, + parentId: '', + openEdition: '', saveIng: false, config: null, pageIndex: 0, @@ -47,48 +53,113 @@ } jumpToManage = () => { - this.props.history.replace('/mobmanage') - // this.props.history.push('/mobdesign/sdafadjfidsf/dsfsdf') + const { oriConfig, config } = this.state + const _this = this + + if (!is(fromJS(oriConfig), fromJS(config))) { + confirm({ + title: '閰嶇疆宸蹭慨鏀癸紝鏀惧純淇濆瓨鍚楋紵', + content: '', + okText: _this.state.dict['mob.confirm'], + cancelText: _this.state.dict['mob.cancel'], + onOk() { + _this.props.history.replace('/mobmanage') + }, + onCancel() {} + }) + } else { + _this.props.history.replace('/mobmanage') + } } triggerSave = () => { - // const { config } = this.state + const { config, openEdition, parentId } = this.state + this.setState({ saveIng: true }) + + let param = { + func: 'sPC_TrdMenu_AddUpt', + ParentID: config.entrance ? '' : 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 + }) + } + }) + } getAppParam = (id) => { Api.getSystemConfig({ func: 'sPC_Get_LongParam', - MenuID: id + MenuID: id, + TypeCharOne: 'mob' }).then(result => { if (result.status) { - let appConfig = null + let config = null if (result.LongParam) { try { - appConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) + config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) } catch (e) { console.warn('Parse Failure') - appConfig = null + config = null } } - if (!appConfig) { - appConfig = { + if (!config) { + config = { version: 1.0, + entrance: true, label: '', uuid: this.props.match.params.appId, pageIndex: 0, + MenuNo: this.props.match.params.appCode, sourcelist: [], components: [] } } - this.setState({ - appConfig: appConfig, - config: fromJS(appConfig).toJS() + oriConfig: config, + config: fromJS(config).toJS(), + openEdition: result.open_edition || '', }) } else { notification.warning({ -- Gitblit v1.8.0