king
2019-12-03 343e35d61733028e884bc60963183983154ca093
src/templates/modalconfig/index.jsx
@@ -3,15 +3,15 @@
import { is, fromJS } from 'immutable'
import { DndProvider } from 'react-dnd'
import HTML5Backend from 'react-dnd-html5-backend'
import { Button, Card, Modal, Collapse, notification, Select, List, Icon, Empty } from 'antd'
import DragElement from './dragelement'
import { Button, Card, Modal, Collapse, notification, Select, List, Icon } from 'antd'
// import DragElement from './dragelement'
import SourceElement from './dragelement/source'
import Api from '@/api'
import SearchForm from './searchform'
import ActionForm from './actionform'
import ColumnForm from './columnform'
import SettingForm from './settingform'
import EditCard from './editcard'
// import SearchForm from './searchform'
// import ActionForm from './actionform'
// import ColumnForm from './columnform'
// import SettingForm from './settingform'
// import EditCard from './editcard'
import MenuForm from './menuform'
import zhCN from '@/locales/zh-CN/comtable.js'
import enUS from '@/locales/en-US/comtable.js'
@@ -26,11 +26,9 @@
class ComTableConfig extends Component {
  static propTpyes = {
    type: PropTypes.string,
    menu: PropTypes.any,
    handleConfig: PropTypes.func,
    supMenuList: PropTypes.array,
    supMenu: PropTypes.object,
    editAction: PropTypes.object,
    handleConfig: PropTypes.func
  }
  state = {
@@ -42,7 +40,7 @@
    addType: '', // 添加类型-搜索条件或显示列
    tableColumns: [], // 表格显示列
    fields: null, // 搜索条件及显示列,可选字段
    menuformlist: null, // 基本信息表单字段
    modalformlist: null, // 基本信息表单字段
    formlist: null, // 搜索条件、按钮、显示列表单字段
    formtemp: '', // 表单类型,显示列、按钮、搜索条件
    card: null, // 编辑元素
@@ -58,43 +56,27 @@
  }
  UNSAFE_componentWillMount () {
    const {menu, supMenu} = this.props
    let _LongParam = menu.LongParam
    let _config = ''
    if (this.props.type === 'add' || !_LongParam) {
      _config = JSON.parse(JSON.stringify((Source.baseConfig)))
    } else {
      let _setting = Source.baseConfig.setting
      if (_LongParam.setting) {
        _setting = {..._setting, ..._LongParam.setting}
      }
      _LongParam.setting = _setting
      _config = _LongParam
    }
    const {menu, editAction} = this.props
    this.setState({
      operaType: this.props.type,
      originMenu: JSON.parse(JSON.stringify({...menu, ParentID: supMenu.MenuID})),
      config: _config,
      selectedTables: _config.tables || [],
      menuformlist: [
      // config: _config,
      // selectedTables: _config.tables || [],
      modalformlist: [
        {
          type: 'select',
          key: 'parentId',
          type: 'text',
          key: 'supMenu',
          label: this.state.dict['header.menu.supMenu'],
          initVal: this.props.supMenu.MenuID,
          initVal: menu.MenuName,
          required: true,
          readonly: false,
          options: this.props.supMenuList
          readonly: true,
        },
        {
          type: 'text',
          key: 'menuName',
          label: this.state.dict['header.menu.menuName'],
          initVal: menu.MenuName,
          key: 'btnName',
          label: '按钮名称',
          initVal: editAction.label,
          required: true,
          readonly: false
          readonly: true
        },
        {
          type: 'text',
@@ -102,63 +84,36 @@
          label: this.state.dict['header.menu.menuNo'],
          initVal: menu.MenuNo,
          required: true,
          readonly: false
          readonly: true
        },
        {
          type: 'select',
          type: 'text',
          key: 'opentype',
          label: this.state.dict['header.menu.openType'],
          initVal: menu.PageParam.OpenType,
          initVal: '弹窗(表单)',
          required: true,
          options: [{
            MenuID: 'newtab',
            text: this.state.dict['header.form.tab']
          }, {
            MenuID: 'newpage',
            text: this.state.dict['header.form.newpage']
          }]
          readonly: true
        }
      ]
    })
  }
  componentDidMount () {
    let _text = "select TbName ,Remark from sDataDictionary where IsKey!='' and Deleted =0"
    let _text = 'select TbName ,Remark from sDataDictionary where IsKey!=\'\' and Deleted =0'
    _text = Utils.formatOptions(_text)
    Api.getSystemConfig({func: 'sPC_Get_SelectedList', LText: _text, obj_name: ''}).then(res => {
      this.setState({
        tables: [
          {
            TbName: 'SRMPurchaseOrder',
            Remark: '采购单'
          },
          {
            TbName: 'sOrganizationAccount',
            Remark: '公司账号'
          },
          {
            TbName: 'sOrganization',
            Remark: '公司'
          },
          {
            TbName: 'BDFactory',
            Remark: '工厂主数据'
          },
          {
            TbName: 'BDWMSWareHouse',
            Remark: '库存地点主数据'
          },
          {
            TbName: 'BDFactoryPerson',
            Remark: '工厂联系人'
          },
          {
            TbName: 'BDWMSStockType',
            Remark: '存储类型'
          }
        ]
      })
    Api.getSystemConfig({func: 'sPC_Get_SelectedList', LText: _text, obj_name: 'data', arr_field: 'TbName,Remark'}).then(res => {
      if (res.status) {
        this.setState({
          tables: res.data
        })
      } else {
        notification.warning({
          top: 92,
          message: res.message,
          duration: 10
        })
      }
    })
    let deffers = this.state.selectedTables.map(item => {
@@ -1161,7 +1116,7 @@
              <Panel header="基本信息" key="0" id="common-basedata">
                <MenuForm
                  dict={this.state.dict}
                  formlist={this.state.menuformlist}
                  formlist={this.state.modalformlist}
                  wrappedComponentRef={(inst) => this.menuformRef = inst}
                />
                <div className="ant-col ant-form-item-label">
@@ -1177,7 +1132,6 @@
                  showArrow={false}
                  getPopupContainer={() => document.getElementById('common-basedata')}
                  filterOption={(input, option) => {
                    console.log(option)
                    return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                  }}
                > 
@@ -1196,60 +1150,25 @@
                  </List.Item>}
                />}
              </Panel>
              <Panel header="搜索" key="1">
              <Panel header="表单" key="1">
                <div className="search-element">
                  {Source.searchItems.map((item, index) => {
                    return (<SourceElement key={index} content={item}/>)
                  })}
                </div>
                <Button type="primary" block onClick={() => this.queryField('search')}>添加搜索条件</Button>
              </Panel>
              <Panel header="按钮" key="2">
                <div className="search-element">
                  {Source.actionItems.map((item, index) => {
                    return (<SourceElement key={index} content={item}/>)
                  })}
                </div>
                <div>
                  <p style={{marginTop: '20px', marginBottom: '10px', color: '#1890ff'}}>可配置按钮:</p>
                  {this.state.config.action.map((item, index) => {
                    if (item.OpenType === 'pop' && !item.origin) {
                      return (
                        <div key={index}>
                          <Button
                            icon={item.icon}
                            style={{marginBottom: '10px'}}
                            className={'mk-btn mk-' + item.class}
                            onClick={() => this.queryField('search')}
                          >{item.label}</Button>
                        </div>
                      )
                    } else {
                      return ''
                    }
                  })}
                </div>
              </Panel>
              <Panel header="显示列" key="3">
                <div className="search-element">
                  {Source.columnItems.map((item, index) => {
                    return (<SourceElement key={index} content={item}/>)
                  })}
                </div>
                <Button type="primary" block onClick={() => this.queryField('columns')}>添加显示列</Button>
                <Button type="primary" block onClick={() => this.queryField('search')}>添加表单</Button>
              </Panel>
            </Collapse>
          </div>
          <div className="setting">
            <Card title="页面配置" bordered={false} extra={
            <Card title="表单配置" bordered={false} extra={
              <div>
                <Button type="primary" onClick={this.changeTemplate}>{this.state.dict['header.menu.template.change']}</Button>
                <Button type="primary" onClick={this.submitConfig} loading={this.state.menuloading}>{this.state.dict['header.save']}</Button>
                <Button onClick={this.cancelConfig}>{this.state.dict['header.return']}</Button>
              </div>
            } style={{ width: '100%' }}>
              <Icon type="setting" onClick={this.changeSetting} />
              <div className="search-list">
              {/* <div className="search-list">
                {this.state.config.search && !this.state.searchloading &&
                <DragElement
                  list={this.state.config.search}
@@ -1258,31 +1177,11 @@
                  handleList={this.handleList}
                  handleMenu={this.handleSearch}
                />}
              </div>
              <div className="action-list">
                {this.state.config.action && !this.state.actionloading &&
                <DragElement
                  list={this.state.config.action}
                  type="action"
                  placeholder={this.state.dict['header.form.action.placeholder']}
                  handleList={this.handleList}
                  handleMenu={this.handleAction}
                />}
              </div>
              <div className="column-list">
                {this.state.config.columns && !this.state.columnsloading &&
                <DragElement
                  list={this.state.config.columns}
                  type="columns"
                  placeholder={this.state.dict['header.form.column.placeholder']}
                  handleList={this.handleList}
                  handleMenu={this.handleColumn}
                />}
              </div>
              </div> */}
            </Card>
          </div>
        </DndProvider>
        <Modal
        {/* <Modal
          title={this.state.dict['header.edit']}
          visible={this.state.visible}
          width={700}
@@ -1359,7 +1258,7 @@
          destroyOnClose
        >
          菜单配置已修改,是否保存配置信息?
        </Modal>
        </Modal> */}
      </div>
    )
  }