king
2021-03-05 e36eb1999794bd71e76482b92a0b0b20f49d0032
src/templates/calendarconfig/index.jsx
@@ -16,7 +16,6 @@
import SearchComponent from '@/templates/sharecomponent/searchcomponent'
import MenuForm from '@/templates/comtableconfig/menuform'
// import EditComponent from '@/templates/zshare/editcomponent'
import SourceElement from '@/templates/zshare/dragsource'
import Source from './source'
import './index.scss'
@@ -24,6 +23,7 @@
const { Panel } = Collapse
const { confirm } = Modal
const EditComponent = asyncComponent(() => import('@/templates/zshare/editcomponent'))
const SettingComponent = asyncComponent(() => import('@/templates/sharecomponent/settingcalcomponent'))
const TabComponent = asyncComponent(() => import('./tabcomponent'))
const CalComponent = asyncComponent(() => import('./calcomponent'))
@@ -34,16 +34,14 @@
class SubTableConfig extends Component {
  static propTpyes = {
    menu: PropTypes.any,
    optionLibs: PropTypes.any,
    reloadmenu: PropTypes.func,
    handleView: PropTypes.func
  }
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,        // 字典
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,        // 字典
    config: null,            // 页面配置
    visible: false,          // 搜索条件、按钮、显示列,模态框显示控制
    tableFields: [],         // 已选表字段集
    fields: null,            // 搜索条件及显示列,可选字段
    formlist: null,          // 搜索条件、按钮、显示列表单字段
    menuloading: false,      // 菜单保存中
@@ -52,9 +50,7 @@
    closeVisible: false,     // 关闭模态框
    originConfig: null,      // 原配置
    tabviews: [],            // 所有标签页
    optionLibs: null,        // 自定义下拉选项库
    activeKey: '0',          // 默认展开基本信息
    pasteContent: null,      // 粘贴内容
    openEdition: '',         // 编辑版本标记,防止多人操作
    mockdata: [],            // 测试数据
  }
