king
2019-11-23 9f9d68cf40f1d7470bfb49220266b26663cbb722
2019-11-23-01
15个文件已修改
1个文件已添加
685 ■■■■■ 已修改文件
src/components/header/index.jsx 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/sidemenu/editthdmenu/index.jsx 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/index.js 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/locales/en-US/comtable.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/locales/zh-CN/comtable.js 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/action-type.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/action.js 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/reducer.js 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/dragelement/card.jsx 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/editcard/index.jsx 53 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 232 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/searchform/index.jsx 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/settingform/index.jsx 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.jsx 138 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.scss 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/loginform.jsx 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/header/index.jsx
@@ -6,7 +6,7 @@
import {Dropdown, Menu, Icon, Modal, message, Form, notification, Switch } from 'antd'
import md5 from 'md5'
import asyncComponent from '@/utils/asyncComponent'
import {toggleCollapse, modifyMainMenu, resetState, resetDebug, resetEditState, resetEditLevel} from '@/store/action'
import {toggleCollapse, modifyMainMenu, resetState, resetDebug, resetEditState, resetEditLevel, logout} from '@/store/action'
import Resetpwd from '@/components/resetpwd'
import Api from '@/api'
import zhCN from '@/locales/zh-CN/header.js'
@@ -105,6 +105,8 @@
      okText: this.state.dict['header.confirm'],
      cancelText: this.state.dict['header.cancel'],
      onOk() {
        sessionStorage.clear()
        _this.props.logout()
        _this.props.history.replace('/login')
        // return Api.logoutsystem().then(res => {
        //   if (res.status) {
@@ -286,10 +288,11 @@
  return {
    toggleCollapse: (collapse) => dispatch(toggleCollapse(collapse)),
    modifyMainMenu: (selectmenu) => dispatch(modifyMainMenu(selectmenu)),
    resetEditState: (state) => dispatch(resetEditState(state)),
    resetEditLevel: (level) => dispatch(resetEditLevel(level)),
    resetState: () => dispatch(resetState()),
    resetDebug: () => dispatch(resetDebug()),
    resetEditState: (state) => dispatch(resetEditState(state)),
    resetEditLevel: (level) => dispatch(resetEditLevel(level))
    logout: () => dispatch(logout())
  }
}
src/components/sidemenu/editthdmenu/index.jsx
@@ -281,6 +281,7 @@
  useTemplate = (template) => {
    const { type, editMenu } = this.state
    // 选择模板:添加菜单时
    if (type === 'add') {
      this.setState({
@@ -293,13 +294,13 @@
          src: '',
          text: '',
          type: template.type,
          PageParam: {OpenType: "newtab", Template: template.type},
          PageParam: {OpenType: 'newtab', Template: template.type},
          LongParam: '',
          ParentID: this.props.supMenu.MenuID
        }
      })
    } else {
      let _PageParam = {OpenType: editMenu.PageParam.OpenType, Template: template.type}
      let _PageParam = {OpenType: editMenu.PageParam.OpenType || 'newtab', Template: template.type}
      this.setState({
        tabview: template.type,
src/index.js
@@ -6,7 +6,11 @@
import * as serviceWorker from './serviceWorker'
import '@/assets/css/main.scss'
import '@/assets/css/action.scss'
import '@/assets/css/minkeicon.css';
import '@/assets/css/minkeicon.css'
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
  window.location.replace(window.location.href.split('build/')[0] + 'index.html')
}
const render  = Component => {
  ReactDOM.render(
src/locales/en-US/comtable.js
@@ -45,6 +45,9 @@
  'header.form.link': '关联菜单',
  'header.form.dateday': 'Date(Day)',
  'header.form.datetime': 'Date(Second)',
  'header.form.dateweek': '日期(周)',
  'header.form.datemonth': '日期(月)',
  'header.form.dateyear': '日期(年)',
  'header.form.initval': 'Initial Value',
  'header.form.isRequired': '行设置',
  'header.form.notRequired': '不选择行',
src/locales/zh-CN/comtable.js
@@ -45,6 +45,9 @@
  'header.form.link': '关联菜单',
  'header.form.dateday': '日期(天)',
  'header.form.datetime': '日期(秒)',
  'header.form.dateweek': '日期(周)',
  'header.form.datemonth': '日期(月)',
  'header.form.dateyear': '日期(年)',
  'header.form.initval': '初始值',
  'header.form.isRequired': '行设置',
  'header.form.notRequired': '不选择行',
src/store/action-type.js
@@ -23,4 +23,7 @@
export const RESET_EDITSTATE = 'RESET_EDITSTATE'
// 重置编辑级别
export const RESET_EDITLEVEL = 'RESET_EDITLEVEL'
export const RESET_EDITLEVEL = 'RESET_EDITLEVEL'
// 退出
export const LOGOUT = 'LOGOUT'
src/store/action.js
@@ -64,13 +64,15 @@
// 重置编辑级别
export const resetEditLevel = (editLevel) => {
  // if (editLevel) {
  //   document.getElementById('root').style.overflow = 'hidden'
  // } else {
  //   document.getElementById('root').style.overflow = 'visible'
  // }
  return {
    type: user.RESET_EDITLEVEL,
    editLevel
  }
}
// 退出重置
export const logout = () => {
  return {
    type: user.LOGOUT
  }
}
src/store/reducer.js
@@ -65,6 +65,17 @@
        ...state,
        editLevel: action.editLevel
      }
    case Type.LOGOUT:
      return {
        selectedMainMenu: '',
        tabviews: [],
        collapse: false,
        isiframe: false,
        debug: false,
        editState: false,
        editLevel: null,
        refreshTab: null
      }
    default:
      return state
  }
src/templates/comtableconfig/dragelement/card.jsx
@@ -5,6 +5,8 @@
import ItemTypes from './itemtypes'
import './index.scss'
const { MonthPicker, WeekPicker } = DatePicker
const Card = ({ id, type, card, moveCard, findCard, editCard, copyCard, hasDrop }) => {
  const originalIndex = findCard(id).index
  const [{ isDragging }, drag] = useDrag({
@@ -47,17 +49,23 @@
            <label title={card.label}>{card.label}</label>
          </div>
          <div className="ant-col ant-form-item-control-wrapper">
            {card.type === 'text' &&
              <Input style={{marginTop: '4px'}} defaultValue={card.initval} />
            {card.type === 'text' ?
              <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> : null
            }
            {(card.type === 'select' || card.type === 'link') &&
              <Select defaultValue={card.initval}></Select>
            {(card.type === 'select' || card.type === 'link') ?
              <Select defaultValue={card.initval}></Select> : null
            }
            {card.type === 'date' &&
              <DatePicker defaultValue={card.initval ? moment(card.initval, 'YYYY-MM-DD') : null} />
            {card.type === 'date' ?
              <DatePicker defaultValue={card.initval ? moment().subtract(card.initval, 'days') : null} /> : null
            }
            {card.type === 'datetime' &&
              <DatePicker showTime defaultValue={card.initval ? moment(card.initval, 'YYYY-MM-DD HH:mm:ss') : null} />
            {card.type === 'dateweek' ?
              <WeekPicker defaultValue={card.initval ? moment().subtract(card.initval * 7, 'days') : null} /> : null
            }
            {card.type === 'datemonth' ?
              <MonthPicker defaultValue={card.initval ? moment().subtract(card.initval, 'month') : null} /> : null
            }
            {card.type === 'datetime' ?
              <DatePicker showTime defaultValue={card.initval ? moment(card.initval, 'YYYY-MM-DD HH:mm:ss') : null} /> : null
            }
            <div className="input-mask"></div>
          </div>
src/templates/comtableconfig/editcard/index.jsx
@@ -6,8 +6,21 @@
  constructor(props) {
    super(props)
    let _type = props.card.type
    if (props.type === 'columns') {
      if (_type !== 'picture') {
        _type = 'text'
      }
    } else if (props.type === 'search') {
      if (_type === 'number') {
        _type = 'text'
      } else if (_type === 'datetime') {
        _type = 'date'
      }
    }
    this.state = {
      card: props.card,
      card: {...props.card, type: _type},
      type: props.type
    }
  }
@@ -28,34 +41,26 @@
  render() {
    const { card, type } = this.state
    let _type = card.type
    if (type === 'columns') {
      if (_type !== 'picture') {
        _type = 'text'
      }
    } else if (type === 'search') {
      if (_type === 'number') {
        _type = 'text'
      } else if (_type === 'datetime') {
        _type = 'date'
      }
    }
    return (
      <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '')} >
        <div className="base" onClick={this.changeSelect}>
          <Icon type="check" />
          <p title={card.field}>字段名: <span>{card.field}</span></p>
          <p title={card.label}>提示文字: <span>{card.label}</span></p>
          <p title={card.field}>字段: <span>{card.field}</span></p>
          <p title={card.label}>名称: <span>{card.label}</span></p>
        </div>
        {type === 'search' && <Radio.Group onChange={this.changeType} value={_type} disabled={!card.selected}>
          <Radio value="text">text</Radio>
          <Radio value="select">select</Radio>
          <Radio value="date">date</Radio>
        </Radio.Group>}
        {type === 'columns' && <Radio.Group onChange={this.changeType} value={_type} disabled={!card.selected}>
          <Radio value="text">text</Radio>
          <Radio value="picture">picture</Radio>
        </Radio.Group>}
        {type === 'search' ?
          <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}>
            <Radio value="text">text</Radio>
            <Radio value="select">select</Radio>
            <Radio value="date">date</Radio>
          </Radio.Group> : null
        }
        {type === 'columns' ?
          <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}>
            <Radio value="text">text</Radio>
            <Radio value="picture">picture</Radio>
          </Radio.Group> : null
        }
      </div>
    )
  }
src/templates/comtableconfig/index.jsx
@@ -198,6 +198,7 @@
                field: item.FieldName,
                label: item.FieldDec,
                type: _type,
                datatype: _type,
                decimal: _decimal
              }
            })
@@ -273,20 +274,26 @@
          initVal: card.type,
          required: true,
          options: [{
            MenuID: 'text',
            value: 'text',
            text: this.state.dict['header.form.text']
          }, {
            MenuID: 'select',
            value: 'select',
            text: this.state.dict['header.form.select']
          }, {
            MenuID: 'link',
            value: 'link',
            text: this.state.dict['header.form.link']
          }, {
            MenuID: 'date',
            value: 'date',
            text: this.state.dict['header.form.dateday']
          }, {
            MenuID: 'datetime',
            text: this.state.dict['header.form.datetime']
            value: 'dateweek',
            text: this.state.dict['header.form.dateweek']
          }, {
            value: 'datemonth',
            text: this.state.dict['header.form.datemonth']
          }, {
            value: 'dateyear',
            text: this.state.dict['header.form.dateyear']
          }]
        },
        {
@@ -303,10 +310,10 @@
          initVal: card.resourceType || '0',
          required: true,
          options: [{
            MenuID: '0',
            value: '0',
            text: this.state.dict['header.form.custom']
          }, {
            MenuID: '1',
            value: '1',
            text: this.state.dict['header.form.datasource']
          }]
        },
@@ -316,10 +323,10 @@
          label: this.state.dict['header.form.setAll'],
          initVal: card.setAll || 'false',
          options: [{
            MenuID: 'true',
            value: 'true',
            text: this.state.dict['header.form.true']
          }, {
            MenuID: 'false',
            value: 'false',
            text: this.state.dict['header.form.false']
          }]
        },
