From 697d8416feb8919f1371ea4a32988ed63dac24c0 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 一月 2020 15:31:03 +0800 Subject: [PATCH] 2020-01-14 --- src/templates/formtabconfig/groupform/index.scss | 13 + src/templates/formtabconfig/groupform/index.jsx | 119 +++++++++++++ src/templates/formtabconfig/source.jsx | 1 src/templates/formtabconfig/transferform/index.jsx | 75 ++++++++ src/templates/formtabconfig/index.jsx | 263 ++++++++++++++++------------ src/templates/formtabconfig/transferform/index.scss | 6 src/templates/comtableconfig/index.jsx | 1 src/tabviews/tableshare/actionList/index.jsx | 2 src/templates/tableshare/editcard/index.jsx | 10 + src/views/login/index.jsx | 2 10 files changed, 380 insertions(+), 112 deletions(-) diff --git a/src/tabviews/tableshare/actionList/index.jsx b/src/tabviews/tableshare/actionList/index.jsx index 47693ca..baf03ed 100644 --- a/src/tabviews/tableshare/actionList/index.jsx +++ b/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, diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 564910d..ba0c819 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/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 || '', diff --git a/src/templates/formtabconfig/groupform/index.jsx b/src/templates/formtabconfig/groupform/index.jsx new file mode 100644 index 0000000..ee1c03c --- /dev/null +++ b/src/templates/formtabconfig/groupform/index.jsx @@ -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) \ No newline at end of file diff --git a/src/templates/formtabconfig/groupform/index.scss b/src/templates/formtabconfig/groupform/index.scss new file mode 100644 index 0000000..091801f --- /dev/null +++ b/src/templates/formtabconfig/groupform/index.scss @@ -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%; + } +} \ No newline at end of file diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index e8a15df..c09e724 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/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> ) diff --git a/src/templates/formtabconfig/source.jsx b/src/templates/formtabconfig/source.jsx index 6c209eb..1ee4c76 100644 --- a/src/templates/formtabconfig/source.jsx +++ b/src/templates/formtabconfig/source.jsx @@ -25,6 +25,7 @@ isDefault: true, uuid: Utils.getuuid(), label: 'label', + sort: 101, sublist: [ { origin: true, diff --git a/src/templates/formtabconfig/transferform/index.jsx b/src/templates/formtabconfig/transferform/index.jsx new file mode 100644 index 0000000..7f15de8 --- /dev/null +++ b/src/templates/formtabconfig/transferform/index.jsx @@ -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 diff --git a/src/templates/formtabconfig/transferform/index.scss b/src/templates/formtabconfig/transferform/index.scss new file mode 100644 index 0000000..fcb7ff4 --- /dev/null +++ b/src/templates/formtabconfig/transferform/index.scss @@ -0,0 +1,6 @@ +.modal-fields-transfer { + padding-left: 18px; + .ant-transfer-list { + width: 296px; + } +} \ No newline at end of file diff --git a/src/templates/tableshare/editcard/index.jsx b/src/templates/tableshare/editcard/index.jsx index f005744..53f3492 100644 --- a/src/templates/tableshare/editcard/index.jsx +++ b/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> ) } diff --git a/src/views/login/index.jsx b/src/views/login/index.jsx index 0767646..61672db 100644 --- a/src/views/login/index.jsx +++ b/src/views/login/index.jsx @@ -27,7 +27,7 @@ copyright: window.GLOB.copyRight || 'Copyright漏2017 鎵�鏈夌浉鍏崇増鏉冨綊 鍖椾含鏄庣鏅崕淇℃伅鎶�鏈湁闄愬叕鍙�', ICP: window.GLOB.icp || 'ICP澶囨锛� 浜琁CP澶�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') } -- Gitblit v1.8.0