king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/views/mobdesign/index.jsx
@@ -47,6 +47,7 @@
sessionStorage.setItem('appType', 'mob')       // 应用类型
document.body.className = ''
window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件
window.GLOB.TabsMap = new Map()          // 缓存用户操作的标签页
window.GLOB.CacheIndependent = new Map()
window.GLOB.urlFields = []               // url变量
window.GLOB.customMenu = null            // 保存菜单信息
@@ -63,7 +64,6 @@
    menuloading: false,
    oriConfig: null,
    config: null,
    visible: false,
    customComponents: [],
    direction: 'vertical',
    settingshow: true,
@@ -81,7 +81,7 @@
        sessionStorage.setItem('lang', param.lang || 'zh-CN')
        sessionStorage.setItem('kei_no', param.kei_no || '')
        sessionStorage.setItem('role_type', param.role_type || 'true')
        sessionStorage.setItem('login_types', param.login_types || 'true')
        sessionStorage.setItem('login_types', param.login_types || 'false')
        sessionStorage.setItem('typename', param.typename || 'mob')
        this.setState({
@@ -108,7 +108,7 @@
          this.getMenuParam(param)
        })
      }
    } catch {
    } catch (e) {
      notification.warning({
        top: 92,
        message: '菜单信息解析错误!',
@@ -133,6 +133,7 @@
      return
    }
    MKEmitter.addListener('changeEditMenu', this.changeEditMenu)
    MKEmitter.addListener('triggerMenuSave', this.submitConfig)
    MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
    setTimeout(() => {
@@ -151,6 +152,7 @@
      return
    }
    MKEmitter.removeListener('changeEditMenu', this.changeEditMenu)
    MKEmitter.removeListener('triggerMenuSave', this.submitConfig)
    MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
    MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
  }
@@ -276,13 +278,11 @@
            })
          } else {
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
            sessionStorage.setItem('appHomeId', homeId)
            this.props.history.replace('/mobdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view'}))))
          }
        })
      } else {
        sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
        sessionStorage.setItem('appHomeId', homeId)
        this.props.history.replace('/mobdesign/' + window.btoa(window.encodeURIComponent(JSON.stringify({MenuID: homeId, type: 'view'}))))
      }
    })
@@ -311,6 +311,17 @@
      }).then(res => {
        if (res.status) {
          sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
        }
      })
      Api.getSystemConfig({
        func: 's_url_db_adduptdel',
        PageIndex: 0,  // 0 代表全部
        PageSize: 0,   // 0 代表全部
        typecharone: 'color',
        type: 'search'
      }).then(res => {
        if (res.status) {
          sessionStorage.setItem('app_colors', JSON.stringify(res.data || []))
        }
      })
    })
@@ -503,6 +514,11 @@
      appIndeList = appIndeList.map(item => (item.keys_type !== 'index' ? item.keys_id : '')).join(',')
      let menus = res.menus.filter(item => appIndeList.indexOf(item.MenuID) === -1)
      menus = menus.map(item => {
        item.value = item.MenuID
        item.label = item.MenuName
        return item
      })
      sessionStorage.setItem('appMenus', JSON.stringify(menus))
    })
  }
@@ -675,7 +691,10 @@
          title: item.name,
          children: []
        }
        if (item.type === 'tabs') {
        if (item.type === 'topbar' || item.type === 'login') {
          return null
        } else if (item.type === 'tabs') {
          let tabs = []
          item.subtabs.forEach(tab => {
            let s = traversal(tab.components)
@@ -751,6 +770,13 @@
              title: menu.setting.name
            }
          })
        } else if (item.type === 'form') {
          m.children = item.subcards.map(m => {
            return {
              key: m.uuid,
              title: m.setting.title
            }
          })
        } else if (item.type === 'table' && item.subtype === 'normaltable') {
          item.action && item.action.forEach(btn => {
            this.checkBtn(btn)
@@ -770,8 +796,6 @@
            })
          })
        }
        if (m.children.length === 0) return null
        return m
      })