@@ -377,10 +384,10 @@
          label: this.state.dict['header.form.orderType'],
          initVal: card.orderType || 'asc',
          options: [{
            MenuID: 'asc',
            value: 'asc',
            text: this.state.dict['header.form.asc']
          }, {
            MenuID: 'desc',
            value: 'desc',
            text: this.state.dict['header.form.desc']
          }]
        },
@@ -391,19 +398,19 @@
          initVal: card.match || 'like',
          required: true,
          options: [{
            MenuID: 'like',
            value: 'like',
            text: 'like'
          }, {
            MenuID: 'equal',
            value: 'equal',
            text: 'equal'
          }, {
            MenuID: 'greater',
            value: 'greater',
            text: '>'
          }, {
            MenuID: 'less',
            value: 'less',
            text: '<'
          }, {
            MenuID: 'greaterequal',
            value: 'greaterequal',
            text: '>='
          }]
        },
@@ -414,10 +421,10 @@
          initVal: card.display || 'dropdown',
          required: true,
          options: [{
            MenuID: 'dropdown',
            value: 'dropdown',
            text: this.state.dict['header.form.dropdown']
          }, {
            MenuID: 'button',
            value: 'button',
            text: this.state.dict['header.form.button']
          }]
        }
@@ -686,6 +693,7 @@
            return item
          }
        })
        _config[res.type] = _config[res.type].filter(item => !item.origin)
      }
      this.setState({
@@ -916,6 +924,7 @@
  queryField = (type) => {
    const {selectedTables, tableColumns, config} = this.state
    // 判断是否已选择表名
    if (selectedTables.length === 0) {
      notification.warning({
        top: 92,
@@ -925,6 +934,7 @@
      return
    }
    // 表字段集转为map数据
    let columns = new Map()
    tableColumns.forEach(table => {
      table.columns.forEach(column => {
@@ -933,19 +943,24 @@
    })
    if (type === 'search') {
      // 添加搜索条件,字段集中存在搜索条件字段,使用搜索条件对象替换字段集,设置数据类型
      config.search.forEach(item => {
        if (columns.has(item.field)) {
          columns.set(item.field, {...item, selected: true, type: item.type})
          let _datatype = columns.get(item.field).datatype
          columns.set(item.field, {...item, selected: true, datatype: _datatype})
        }
      })
    } else if (type === 'columns') {
      // 添加显示列,字段集中存在显示列字段,使用显示列对象替换字段集,设置数据类型
      config.columns.forEach(item => {
        if (columns.has(item.field)) {
          columns.set(item.field, {...item, selected: true, type: item.type})
          let _datatype = columns.get(item.field).datatype
          columns.set(item.field, {...item, selected: true, datatype: _datatype})
        }
      })
    }
    // 显示字段集弹窗
    this.setState({
      addType: type,
      tableVisible: true,
@@ -954,6 +969,7 @@
  }
  addFieldSubmit = () => {
    // 字段集为空,关闭弹窗
    if (!this.state.fields || this.state.fields.length === 0) {
      this.setState({
        tableVisible: false,
@@ -962,34 +978,72 @@
    }
    const {addType, config} = this.state
    const textmatch = { // 选择text时匹配规则
      text: 'like',
      number: 'like',
      datetime: 'like',
      date: 'like'
    }
    const selectmatch = { // 选择select时匹配规则
      text: 'equal',
      number: 'equal',
      datetime: 'equal',
      date: 'equal'
    }
    const datematch = { // 选择date时匹配规则
      text: 'between',
      number: 'between',
      datetime: 'between',
      date: 'between'
    }
    // 获取已选字段集合
    let cards = this.refs.searchcard.getSelectedCard()
    let columns = new Map()
    let columnsMap = new Map()
    cards.forEach(card => {
      columns.set(card.field, card)
      columnsMap.set(card.field, card)
    })
    let items = []
    if (addType === 'search') {
      config.search.forEach(item => {
        if (columns.has(item.field)) {
          let cell = columns.get(item.field)
        if (columnsMap.has(item.field)) {
          let cell = columnsMap.get(item.field)
          if (cell.selected) {
          if (cell.selected && cell.type === item.type) { // 数据未修改
            items.push(item)
          } else if (cell.selected) { // 数据类型修改
            if (cell.type === 'text') {
              item.match = textmatch[cell.datatype]
            } else if (cell.type === 'select') {
              item.match = selectmatch[cell.datatype]
            } else if (cell.type === 'date') {
              item.match = datematch[cell.datatype]
            }
            item.initval = ''
            items.push(item)
          }
          columns.delete(item.field)
          columnsMap.delete(item.field)
        } else if (!item.origin) {
          items.push(item)
        }
      })
      let _columns = [...columns.values()]
      let _columns = [...columnsMap.values()]
      let indexes = items.map(card => {return card.id})
      let id = Math.max(...indexes, 0)
      let id = Math.max(...indexes, 0) + 1
      _columns.forEach(item => {
        if (item.selected) {
          let _match = ''
          if (item.type === 'text') {
            _match = textmatch[item.datatype]
          } else if (item.type === 'select') {
            _match = selectmatch[item.datatype]
          } else if (item.type === 'date') {
            _match = datematch[item.datatype]
          }
          let newcard = {
            id: id,
            uuid: Utils.getuuid(),
@@ -1006,6 +1060,7 @@
            valueText: '',
            orderBy: '',
            orderType: 'asc',
            match: _match,
            display: 'dropdown'
          }
@@ -1015,19 +1070,19 @@
      })
    } else {
      config.columns.forEach(item => {
        if (columns.has(item.field)) {
          let cell = columns.get(item.field)
        if (columnsMap.has(item.field)) {
          let cell = columnsMap.get(item.field)
          if (cell.selected) {
            items.push(item)
          }
          columns.delete(item.field)
          columnsMap.delete(item.field)
        } else if (!item.origin) {
          items.push(item)
        }
      })
      let _columns = [...columns.values()]
      let _columns = [...columnsMap.values()]
      let indexes = items.map(card => {return card.id})
      let id = Math.max(...indexes, 0)
@@ -1086,16 +1141,6 @@
              } else if (/^decimal/.test(_type)) {
                _decimal = _type.split(',')[1]
                _decimal = parseInt(_decimal)
                if (_decimal > 4) {
                  _decimal = 4
                }
                _type = 'number'
              } else if (/^decimal/.test(_type)) {
                _decimal = _type.split(',')[1]
                _decimal = parseInt(_decimal)
                if (_decimal > 4) {
                  _decimal = 4
                }
                _type = 'number'
              } else if (/^datetime/.test(_type)) {
                _type = 'datetime'
@@ -1109,6 +1154,7 @@
                field: item.FieldName,
                label: item.FieldDec,
                type: _type,
                datatype: _type,
                decimal: _decimal
              }
            })
@@ -1316,34 +1362,37 @@
            } style={{ width: '100%' }}>
              <Icon type="setting" onClick={this.changeSetting} />
              <div className="search-list">
                {this.state.config.search && !this.state.searchloading &&
                <DragElement
                  list={this.state.config.search}
                  type="search"
                  placeholder={this.state.dict['header.form.search.placeholder']}
                  handleList={this.handleList}
                  handleMenu={this.handleSearch}
                />}
                {!this.state.searchloading ?
                  <DragElement
                    list={this.state.config.search}
                    type="search"
                    placeholder={this.state.dict['header.form.search.placeholder']}
                    handleList={this.handleList}
                    handleMenu={this.handleSearch}
                  /> : null
                }
              </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}
                />}
                {!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}
                  /> : null
                }
              </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}
                />}
                {!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}
                  /> : null
                }
              </div>
            </Card>
          </div>
@@ -1361,24 +1410,30 @@
          ]}
          destroyOnClose
        >
          {this.state.formtemp === 'search' && <SearchForm
            dict={this.state.dict}
            formlist={this.state.formlist}
            card={this.state.card}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />}
          {this.state.formtemp === 'action' && <ActionForm
            dict={this.state.dict}
            card={this.state.card}
            formlist={this.state.formlist}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />}
          {this.state.formtemp === 'columns' && <ColumnForm
            dict={this.state.dict}
            card={this.state.card}
            formlist={this.state.formlist}
            wrappedComponentRef={(inst) => this.formRef = inst}
          />}
          {this.state.formtemp === 'search' ?
            <SearchForm
              dict={this.state.dict}
              formlist={this.state.formlist}
              card={this.state.card}
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
          {this.state.formtemp === 'action' ?
            <ActionForm
              dict={this.state.dict}
              card={this.state.card}
              formlist={this.state.formlist}
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
          {this.state.formtemp === 'columns' ?
            <ColumnForm
              dict={this.state.dict}
              card={this.state.card}
              formlist={this.state.formlist}
              wrappedComponentRef={(inst) => this.formRef = inst}
            /> : null
          }
        </Modal>
        {/* 根据字段名添加显示列及搜索条件 */}
        <Modal
@@ -1396,11 +1451,8 @@
          }}
          destroyOnClose
        >
          {this.state.addType === 'search' && this.state.fields.length > 0 &&
            <EditCard data={this.state.fields} ref="searchcard" type="search" />
          }
          {this.state.addType === 'columns' && this.state.fields.length > 0 &&
            <EditCard data={this.state.fields} ref="searchcard" type="columns" />
          {this.state.addType && this.state.fields.length > 0 ?
            <EditCard data={this.state.fields} ref="searchcard" type={this.state.addType} /> : null
          }
          {(!this.state.fields || this.state.fields.length === 0) &&
            <Empty />
src/templates/comtableconfig/searchform/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Select, Icon, Radio, notification } from 'antd'
import moment from 'moment'
// import moment from 'moment'
import EditTable from '../editable'
import './index.scss'
@@ -17,7 +17,13 @@
  state = {
    openType: null,
    resourceType: null,
    formlist: null
    formlist: null,
    dateoptions: {
      date: [{value: '', text: '空'}, {value: '0', text: '当天'}, {value: 1, text: '前一天'}, {value: 3, text: '前三天'}, {value: 7, text: '前七天'}, {value: 30, text: '前30天'}],
      dateweek: [{value: '', text: '空'}, {value: '0', text: '本周'}, {value: 1, text: '上周'}, {value: 3, text: '前三周'}, {value: 7, text: '前七周'}],
      datemonth: [{value: '', text: '空'}, {value: '0', text: '本月'}, {value: 1, text: '上月'}, {value: 3, text: '前三月'}, {value: 7, text: '前七月'}],
      dateyear: [{value: '', text: '空'}, {value: '0', text: '当年'}, {value: 1, text: '去年'}, {value: 3, text: '前年'}],
    }
  }
  openTypeChange = (key, value) => {
@@ -37,7 +43,26 @@
        openType: value,
        formlist: this.state.formlist.map(form => {
          form.hidden = !_options.includes(form.key)
          if (form.key === 'initval') {
            if (this.state.dateoptions.hasOwnProperty(value)) {
              form.options = this.state.dateoptions[value]
              form.type = 'select'
            } else {
              form.type = 'text'
            }
            form.initVal = ''
            form.hidden = true
          }
          return form
        })
      }, () => {
        this.setState({
          formlist: this.state.formlist.map(form => {
            if (form.key === 'initval') {
              form.hidden = false
            }
            return form
          })
        })
      })
    }
@@ -74,12 +99,6 @@
      if (item.hidden) return
      if (item.type === 'text') { // 文本搜索
        let placeholder = ''
        if (item.key === 'initval' && this.state.openType === 'date') {
          placeholder = '例:' + moment().format('YYYY-MM-DD')
        } else if (item.key === 'initval' && this.state.openType === 'datetime') {
          placeholder = '例:' + moment().format('YYYY-MM-DD HH:mm:ss')
        }
        fields.push(
          <Col span={12} key={index}>
            <Form.Item label={item.label}>
@@ -91,7 +110,7 @@
                    message: this.props.dict['form.required.input'] + item.label + '!'
                  }
                ]
              })(<Input placeholder={placeholder} autoComplete="off" disabled={item.readonly} />)}
              })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)}
            </Form.Item>
          </Col>
        )