@@ -65,7 +61,7 @@
   * 2、设置操作类型、原始菜单信息(每次保存后重置)、已使用表及基本信息表单
   */
  UNSAFE_componentWillMount () {
    const { menu, optionLibs } = this.props
    const { menu } = this.props
    let _LongParam = menu.LongParam
    let _config = ''
@@ -74,21 +70,6 @@
      _config.isAdd = true
    } else {
      _config = _LongParam
      _config.search.forEach(item => {
        if (
          (item.type === 'select' || item.type === 'multiselect' || item.type === 'link') &&
          item.resourceType === '0' &&
          item.options && item.options.length > 0
        ) {
          optionLibs.set(menu.MenuID + item.uuid, {
            uuid: menu.MenuID + item.uuid,
            label: item.label,
            parname: menu.MenuName,
            type: 'search',
            options: item.options
          })
        }
      })
    }
    if (_config.type === 'user') {
@@ -112,7 +93,6 @@
    this.setState({
      openEdition: menu.open_edition || '',
      optionLibs: optionLibs,
      activeKey: menu.activeKey || '0',
      config: _config,
      originMenu: fromJS(_config).toJS(),
@@ -234,7 +214,6 @@
  handleViewBack = () => {
    let param = {
      editMenu: null,
      optionLibs: null,
      editTab: null,
      tabConfig: null,
      subTabConfig: null,
@@ -250,19 +229,20 @@
  getFuncNames = (data, funcNames, tableNames) => {
    data.forEach(item => {
      if (item.subfuncs) {
        this.getFuncNames(item.subfuncs, funcNames, tableNames)
      } else {
        if (item.tableName) {
          tableNames.push(item.tableName)
        }
        if (item.innerFunc) {
          funcNames.push({func: item.innerFunc, label: item.label || ''})
        }
      // if (item.subfuncs) {
      //   this.getFuncNames(item.subfuncs, funcNames, tableNames)
      //   return
      // }
        if (item.callbackFunc) {
          funcNames.push({func: item.callbackFunc, label: item.label || ''})
        }
      if (item.tableName) {
        tableNames.push(item.tableName)
      }
      if (item.innerFunc) {
        funcNames.push({func: item.innerFunc, label: item.label || ''})
      }
      if (item.callbackFunc) {
        funcNames.push({func: item.callbackFunc, label: item.label || ''})
      }
    })
@@ -342,33 +322,34 @@
    }
    new Promise(resolve => {
      if (_config.tab) {
        Api.getSystemConfig({
          func: 'sPC_Get_LongParam',
          MenuID: _config.tab.linkTab
        }).then(result => {
          if (result.status && result.LongParam) {
            let _LongParam = ''
      // if (_config.tab) {
      //   Api.getSystemConfig({
      //     func: 'sPC_Get_LongParam',
      //     MenuID: _config.tab.linkTab
      //   }).then(result => {
      //     if (result.status && result.LongParam) {
      //       let _LongParam = ''
  
            if (result.LongParam) {
              try {
                _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
              } catch (e) {
                console.warn('Parse Failure')
                _LongParam = ''
              }
            }
      //       if (result.LongParam) {
      //         try {
      //           _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
      //         } catch (e) {
      //           console.warn('Parse Failure')
      //           _LongParam = ''
      //         }
      //       }
            if (_LongParam) {
              _config.funcs[1].menuNo = _LongParam.tabNo || ''
              _config.funcs[1].subfuncs = _LongParam.funcs || []
            }
          }
          resolve()
        })
      } else {
        resolve()
      }
      //       if (_LongParam) {
      //         _config.funcs[1].menuNo = _LongParam.tabNo || ''
      //         _config.funcs[1].subfuncs = _LongParam.funcs || []
      //       }
      //     }
      //     resolve()
      //   })
      // } else {
      //   resolve()
      // }
      resolve()
    }).then(() => {
      // 保存时删除配置类型,system 、user
      delete _config.type
@@ -402,7 +383,7 @@
        tabParam.LText = Utils.formatOptions(`select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort`)
      }
      tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
      tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
      let _vals = this.getFuncNames(_config.funcs, [], [])
@@ -432,7 +413,7 @@
      param.LText = Utils.formatOptions(param.LText)
      param.LTexttb = param.LTexttb.join(' union all ')
      param.LTexttb = Utils.formatOptions(param.LTexttb)
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
      param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
      if (openEdition) { // 版本管理
@@ -533,7 +514,7 @@
   */
  setSubConfig = () => {
    const { menu } = this.props
    const { config, originMenu, optionLibs, activeKey, openEdition } = this.state
    const { config, originMenu, activeKey, openEdition } = this.state
    if (config.isAdd) { // 新建菜单,提示菜单尚未保存
      notification.warning({
@@ -579,7 +560,6 @@
      _Menu.open_edition = openEdition  // 更新版本号
      let param = {
        optionLibs: optionLibs,
        editMenu: _Menu,
        editTab: fromJS(config.tab).toJS(),
        tabConfig: null,
@@ -707,25 +687,17 @@
        config: res.config
      })
    } else if (res.type === 'paste') {
      this.setState({
        pasteContent: res.content
      }, () => {
        this.setState({
          pasteContent: null
        })
      })
      this.setState({config: res.config})
    }
  }
  /**
   * @description 更新搜索条件配置信息
   */
  updatesearch = (config, options) => {
    const { optionLibs } = this.state
  updatesearch = (config) => {
    this.setState({
      config: config,
      optionLibs: options || optionLibs
      config: config
    })
  }
@@ -735,18 +707,6 @@
  updateconfig = (config) => {
    this.setState({
      config: config
    })
  }
  /**
   * @description 更新常用表信息,快捷添加后更新配置信息
   */
  updatetable = (config, fields) => {
    const { tableFields } = this.state
    this.setState({
      config: config,
      tableFields: fields ? fields : tableFields
    })
  }
@@ -780,7 +740,7 @@
                <TableComponent
                  config={config}
                  containerId="subtable-basedata"
                  updatetable={this.updatetable}
                  updatetable={this.updateconfig}
                />
              </Panel>
              {/* 搜索条件添加 */}
@@ -793,7 +753,6 @@
                <FieldsComponent
                  config={config}
                  type="search"
                  tableFields={this.state.tableFields}
                  updatefield={this.updateconfig}
                />
              </Panel>
@@ -807,7 +766,7 @@
              </div>
            } bordered={false} extra={
              <div>
                {/* <EditComponent dict={this.state.dict} type="subtable" config={this.state.config} refresh={this.updateConfig}/> */}
                <EditComponent dict={this.state.dict} options={['search']} config={this.state.config} refresh={this.updateConfig}/>
                <Switch className="big" checkedChildren="启" unCheckedChildren="停" checked={this.state.config.enabled} onChange={this.onEnabledChange} />
                <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['model.save']}</Button>
                <Button onClick={this.cancelConfig}>{this.state.dict['model.back']}</Button>
@@ -816,16 +775,11 @@
              <SettingComponent
                config={config}
                MenuID={menu.MenuID}
                tableFields={this.state.tableFields}
                permFuncField={this.props.permFuncField}
                updateConfig={this.updateconfig}
              />
              <SearchComponent
                menu={{MenuID: menu.MenuID, MenuName: config.MenuName}}
                config={config}
                pasteContent={this.state.pasteContent}
                sysRoles={this.props.sysRoles}
                optionLibs={this.state.optionLibs}
                updatesearch={this.updatesearch}
              />
              <div className="calendar-wrap">
@@ -861,8 +815,6 @@
const mapStateToProps = (state) => {
  return {
    sysRoles: state.sysRoles,
    permFuncField: state.permFuncField,
    memberLevel: state.memberLevel
  }
}