@@ -850,12 +874,14 @@
        config.enabled = false
      }
      let parMenuId = sessionStorage.getItem('kei_no') + 'pc' + sessionStorage.getItem('lang')
      let roleParam = {type: 'view', key: config.uuid, title: config.MenuName, children: []}
      roleParam.children = this.getMenuMessage()
      let param = {
        func: 'sPC_TrdMenu_AddUpt',
        FstID: parMenuId,
        SndID: parMenuId,
        ParentID: parMenuId,
        FstID: 'mk_app',
        SndID: 'mk_app',
        ParentID: 'mk_app',
        MenuID: config.uuid,
        MenuNo: config.MenuNo || '',
        EasyCode: '',
@@ -865,16 +891,13 @@
        MenuName: config.MenuName || '',
        PageParam: JSON.stringify({Template: 'webPage'}),
        open_edition: config.open_edition,
        menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roleParam))),
        LText: '',
        LTexttb: ''
      }
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt('', param.timestamp)
      let roleParam = {key: config.uuid, title: config.MenuName, children: []}
      roleParam.children = this.getMenuMessage()
      console.log(roleParam)
      new Promise(resolve => {
        let _config = fromJS(config).toJS()
@@ -905,29 +928,8 @@
                return
              }
              let _param = {
                func: 'sPC_TrdMenu_AddUpt',
                FstID: parMenuId,
                SndID: parMenuId,
                ParentID: parMenuId,
                MenuID: item.uuid,
                MenuNo: item.wrap.MenuNo || Utils.getuuid(),
                EasyCode: '',
                Template: item.type,
                TypeCharOne: sessionStorage.getItem('kei_no'),
                Typename: sessionStorage.getItem('typename'),
                MenuName: item.name || '',
                PageParam: JSON.stringify({Template: item.type}),
                open_edition: item.open_edition || '',
                LText: '',
                LTexttb: ''
              }
              _param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(item)))
              _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              _param.secretkey = Utils.encrypt('', _param.timestamp)
              let roles = {
                type: 'navbar',
                key: item.uuid,
                title: item.name,
                children: []
@@ -939,7 +941,29 @@
                  title: menu.name
                }
              })
              console.log(roles)
              let _param = {
                func: 'sPC_TrdMenu_AddUpt',
                FstID: 'mk_app',
                SndID: 'mk_app',
                ParentID: 'mk_app',
                MenuID: item.uuid,
                MenuNo: item.wrap.MenuNo || Utils.getuuid(),
                EasyCode: '',
                Template: item.type,
                TypeCharOne: sessionStorage.getItem('kei_no'),
                Typename: sessionStorage.getItem('typename'),
                MenuName: item.name || '',
                PageParam: JSON.stringify({Template: item.type}),
                open_edition: item.open_edition || '',
                menus_rolelist: window.btoa(window.encodeURIComponent(JSON.stringify(roles))),
                LText: '',
                LTexttb: ''
              }
              _param.LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(item)))
              _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
              _param.secretkey = Utils.encrypt('', _param.timestamp)
              
              Api.getSystemConfig(_param).then(res => {
                if (!res.status) {
@@ -1035,12 +1059,7 @@
          this.setState({
            config,
            oriConfig: fromJS(config).toJS(),
            menuloading: false,
            comloading: true
          }, () => {
            this.setState({
              comloading: false
            })
            menuloading: false
          })
          notification.success({
@@ -1058,6 +1077,7 @@
            menuloading: false
          })
        }
        MKEmitter.emit('completeSave')
      })
    }, 300)
  }
@@ -1125,7 +1145,7 @@
          error = `导航栏《${item.name}》未设置菜单参数!`
        }
        if (['propcard', 'brafteditor', 'sandbox', 'tabbar', 'stepform'].includes(item.subtype) && item.wrap.datatype === 'static') return
        if (['propcard', 'brafteditor', 'sandbox', 'tabbar', 'stepform', 'tabform'].includes(item.subtype) && item.wrap.datatype === 'static') return
        if (['balcony'].includes(item.type) && item.wrap.datatype === 'static') return
        if (item.setting) {
@@ -1251,7 +1271,6 @@
              duration: 5
            })
          } else {
            sessionStorage.setItem('appHomeId', config.MenuID)
            sessionStorage.setItem('appViewList', JSON.stringify(appViewList))
          }
        })
@@ -1342,19 +1361,21 @@
                {controlshow ? <Icon onClick={() => {this.setState({controlshow: false})}} type="double-right" /> : null}
                {!controlshow ? <Icon onClick={() => {this.setState({controlshow: true})}} type="double-left" /> : null}
              </div>
              <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
              <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
              <CreateView resetmenu={this.getAppMenus} />
              <PasteController type="menu" Tab={null} insert={this.insert} />
              <StyleCombControlButton menu={config} />
              <SysInterface config={config} updateConfig={this.updateConfig}/>
              <PictureController/>
              <Quotecomponent config={config} updateConfig={this.updateConfig}/>
              <Button className="mk-border-green" icon="home" onClick={this.setHomeView}>设为首页</Button>
              <Button className="mk-border-danger" icon="redo" onClick={this.refreshView}>强制刷新</Button>
              <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
              <Transfer MenuID={MenuId} />
              <Button type="default" onClick={this.closeView}>关闭</Button>
              <div className="wrap">
                <Button type="primary" onClick={this.submitConfig} loading={menuloading}>{dict['mob.save']}</Button>
                <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
                <CreateView resetmenu={this.getAppMenus} />
                <PasteController type="menu" Tab={null} insert={this.insert} />
                <StyleCombControlButton menu={config} />
                <SysInterface config={config} updateConfig={this.updateConfig}/>
                <PictureController/>
                <Quotecomponent config={config} updateConfig={this.updateConfig}/>
                <Button className="mk-border-green" icon="home" onClick={this.setHomeView}>设为首页</Button>
                <Button className="mk-border-danger" icon="redo" onClick={this.refreshView}>强制刷新</Button>
                <ReplaceField type="custom" config={config} updateConfig={this.resetConfig}/>
                <Transfer MenuID={MenuId} />
                <Button type="default" onClick={this.closeView}>关闭</Button>
              </div>
            </div>
            <div className={'menu-body menu-view' + (menuloading ? 'saving' : '')}>
              {config && !comloading ? <div className="mob-shell" style={{width: window.GLOB.shellWidth, height: window.GLOB.shellHeight}}>