@@ -115,7 +134,7 @@
                  getPopupContainer={() => document.getElementById('commontable-search-form-box')}
                >
                  {item.options.map(option =>
                    <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}>
                    <Select.Option id={option.value} title={option.text} key={option.value} value={option.value}>
                      {item.key === 'icon' && <Icon type={option.text} />} {option.text}
                    </Select.Option>
                  )}
@@ -141,7 +160,7 @@
                  {
                    item.options.map(option => {
                      return (
                        <Radio key={option.MenuID} value={option.MenuID}>{option.text}</Radio>
                        <Radio key={option.value} value={option.value}>{option.text}</Radio>
                      )
                    })
                  }
@@ -175,6 +194,7 @@
        )
      }
    })
    return fields
  }
@@ -241,6 +261,10 @@
      openType: type,
      resourceType: resourceType,
      formlist: formlist.map(form => {
        if (this.state.dateoptions.hasOwnProperty(type) && form.key === 'initval') {
          form.options = this.state.dateoptions[type]
          form.type = 'select'
        }
        form.hidden = !_options.includes(form.key)
        return form
      })
src/templates/comtableconfig/settingform/index.jsx
@@ -12,10 +12,6 @@
    card: PropTypes.object
  }
  state = {
  }
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
src/views/login/index.jsx
@@ -1,5 +1,5 @@
import React, {Component} from 'react'
import { Form, Icon, Input, Button, Checkbox, Dropdown, Menu, message, Modal } from 'antd'
import { message } from 'antd'
import md5 from 'md5'
import moment from 'moment'
import Api from '@/api'
@@ -7,45 +7,25 @@
import enUS from '@/locales/en-US/login.js'
import options from '@/store/options.js'
import Utils from '@/utils/utils.js'
import asyncComponent from '@/utils/asyncComponent'
import logourl from '../../assets/img/login-logo.png'
import './index.scss'
const { warning } = Modal
const LoginForm = asyncComponent(() => import('./loginform'))
const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN'
class Login extends Component {
  constructor (props) {
    super(props)
    const iszhCN = !localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN'
    this.state = {
      langs: [{
        name: '中文简体',
        value: 'zh-CN'
      }, {
        name: 'English',
        value: 'en-US'
      }],
      selectedlang: iszhCN ?
        {
          name: '中文简体',
          value: 'zh-CN'
        } :
        {
          name: 'English',
          value: 'en-US'
        },
      dict: iszhCN ? zhCN : enUS,
      isDisabled: false,
      auth: false
    }
  state = {
    selectedlang: iszhCN ? 'zh-CN' : 'en-US',
    dict: iszhCN ? zhCN : enUS,
    isDisabled: false,
    auth: false
  }
  changelang (item) {
    // 切换语言
    this.setState({
      selectedlang: item,
      dict: item.value === 'zh-CN' ? zhCN : enUS
      dict: item === 'zh-CN' ? zhCN : enUS
    })
  }
  
@@ -55,25 +35,12 @@
    return md5(md5(pwd + salt))
  }
  handleSubmit = e => {
    // 登录参数检验
    e.preventDefault()
    if (!this.state.auth) {
      warning({
        title: this.state.dict['login.auth.tip'],
        okText: this.state.dict['login.auth.ok'],
        cancelText: this.state.dict['login.auth.cancel'],
        onOk() {},
        onCancel() {}
      })
      return
    }
    this.props.form.validateFields((err, values) => {
      if (err) return
  handleSubmit = () => {
    this.loginformRef.handleConfirm().then(res => {
      this.setState({
        isDisabled: true
      })
      this.loginsubmit(values)
      this.loginsubmit(res)
    })
  }
@@ -88,7 +55,7 @@
          sessionStorage.setItem('UserID', res.UserID)
          sessionStorage.setItem('SessionUid', Utils.getuuid())
          sessionStorage.setItem('LoginUID', res.LoginUID)
          localStorage.setItem('lang', this.state.selectedlang.value)
          localStorage.setItem('lang', param.lang)
    
          if (param.remember) { // 记住密码时账号密码存入localStorage
            localStorage.setItem('username', param.username)
@@ -116,7 +83,7 @@
    }
  }
  UNSAFE_componentWillMount () {
  componentDidMount () {
    let timeStamp = new Date().getTime()
    let str = md5('MK19' + options.AppId + timeStamp)
    Api.systemauth(options.AppId, timeStamp).then(res => {
@@ -140,9 +107,6 @@
      }
    })
    // console.log(options)
    // localStorage.setItem('AuthCode', [md5('mksoft' + moment().format('YYYYMMDD'))])
    let authCode = localStorage.getItem('AuthCode')
    let _s = md5('mksoft' + moment().format('YYYYMMDD'))
    if (authCode && authCode.includes(_s)) {
@@ -152,74 +116,22 @@
    }
  }
  componentDidMount () {
    const input = document.getElementById('username')
    if (input) {
      input.focus()
    }
  }
  render () {
    const { getFieldDecorator } = this.props.form
    const menu = (
      <Menu>
        {this.state.langs.map((item, index) => {
          return (
            <Menu.Item key={index} onClick={() => {this.changelang(item)}}>
              <span>{item.name}</span>
            </Menu.Item>
          )
        })}
      </Menu>
    )
    return (
      <div className="login-container">
        <div className="logo">
          <img src={logourl} alt=""/>
        </div>
        <div className="login-middle">
          <Form onSubmit={this.handleSubmit} className="login-form">
            <h4>明科商业智能开放平台</h4>
            <Form.Item>
              {getFieldDecorator('username', {
                rules: [{ required: true, message: this.state.dict['login.username.empty'] }],
                initialValue: localStorage.getItem('username') || '',
              })(
                <Input
                  prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
                  placeholder={this.state.dict['login.username']}
                />,
              )}
            </Form.Item>
            <Form.Item>
              {getFieldDecorator('password', {
                rules: [{ required: true, message: this.state.dict['login.password.empty'] }],
                initialValue: localStorage.getItem('password') || '',
              })(
                <Input
                  prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
                  type="password"
                  placeholder={this.state.dict['login.password']}
                />,
              )}
            </Form.Item>
            <Form.Item className="minline">
              {getFieldDecorator('remember', {
                valuePropName: 'checked',
                initialValue: true,
              })(<Checkbox>{this.state.dict['login.remember']}</Checkbox>)}
              <Dropdown overlay={menu} trigger={['click']} placement="bottomRight">
                <span className="ant-dropdown-link">
                  {this.state.selectedlang.name} <Icon type="down" />
                </span>
              </Dropdown>
            </Form.Item>
            <Form.Item className="btn-login">
              <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.state.isDisabled} loading={this.state.isDisabled}>
                {this.state.dict['login.submit']}
              </Button>
            </Form.Item>
          </Form>
          <LoginForm
            dict={this.state.dict}
            auth={this.state.auth}
            lang={this.state.selectedlang}
            isDisabled={this.state.isDisabled}
            changelang={(value) => this.changelang(value)}
            handleSubmit={() => this.handleSubmit()}
            wrappedComponentRef={(inst) => this.loginformRef = inst}
          />
        </div>
        <div className="login-bottom">
          <p>
@@ -237,4 +149,4 @@
  }
}
export default Form.create()(Login)
export default Login
src/views/login/index.scss
@@ -22,7 +22,6 @@
      float: right;
      margin-top: 5%;
      margin-right: 20%;
      // padding: 15px;
      padding: 1.6vw;
      background: #ffffff;
      width: 22vw;
@@ -43,12 +42,24 @@
        margin-bottom: 3vh;
      }
      .minline {
        display: inline-block;
        margin-bottom: 3vh;
        margin-top: -10px;
      }
      .minline.right {
        float: right;
        width: 100px;
        .ant-select-selection {
          border: 0;
          box-shadow: none;
          .ant-select-selection-selected-value {
            float: right;
            margin-right: 10px;
          }
        }
      }
      button {
        width: 100%;
        // height: 40px;
        height: calc(2vw + 10px);
        line-height: 1;
      }
@@ -66,7 +77,6 @@
      }
      .ant-input {
        font-size: 16px;
        // height: 36px;
        height: calc(2vw + 5px);
      }
      .ant-form label {
src/views/login/loginform.jsx
New file
@@ -0,0 +1,118 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Icon, Input, Button, Checkbox, Select, Modal } from 'antd'
import './index.scss'
const { warning } = Modal
class MainSearch extends Component {
  static propTpyes = {
    isDisabled: PropTypes.bool,
    changelang: PropTypes.func,
    handleSubmit: PropTypes.func,
    dict: PropTypes.object,
    auth: PropTypes.bool,
    lang: PropTypes.string,
  }
  state = {}
  handleConfirm = () => {
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          resolve(values)
        } else {
          reject(err)
        }
      })
    })
  }
  changelang = (item) => {
    this.props.changelang(item)
  }
  handleSubmit = e => {
    // 登录参数检验
    e.preventDefault()
    if (!this.props.auth) {
      warning({
        title: this.props.dict['login.auth.tip'],
        okText: this.props.dict['login.auth.ok'],
        cancelText: this.props.dict['login.auth.cancel'],
        onOk() {},
        onCancel() {}
      })
      return
    }
    this.props.handleSubmit()
  }
  componentDidMount () {
    const input = document.getElementById('username')
    if (input) {
      input.focus()
    }
  }
  render() {
    const { getFieldDecorator } = this.props.form
    return (
      <Form onSubmit={this.handleSubmit} className="login-form" id="login-form">
        <h4>明科商业智能开放平台</h4>
        <Form.Item>
          {getFieldDecorator('username', {
            rules: [{ required: true, message: this.props.dict['login.username.empty'] }],
            initialValue: localStorage.getItem('username') || '',
          })(
            <Input
              prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
              placeholder={this.props.dict['login.username']}
            />,
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('password', {
            rules: [{ required: true, message: this.props.dict['login.password.empty'] }],
            initialValue: localStorage.getItem('password') || '',
          })(
            <Input
              prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
              type="password"
              placeholder={this.props.dict['login.password']}
            />,
          )}
        </Form.Item>
        <Form.Item className="minline">
          {getFieldDecorator('remember', {
            valuePropName: 'checked',
            initialValue: true,
          })(<Checkbox>{this.props.dict['login.remember']}</Checkbox>)}
        </Form.Item>
        <Form.Item className="minline right">
          {getFieldDecorator('lang', {
            initialValue: this.props.lang,
          })(
            <Select
              onChange={(value) => {this.changelang(value)}}
              getPopupContainer={() => document.getElementById('login-form')}
            >
              <Select.Option value="zh-CN">中文简体</Select.Option>
              <Select.Option value="en-US">English</Select.Option>
            </Select>
          )}
        </Form.Item>
        <Form.Item className="btn-login">
          <Button type="primary" htmlType="submit" className="login-form-button" disabled={this.props.isDisabled} loading={this.props.isDisabled}>
            {this.props.dict['login.submit']}
          </Button>
        </Form.Item>
      </Form>
    )
  }
}
export default Form.create()(MainSearch)