king
2020-01-14 697d8416feb8919f1371ea4a32988ed63dac24c0
2020-01-14
6个文件已修改
4个文件已添加
492 ■■■■ 已修改文件
src/tabviews/tableshare/actionList/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/comtableconfig/index.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/groupform/index.jsx 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/groupform/index.scss 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/index.jsx 263 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/source.jsx 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/transferform/index.jsx 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/formtabconfig/transferform/index.scss 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/templates/tableshare/editcard/index.jsx 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/index.jsx 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/tabviews/tableshare/actionList/index.jsx
@@ -108,6 +108,8 @@
        message: '弹窗页面不支持此设置!',
        duration: 10
      })
    } else if (item.OpenType === 'outerpage') {
      console.log(item)
    } else {
      notification.warning({
        top: 92,
src/templates/comtableconfig/index.jsx
@@ -1947,6 +1947,7 @@
      let btnParam = { // 添加菜单按钮
        func: 'sPC_Button_AddUpt',
        Type: 40, // 添加菜单下的按钮
        ParentID: menu.MenuID,
        MenuNo: res.menuNo,
        Template: menu.PageParam.Template || '',
src/templates/formtabconfig/groupform/index.jsx
New file
@@ -0,0 +1,119 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, InputNumber } from 'antd'
import { formRule } from '@/utils/option.js'
import TransferForm from '../transferform'
// import Utils from '@/utils/utils.js'
import './index.scss'
class GroupForm extends Component {
  static propTpyes = {
    dict: PropTypes.object, // 字典项
    group: PropTypes.object, // 字典项
    groups: PropTypes.array
  }
  state = {
    source: null,
    selectds: null,
    default: null
  }
  UNSAFE_componentWillMount () {
    const { groups, group } = this.props
    let defaultgroup = groups.filter(item => item.isDefault)[0]
    let _source = defaultgroup.sublist.filter(item => !item.origin)
    let _selectds = group.sublist.map(item => item.uuid )
    _source = [..._source, ...group.sublist]
    this.setState({
      source: _source,
      selectds: _selectds,
    })
  }
  handleConfirm = () => {
    const { groups, group } = this.props
    let defaultgroup = groups.filter(item => item.isDefault)[0]
    // 表单提交时检查输入值是否正确
    return new Promise((resolve, reject) => {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          values.uuid = group.uuid
          if (group.isDefault) {
            values.isDefault = true
            resolve(values)
          } else {
            let targetKeys = this.refs['fields-transfer'].state.targetKeys
            let defaultlist = this.state.source.filter(item => !targetKeys.includes(item.uuid))
            values.sublist = targetKeys.map(item => {
              return this.state.source.filter(cell => cell.uuid === item)[0]
            })
            resolve({
              default: {...defaultgroup, sublist: defaultlist},
              target: values
            })
          }
        } else {
          reject(err)
        }
      })
    })
  }
  render() {
    const { group, groups } = this.props
    const { getFieldDecorator } = this.props.form
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      }
    }
    return (
      <Form {...formItemLayout} className="ant-advanced-search-form modal-setting-form">
        <Row gutter={24}>
          <Col span={12}>
            <Form.Item label="分组名称">
              {getFieldDecorator('label', {
                initialValue: group.label,
                rules: [
                  {
                    required: true,
                    message: this.props.dict['form.required.input'] + '分组名称!'
                  },
                  {
                    max: formRule.input.max,
                    message: formRule.input.message
                  }
                ]
              })(<Input placeholder="" autoComplete="off"/>)}
            </Form.Item>
          </Col>
          <Col span={12}>
            <Form.Item label="排序">
              {getFieldDecorator('sort', {
                initialValue: group.hasOwnProperty('sort') ? group.sort : groups.length
              })(<InputNumber min={0} max={100} precision={0} />)}
            </Form.Item>
          </Col>
          {!group.isDefault ? <Col span={24}>
            <TransferForm dict={this.props.dict} fields={this.state.source} ref="fields-transfer" selected={this.state.selectds}/>
          </Col> : null}
        </Row>
      </Form>
    )
  }
}
export default Form.create()(GroupForm)
src/templates/formtabconfig/groupform/index.scss
New file
@@ -0,0 +1,13 @@
.ant-advanced-search-form.modal-setting-form {
  .textarea {
    .ant-form-item-label {
      width: 16.3%;
    }
    .ant-form-item-control-wrapper {
      width: 83.33333333%;
    }
  }
  .ant-input-number {
    width: 100%;
  }
}
src/templates/formtabconfig/index.jsx
@@ -13,6 +13,7 @@
import Api from '@/api'
import SearchForm from './modalform'
import DragElement from './dragelement'
import GroupForm from './groupform'
import EditCard from '@/templates/tableshare/editcard'
import VerifyCard from '@/templates/tableshare/verifycard'
import MenuForm from '@/templates/tableshare/menuform'
@@ -43,7 +44,6 @@
    visible: false,          // 搜索条件、按钮、显示列,模态框显示控制
    modalTitle: '',          // 模态框的标题
    tableVisible: false,     // 数据表字段模态框
    addType: '',             // 添加类型-搜索条件或显示列
    tableColumns: [],        // 表格显示列
    fields: null,            // 搜索条件及显示列,可选字段
    menuformlist: null,      // 基本信息表单字段
