king
2022-04-26 5046d0d13dc6a8563b8e54e31913bc44cfa1072f
src/views/mobdesign/index.jsx
@@ -6,7 +6,7 @@
import moment from 'moment'
import HTML5Backend from 'react-dnd-html5-backend'
import { ConfigProvider, notification, Modal, Collapse, Switch, Button, message, Spin, Typography } from 'antd'
import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, RedoOutlined } from '@ant-design/icons'
import { DoubleLeftOutlined, DoubleRightOutlined, HomeOutlined, LoginOutlined, RedoOutlined, ArrowLeftOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils, { setGLOBFuncs } from '@/utils/utils.js'
@@ -17,7 +17,6 @@
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
import backurl from '@/assets/img/back.jpg'
import './index.scss'
@@ -265,6 +264,7 @@
    let param = {
      MenuID: menu.MenuID,
      copyMenuId: menu.copyMenuId || '',
      clearMenu: menu.clearMenu !== 'false',
      type: 'view'
    }
@@ -748,7 +748,7 @@
          }
        }
      } else {
        config.components = MenuUtils.resetConfig(config.components)
        config.components = MenuUtils.resetConfig(config.components, {}, urlParam.clearMenu)
        config.enabled = false
        message.success('复制成功,保存后生效。')
      }
@@ -857,34 +857,58 @@
    const { config } = this.state
    
    let traversal = (components) => {
      let list = components.map(item => {
      let list = []
      components.forEach(item => {
        let m = {
          key: item.uuid,
          title: item.name,
          children: []
        }
        if (item.type === 'topbar' || item.type === 'login' || item.type === 'navbar') {
        if (item.type === 'topbar' || item.type === 'login' || item.type === 'navbar' || (item.type === 'menubar' && item.subtype === 'commonbar')) {
          return null
        } else if (item.type === 'tabs') {
          let tabs = []
          let mm = []
          item.subtabs.forEach(tab => {
            let s = traversal(tab.components)
            if (s.length === 0) return
            tabs.push({
              key: tab.uuid,
              title: tab.label,
              children: s
            })
            mm.push(...s)
          })
          if (tabs.length > 0) {
            m.children = tabs
          }
          if (item.setting.permission === 'true') {
            list.push(m)
          } else if (mm.length) {
            list.push(...mm)
          }
          return null
        } else if (item.type === 'group') {
          m.children = traversal(item.components)
          if (item.setting.permission === 'true') {
            list.push(m)
          } else if (m.children.length) {
            list.push(...m.children)
          }
          return null
        } if (item.plot && item.plot.permission !== 'true') {
          return null
        } if (item.wrap && item.wrap.permission !== 'true') {
          return null
        } else if (item.type === 'card' || (item.type === 'table' && item.subtype === 'tablecard')) {
          item.action && item.action.forEach(btn => {
            this.checkBtn(btn)
@@ -961,10 +985,8 @@
          })
        }
        return m
        list.push(m)
      })
      list = list.filter(Boolean)
      return list
    }
@@ -1101,15 +1123,25 @@
        config.enabled = false
      }
      let roleParam = {type: 'view', key: config.uuid, title: config.MenuName, children: []}
      let roleParam = {type: 'view', version: '1.0', key: config.uuid, title: config.MenuName, children: []}
      roleParam.children = this.getMenuMessage()
      config.loginview = false
      config.tabview = false
      if (config.components.findIndex(item => item.type === 'login') > -1) {
        roleParam.login = true
        config.loginview = true
      } else {
        config.loginview = false
      if (config.permission !== 'true') {
        roleParam.pass = true
        roleParam.children = []
      }
      config.components.forEach(item => {
        if (item.type === 'login') {
          roleParam.login = true
          roleParam.children = []
          config.loginview = true
        } else if (item.type === 'navbar') {
          config.tabview = true
        }
      })
      if (adapters.includes('wxmini')) {
        config = this.getMiniStyle(config)
@@ -1168,17 +1200,22 @@
              let roles = {
                type: 'navbar',
                version: '1.0',
                key: item.uuid,
                title: item.name,
                children: []
              }
      
              roles.children = item.menus.map(menu => {
                return {
                  key: menu.MenuID,
                  title: menu.name
                }
              })
              if (item.wrap.permission === 'true') {
                roles.children = item.menus.map(menu => {
                  return {
                    key: menu.MenuID,
                    title: menu.name
                  }
                })
              } else {
                roles.pass = true
              }
              let _param = {
                func: 'sPC_TrdMenu_AddUpt',
@@ -1365,7 +1402,7 @@
  }
  verifyConfig = (show) => {
    const { config, viewType } = this.state
    const { config } = this.state
    let error = ''
    let searchSum = 0
    let swipes = []
@@ -1403,6 +1440,7 @@
          swipes.push(item.name)
        }
        if (['voucher'].includes(item.subtype)) 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 (['menubar'].includes(item.type) && item.wrap.datatype !== 'dynamic') return
@@ -1432,9 +1470,9 @@
    check(config.components)
    if (!error && viewType === 'userbind' && config.components.filter(item => item.type === 'login').length === 0) {
      error = '用户绑定页面必须添加登录。'
    }
    // if (!error && viewType === 'userbind' && config.components.filter(item => item.type === 'login').length === 0) {
    //   error = '用户绑定页面必须添加登录。'
    // }
    if (!error && searchSum > 1) {
      error = '搜索组件与导航栏的搜索功能不可同时使用。'
@@ -1465,13 +1503,27 @@
  insert = (item) => {
    let config = fromJS(this.state.config).toJS()
    if (item.type === 'topbar' && config.components.findIndex(m => m.type === 'topbar') > -1) {
    if (item.type === 'search') {
      notification.warning({
        top: 92,
        message: '导航栏不可重复添加!',
        message: '移动端搜索组件不可粘贴!',
        duration: 5
      })
      return
    }
    if (item.type === 'topbar') {
      if (config.components.findIndex(m => m.type === 'topbar') > -1) {
        notification.warning({
          top: 92,
          message: '导航栏不可重复添加!',
          duration: 5
        })
        return
      }
      if (!config.style.paddingTop) {
        config.style.paddingTop = '50px'
      }
    }
    config.components.push(item)
@@ -1713,7 +1765,7 @@
              <div className="wrap">
                <Button type="primary" onClick={this.submitConfig} id="save-config" loading={menuloading}>{dict['mob.save']}</Button>
                <Switch className="big" checkedChildren={dict['mob.enable']} unCheckedChildren={dict['mob.disable']} checked={config && config.enabled} onChange={this.onEnabledChange} />
                <img title="后退" className="back-view" onClick={this.backView} src={backurl} alt=""/>
                <ArrowLeftOutlined title="后退" className="back-view" onClick={this.backView}/>
                <CreateView resetmenu={this.getAppMenus} />
                <PasteController insert={this.insert} />
                <StyleCombControlButton menu={config} />