From 2cb65d99c9aebf8293cb2838fcfe3e09fb2739ce Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 06 十二月 2019 00:15:12 +0800 Subject: [PATCH] 2019-12-06 --- src/templates/modalconfig/editcard/index.jsx | 77 ++- src/templates/modalconfig/dragelement/itemtypes.js | 1 src/templates/modalconfig/settingform/index.scss | 5 src/components/sidemenu/editsecmenu/index.jsx | 7 src/templates/comtableconfig/dragelement/itemtypes.js | 1 src/templates/comtableconfig/index.jsx | 110 +++- src/templates/modalconfig/modalform/index.jsx | 101 +++-- src/templates/modalconfig/index.jsx | 610 +++++++++++++----------------- src/api/index.js | 14 src/templates/modalconfig/dragelement/index.jsx | 54 +- src/locales/zh-CN/comtable.js | 1 src/tabviews/commontable/index.jsx | 2 public/emp-favicon.ico | 0 src/templates/modalconfig/dragelement/card.jsx | 44 - src/locales/en-US/comtable.js | 1 src/templates/modalconfig/editcard/index.scss | 10 src/templates/modalconfig/index.scss | 37 + public/index.html | 1 src/templates/modalconfig/settingform/index.jsx | 48 +- src/components/sidemenu/editthdmenu/index.jsx | 15 src/components/header/editmenu/index.jsx | 10 src/setupProxy.js | 5 /dev/null | 9 src/assets/img/bg_title.png | 0 src/templates/modalconfig/source.jsx | 18 src/views/login/index.scss | 13 src/templates/modalconfig/modalform/index.scss | 0 27 files changed, 619 insertions(+), 575 deletions(-) diff --git a/public/emp-favicon.ico b/public/emp-favicon.ico new file mode 100644 index 0000000..3ce10c8 --- /dev/null +++ b/public/emp-favicon.ico Binary files differ diff --git a/public/index.html b/public/index.html index c81ee7a..8876915 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,6 @@ <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" /> - <meta name="description" content="minkesoft" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.png" /> <script src="%PUBLIC_URL%/options.js"></script> diff --git a/src/api/index.js b/src/api/index.js index 64f6778..b8303d2 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -22,16 +22,16 @@ return Promise.reject(error) }) -const setCurrentUrl = () => { - if (!!(window.history && window.history.pushState)) { - window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') - window.location.reload() - } -} +// const setCurrentUrl = () => { +// if (!!(window.history && window.history.pushState)) { +// window.history.replaceState(null, null, window.location.href.split('#')[0] + '#/login') +// window.location.reload() +// } +// } axios.interceptors.response.use((response) => { if (response.data.ErrCode === 'LoginError') { - setCurrentUrl() + // setCurrentUrl() } else { return Promise.resolve(response.data) } diff --git a/src/assets/img/bg_title.png b/src/assets/img/bg_title.png new file mode 100644 index 0000000..1a3f6b0 --- /dev/null +++ b/src/assets/img/bg_title.png Binary files differ diff --git a/src/components/header/editmenu/index.jsx b/src/components/header/editmenu/index.jsx index 554204b..fc8bc41 100644 --- a/src/components/header/editmenu/index.jsx +++ b/src/components/header/editmenu/index.jsx @@ -7,9 +7,10 @@ import TransferForm from '@/components/transferform' import DragElement from '../dragelement' import MenuForm from '../menuform' -import Api from '@/api' +import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/header.js' import enUS from '@/locales/en-US/header.js' +import Api from '@/api' import './index.scss' const { confirm } = Modal @@ -233,11 +234,12 @@ let _this = this let param = {} param.func = 'sPC_Menu_SortUpt' - param.LText = [] + let _text = [] previewList.forEach((item, index) => { - param.LText.push('selectmspace\'' + item.MenuID + '\'mspaceasmspaceMenuid,' + (index + 1) * 10 + 'mspaceasmspacesort') + _text.push('select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort') }) - param.LText = param.LText.join('mspaceunionmspace') + _text = _text.join(' union ') + param.LText = Utils.formatOptions(_text) confirm({ title: this.state.dict['header.menu.resetorder'], content: '', diff --git a/src/components/sidemenu/editsecmenu/index.jsx b/src/components/sidemenu/editsecmenu/index.jsx index 213b161..5c8f535 100644 --- a/src/components/sidemenu/editsecmenu/index.jsx +++ b/src/components/sidemenu/editsecmenu/index.jsx @@ -190,11 +190,12 @@ let _this = this let param = {} param.func = 'sPC_Menu_SortUpt' - param.LText = [] + let _text = [] previewList.forEach((item, index) => { - param.LText.push('selectmspace\'' + item.MenuID + '\'mspaceasmspaceMenuid,' + (index + 1) * 10 + 'mspaceasmspacesort') + _text.push('select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort') }) - param.LText = param.LText.join('mspaceunionmspace') + _text = _text.join(' union ') + param.LText = Utils.formatOptions(_text) confirm({ title: this.state.dict['header.menu.resetorder'], content: '', diff --git a/src/components/sidemenu/editthdmenu/index.jsx b/src/components/sidemenu/editthdmenu/index.jsx index 8981993..387cd83 100644 --- a/src/components/sidemenu/editthdmenu/index.jsx +++ b/src/components/sidemenu/editthdmenu/index.jsx @@ -197,11 +197,13 @@ let _this = this let param = {} param.func = 'sPC_Menu_SortUpt' - param.LText = [] + let _text = [] previewList.forEach((item, index) => { - param.LText.push('selectmspace\'' + item.MenuID + '\'mspaceasmspaceMenuid,' + (index + 1) * 10 + 'mspaceasmspacesort') + _text.push('select \'' + item.MenuID + '\' as Menuid,' + (index + 1) * 10 + ' as sort') }) - param.LText = param.LText.join('mspaceunionmspace') + _text = _text.join(' union ') + param.LText = Utils.formatOptions(_text) + confirm({ title: this.state.dict['header.menu.resetorder'], content: '', @@ -366,14 +368,17 @@ handleSubConfig = (item, originMenu, config) => { if (item.OpenType === 'pop') { + item.pageParam = '' + if (config && config.type === 'modal') { + item.pageParam = config + } + this.setState({ editMenu: originMenu, editAction: item, tabview: 'Modal' }) } - console.log(item) - console.log(originMenu) } UNSAFE_componentWillMount () { diff --git a/src/locales/en-US/comtable.js b/src/locales/en-US/comtable.js index 02aeb79..aca4e3e 100644 --- a/src/locales/en-US/comtable.js +++ b/src/locales/en-US/comtable.js @@ -22,6 +22,7 @@ 'header.menu.openType.newWindow': 'A new window', 'header.menu.newpage.service': 'Customer Service', 'header.form.search.placeholder': '璇锋坊鍔犳悳绱㈡潯浠�', + 'header.form.modal.placeholder': '璇锋坊鍔犺〃鍗�', 'header.form.action.placeholder': '璇锋坊鍔犳寜閽�', 'header.form.column.placeholder': '璇锋坊鍔犳樉绀哄垪', 'header.form.column.source': '鏄剧ず鍒�', diff --git a/src/locales/zh-CN/comtable.js b/src/locales/zh-CN/comtable.js index cdaa8a8..8b8d0c0 100644 --- a/src/locales/zh-CN/comtable.js +++ b/src/locales/zh-CN/comtable.js @@ -22,6 +22,7 @@ 'header.menu.openType.newWindow': '鏂扮獥鍙�', 'header.menu.newpage.service': '瀹㈡湇', 'header.form.search.placeholder': '璇锋坊鍔犳悳绱㈡潯浠�', + 'header.form.modal.placeholder': '璇锋坊鍔犺〃鍗�', 'header.form.action.placeholder': '璇锋坊鍔犳寜閽�', 'header.form.column.placeholder': '璇锋坊鍔犳樉绀哄垪', 'header.form.column.source': '鏄剧ず鍒�', diff --git a/src/setupProxy.js b/src/setupProxy.js index 09da2b2..8e6ff05 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -1,8 +1,9 @@ const proxy = require('http-proxy-middleware') +const service = 'mkwms' module.exports = function(app) { app.use(proxy('/webapi', { - target: 'http://qingqiumarket.cn/MKWMS/webapi', + target: `http://qingqiumarket.cn/${service}/webapi`, secure: false, changeOrigin: true, pathRewrite: { @@ -12,7 +13,7 @@ })) app.use(proxy('/zh-CN', { // 鐧诲綍鎺ュ彛 - target: 'http://qingqiumarket.cn/MKWMS/zh-CN', + target: `http://qingqiumarket.cn/${service}/zh-CN`, secure: false, changeOrigin: true, pathRewrite: { diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index b14f9ab..1549350 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -48,8 +48,8 @@ } let result = await Api.getSystemConfig(param) if (result.status && result.LongParam) { - let config = window.decodeURIComponent(window.atob(result.LongParam)) + try { config = JSON.parse(config) this.setState({ diff --git a/src/templates/comtableconfig/dragelement/itemtypes.js b/src/templates/comtableconfig/dragelement/itemtypes.js index d48a2eb..0e7cd9a 100644 --- a/src/templates/comtableconfig/dragelement/itemtypes.js +++ b/src/templates/comtableconfig/dragelement/itemtypes.js @@ -1,5 +1,6 @@ export default { CARD: 'card', + form: 'form', search: 'search', action: 'action', columns: 'columns' diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx index 73a64e1..ab5751c 100644 --- a/src/templates/comtableconfig/index.jsx +++ b/src/templates/comtableconfig/index.jsx @@ -877,8 +877,7 @@ }) _this.setState({ config: _config, - [element.type + 'loading']: true, - visible: false + [element.type + 'loading']: true }, () => { _this.setState({ [element.type + 'loading']: false @@ -944,6 +943,25 @@ return } + let sql = [] + config.action.forEach((item, index) => { + sql.push(`'${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`) + }) + sql = sql.join(' union all select ') + sql = 'select ' + sql + + sql = Utils.formatOptions(sql) + + let btnParam = { + func: 'sPC_Button_AddUpt', + ParentID: menu.MenuID, + MenuNo: res.menuNo, + Template: menu.PageParam.Template || '', + PageParam: '', + LongParam: '', + LongButton: sql + } + if (this.state.operaType === 'add') { // 鏂板缓鑿滃崟 let param = { func: 'sPC_TrdMenu_Add', @@ -955,6 +973,7 @@ PageParam: JSON.stringify(_pageParam), LongParam: _LongParam } + this.setState({ menuloading: true }) @@ -962,7 +981,6 @@ Api.getSystemConfig(param).then(response => { if (response.status) { this.setState({ - menuloading: false, operaType: 'edit', originMenu: { ...originMenu, @@ -973,11 +991,7 @@ ParentID: res.parentId } }) - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 10 - }) + this.submitAction(btnParam) } else { this.setState({ menuloading: false @@ -1006,26 +1020,17 @@ Api.getSystemConfig(param).then(response => { if (response.status) { - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 10 + this.setState({ + originMenu: { + ...originMenu, + LongParam: _config, + PageParam: _pageParam, + MenuName: res.menuName, + MenuNo: res.menuNo, + ParentID: res.parentId + } }) - if (this.state.closeVisible) { - this.props.handleConfig('') - } else { - this.setState({ - menuloading: false, - originMenu: { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, - ParentID: res.parentId - } - }) - } + this.submitAction(btnParam) } else { this.setState({ menuloading: false @@ -1050,10 +1055,32 @@ /** * @description 淇濆瓨鎴栦慨鏀硅彍鍗曟寜閽� */ - submitAction = () => { - if (!is(fromJS(this.state.originActions), fromJS())) { - - } + submitAction = (param) => { + Api.getSystemConfig(param).then(response => { + if (response.status) { + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 10 + }) + if (this.state.closeVisible) { + this.props.handleConfig('') + } else { + this.setState({ + menuloading: false + }) + } + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 10 + }) + } + }) } cancelConfig = () => { @@ -1388,6 +1415,9 @@ }) } + /** + * @description 璁剧疆鍙厤缃寜閽� + */ setSubConfig = (btn) => { const { menu } = this.props const { config, originMenu } = this.state @@ -1422,16 +1452,24 @@ loading: true }) Api.getSystemConfig({ - func: 'sPC_Get_FrozenMenu', - ParentID: btn.uuid, - TYPE: 30 + func: 'sPC_Get_LongParam', + MenuID: btn.uuid }).then(res => { if (res.status) { - let btnconfig = '' this.setState({ loading: false }) - this.props.handleSubConfig(btn, originMenu, btnconfig) + let _LongParam = '' + if (res.LongParam) { + _LongParam = window.decodeURIComponent(window.atob(res.LongParam)) + try { + _LongParam = JSON.parse(_LongParam) + } catch (e) { + _LongParam = '' + } + } + + this.props.handleSubConfig(btn, originMenu, _LongParam) } else { this.setState({ loading: false diff --git a/src/templates/modalconfig/actionform/index.jsx b/src/templates/modalconfig/actionform/index.jsx deleted file mode 100644 index 45308f8..0000000 --- a/src/templates/modalconfig/actionform/index.jsx +++ /dev/null @@ -1,260 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Icon, Radio } from 'antd' -import './index.scss' - -const btnIcons = [{ - MenuID: '', - text: 'unset' -}, { - MenuID: 'plus', - text: 'plus' -}, { - MenuID: 'plus-circle', - text: 'plus-circle' -}, { - MenuID: 'edit', - text: 'edit' -}, { - MenuID: 'form', - text: 'form' -}, { - MenuID: 'close', - text: 'close' -}, { - MenuID: 'close-circle', - text: 'close-circle' -}, { - MenuID: 'delete', - text: 'delete' -}] - -const btnClasses = [{ - MenuID: 'default', - text: '榛樿锛堥粦杈圭櫧搴曪級' -}, { - MenuID: 'primary', - text: '钃濊壊' -}, { - MenuID: 'yellow', - text: '榛勮壊' -}, { - MenuID: 'danger', - text: '绾㈣壊' -}, { - MenuID: 'green', - text: '缁胯壊' -}, { - MenuID: 'dgreen', - text: '娣辩豢鑹�' -}, { - MenuID: 'purple', - text: '绱壊' -}, { - MenuID: 'gray', - text: '鐏拌壊' -}] - -class MainSearch extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - formlist: PropTypes.any, - card: PropTypes.any - } - - state = { - formlist: null, - openType: null, - interType: null - } - - openTypeChange = (key, value) => { - if (key === 'OpenType') { - let _options = null - if (value === 'newpage') { - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class'] - } else { - if (this.state.interType === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class'] - } - } - this.setState({ - openType: value, - formlist: this.state.formlist.map(item => { - item.hidden = !_options.includes(item.key) - return item - }) - }) - } - } - - onChange = (e, key) => { - let value = e.target.value - if (key === 'intertype') { - let _options = null - if (value === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class'] - } - this.setState({ - interType: value, - formlist: this.state.formlist.map(item => { - item.hidden = !_options.includes(item.key) - return item - }) - }) - } - } - - getFields() { - const { getFieldDecorator } = this.props.form - const fields = [] - this.state.formlist.forEach((item, index) => { - if (item.hidden) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children[2].toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.openTypeChange(item.key, value)}} - getPopupContainer={() => document.getElementById('winter')} - > - {item.options.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> - {item.key === 'icon' && option.MenuID && <Icon type={option.MenuID} />} {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onChange(e, item.key)}}> - { - item.options.map(option => { - return ( - <Radio key={option.MenuID} value={option.MenuID}>{option.text}</Radio> - ) - }) - } - </Radio.Group> - )} - </Form.Item> - </Col> - ) - } - }) - return fields - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.id = this.props.card.id - values.uuid = this.props.card.uuid - resolve({ - type: 'action', - values - }) - } else { - reject(err) - } - }) - }) - } - - UNSAFE_componentWillMount () { - let _opentype = this.props.formlist.filter(form => form.key === 'OpenType')[0].initVal - let _intertype = this.props.formlist.filter(form => form.key === 'intertype')[0].initVal - // let _options = ['label', 'intertype', 'interface', 'func', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class'] - let _options = null - if (_opentype === 'newpage') { - _options = ['label', 'Ot', 'OpenType', 'pageTemplate', 'icon', 'class'] - } else { - if (_intertype === 'outer') { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'interface', 'outerFunc', 'callbackFunc', 'Ot', 'icon', 'class'] - } else { - _options = ['label', 'OpenType', 'intertype', 'innerFunc', 'Ot', 'icon', 'class'] - } - } - this.setState({ - openType: _opentype, - interType: _intertype, - formlist: this.props.formlist.map(item => { - if (item.key === 'class') { - item.options = btnClasses - } else if (item.key === 'icon') { - item.options = btnIcons - } - item.hidden = !_options.includes(item.key) - return item - }) - }) - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 6 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 18 } - } - } - return ( - <Form {...formItemLayout} className="ant-advanced-search-form commontable-action-form" id="winter"> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/templates/modalconfig/actionform/index.scss b/src/templates/modalconfig/actionform/index.scss deleted file mode 100644 index 28fc1a4..0000000 --- a/src/templates/modalconfig/actionform/index.scss +++ /dev/null @@ -1,3 +0,0 @@ -.ant-advanced-search-form.commontable-action-form { - min-height: 190px; -} \ No newline at end of file diff --git a/src/templates/modalconfig/columnform/index.jsx b/src/templates/modalconfig/columnform/index.jsx deleted file mode 100644 index efe3cf3..0000000 --- a/src/templates/modalconfig/columnform/index.jsx +++ /dev/null @@ -1,149 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, InputNumber, Radio } from 'antd' -import './index.scss' - -class MainSearch extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - formlist: PropTypes.any, - card: PropTypes.any - } - - state = { - - } - - getFields() { - const { getFieldDecorator } = this.props.form - const fields = [] - this.props.formlist.forEach((item, index) => { - if (item.type === 'text') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { // 鏂囨湰鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<InputNumber min={1} max={1000} precision={item.decimal} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺鎼滅储 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || '', - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - getPopupContainer={() => document.getElementById('columnwinter')} - > - {item.options.map(option => - <Select.Option id={option.MenuID} title={option.text} key={option.MenuID} value={option.MenuID}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group> - { - item.options.map(option => { - return ( - <Radio key={option.MenuID} value={option.MenuID}>{option.text}</Radio> - ) - }) - } - </Radio.Group> - )} - </Form.Item> - </Col> - ) - } - }) - return fields - } - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - return new Promise((resolve, reject) => { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.id = this.props.card.id - values.uuid = this.props.card.uuid - resolve({ - type: 'columns', - values - }) - } else { - reject(err) - } - }) - }) - } - - render() { - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 6 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 18 } - } - } - return ( - <Form {...formItemLayout} className="ant-advanced-search-form commontable-column-form" id="columnwinter"> - <Row gutter={24}>{this.getFields()}</Row> - </Form> - ) - } -} - -export default Form.create()(MainSearch) \ No newline at end of file diff --git a/src/templates/modalconfig/columnform/index.scss b/src/templates/modalconfig/columnform/index.scss deleted file mode 100644 index 4f7e976..0000000 --- a/src/templates/modalconfig/columnform/index.scss +++ /dev/null @@ -1,9 +0,0 @@ -.ant-advanced-search-form.commontable-column-form { - min-height: 190px; - .ant-form-item { - margin-bottom: 15px; - .ant-input-number { - width: 100%; - } - } -} \ No newline at end of file diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx index 3955e21..0052895 100644 --- a/src/templates/modalconfig/dragelement/card.jsx +++ b/src/templates/modalconfig/dragelement/card.jsx @@ -1,20 +1,22 @@ import React from 'react' import { useDrag, useDrop } from 'react-dnd' -import { Icon, Button, Select, DatePicker, Input } from 'antd' +import { Icon, Select, DatePicker, Input } from 'antd' import moment from 'moment' import ItemTypes from './itemtypes' import './index.scss' -const Card = ({ id, type, card, moveCard, findCard, editCard, copyCard, hasDrop }) => { +const { MonthPicker } = DatePicker + +const Card = ({ id, card, moveCard, findCard, editCard, closeCard, hasDrop }) => { const originalIndex = findCard(id).index const [{ isDragging }, drag] = useDrag({ - item: { type: ItemTypes[type], id, originalIndex }, + item: { type: ItemTypes.form, id, originalIndex }, collect: monitor => ({ isDragging: monitor.isDragging(), }), }) const [, drop] = useDrop({ - accept: ItemTypes[type], + accept: ItemTypes.form, canDrop: () => true, drop: (item) => { if (!item.hasOwnProperty('originalIndex')) { @@ -35,19 +37,22 @@ editCard(id) } - const copy = () => { - copyCard(id) + const close = () => { + closeCard(id) } return ( - <div className="page-card" style={type === 'columns' ? { flex: card.Width, opacity: opacity} : { opacity: opacity}}> + <div className="page-card" style={{ opacity: opacity}}> <div ref={node => drag(drop(node))}> - {type === 'search' && <div className="ant-row ant-form-item"> + {<div className="ant-row ant-form-item"> <div className="ant-col ant-form-item-label"> <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 === 'number' && <Input style={{marginTop: '4px'}} defaultValue={card.initval} /> } {(card.type === 'select' || card.type === 'link') && @@ -56,33 +61,18 @@ {card.type === 'date' && <DatePicker defaultValue={card.initval ? moment(card.initval, 'YYYY-MM-DD') : 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} /> } <div className="input-mask"></div> </div> </div>} - {type === 'action' && - <Button - className={'mk-btn mk-' + card.class} - icon={card.icon} - key={card.uuid} - >{card.label}</Button> - } - {type === 'columns' && - <span className="ant-table-header-column"> - <div className="ant-table-column-sorters" title={card.label} style={{textAlign: card.Align}}> - <span className="ant-table-column-title">{card.label}</span> - {card.IsSort === 'true' && <span className="ant-table-column-sorter"> - <Icon type="caret-up" /> - <Icon type="caret-down" /> - </span>} - </div> - </span> - } </div> <Icon className="edit" type="edit" onClick={edit} /> - {type === 'action' && <Icon className="edit copy" type="copy" onClick={copy} />} + <Icon className="edit close" type="close" onClick={close} /> </div> ) } diff --git a/src/templates/modalconfig/dragelement/index.jsx b/src/templates/modalconfig/dragelement/index.jsx index b95d023..17c3e4d 100644 --- a/src/templates/modalconfig/dragelement/index.jsx +++ b/src/templates/modalconfig/dragelement/index.jsx @@ -7,14 +7,14 @@ import ItemTypes from './itemtypes' import './index.scss' -const Container = ({list, type, placeholder, handleList, handleMenu }) => { +const Container = ({list, setting, placeholder, handleList, handleForm, closeForm }) => { let target = null const [cards, setCards] = useState(list) const moveCard = (id, atIndex) => { const { card, index } = findCard(id) const _cards = update(cards, { $splice: [[index, 1], [atIndex, 0, card]] }) setCards(_cards) - handleList({[type]: _cards}) + handleList(_cards) } const findCard = id => { @@ -27,7 +27,12 @@ const editCard = id => { const { card } = findCard(id) - handleMenu(card) + handleForm(card) + } + + const closeCard = id => { + const { card } = findCard(id) + closeForm(card) } const hasDrop = (item) => { @@ -35,30 +40,27 @@ } const [, drop] = useDrop({ - accept: ItemTypes[type], + accept: ItemTypes.form, drop(item) { if (item.hasOwnProperty('originalIndex')) { return } let newcard = {} - if (item.type === 'search') { - newcard.uuid = Utils.getuuid() - newcard.label = 'fieldName' - newcard.field = '' - newcard.initval = '' - newcard.type = item.subType - newcard.resourceType = '0' - newcard.options = [] - newcard.dataSource = '' - newcard.setAll = 'false' - newcard.linkField = '' - newcard.valueField = '' - newcard.valueText = '' - newcard.orderBy = '' - newcard.orderType = 'asc' - newcard.display = 'dropdown' - } + newcard.uuid = Utils.getuuid() + newcard.label = 'label' + newcard.field = '' + newcard.initval = '' + newcard.type = item.subType + newcard.resourceType = '0' + newcard.options = [] + newcard.dataSource = '' + newcard.setAll = 'false' + newcard.linkField = '' + newcard.valueField = '' + newcard.valueText = '' + newcard.orderBy = '' + newcard.orderType = 'asc' let indexes = cards.map(car => {return car.id}) let newid = 0 @@ -83,22 +85,24 @@ const _cards = update(cards, { $splice: [[targetIndex, 0, newcard]] }) setCards(_cards) - handleList({[type]: _cards}) + handleList(_cards) target = null } }) + + let _cols = 24 / (setting.cols || 2) return ( <div ref={drop} className="ant-row"> - {type === 'search' && cards.map(card => ( - <Col key={card.uuid} span={6}> + {cards.map(card => ( + <Col key={card.uuid} span={_cols}> <Card key={card.uuid} id={`${card.id}`} - type={type} card={card} moveCard={moveCard} editCard={editCard} + closeCard={closeCard} findCard={findCard} hasDrop={hasDrop} /> diff --git a/src/templates/modalconfig/dragelement/itemtypes.js b/src/templates/modalconfig/dragelement/itemtypes.js index d48a2eb..0e7cd9a 100644 --- a/src/templates/modalconfig/dragelement/itemtypes.js +++ b/src/templates/modalconfig/dragelement/itemtypes.js @@ -1,5 +1,6 @@ export default { CARD: 'card', + form: 'form', search: 'search', action: 'action', columns: 'columns' diff --git a/src/templates/modalconfig/editcard/index.jsx b/src/templates/modalconfig/editcard/index.jsx index f691210..398cfee 100644 --- a/src/templates/modalconfig/editcard/index.jsx +++ b/src/templates/modalconfig/editcard/index.jsx @@ -1,6 +1,8 @@ import React, {Component} from 'react' -import { Row, Col, Icon, Radio } from 'antd' +import { Row, Col, Icon, Radio, Input } from 'antd' import './index.scss' + +const { Search } = Input class EditCardCell extends Component { constructor(props) { @@ -16,6 +18,8 @@ const { card } = this.state this.setState({ card: {...card, selected: !card.selected} + }, () => { + this.props.changeCard(this.state.card) }) } @@ -27,34 +31,21 @@ } 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' - } - } + const { card } = this.state return ( <div className={'ant-card ant-card-bordered ' + (card.selected ? 'selected' : '')} > <div className="base" onClick={this.changeSelect}> <Icon type="check" /> - <p title={card.field}>瀛楁鍚�: {card.field}</p> - <p title={card.label}>鎻愮ず鏂囧瓧: {card.label}</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.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 value="datetime">datetime</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>} + </Radio.Group> </div> ) } @@ -66,16 +57,29 @@ this.state = { dataSource: props.data, - type: props.type + selectCards: props.data.filter(item => item.selected), + type: props.type, + searchKey: '' } } - getSelectedCard = () => { - let box = [] - this.state.dataSource.forEach((item, index) => { - box.push(this.refs['cellCard' + index].state.card) + changeCard = (item) => { + let cards = JSON.parse(JSON.stringify(this.state.selectCards)) + let isAdd = true + cards = cards.map(card => { + if (card.field === item.field) { + isAdd = false + return item + } else { + return card + } }) - return box + if (isAdd) { + cards.push(item) + } + this.setState({ + selectCards: cards + }) } render() { @@ -83,12 +87,23 @@ return ( <div className="common-modal-edit-card"> + <Row className="search-row"> + <Col span={8}> + <Search placeholder="璇疯緭鍏ュ瓧娈靛悕" onSearch={value => {this.setState({searchKey: value})}} enterButton /> + </Col> + </Row> <Row> - {dataSource.map((item, index) => ( - <Col key={index} span={8}> - <EditCardCell ref={'cellCard' + index} type={type} card={item} /> - </Col> - ))} + {dataSource.map((item, index) => { + if (item.field.toLowerCase().indexOf(this.state.searchKey.toLowerCase()) >= 0) { + return ( + <Col key={index} span={8}> + <EditCardCell ref={'cellCard' + index} type={type} card={item} changeCard={this.changeCard} /> + </Col> + ) + } else { + return '' + } + })} </Row> </div> ) diff --git a/src/templates/modalconfig/editcard/index.scss b/src/templates/modalconfig/editcard/index.scss index d4c39dd..52f6905 100644 --- a/src/templates/modalconfig/editcard/index.scss +++ b/src/templates/modalconfig/editcard/index.scss @@ -12,7 +12,7 @@ white-space: nowrap; } label { - margin-right: 7px; + margin-right: 15px; span.ant-radio + * { padding-right: 0px; padding-left: 4px; @@ -35,6 +35,14 @@ opacity: 1; color: #1890ff; } + p { + color: #1890ff; + } + } + } + .search-row { + .ant-col { + padding-top: 0px; } } } diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 1a28518..b8ce5bd 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -3,15 +3,13 @@ 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 } from 'antd' +import { Button, Card, Modal, Collapse, notification, Select, List, Icon, Empty } 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 ModalForm from './modalform' import SettingForm from './settingform' -// import EditCard from './editcard' +import EditCard from './editcard' import MenuForm from './menuform' import zhCN from '@/locales/zh-CN/comtable.js' import enUS from '@/locales/en-US/comtable.js' @@ -42,11 +40,8 @@ fields: null, // 鎼滅储鏉′欢鍙婃樉绀哄垪锛屽彲閫夊瓧娈� modalformlist: null, // 鍩烘湰淇℃伅琛ㄥ崟瀛楁 formlist: null, // 鎼滅储鏉′欢銆佹寜閽�佹樉绀哄垪琛ㄥ崟瀛楁 - formtemp: '', // 琛ㄥ崟绫诲瀷锛屾樉绀哄垪銆佹寜閽�佹悳绱㈡潯浠� card: null, // 缂栬緫鍏冪礌 - searchloading: false, // 鎼滅储鏉′欢鍔犺浇涓� - actionloading: false, // 鎸夐挳鍔犺浇涓� - columnsloading: false, // 鏄剧ず鍒楀姞杞戒腑 + loading: false, // 鎼滅储鏉′欢鍔犺浇涓� menuloading: false, // 鑿滃崟淇濆瓨涓� settingVisible: false, // 鍏ㄥ眬閰嶇疆妯℃�佹 closeVisible: false, // 鍏抽棴妯℃�佹 @@ -58,10 +53,22 @@ UNSAFE_componentWillMount () { const {menu, editAction} = this.props - let _config = JSON.parse(JSON.stringify((Source.baseConfig))) + let _config = '' + let _operaType = 'add' + if (editAction.pageParam) { + _config = editAction.pageParam + _operaType = 'edit' + } else { + _config = JSON.parse(JSON.stringify((Source.baseConfig))) + } + + if (!_config.setting.title) { + _config.setting.title = editAction.label + } this.setState({ config: _config, + operaType: _operaType, selectedTables: _config.tables || [], modalformlist: [ { @@ -77,22 +84,6 @@ key: 'btnName', label: '鎸夐挳鍚嶇О', initVal: editAction.label, - required: true, - readonly: true - }, - { - type: 'text', - key: 'menuNo', - label: this.state.dict['header.menu.menuNo'], - initVal: menu.MenuNo, - required: true, - readonly: true - }, - { - type: 'text', - key: 'opentype', - label: this.state.dict['header.menu.openType'], - initVal: '寮圭獥锛堣〃鍗曪級', required: true, readonly: true } @@ -185,36 +176,28 @@ }) } - handleList = (listObj) => { - let config = this.state.config - if (this.state.operaType === 'add') { - let key = Object.keys(listObj)[0] - let newlength = listObj[key].length - if (newlength > config[key].length) { - listObj[key] = listObj[key].filter(item => !item.origin) - } - if (newlength > listObj[key].length) { + handleList = (list) => { + let _config = JSON.parse(JSON.stringify(this.state.config)) + + if (list.length > _config.fields.length) { + _config.fields = list.filter(item => !item.origin) + this.setState({ + loading: true, + config: _config + }, () => { this.setState({ - [key + 'loading']: true, - config: {...config, ...listObj} + loading: false }) - setTimeout(() => { - this.setState({ - [key + 'loading']: false - }) - }, 100) - } else { - this.setState({config: {...config, ...listObj}}) - } + }) } else { - this.setState({config: {...config, ...listObj}}) + _config.fields = list + this.setState({config: _config}) } } - handleSearch = (card) => { + handleForm = (card) => { this.setState({ visible: true, - formtemp: 'search', card: card, formlist: [ { @@ -234,34 +217,40 @@ readonly: false }, { - type: 'text', - key: 'initval', - label: this.state.dict['header.form.initval'], - initVal: card.initval, - required: false - }, - { type: 'select', key: 'type', label: this.state.dict['header.form.type'], 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: 'daterange', + text: this.state.dict['header.form.daterange'] }] + }, + { + type: 'text', + key: 'initval', + label: this.state.dict['header.form.initval'], + initVal: card.initval, + required: false }, { type: 'radio', @@ -270,10 +259,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'] }] }, @@ -283,10 +272,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'] }] }, @@ -344,25 +333,11 @@ 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'] - }] - }, - { - type: 'select', - key: 'display', - label: this.state.dict['header.form.display'], - initVal: card.display || 'dropdown', - required: true, - options: [{ - MenuID: 'dropdown', - text: this.state.dict['header.form.dropdown'] - }, { - MenuID: 'button', - text: this.state.dict['header.form.button'] }] } ] @@ -371,70 +346,56 @@ handleSubmit = () => { this.formRef.handleConfirm().then(res => { - let _config = this.state.config - - if (this.state.operaType === 'add') { - _config[res.type] = _config[res.type].map(item => { - if (item.uuid === res.values.uuid) { - return res.values - } else { - return item - } - }) - _config[res.type] = _config[res.type].filter(item => !item.origin) - } else { - _config[res.type] = _config[res.type].map(item => { - if (item.uuid === res.values.uuid) { - return res.values - } else { - return item - } - }) - } + let _config = JSON.parse(JSON.stringify(this.state.config)) + console.log(res) + _config.fields = _config.fields.map(item => { + if (item.uuid === res.uuid) { + return res + } else { + return item + } + }) + _config.fields = _config.fields.filter(item => !item.origin) this.setState({ config: _config, - [res.type + 'loading']: true, + loading: true, visible: false + }, () => { + this.setState({ + loading: false + }) }) - this.resetFrom() }) } - deleteElement = () => { - let _config = this.state.config - _config[this.state.formtemp] = _config[this.state.formtemp].filter(item => { - if (item.uuid === this.state.card.uuid) { - return false - } else { - return true - } - }) - this.setState({ - config: _config, - [this.state.formtemp + 'loading']: true, - visible: false - }) - this.resetFrom() - } + closeForm = (card) => { + let _this = this - handleCancel = () => { - this.setState({ - visible: false + confirm({ + content: `纭畾鍒犻櫎<<${card.label}>>鍚楋紵`, + okText: this.state.dict['header.confirm'], + cancelText: this.state.dict['header.cancel'], + onOk() { + let _config = JSON.parse(JSON.stringify(_this.state.config)) + _config.fields = _config.fields.filter(item => { + if (item.uuid === card.uuid) { + return false + } else { + return true + } + }) + _this.setState({ + config: _config, + loading: true + }, () => { + _this.setState({ + loading: false + }) + }) + }, + onCancel() {} }) - this.resetFrom() - } - - resetFrom = () => { - setTimeout(() => { - this.setState({ - // formtemp: '', - searchloading: false, - actionloading: false, - columnsloading: false - // formlist: null - }) - }, 10) } changeTemplate = () => { @@ -445,26 +406,11 @@ const { menu } = this.props const { config, originMenu } = this.state this.menuformRef.handleConfirm().then(res => { - if (config.search[0] && config.search[0].origin) { + + if (!config.fields[0] && config.fields[0].origin) { notification.warning({ top: 92, - message: '璇疯缃悳绱㈡潯浠�', - duration: 10 - }) - return - } - if (config.action[0] && config.action[0].origin) { - notification.warning({ - top: 92, - message: '璇疯缃寜閽�', - duration: 10 - }) - return - } - if (config.columns[0] && config.columns[0].origin) { - notification.warning({ - top: 92, - message: '璇疯缃樉绀哄垪', + message: '璇锋坊鍔犺〃鍗�', duration: 10 }) return @@ -485,51 +431,53 @@ return } - if (this.state.operaType === 'add') { - let param = { - func: 'sPC_TrdMenu_Add', - ParentID: res.parentId, - MenuID: menu.MenuID, - MenuNo: res.menuNo, - Template: menu.PageParam.Template || '', - MenuName: res.menuName, - PageParam: JSON.stringify(_pageParam), - LongParam: _LongParam - } - this.setState({ - menuloading: true - }) + let param = { + func: 'sPC_ButtonParam_AddUpt', + ParentID: res.parentId, + MenuID: menu.MenuID, + MenuNo: res.menuNo, + Template: menu.PageParam.Template || '', + MenuName: res.menuName, + PageParam: JSON.stringify(_pageParam), + LongParam: _LongParam + } + this.setState({ + menuloading: true + }) - Api.getSystemConfig(param).then(response => { - if (response.status) { - this.setState({ - menuloading: false, - operaType: 'edit', - originMenu: { - ...originMenu, - LongParam: _config, - PageParam: _pageParam, - MenuName: res.menuName, - MenuNo: res.menuNo, - ParentID: res.parentId - } - }) - notification.success({ - top: 92, - message: '淇濆瓨鎴愬姛', - duration: 10 - }) - } else { - this.setState({ - menuloading: false - }) - notification.warning({ - top: 92, - message: response.message, - duration: 10 - }) - } - }) + Api.getSystemConfig(param).then(response => { + if (response.status) { + this.setState({ + menuloading: false, + operaType: 'edit', + originMenu: { + ...originMenu, + LongParam: _config, + PageParam: _pageParam, + MenuName: res.menuName, + MenuNo: res.menuNo, + ParentID: res.parentId + } + }) + notification.success({ + top: 92, + message: '淇濆瓨鎴愬姛', + duration: 10 + }) + } else { + this.setState({ + menuloading: false + }) + notification.warning({ + top: 92, + message: response.message, + duration: 10 + }) + } + }) + + if (this.state.operaType === 'add') { + } else { let param = { func: 'sPC_TrdMenu_Upt', @@ -631,7 +579,7 @@ } } - queryField = (type) => { + queryField = () => { const {selectedTables, tableColumns, config} = this.state if (selectedTables.length === 0) { notification.warning({ @@ -649,22 +597,13 @@ }) }) - if (type === 'search') { - config.search.forEach(item => { - if (columns.has(item.field)) { - columns.set(item.field, {...item, selected: true, type: item.type}) - } - }) - } else if (type === 'columns') { - config.columns.forEach(item => { - if (columns.has(item.field)) { - columns.set(item.field, {...item, selected: true, type: item.type}) - } - }) - } + config.fields.forEach(item => { + if (columns.has(item.field)) { + columns.set(item.field, {...item, selected: true, type: item.type}) + } + }) this.setState({ - addType: type, tableVisible: true, fields: [...columns.values()] }) @@ -673,118 +612,75 @@ addFieldSubmit = () => { if (!this.state.fields || this.state.fields.length === 0) { this.setState({ - tableVisible: false, - addType: '' + tableVisible: false }) } - const {addType, config} = this.state + let _config = JSON.parse(JSON.stringify(this.state.config)) - let cards = this.refs.searchcard.getSelectedCard() + let cards = this.refs.searchcard.state.selectCards let columns = new Map() cards.forEach(card => { columns.set(card.field, card) }) let items = [] - if (addType === 'search') { - config.search.forEach(item => { - if (columns.has(item.field)) { - let cell = columns.get(item.field) + _config.fields.forEach(item => { + if (columns.has(item.field)) { + let cell = columns.get(item.field) - if (cell.selected) { - items.push(item) - } - columns.delete(item.field) - } else if (!item.origin) { + if (cell.selected && cell.type === item.type) { // 鏁版嵁鏈慨鏀� + items.push(item) + } else if (cell.selected) { // 鏁版嵁绫诲瀷淇敼 + item.type = cell.type + item.initval = '' items.push(item) } - }) - - let _columns = [...columns.values()] - let indexes = items.map(card => {return card.id}) - let id = Math.max(...indexes, 0) - - _columns.forEach(item => { - if (item.selected) { - let newcard = { - id: id, - 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', - display: 'dropdown' - } - - items.push(newcard) - id++ - } - }) - } else { - config.columns.forEach(item => { - if (columns.has(item.field)) { - let cell = columns.get(item.field) - - if (cell.selected) { - items.push(item) - } - columns.delete(item.field) - } else if (!item.origin) { - items.push(item) - } - }) - - let _columns = [...columns.values()] - let indexes = items.map(card => {return card.id}) - let id = Math.max(...indexes, 0) - - _columns.forEach(item => { - if (item.selected) { - let newcard = { - id: id, - uuid: Utils.getuuid(), - Align: 'left', - label: item.label, - field: item.field, - Hide: 'false', - IsSort: 'true', - type: 'text', - Width: 120 - } - - items.push(newcard) - id++ - } - }) - } - - this.setState({ - tableVisible: false, - [addType + 'loading']: true, - addType: '', - config: {...config, [addType]: items} + columns.delete(item.field) + } else if (!item.origin) { + items.push(item) + } }) - setTimeout(() => { - this.setState({ - [addType + 'loading']: false - }) - }, 100) - } - cancelFieldSubmit = () => { + let _columns = [...columns.values()] + let indexes = items.map(card => {return card.id}) + let id = Math.max(...indexes, 0) + 1 + + _columns.forEach(item => { + if (item.selected) { + let newcard = { + id: id, + 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', + } + + items.push(newcard) + id++ + } + }) + + _config.fields = items + this.setState({ tableVisible: false, - addType: '' + loading: true, + config: _config + }, () => { + this.setState({ + loading: false + }) }) } @@ -811,16 +707,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' @@ -877,19 +763,20 @@ }) } - cancelSetting = () => { - this.setState({ - settingVisible: false - }) - } - render () { + const { config } = this.state + return ( <div className="modal-form-board"> <DndProvider backend={HTML5Backend}> <div className="tools"> <Collapse accordion defaultActiveKey="0" bordered={false}> <Panel header="鍩烘湰淇℃伅" key="0" id="modal-basedata"> + <MenuForm + dict={this.state.dict} + formlist={this.state.modalformlist} + wrappedComponentRef={(inst) => this.menuformRef = inst} + /> <MenuForm dict={this.state.dict} formlist={this.state.modalformlist} @@ -932,7 +819,7 @@ return (<SourceElement key={index} content={item}/>) })} </div> - <Button type="primary" block onClick={() => this.queryField('search')}>娣诲姞琛ㄥ崟</Button> + <Button type="primary" block onClick={() => this.queryField()}>娣诲姞琛ㄥ崟</Button> </Panel> </Collapse> </div> @@ -944,31 +831,51 @@ </div> } style={{ width: '100%' }}> <Icon type="setting" onClick={this.changeSetting} /> - <div className="search-list"> - {<DragElement - list={this.state.config.search} - type="search" - placeholder={this.state.dict['header.form.search.placeholder']} - handleList={this.handleList} - handleMenu={this.handleSearch} - />} + <div className="ant-modal-content" style={{width: config.setting.width + '%'}}> + <button type="button" className="ant-modal-close"> + <span className="ant-modal-close-x"><Icon type="close"/></span> + </button> + <div className="ant-modal-header"> + <div className="ant-modal-title">{config.setting.title}</div> + </div> + <div className="ant-modal-body"> + <div className="modal-form"> + {!this.state.loading ? + <DragElement + list={config.fields} + setting={config.setting} + placeholder={this.state.dict['header.form.modal.placeholder']} + handleList={this.handleList} + handleForm={this.handleForm} + closeForm={this.closeForm} + /> : null + } + </div> + </div> + <div className="ant-modal-footer"> + <div> + <button type="button" className="ant-btn"><span>鍙� 娑�</span></button> + <button type="button" className="ant-btn ant-btn-primary"><span>纭� 瀹�</span></button> + </div> + <div className="action-mask"></div> + </div> </div> </Card> </div> </DndProvider> - {/* <Modal + <Modal title={this.state.dict['header.edit']} visible={this.state.visible} width={700} - onCancel={this.handleCancel} - footer={[ - <Button key="delete" type="danger" onClick={this.deleteElement}>{this.state.dict['header.delete']}</Button>, - <Button key="cancel" onClick={this.handleCancel}>{this.state.dict['header.cancel']}</Button>, - <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button> - ]} + onCancel={() => { + this.setState({ + visible: false + }) + }} + onOk={this.handleSubmit} destroyOnClose > - {this.state.formtemp === 'search' && <SearchForm + {<ModalForm dict={this.state.dict} formlist={this.state.formlist} card={this.state.card} @@ -981,29 +888,34 @@ width={'65vw'} style={{minWidth: '900px', maxWidth: '1200px'}} onOk={this.addFieldSubmit} - onCancel={this.cancelFieldSubmit} + onCancel={() => { + this.setState({ + tableVisible: false + }) + }} 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.fields && this.state.fields.length > 0 ? + <EditCard data={this.state.fields} ref="searchcard" type="search" /> : null } {(!this.state.fields || this.state.fields.length === 0) && <Empty /> } - </Modal> */} + </Modal> <Modal title={this.state.dict['header.edit']} visible={this.state.settingVisible} width={700} onOk={this.settingSave} - onCancel={this.cancelSetting} + onCancel={() => { + this.setState({ + settingVisible: false + }) + }} destroyOnClose > <SettingForm - data={this.state.config.setting} + data={config.setting} dict={this.state.dict} wrappedComponentRef={(inst) => this.settingRef = inst} /> diff --git a/src/templates/modalconfig/index.scss b/src/templates/modalconfig/index.scss index f3edb88..f929a8c 100644 --- a/src/templates/modalconfig/index.scss +++ b/src/templates/modalconfig/index.scss @@ -131,9 +131,34 @@ .ant-card-body { position: relative; padding: 0; + .ant-modal-content { + max-width: 95%; + margin: 0 auto; + margin-top: 30px; + .ant-modal-header { + position: relative; + z-index: 10; + background: transparent; + } + .ant-modal-close { + opacity: 0.5; + } + .ant-modal-footer { + position: relative; + button { + opacity: 0.5; + } + } + .action-mask { + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; + } + } - .search-list { - padding: 1px 24px 20px; + .modal-form { min-height: 87px; > .ant-row { min-height: 65px; @@ -172,6 +197,7 @@ margin-top: 4px; } .ant-calendar-picker { + width: 100%; margin-top: 4px; } .input-mask { @@ -187,10 +213,15 @@ .edit { position: absolute; left: 0; - top: 5px; + top: 0px; + color: #1890ff; cursor: pointer; display: none; } + .edit.close { + left: 20px; + color: #ff4d4f; + } } .page-card:hover { .edit { diff --git a/src/templates/modalconfig/searchform/index.jsx b/src/templates/modalconfig/modalform/index.jsx similarity index 69% rename from src/templates/modalconfig/searchform/index.jsx rename to src/templates/modalconfig/modalform/index.jsx index f4d2ac1..2583990 100644 --- a/src/templates/modalconfig/searchform/index.jsx +++ b/src/templates/modalconfig/modalform/index.jsx @@ -1,7 +1,6 @@ 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 EditTable from '../editable' import './index.scss' @@ -17,44 +16,69 @@ 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: '鍓嶄竷鏈�'}], + daterange: [{value: '', text: '绌�'}, {value: '0', text: '浠婂ぉ'}, {value: 1, text: '鏄ㄥぉ'}, {value: 3, text: '鍓嶄笁澶�'}, {value: 7, text: '鍓嶄竷澶�'}, {value: 30, text: '鍓�30澶�'}], + } } openTypeChange = (key, value) => { if (key === 'type') { let _options = ['label', 'field', 'initval', 'type'] - if (value === 'select' && this.state.resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'display']] - } else if (value === 'select' && this.state.resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (value === 'link' && this.state.resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'linkField', 'display']] - } else if (value === 'link' && this.state.resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + if (value === 'select' || value === 'link') { // 鍒囨崲绫诲瀷涓洪�夋嫨鎴栧叧鑱旀椂锛屾潵婧愰粯璁や负鑷畾涔� + _options = [..._options, 'resourceType', 'setAll', 'options'] + } + + if (value === 'link') { + _options = [..._options, 'linkField'] } this.setState({ openType: value, + resourceType: '0', 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 + }) }) }) } } onChange = (e, key) => { + const { openType } = this.state let value = e.target.value if (key === 'resourceType') { let _options = ['label', 'field', 'initval', 'type', 'resourceType', 'setAll'] - if (this.state.openType === 'select' && value === '0') { - _options = [..._options, ...['options', 'display']] - } else if (this.state.openType === 'select' && value === '1') { - _options = [..._options, ...['dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (this.state.openType === 'link' && value === '0') { - _options = [..._options, ...['options', 'linkField', 'display']] - } else if (this.state.openType === 'link' && value === '1') { - _options = [..._options, ...['dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + if (value === '0') { + _options = [..._options, 'options'] + } else if (value === '1') { + _options = [..._options, 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] + } + + if (openType === 'link') { + _options = [..._options, 'linkField'] } this.setState({ @@ -74,12 +98,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 +109,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 +133,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 +159,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> ) }) } @@ -150,7 +168,6 @@ </Form.Item> </Col> ) - } else if (item.type === 'textarea') { fields.push( <Col span={20} offset={4} key={index}> @@ -175,6 +192,7 @@ ) } }) + return fields } @@ -204,10 +222,7 @@ } if (isvalid) { - resolve({ - type: 'search', - values - }) + resolve(values) } else { notification.warning({ top: 92, @@ -226,21 +241,25 @@ if (!formlist) return let type = formlist.filter(cell => cell.key === 'type')[0].initVal let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal - let _options = ['label', 'field', 'initval', 'type'] - if (type === 'select' && resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'display']] - } else if (type === 'select' && resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] - } else if (type === 'link' && resourceType === '0') { - _options = [..._options, ...['resourceType', 'setAll', 'options', 'linkField', 'display']] - } else if (type === 'link' && resourceType === '1') { - _options = [..._options, ...['resourceType', 'setAll', 'dataSource', 'linkField', 'valueField', 'valueText', 'orderBy', 'orderType', 'display']] + let _options = ['label', 'field', 'initval', 'type'] // 榛樿鏄剧ず椤� + if ((type === 'select' || type === 'link') && resourceType === '0') { // 閫夋嫨绫诲瀷銆佽嚜瀹氫箟璧勬簮 + _options = [..._options, 'resourceType', 'setAll', 'options'] + } else if ((type === 'select' || type === 'link') && resourceType === '1') { // 閫夋嫨绫诲瀷銆佹暟鎹簮 + _options = [..._options, 'resourceType', 'setAll', 'dataSource', 'valueField', 'valueText', 'orderBy', 'orderType'] + } + + if (type === 'link') { // 鍏宠仈绫诲瀷銆佸鍔犲叧鑱斿瓧娈� + _options = [..._options, 'linkField'] } this.setState({ 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 }) diff --git a/src/templates/modalconfig/searchform/index.scss b/src/templates/modalconfig/modalform/index.scss similarity index 100% rename from src/templates/modalconfig/searchform/index.scss rename to src/templates/modalconfig/modalform/index.scss diff --git a/src/templates/modalconfig/settingform/index.jsx b/src/templates/modalconfig/settingform/index.jsx index 80780e0..af9244d 100644 --- a/src/templates/modalconfig/settingform/index.jsx +++ b/src/templates/modalconfig/settingform/index.jsx @@ -1,15 +1,14 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio } from 'antd' +import { Form, Row, Col, Input, Radio, InputNumber } from 'antd' import './index.scss' -const { TextArea } = Input +// const { TextArea } = Input class SettingForm extends Component { static propTpyes = { dict: PropTypes.object, // 瀛楀吀椤� - formlist: PropTypes.any, - card: PropTypes.object + data: PropTypes.object } state = { @@ -30,9 +29,9 @@ } render() { - const { data, dict } = this.props + const { data } = this.props const { getFieldDecorator } = this.props.form - + console.log(data) const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -44,33 +43,36 @@ } } return ( - <Form {...formItemLayout} className="ant-advanced-search-form commontable-setting-form"> + <Form {...formItemLayout} className="ant-advanced-search-form modal-setting-form"> <Row gutter={24}> <Col span={12}> - <Form.Item label="鍥哄畾鎸夐挳"> - {getFieldDecorator('actionfixed', { - initialValue: data.actionfixed + <Form.Item label="鏍囬"> + {getFieldDecorator('title', { + initialValue: data.title + })(<Input placeholder="" autoComplete="off"/>)} + </Form.Item> + </Col> + <Col span={12}> + <Form.Item label="鍒楁暟"> + {getFieldDecorator('cols', { + initialValue: data.cols })( <Radio.Group> - <Radio value={true}>鏄�</Radio> - <Radio value={false}>鍚�</Radio> + <Radio value="1">1鍒�</Radio> + <Radio value="2">2鍒�</Radio> + <Radio value="3">3鍒�</Radio> </Radio.Group> )} </Form.Item> </Col> <Col span={12}> - <Form.Item label="鍥哄畾鍒�"> - {getFieldDecorator('columnfixed', { - initialValue: data.columnfixed - })( - <Radio.Group> - <Radio value={true}>鏄�</Radio> - <Radio value={false}>鍚�</Radio> - </Radio.Group> - )} + <Form.Item label="瀹藉害"> + {getFieldDecorator('width', { + initialValue: data.width + })(<InputNumber min={30} max={90} precision={0} />)} </Form.Item> </Col> - <Col span={24}> + {/* <Col span={24}> <Form.Item label="鏁版嵁婧�" className="textarea"> {getFieldDecorator('dataresource', { initialValue: data.dataresource, @@ -82,7 +84,7 @@ ] })(<TextArea rows={4} />)} </Form.Item> - </Col> + </Col> */} </Row> </Form> ) diff --git a/src/templates/modalconfig/settingform/index.scss b/src/templates/modalconfig/settingform/index.scss index bf9fa12..091801f 100644 --- a/src/templates/modalconfig/settingform/index.scss +++ b/src/templates/modalconfig/settingform/index.scss @@ -1,4 +1,4 @@ -.ant-advanced-search-form.commontable-setting-form { +.ant-advanced-search-form.modal-setting-form { .textarea { .ant-form-item-label { width: 16.3%; @@ -7,4 +7,7 @@ width: 83.33333333%; } } + .ant-input-number { + width: 100%; + } } \ No newline at end of file diff --git a/src/templates/modalconfig/source.jsx b/src/templates/modalconfig/source.jsx index 81fd454..b35b740 100644 --- a/src/templates/modalconfig/source.jsx +++ b/src/templates/modalconfig/source.jsx @@ -6,7 +6,7 @@ class CommonTableBaseData { baseConfig = { - type: 'system', + type: 'modal', setting: { title: '', width: 60, @@ -74,31 +74,37 @@ searchItems = [ { - type: 'search', + type: 'form', label: '鏂囨湰妗�', subType: 'text', url: '' }, { - type: 'search', + type: 'form', + label: '鏁板�兼', + subType: 'number', + url: '' + }, + { + type: 'form', label: '涓嬫媺妗�', subType: 'select', url: '' }, { - type: 'search', + type: 'form', label: '鏃堕棿妗嗭紙澶╋級', subType: 'date', url: '' }, { - type: 'search', + type: 'form', label: '鏃堕棿妗嗭紙鏈堬級', subType: 'datemonth', url: '' }, { - type: 'search', + type: 'form', label: '鏃堕棿妗嗭紙绉掞級', subType: 'datetime', url: '' diff --git a/src/views/login/index.scss b/src/views/login/index.scss index 003ca7b..dd2a238 100644 --- a/src/views/login/index.scss +++ b/src/views/login/index.scss @@ -62,6 +62,7 @@ button { width: 100%; height: calc(2vw + 10px); + min-height: 30px; line-height: 1; } .ant-dropdown-link { @@ -79,6 +80,7 @@ .ant-input { font-size: 16px; height: calc(2vw + 5px); + min-height: 30px; } .ant-form label { font-size: 16px; @@ -108,4 +110,15 @@ .ant-message { top: 50px; z-index: 1080; +} +@media screen and (max-width: 500px) { + .login-container { + .login-middle { + .login-form { + float: unset; + margin: 0 auto; + margin-top: 5%; + } + } + } } \ No newline at end of file -- Gitblit v1.8.0