@@ -64,7 +64,9 @@
    delActions: [],          // 删除按钮列表
    funcLoading: false,      // 存储过程创建中
    tabviews: [],            // 所有标签页
    profileVisible: false    // 验证信息模态框
    profileVisible: false,   // 验证信息模态框
    editgroup: null,
    groupVisible: null
  }
  /**
@@ -74,7 +76,7 @@
   */
  UNSAFE_componentWillMount () {
    const { menu, editAction, config } = this.props
    console.log(menu)
    let _config = ''
    if (!config) {
@@ -276,13 +278,13 @@
      }
    } else if (type === 'search') {
      let _group = config.groups.filter(group => group.uuid === groupId)[0]
      let isChange = list.length > _group.length
      let isAdd = !elementId && list.length > _group.length
      let isChange = elementId && list.length > _group.sublist.length
      let isAdd = !elementId && list.length > _group.sublist.length
      if (isAdd) {
        _group.sublist = list.filter(item => !item.origin)
        this.handleSearch(card)
      } else if (elementId) {
      } else if (isChange) {
        // 修改已有元素的分组
        let element = null
        config.groups.forEach(item => {
@@ -1595,6 +1597,7 @@
      let btnParam = { // 添加菜单按钮
        func: 'sPC_Button_AddUpt',
        Type: 60, // 添加按钮表单页下的按钮
        ParentID: menu.MenuID,
        MenuNo: res.menuNo,
        Template: menu.PageParam.Template || '',
@@ -1863,49 +1866,30 @@
    if (type === 'search') {
      // 添加搜索条件,字段集中存在搜索条件字段,使用搜索条件对象替换字段集,设置数据类型
      config.search.forEach(item => {
        if (columns.has(item.field)) {
          let _datatype = columns.get(item.field).datatype
          columns.set(item.field, {...item, selected: true, datatype: _datatype})
        }
      config.groups.forEach(group => {
        group.sublist.forEach(item => {
          if (columns.has(item.field)) {
            let _datatype = columns.get(item.field).datatype
            columns.set(item.field, {...item, selected: true, datatype: _datatype})
          }
        })
      })
    }
    // 显示字段集弹窗
    this.setState({
      addType: type,
      tableVisible: true,
      fields: [...columns.values()]
    })
  }
  addFieldSubmit = () => {
    const {config} = this.state
    // 字段集为空,关闭弹窗
    if (!this.state.fields || this.state.fields.length === 0) {
      this.setState({
        tableVisible: false,
        addType: ''
      })
    }
    const {addType, config} = this.state
    const textmatch = { // 选择text时匹配规则
      text: 'like',
      number: 'like',
      datetime: 'like',
      date: 'like'
    }
    const selectmatch = { // 选择select时匹配规则
      text: '=',
      number: '=',
      datetime: '=',
      date: '='
    }
    const datematch = { // 选择dateRange时匹配规则
      text: 'between',
      number: 'between',
      datetime: 'between',
      date: 'between'
    }
    // 获取已选字段集合
@@ -1915,77 +1899,50 @@
      columnsMap.set(card.field, card)
    })
    let items = []
    config.search.forEach(item => {
      if (columnsMap.has(item.field)) {
        let cell = columnsMap.get(item.field)
        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 === 'daterange') {
            item.match = datematch[cell.datatype]
          } else {
            cell.type = 'text'
            item.match = textmatch[cell.datatype]
    console.log(cards)
    let groups = config.groups.map(group => {
      group.sublist = group.sublist.map(item => {
        if (columnsMap.has(item.field)) {
          let cell = columnsMap.get(item.field)
          if (cell.selected && cell.type !== item.type) { // 数据类型修改
            item.type = cell.type
            item.initval = ''
          }
          item.type = cell.type
          item.initval = ''
          items.push(item)
          columnsMap.delete(item.field)
        }
        columnsMap.delete(item.field)
      } else if (!item.origin) {
        items.push(item)
      }
        return item
      })
      return group
    })
    let _columns = [...columnsMap.values()]
    _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 === 'daterange') {
          _match = datematch[item.datatype]
        } else {
          item.type = 'text'
          _match = textmatch[item.datatype]
        }
        let newcard = {
          uuid: Utils.getuuid(),
          label: item.label,
          field: item.field,
          initval: '',
          type: item.type,
          resourceType: '0',
          setAll: 'false',
          options: [],
          dataSource: '',
          linkField: '',
          valueField: '',
          valueText: '',
          orderBy: '',
          orderType: 'asc',
          match: _match,
          display: 'dropdown'
        }
        items.push(newcard)
    let items =  [...columnsMap.values()].map(item => {
      let newcard = {
        uuid: Utils.getuuid(),
        label: item.label,
        field: item.field,
        initval: '',
        type: item.type,
        resourceType: '0',
        setAll: 'false',
        options: [],
        orderType: 'asc'
      }
      return newcard
    })
    groups = groups.map(group => {
      if (group.isDefault) {
        group.sublist = [...group.sublist, ...items]
        group.sublist = group.sublist.filter(item => !item.origin)
      }
      return group
    })
    this.setState({
      [addType + 'loading']: true,
      config: {...config, [addType]: items}
      searchloading: true,
      config: {...config, groups: groups}
    }, () => {
      notification.success({
        top: 92,
@@ -1993,7 +1950,7 @@
        duration: 2
      })
      this.setState({
        [addType + 'loading']: false
        searchloading: false
      })
    })
  }
@@ -2296,6 +2253,83 @@
    })
  }
  handleGroup = (group) => {
    let editgroup = {
      label: '',
      sort: 0,
      uuid: Utils.getuuid(),
      sublist: []
    }
    if (group) {
      editgroup = group
    }
    this.setState({
      groupVisible: true,
      editgroup: editgroup
    })
  }
  closeGroup = (group) => {
    const { config } = this.state
    let _this = this
    confirm({
      content: `确定删除分组<<${group.label}>>吗?`,
      okText: this.state.dict['header.confirm'],
      cancelText: this.state.dict['header.cancel'],
      onOk() {
        let groups = config.groups.filter(item => !(item.uuid === group.uuid))
        groups = groups.map(item => {
          if (item.isDefault) {
            item.sublist = [...item.sublist, ...group.sublist]
          }
          return item
        })
        _this.setState({
          config: {...config, groups: groups},
          searchloading: true
        }, () => {
          _this.setState({
            searchloading: false
          })
        })
      },
      onCancel() {}
    })
  }
  handleGroupSave = () => {
    const { editgroup, config } = this.state
    let groups = config.groups.filter(item => !item.isDefault && item.uuid !== editgroup.uuid)
    this.groupRef.handleConfirm().then(res => {
      if (editgroup.isDefault) {
        groups.push(res)
      } else {
        groups.push(res.default, res.target)
      }
      groups = groups.sort((a, b) => {
        return a.sort - b.sort
      })
      this.setState({
        config: {...config, groups: groups},
        editgroup: '',
        groupVisible: false,
        searchloading: true
      }, () => {
        this.setState({
          searchloading: false
        })
      })
    })
  }
  render () {
    const { config } = this.state
    let _length = config.groups.length
@@ -2425,21 +2459,15 @@
                    <span>
                      {index === _length - 1 ? <Icon
                        type="plus"
                        onClick={event => {
                          event.stopPropagation()
                        }}
                        onClick={() => { this.handleGroup()}}
                      /> : null}
                      {_length > 1 && index !== _length - 1 ? <Icon
                        type="delete"
                        onClick={event => {
                          event.stopPropagation()
                        }}
                        onClick={() => { this.closeGroup(group) }}
                      /> : null}
                      <Icon
                        type="edit"
                        onClick={event => {
                          event.stopPropagation()
                        }}
                        onClick={() => { this.handleGroup(group) }}
                      />
                    </span>
                  )}>
@@ -2549,14 +2577,13 @@
          onOk={this.addFieldSubmit}
          onCancel={() => { // 取消添加
            this.setState({
              tableVisible: false,
              addType: ''
              tableVisible: false
            })
          }}
          destroyOnClose
        >
          {this.state.addType && this.state.fields.length > 0 ?
            <EditCard data={this.state.fields} ref="searchcard" type={this.state.addType} dict={this.state.dict} /> : null
          {this.state.fields && this.state.fields.length > 0 ?
            <EditCard data={this.state.fields} ref="searchcard" type={'form'} dict={this.state.dict} /> : null
          }
          {(!this.state.fields || this.state.fields.length === 0) &&
            <Empty />
@@ -2597,7 +2624,6 @@
            dict={this.state.dict}
            menu={this.props.menu}
            config={this.state.config}
            data={this.state.config.setting}
            columns={this.state.config.columns}
            usefulFields={this.props.permFuncField}
            wrappedComponentRef={(inst) => this.settingRef = inst}
@@ -2617,6 +2643,21 @@
        >
          {this.state.dict['header.menu.config.placeholder']}
        </Modal>
        <Modal
          title={this.state.dict['header.menu.group.manage']}
          visible={this.state.groupVisible}
          width={700}
          onOk={this.handleGroupSave}
          onCancel={() => { this.setState({ groupVisible: false }) }}
          destroyOnClose
        >
          <GroupForm
            groups={config.groups}
            group={this.state.editgroup}
            dict={this.state.dict}
            wrappedComponentRef={(inst) => this.groupRef = inst}
          />
        </Modal>
        {this.state.loading && <Spin size="large" />}
      </div>
    )
src/templates/formtabconfig/source.jsx
@@ -25,6 +25,7 @@
        isDefault: true,
        uuid: Utils.getuuid(),
        label: 'label',
        sort: 101,
        sublist: [
          {
            origin: true,
src/templates/formtabconfig/transferform/index.jsx
New file
@@ -0,0 +1,75 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Transfer } from 'antd'
import './index.scss'
class TransferForm extends Component {
  static propTypes = {
    fields: PropTypes.array,
    selected: PropTypes.array,
    dict: PropTypes.object, // 字典项
  }
  state = {
    data: [],
    targetKeys: [],
    selectedKeys: []
  }
  handleChange = (nextTargetKeys, direction, moveKeys) => {
    this.setState({ targetKeys: nextTargetKeys })
  }
  handleSelectChange = (sourceSelectedKeys, targetSelectedKeys) => {
    this.setState({ selectedKeys: [...sourceSelectedKeys, ...targetSelectedKeys] })
  }
  UNSAFE_componentWillMount() {
    let datas = new Map()
    this.props.fields.forEach(item => {
      if (!item.origin) {
        datas.set(item.uuid, item)
      }
    })
    let selecteds = []
    this.props.selected.forEach(item => {
      if (datas.has(item)) {
        selecteds.push(item)
      }
    })
    this.setState({
      data: [...datas.values()].map(item => {
        return {
          key: item.uuid,
          title: item.label,
          description: ''
        }
      }),
      targetKeys: selecteds
    })
  }
  render() {
    const { data, targetKeys, selectedKeys } = this.state
    return (
      <div className="modal-fields-transfer">
        <Transfer
          dataSource={data}
          titles={[this.props.dict['header.form.column.source'], this.props.dict['header.form.column.target']]}
          targetKeys={targetKeys}
          locale={{itemUnit: this.props.dict['header.form.column.itemUnit'], itemsUnit: this.props.dict['header.form.column.itemsUnit']}}
          selectedKeys={selectedKeys}
          onChange={this.handleChange}
          onSelectChange={this.handleSelectChange}
          render={item => item.title}
        />
      </div>
    )
  }
}
export default TransferForm
src/templates/formtabconfig/transferform/index.scss
New file
@@ -0,0 +1,6 @@
.modal-fields-transfer {
  padding-left: 18px;
  .ant-transfer-list {
    width: 296px;
  }
}
src/templates/tableshare/editcard/index.jsx
@@ -19,6 +19,8 @@
      } else if (_type === 'datetime') {
        _type = 'daterange'
      }
    } else if (props.type === 'form') {
    }
    this.state = {
@@ -68,6 +70,14 @@
            <Radio value="picture">picture</Radio>
          </Radio.Group> : null
        }
        {type === 'form' ?
          <Radio.Group onChange={this.changeType} value={card.type} disabled={!card.selected}>
            <Radio value="text">text</Radio>
            <Radio value="number">number</Radio>
            <Radio value="select">select</Radio>
            <Radio value="date">date</Radio>
          </Radio.Group> : null
        }
      </div>
    )
  }
src/views/login/index.jsx
@@ -27,7 +27,7 @@
    copyright: window.GLOB.copyRight || 'Copyright©2017    所有相关版权归    北京明科普华信息技术有限公司',
    ICP: window.GLOB.icp || 'ICP备案: 京ICP备12007830号',
    bgColor: window.GLOB.bgColor || '#000000',
    lineColor: window.GLOB.lineColor || '#06b4f7',
    lineColor: window.GLOB.lineColor || '#1890ff',
    website: window.GLOB.website || (!window.GLOB.copyRight && 'http://minkesoft.com')
  }