king
2021-04-14 30b6c01972cc74152b733a94edcc0c2a614a2268
src/views/pcdesign/index.jsx
@@ -16,7 +16,6 @@
import MKEmitter from '@/utils/events.js'
import MenuUtils from '@/utils/utils-custom.js'
import asyncComponent from '@/utils/asyncComponent'
import { modifyCustomMenu } from '@/store/action'
import './index.scss'
@@ -31,6 +30,7 @@
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const SysInterface = asyncComponent(() => import('@/menu/sysinterface'))
const UrlFieldComponent = asyncComponent(() => import('@/menu/urlfieldcomponent'))
const PictureController = asyncComponent(() => import('@/menu/picturecontroller'))
const ModalController = asyncComponent(() => import('@/menu/modalconfig/controller'))
const StyleCombController = asyncComponent(() => import('@/menu/stylecombcontroller'))
@@ -43,6 +43,8 @@
document.body.className = ''
window.GLOB.UserComponentMap = new Map() // 缓存用户自定义组件
window.GLOB.CacheIndependent = new Map()
window.GLOB.urlFields = []               // url变量
window.GLOB.customMenu = null            // 保存菜单信息
class MenuDesign extends Component {
  state = {
@@ -125,6 +127,7 @@
    setTimeout(() => {
      this.updateCustomComponent()
      this.getAppPictures()
      this.getSmStemp()
    }, 1000)
  }
@@ -247,6 +250,37 @@
    })
  }
  getSmStemp = () => {
    let _sql = `select ID,TemplateCode,SignName from bd_msn_sms_temp where deleted=0 and appkey='${window.GLOB.appkey}'`
    _sql = Utils.formatOptions(_sql)
    let param = {
      func: 'sPC_Get_SelectedList',
      LText: _sql,
      obj_name: 'data',
      arr_field: 'ID,TemplateCode,SignName'
    }
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // 云端数据验证
    Api.getSystemConfig(param).then(res => {
      let msgs = []
      if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
      } else if (res.data) {
        msgs = res.data
      }
      sessionStorage.setItem('msgTemplate', JSON.stringify(msgs))
    })
  }
  getAppPictures = () => {
    if (sessionStorage.getItem('app_videos') || sessionStorage.getItem('app_pictures')) return
@@ -259,6 +293,12 @@
    }).then(res => {
      if (res.status) {
        sessionStorage.setItem('app_pictures', JSON.stringify(res.data || []))
      } else if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
      }
      Api.getSystemConfig({
@@ -270,6 +310,12 @@
      }).then(res => {
        if (res.status) {
          sessionStorage.setItem('app_videos', JSON.stringify(res.data || []))
        } else if (!res.status) {
          notification.warning({
            top: 92,
            message: res.message,
            duration: 5
          })
        }
      })
    })
@@ -281,7 +327,13 @@
      typecharone: ''
    }).then(res => {
      let coms = []
      if (res.cus_list && res.cus_list.length > 0) {
      if (!res.status) {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 5
        })
      } else if (res.cus_list && res.cus_list.length > 0) {
        res.cus_list.forEach(item => {
          let config = ''
@@ -446,6 +498,7 @@
        config.uuid = MenuId
        config.MenuID = MenuId
        config.open_edition = result.open_edition || ''
        window.GLOB.urlFields = config.urlFields || []
        if (urlParam.fixed) {
          config.fixed = true
@@ -466,8 +519,8 @@
            config: fromJS(config).toJS(),
            loading: false
          })
          this.props.modifyCustomMenu(config)
          window.GLOB.customMenu = config
        } else {
          this.jointComponents(config, indeComs, isCreate)
        }
@@ -581,8 +634,7 @@
          config: fromJS(config).toJS(),
          loading: false
        })
        this.props.modifyCustomMenu(config)
        window.GLOB.customMenu = config
      } else {
        this.jointComponents(config, indeComs, true)
      }
@@ -658,7 +710,7 @@
        loading: false
      })
      this.props.modifyCustomMenu(config)
      window.GLOB.customMenu = config
    })
  }
@@ -1266,25 +1318,40 @@
    const { config } = this.state
    let error = ''
    config.components.forEach(item => {
      if (error) return
      if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && item.wrap.datatype === 'static') return
    let check = (components) => {
      components.forEach(item => {
        if (error) return
        if (item.type === 'tabs') {
          item.subtabs.forEach(tab => {
            check(tab.components)
          })
          return
        } else if (item.type === 'group') {
          check(item.components)
          return
        }
        if (['propcard', 'brafteditor', 'sandbox'].includes(item.subtype) && 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) {
            error = `组件《${item.name}》未设置主键!`
          }
        }
        if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
          if (!item.plot.Xaxis) {
            error = `组件《${item.name}》图表字段尚未设置!`
          }
        } else if (item.type === 'dashboard' && !item.plot.valueField) {
          error = `组件《${item.name}》显示值尚未设置!`
        }
      })
    }
      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) {
          error = `组件《${item.name}》未设置主键!`
        }
      }
      if (item.type === 'bar' || item.type === 'line' || item.type === 'pie') {
        if (!item.plot.Xaxis) {
          error = `组件《${item.name}》图表字段尚未设置!`
        }
      }
    })
    check(config.components)
    if (show && error) {
      notification.warning({
@@ -1303,7 +1370,7 @@
      config: config
    })
    this.props.modifyCustomMenu(config)
    window.GLOB.customMenu = config
  }
  insert = (item) => {
@@ -1312,7 +1379,7 @@
    config.components.push(item)
    this.setState({config})
    this.props.modifyCustomMenu(config)
    window.GLOB.customMenu = config
  }
  refreshView = () => {
@@ -1424,6 +1491,7 @@
                      MenuId={MenuId}
                      updateConfig={this.updateConfig}
                    /> : null}
                    {config ? <UrlFieldComponent config={config} updateConfig={this.updateConfig}/> : null}
                    {/* 表名添加 */}
                    {config ? <TableComponent config={config} updatetable={this.updateConfig}/> : null}
                  </Panel>
@@ -1475,10 +1543,8 @@
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyCustomMenu: (customMenu) => dispatch(modifyCustomMenu(customMenu))
  }
const mapDispatchToProps = () => {
  return {}
}
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MenuDesign))