From 5423c7caa9723e0b232ea6c5ef4aaf90bd7a3334 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 21 十月 2020 14:46:25 +0800 Subject: [PATCH] 2020-10-21 --- src/components/tabview/index.jsx | 4 src/templates/zshare/createinterface/mutilform/index.jsx | 32 + src/templates/zshare/modalform/index.jsx | 12 src/templates/zshare/modalform/fieldtable/index.jsx | 2 src/templates/zshare/modalform/fieldtable/index.scss | 7 src/tabviews/zshare/mutilform/index.scss | 55 ++ src/templates/formtabconfig/index.jsx | 7 src/templates/modalconfig/checkCard/index.scss | 2 src/tabviews/zshare/mutilform/customSwitch/index.scss | 0 src/templates/modalconfig/checkCard/index.jsx | 15 src/tabviews/tabmanage/mutilform/index.jsx | 2 src/templates/modalconfig/index.jsx | 4 src/tabviews/zshare/actionList/normalbutton/index.jsx | 4 src/templates/modalconfig/dragelement/card.jsx | 9 src/utils/utils.js | 24 src/tabviews/zshare/actionList/tabbutton/index.jsx | 19 src/templates/modalconfig/index.scss | 12 src/tabviews/tabmanage/mutilform/index.scss | 2 src/templates/zshare/modalform/datatable/index.jsx | 7 src/tabviews/zshare/mutilform/checkCard/index.jsx | 113 +++++ src/tabviews/zshare/mutilform/customSwitch/index.jsx | 44 ++ src/templates/modalconfig/dragelement/index.scss | 5 src/tabviews/zshare/actionList/printbutton/index.jsx | 4 src/tabviews/zshare/mutilform/checkCard/index.scss | 39 ++ /dev/null | 3 src/tabviews/zshare/mutilform/index.jsx | 368 +++++++++++++----- src/templates/zshare/modalform/index.scss | 3 src/templates/zshare/createinterface/index.jsx | 268 +++++++++----- src/templates/zshare/modalform/datatable/index.scss | 3 src/components/sidemenu/index.jsx | 16 src/templates/zshare/modalform/modaleditable/index.scss | 6 31 files changed, 803 insertions(+), 288 deletions(-) diff --git a/src/components/sidemenu/index.jsx b/src/components/sidemenu/index.jsx index a463c20..dc61f5d 100644 --- a/src/components/sidemenu/index.jsx +++ b/src/components/sidemenu/index.jsx @@ -214,14 +214,22 @@ this.props.modifyTabview([menu]) e.preventDefault() } else { - let tabs = JSON.parse(JSON.stringify(this.props.tabviews)) + let tabs = fromJS(this.props.tabviews).toJS() tabs = tabs.filter(tab => { tab.selected = false return tab.MenuID !== menu.MenuID }) - menu.selected = true - tabs.push(menu) - this.props.modifyTabview(tabs) + + if (this.props.tabviews.length !== tabs.length) { + this.props.modifyTabview(fromJS(tabs).toJS()) + } + + this.setState({}, () => { + menu.selected = true + tabs.push(menu) + this.props.modifyTabview(tabs) + }) + e.preventDefault() } } diff --git a/src/components/tabview/index.jsx b/src/components/tabview/index.jsx index ba0c4c4..5e5860e 100644 --- a/src/components/tabview/index.jsx +++ b/src/components/tabview/index.jsx @@ -52,7 +52,7 @@ handleTabview = (e, menu) => { e.stopPropagation() // 鍏抽棴tab椤碉紝閲嶆柊閫夋嫨鏄剧ず椤� - let tabs = JSON.parse(JSON.stringify(this.state.tabviews)) + let tabs = fromJS(this.state.tabviews).toJS() tabs = tabs.filter(tab => { return tab.MenuID !== menu.MenuID }) @@ -78,7 +78,7 @@ changeTab = (e, menu) => { e.stopPropagation() // 绐楀彛鍒囨崲 - let tabs = JSON.parse(JSON.stringify(this.state.tabviews)) + let tabs = fromJS(this.state.tabviews).toJS() tabs = tabs.map(tab => { tab.selected = false diff --git a/src/tabviews/tabmanage/mutilform/index.jsx b/src/tabviews/tabmanage/mutilform/index.jsx index 5b4f25d..7a88287 100644 --- a/src/tabviews/tabmanage/mutilform/index.jsx +++ b/src/tabviews/tabmanage/mutilform/index.jsx @@ -55,7 +55,7 @@ } } return ( - <Form {...formItemLayout} className="ant-advanced-search-form main-form-field" id="tab-handle-form-box"> + <Form {...formItemLayout} className="tab-manage-form-field" id="tab-handle-form-box"> <Row gutter={24}> <Col span={24}> <Form.Item label="鏍囩鍚嶇О"> diff --git a/src/tabviews/tabmanage/mutilform/index.scss b/src/tabviews/tabmanage/mutilform/index.scss index 919cf39..59c912c 100644 --- a/src/tabviews/tabmanage/mutilform/index.scss +++ b/src/tabviews/tabmanage/mutilform/index.scss @@ -1,4 +1,4 @@ -.ant-advanced-search-form.main-form-field { +.tab-manage-form-field { position: relative; padding: 0px 24px 20px; .ant-form-item { diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index 17b83ea..21966a1 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -951,7 +951,7 @@ _LongParam.groups.forEach(group => { group.sublist = group.sublist.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛� 鏉冮檺榛戝悕鍗曞瓧娈佃缃负闅愯棌琛ㄥ崟 - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) if (this.props.dataManager) { // 鏁版嵁鏉冮檺 @@ -983,7 +983,7 @@ } else { _LongParam.fields = _LongParam.fields.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) if (this.props.dataManager) { // 鏁版嵁鏉冮檺 diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index ddd5cfc..7e01db0 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1054,7 +1054,7 @@ _LongParam.groups.forEach(group => { group.sublist = group.sublist.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) if (this.props.dataManager) { // 鏁版嵁鏉冮檺 @@ -1086,7 +1086,7 @@ } else { _LongParam.fields = _LongParam.fields.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 - if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) if (this.props.dataManager) { // 鏁版嵁鏉冮檺 diff --git a/src/tabviews/zshare/actionList/tabbutton/index.jsx b/src/tabviews/zshare/actionList/tabbutton/index.jsx index ccd4e50..33964c5 100644 --- a/src/tabviews/zshare/actionList/tabbutton/index.jsx +++ b/src/tabviews/zshare/actionList/tabbutton/index.jsx @@ -117,29 +117,28 @@ } let index = 0 - let isexit = false - let tabs = tabviews.map((tab, i) => { + let tabs = tabviews.filter((tab, i) => { tab.selected = false if (tab.MenuID === MenuID) { index = i - } else if (tab.MenuID === btn.uuid) { - tab.selected = true - isexit = true } - return tab + return tab.MenuID !== newtab.MenuID }) - if (!isexit) { - tabs.splice(index + 1, 0, newtab) + if (tabviews.length !== tabs.length) { + this.props.modifyTabview(fromJS(tabs).toJS()) } + + this.setState({}, () => { + tabs.splice(index + 1, 0, newtab) + this.props.modifyTabview(tabs) + }) if (this.props.updateStatus) { this.props.updateStatus('trigger') } - - this.props.modifyTabview(tabs) } render() { diff --git a/src/tabviews/zshare/checkCard/index.jsx b/src/tabviews/zshare/checkCard/index.jsx deleted file mode 100644 index ff76da2..0000000 --- a/src/tabviews/zshare/checkCard/index.jsx +++ /dev/null @@ -1,56 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' -import { Col, Row } from 'antd' - -import './index.scss' - - -class CheckCard extends Component { - static propTpyes = { - multiple: PropTypes.bool, // 鏄惁鍙閫� - width: PropTypes.number, // 瀹藉害 - display: PropTypes.string, // 鏄剧ず涓猴細text锛堟枃鏈級銆乸icture锛堝浘鐗囷級 - fields: PropTypes.array, // 瀛楁闆� - options: PropTypes.array, // 鏁版嵁鍒楄〃 - onChange: PropTypes.func, // 鏁版嵁鍒囨崲 - } - - state = { - selectKeys: null, // 閫変腑鏁版嵁id - } - - UNSAFE_componentWillMount () { - - } - - UNSAFE_componentWillReceiveProps (nextProps) { - - } - - getCards = () => { - const { display, options, fields } = this.props - if (display === 'picture') { - return options.map(item => { - <Col> - <div> - {fields.map(col => { - return <span></span> - })} - </div> - </Col> - }) - } else { - return <Col></Col> - } - } - - render() { - - return ( - <Row gutter={24}>{this.getCards()}</Row> - ) - } -} - -export default CheckCard \ No newline at end of file diff --git a/src/tabviews/zshare/checkCard/index.scss b/src/tabviews/zshare/checkCard/index.scss deleted file mode 100644 index 4e9c6be..0000000 --- a/src/tabviews/zshare/checkCard/index.scss +++ /dev/null @@ -1,3 +0,0 @@ -.check-card-edit-box { - -} \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/checkCard/index.jsx b/src/tabviews/zshare/mutilform/checkCard/index.jsx new file mode 100644 index 0000000..8f45c60 --- /dev/null +++ b/src/tabviews/zshare/mutilform/checkCard/index.jsx @@ -0,0 +1,113 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Col, Row } from 'antd' + +import './index.scss' + +class CheckCard extends Component { + static propTpyes = { + card: PropTypes.bool, // 鍗$墖淇℃伅 + onChange: PropTypes.func // 鏁版嵁鍒囨崲 + } + + state = { + selectKeys: null + } + + UNSAFE_componentWillMount() { + const { card } = this.props + + if (card.multiple === 'true') { + this.setState({ + selectKeys: card.initval ? card.initval.split(',') : [] + }) + } else { + this.setState({ + selectKeys: card.initval + }) + } + } + + changeCard = (item) => { + const { multiple } = this.props.card + const { selectKeys } = this.state + + if (multiple === 'true') { + let keys = [] + if (selectKeys.includes(item.$value)) { + keys = selectKeys.filter(key => key !== item.$value) + } else { + keys = [...selectKeys, item.$value] + } + + this.setState({ + selectKeys: keys + }, () => { + this.props.onChange && this.props.onChange(keys.join(',')) + }) + } else if (multiple !== 'true' && selectKeys !== item.$value) { + this.setState({ + selectKeys: item.$value + }, () => { + this.props.onChange && this.props.onChange(item.$value) + }) + } + } + + getCards = () => { + const { display, width, options, fields, ratio, multiple } = this.props.card + const { selectKeys } = this.state + + let paddingTop = '100%' + if (ratio === '4:3') { + paddingTop = '75%' + } else if (ratio === '3:2') { + paddingTop = '66.7%' + } else if (ratio === '16:9') { + paddingTop = '56.25%' + } + + if (display !== 'picture') { + return options.map(item => { + let _active = false + if (multiple === 'true' && selectKeys.includes(item.$value)) { + _active = true + } else if (multiple !== 'true' && selectKeys === item.$value) { + _active = true + } + + return <Col span={width} key={item.key}> + <div className={'card-cell ' + (_active ? 'active' : '')} onClick={() => this.changeCard(item)}> + {fields.map(col => { + return <span key={col.key} style={{color: col.color, fontSize: col.fontSize + 'px', height: col.fontSize * 1.5 + 'px', textAlign: col.align}}>{item[col.field]}</span> + })} + </div> + </Col> + }) + } else { + return options.map(item => { + let _active = false + if (multiple === 'true' && selectKeys.includes(item.$value)) { + _active = true + } else if (multiple !== 'true' && selectKeys === item.$value) { + _active = true + } + + return <Col span={width} key={item.key}> + <div className={'card-pic-cell ' + (_active ? 'active' : '')} onClick={() => this.changeCard(item)} style={{paddingTop, backgroundImage: `url(${item.$url})`}}> + </div> + </Col> + }) + } + } + + render() { + return ( + <div className="check-card-form-box"> + <Row gutter={12}>{this.getCards()}</Row> + </div> + ) + } +} + +export default CheckCard \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/checkCard/index.scss b/src/tabviews/zshare/mutilform/checkCard/index.scss new file mode 100644 index 0000000..3d87dc7 --- /dev/null +++ b/src/tabviews/zshare/mutilform/checkCard/index.scss @@ -0,0 +1,39 @@ +.check-card-form-box { + margin-top: 10px; + margin-bottom: -10px; + .card-cell { + border: 1px solid #bcbcbc; + border-radius: 4px; + padding: 6px; + margin-bottom: 12px; + line-height: 1.5; + transition: all 0.3s; + cursor: pointer; + span { + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } + .card-cell:hover, .card-cell.active { + border-color: #1890ff; + background: #1890ff; + span { + color: #ffffff!important; + } + } + .card-pic-cell { + border: 1px solid #bcbcbc; + border-radius: 4px; + background-size: cover; + background-position: center; + margin-bottom: 12px; + line-height: 1.5; + cursor: pointer; + } + .card-pic-cell:hover, .card-pic-cell.active { + border-color: #1890ff; + box-shadow: 0px 0px 4px #1890ff; + } +} \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/customSwitch/index.jsx b/src/tabviews/zshare/mutilform/customSwitch/index.jsx new file mode 100644 index 0000000..4c8d573 --- /dev/null +++ b/src/tabviews/zshare/mutilform/customSwitch/index.jsx @@ -0,0 +1,44 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Switch } from 'antd' + +import './index.scss' + +class CheckCard extends Component { + static propTpyes = { + Item: PropTypes.bool, // 琛ㄥ崟 + onChange: PropTypes.func // 鏁版嵁鍒囨崲 + } + + state = { + defaultChecked: this.props.Item.initval === true + } + + UNSAFE_componentWillMount () { + const { Item, onChange } = this.props + if (Item.initval === true) { + onChange && onChange(Item.openVal) + } else { + onChange && onChange(Item.closeVal) + } + } + + onChange = (val) => { + const { Item, onChange } = this.props + if (val) { + onChange && onChange(Item.openVal) + } else { + onChange && onChange(Item.closeVal) + } + } + + render() { + const { defaultChecked } = this.state + + return ( + <Switch defaultChecked={defaultChecked} onChange={this.onChange}/> + ) + } +} + +export default CheckCard \ No newline at end of file diff --git a/src/tabviews/zshare/mutilform/customSwitch/index.scss b/src/tabviews/zshare/mutilform/customSwitch/index.scss new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tabviews/zshare/mutilform/customSwitch/index.scss diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx index 31363df..30b79f4 100644 --- a/src/tabviews/zshare/mutilform/index.jsx +++ b/src/tabviews/zshare/mutilform/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification } from 'antd' +import { Form, Row, Col, Input, InputNumber, Select, DatePicker, notification, Checkbox, Radio, Tooltip, Icon } from 'antd' import moment from 'moment' import Api from '@/api' @@ -9,6 +9,8 @@ import { formRule, calendarColors } from '@/utils/option.js' import Utils from '@/utils/utils.js' import FileUpload from '../fileupload' +import CustomSwitch from './customSwitch' +import CheckCard from './checkCard' import './index.scss' const {MonthPicker} = DatePicker @@ -120,7 +122,7 @@ writein[item.field] = item.writein !== 'false' fieldlen[item.field] = _fieldlen - if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect') { + if (item.type === 'select' || item.type === 'link' || item.type === 'multiselect' || item.type === 'radio' || item.type === 'checkbox') { if (item.setAll === 'true') { item.options.unshift({ key: Utils.getuuid(), @@ -192,6 +194,14 @@ newval = window.decodeURIComponent(window.atob(newval)) } catch (e) { console.warn(e) + } + } else if (item.type === 'switch' && newval !== '') { // 寮�鍏冲彧鎺ユ敹鍥哄畾鍊� + if (newval !== item.closeVal && newval !== item.openVal) { + newval = '' + } else if (newval === item.openVal) { + newval = true + } else { + newval = false } } @@ -277,7 +287,7 @@ const { formlist } = this.state // 闇�瑕佸姩鎬佽幏鍙栦笅鎷夎彍鍗曠殑琛ㄥ崟 - let deForms = formlist.filter(item => ['select', 'link', 'multiselect'].includes(item.type) && item.resourceType === '1' && (item.type === 'link' || item.hidden !== 'true')) + let deForms = formlist.filter(item => ['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && item.resourceType === '1' && (item.type === 'link' || item.hidden !== 'true')) if (deForms.length === 0) { return @@ -395,17 +405,21 @@ delete result.status let _formlist = formlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { let options = result[item.field].map(cell => { - let _cell = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] + let _cell = { key: Utils.getuuid() } + + if (item.type !== 'checkcard') { + _cell.Value = cell[item.valueField] + _cell.Text = cell[item.valueText] + } else { + _cell.$value = cell[item.valueField] + _cell = {..._cell, ...cell} } if (item.type === 'link') { _cell.ParentID = cell[item.linkField] - } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) { + } else if ((item.type === 'select' || item.type === 'radio') && item.linkSubField && item.linkSubField.length > 0) { item.linkSubField.forEach(_field => { _cell[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' }) @@ -427,7 +441,7 @@ } else { item.options = item.oriOptions } - } else if (item.type === 'select' || item.type === 'multiselect') { + } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } return item @@ -485,17 +499,21 @@ delete result.status let _formlist = formlist.map(item => { - if (['select', 'link', 'multiselect'].includes(item.type) && result[item.field] && result[item.field].length > 0) { + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type) && result[item.field] && result[item.field].length > 0) { let options = result[item.field].map(cell => { - let _cell = { - key: Utils.getuuid(), - Value: cell[item.valueField], - Text: cell[item.valueText] + let _cell = { key: Utils.getuuid() } + + if (item.type !== 'checkcard') { + _cell.Value = cell[item.valueField] + _cell.Text = cell[item.valueText] + } else { + _cell.$value = cell[item.valueField] + _cell = {..._cell, ...cell} } if (item.type === 'link') { _cell.ParentID = cell[item.linkField] - } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) { + } else if ((item.type === 'select' || item.type === 'radio') && item.linkSubField && item.linkSubField.length > 0) { item.linkSubField.forEach(_field => { _cell[_field] = (cell[_field] || cell[_field] === 0) ? cell[_field] : '' }) @@ -517,7 +535,7 @@ } else { item.options = item.oriOptions } - } else if (item.type === 'select' || item.type === 'multiselect') { + } else if (['select', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(item.type)) { item.options = item.oriOptions } return item @@ -554,7 +572,7 @@ } } - selectChange = (_field, value, option) => { + selectChange = (_field, value) => { const { record } = this.state let formlist = fromJS(this.state.formlist).toJS() @@ -576,15 +594,18 @@ }) // 琛ㄥ崟鍒囨崲鏃讹紝鏇存柊鍏宠仈瀛楁 - if (_field.type === 'select' && _field.linkSubField && _field.linkSubField.length > 0 && option.props.data) { - let _data = option.props.data - _field.linkSubField.forEach(subfield => { - if (this.props.form.getFieldValue(subfield) !== undefined) { - fieldsvalue[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' - } else { - _record[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' - } - }) + if ((_field.type === 'select' || _field.type === 'radio') && _field.linkSubField && _field.linkSubField.length > 0) { + let _data = _field.options.filter(op => op.Value === value)[0] + + if (_data) { + _field.linkSubField.forEach(subfield => { + if (this.props.form.getFieldValue(subfield) !== undefined) { + fieldsvalue[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' + } else { + _record[subfield] = (_data[subfield] || _data[subfield] === 0) ? _data[subfield] : '' + } + }) + } } if (subfields.length === 0) { @@ -629,17 +650,47 @@ callback() } - getFields(formlist) { + getFields() { const { getFieldDecorator } = this.props.form - const { cols } = this.state + const { cols, formlist } = this.state const fields = [] + let filtration = {} formlist.forEach((item, index) => { + if ((!item.field && item.type !== 'title' && item.type !== 'hint') || item.hidden === 'true' || item.type === 'funcvar') return + if (item.supField) { // 澶氬眰琛ㄥ崟鎺у埗 + let _supVal = this.props.form.getFieldValue(item.supField) + + if (_supVal === undefined && filtration[item.supField]) { + _supVal = filtration[item.supField] + } + + if (item.supvalue.includes(_supVal)) { + let _subVal = this.props.form.getFieldValue(item.field) + filtration[item.field] = _subVal === undefined ? item.initval : _subVal + } else { + return + } + } + + let _colspan = 24 / cols + if (item.entireLine === 'true') { + _colspan = 24 + } + if (item.type === 'title') { fields.push( <Col span={24} key={index}> <p>{item.label}</p> + </Col> + ) + } else if (item.type === 'hint') { + fields.push( + <Col span={24} key={index}> + <Form.Item colon={!!item.label} label={item.label || ' '} className="hint"> + <div className="message">{item.message}</div> + </Form.Item> </Col> ) } else if (item.type === 'text') { @@ -669,8 +720,13 @@ } } fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -693,8 +749,13 @@ let precision = (item.decimal || item.decimal === 0) ? item.decimal : null fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: _initval, rules: [ @@ -716,8 +777,13 @@ ) } else if (item.type === 'color') { // 棰滆壊閫夋嫨 fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -727,7 +793,7 @@ } ] })( - <Select onChange={(value, option) => {this.selectChange(item, value, option)}} disabled={item.readonly === 'true'}> + <Select disabled={item.readonly === 'true'}> {calendarColors.map(option => <Select.Option key={option.name} style={{background: option.value, color: '#ffffff'}} value={option.name}>{option.name}</Select.Option> )} @@ -736,15 +802,109 @@ </Form.Item> </Col> ) - } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 - let hasSubField = false - if (item.linkSubField && item.linkSubField.length > 0) { // 瀛樺湪鍏宠仈瀛楁锛屾暟鎹瓨鍌� - hasSubField = true - } + } else if (item.type === 'checkcard') { // 澶氶�夋 + fields.push( + <Col span={24} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + } className="checkcard"> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })(<CheckCard card={item} />)} + </Form.Item> + </Col> + ) + } else if (item.type === 'switch') { // 澶氶�夋 + fields.push( + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })(<CustomSwitch Item={item} />)} + </Form.Item> + </Col> + ) + } else if (item.type === 'checkbox') { // 澶氶�夋 + let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.field, { + initialValue: _initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Checkbox.Group disabled={item.readonly === 'true'}> + {item.options.map(option => <Checkbox key={option.key} title={option.Text} value={option.Value}>{option.Text}</Checkbox>)} + </Checkbox.Group> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'radio') { // 鍗曢�夋 + fields.push( + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> + {getFieldDecorator(item.field, { + initialValue: item.initval, + rules: [ + { + required: item.required === 'true', + message: this.props.dict['form.required.select'] + item.label + '!' + } + ] + })( + <Radio.Group disabled={item.readonly === 'true'} onChange={(e) => {this.selectChange(item, e.target.value)}}> + {item.options.map(option => <Radio key={option.key} value={option.Value}>{option.Text}</Radio>)} + </Radio.Group> + )} + </Form.Item> + </Col> + ) + } else if (item.type === 'select' || item.type === 'link') { // 涓嬫媺鎼滅储 + fields.push( + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -757,11 +917,11 @@ <Select showSearch filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value, option) => {this.selectChange(item, value, option)}} + onChange={(value) => {this.selectChange(item, value)}} disabled={item.readonly === 'true'} > {item.options.map(option => - <Select.Option id={option.key} data={hasSubField ? option : ''} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> + <Select.Option id={option.key} title={option.Text} key={option.key} value={option.Value}>{option.Text}</Select.Option> )} </Select> )} @@ -771,8 +931,13 @@ } else if (item.type === 'multiselect') { // 澶氶�� let _initval = item.initval ? item.initval.split(',').filter(Boolean) : [] fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: _initval, rules: [ @@ -798,8 +963,13 @@ ) } else if (item.type === 'date') { // 鏃堕棿鎼滅储 fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -816,8 +986,13 @@ ) } else if (item.type === 'datemonth') { fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -834,8 +1009,13 @@ ) } else if (item.type === 'datetime') { fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -871,8 +1051,13 @@ } fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: filelist, rules: [ @@ -889,8 +1074,13 @@ ) } else if (item.type === 'linkMain') { fields.push( - <Col span={24 / cols} key={index}> - <Form.Item label={item.label}> + <Col span={_colspan} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -907,15 +1097,14 @@ // 鍑芥暟鍙橀噺瀛楁锛岄粯璁や笉鏄剧ず } else if (item.type === 'textarea') { let _max = item.fieldlength || 512 - let _labelcol = cols !== 3 ? 8 / cols : 3 - let _wrapcol = cols !== 3 ? 16 + (cols - 1) * 4 : 21 - let _style = {} - if (cols === 2 || cols === 4) { - _style.paddingLeft = '7px' - } fields.push( - <Col span={24} key={index} className="textarea-row" style={{..._style}}> - <Form.Item label={item.label} labelCol={{xs: { span: 24 }, sm: { span: _labelcol }}} wrapperCol={ {xs: { span: 24 }, sm: { span: _wrapcol }} }> + <Col span={24} key={index}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.field, { initialValue: item.initval, rules: [ @@ -1034,7 +1223,7 @@ } else if (this.state.datatype[key] === 'number') { _value = values[key] - } else if (this.state.datatype[key] === 'multiselect') { + } else if (this.state.datatype[key] === 'multiselect' || this.state.datatype[key] === 'checkbox') { _value = values[key] ? values[key].join(',') : '' } else if (this.state.datatype[key] === 'fileupload') { @@ -1104,7 +1293,7 @@ } render() { - const { formlist, cols } = this.state + const { cols } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -1116,52 +1305,9 @@ } } - let _formlist = [] - let rowIndex = 0 - let colIndex = 0 - let filtration = {} - - // 琛ㄥ崟鍒嗚锛岄伩鍏嶆帓鍒椾笉鏁撮綈 - formlist.forEach(item => { - if ((!item.field && item.type !== 'title') || item.hidden === 'true' || item.type === 'funcvar') return - if (item.supField) { // 澶氬眰琛ㄥ崟鎺у埗 - let _supVal = this.props.form.getFieldValue(item.supField) - - if (_supVal === undefined && filtration[item.supField]) { - _supVal = filtration[item.supField] - } - - if (item.supvalue.includes(_supVal)) { - let _subVal = this.props.form.getFieldValue(item.field) - filtration[item.field] = _subVal === undefined ? item.initval : _subVal - } else { - return - } - } - - _formlist[rowIndex] = _formlist[rowIndex] || [] - if (item.type === 'textarea' || item.type === 'title') { - if (colIndex === 0) { - _formlist[rowIndex].push(item) - } else { - rowIndex++ - _formlist[rowIndex] = [item] - } - rowIndex++ - colIndex = 0 - } else { - _formlist[rowIndex].push(item) - colIndex++ - } - if (colIndex >= cols) { - rowIndex++ - colIndex = 0 - } - }) - return ( <Form {...formItemLayout} className="ant-advanced-search-form main-form-field" id="main-form-box"> - {_formlist.map((formrow, index) => <Row key={index} gutter={24}>{this.getFields(formrow)}</Row>)} + <Row className={'cols' + cols} gutter={24}>{this.getFields()}</Row> </Form> ) } diff --git a/src/tabviews/zshare/mutilform/index.scss b/src/tabviews/zshare/mutilform/index.scss index 919cf39..eff2b51 100644 --- a/src/tabviews/zshare/mutilform/index.scss +++ b/src/tabviews/zshare/mutilform/index.scss @@ -1,8 +1,40 @@ .ant-advanced-search-form.main-form-field { position: relative; padding: 0px 24px 20px; + >.ant-row >.ant-col { + display: inline-block; + float: none; + vertical-align: top; + } + .ant-form-item-label .anticon-question-circle { + color: #c49f47; + margin-right: 3px; + } + .ant-checkbox-group { + line-height: unset; + .ant-checkbox-wrapper { + margin-right: 8px; + } + .ant-checkbox-wrapper + .ant-checkbox-wrapper { + margin-left: 0; + } + } .ant-form-item { display: flex; + } + .ant-form-item.checkcard { + margin-bottom: 10px; + .ant-form-item-control { + line-height: 1.5; + } + } + .ant-form-item.hint { + margin-bottom: 0px; + .message { + margin-top: 9px; + line-height: 1.5; + color: rgba(0, 0, 0, 0.85); + } } .ant-form-item-control-wrapper { flex: 1; @@ -13,12 +45,25 @@ text-overflow: ellipsis; white-space: nowrap; } - .textarea-row { - .ant-col-sm-3 { - width: 10.5%; + >.ant-row.cols2 .ant-col-24 { + .ant-form-item { + .ant-form-item-label { + width: 16%; + } } - .ant-col-sm-21 { - width: 89.5%; + } + >.ant-row.cols3 .ant-col-24 { + .ant-form-item { + .ant-form-item-label { + width: 10.5%; + } + } + } + >.ant-row.cols4 .ant-col-24 { + .ant-form-item { + .ant-form-item-label { + width: 7.5%; + } } } .ant-input-number { diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx index 3d0de8a..4fd31c3 100644 --- a/src/templates/formtabconfig/index.jsx +++ b/src/templates/formtabconfig/index.jsx @@ -486,7 +486,12 @@ this.setState({ modaltype: 'search', card: card, - formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, false, roleList) + formlist: getModalForm(card, _inputfields, _linkableFields, _linksupFields, false, roleList).map(item => { + if (item.key === 'type') { + item.options = item.options.filter(option => !['switch', 'checkbox', 'radio', 'checkcard', 'hint'].includes(option.value)) + } + return item + }) }) } diff --git a/src/templates/modalconfig/checkCard/index.jsx b/src/templates/modalconfig/checkCard/index.jsx index bc378bf..ea21875 100644 --- a/src/templates/modalconfig/checkCard/index.jsx +++ b/src/templates/modalconfig/checkCard/index.jsx @@ -1,10 +1,8 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' import { Col, Row } from 'antd' import './index.scss' - class CheckCard extends Component { static propTpyes = { @@ -17,17 +15,7 @@ onChange: PropTypes.func, // 鏁版嵁鍒囨崲 } - state = { - selectKeys: null, // 閫変腑鏁版嵁id - } - - UNSAFE_componentWillMount () { - - } - - UNSAFE_componentWillReceiveProps (nextProps) { - - } + state = {} getCards = () => { const { display, width, options, fields, ratio } = this.props @@ -62,7 +50,6 @@ } render() { - return ( <div className="check-card-edit-box" style={{marginTop: '10px'}}> <Row gutter={12}>{this.getCards()}</Row> diff --git a/src/templates/modalconfig/checkCard/index.scss b/src/templates/modalconfig/checkCard/index.scss index fc1475f..985c786 100644 --- a/src/templates/modalconfig/checkCard/index.scss +++ b/src/templates/modalconfig/checkCard/index.scss @@ -3,6 +3,7 @@ border: 1px solid #bcbcbc; border-radius: 4px; padding: 6px; + margin-bottom: 12px; span { display: block; overflow: hidden; @@ -15,5 +16,6 @@ border-radius: 4px; background-size: cover; background-position: center; + margin-bottom: 12px; } } \ No newline at end of file diff --git a/src/templates/modalconfig/dragelement/card.jsx b/src/templates/modalconfig/dragelement/card.jsx index 8d78aab..4f481bf 100644 --- a/src/templates/modalconfig/dragelement/card.jsx +++ b/src/templates/modalconfig/dragelement/card.jsx @@ -105,14 +105,19 @@ } else if (card.type === 'switch') { formItem = (<Switch style={{marginTop: '8px'}} checked={card.initval}/>) } else if (card.type === 'radio') { - formItem = (<Radio.Group style={{marginTop: '8px'}} value={1}> + formItem = card.options && card.options.length > 0 ? (<Radio.Group value={card.initval}> + {card.options.map(cell => <Radio key={cell.key} value={cell.Value}>{cell.Text}</Radio>)} + </Radio.Group>) : (<Radio.Group value={1}> <Radio value={1}>A</Radio> <Radio value={2}>B</Radio> <Radio value={3}>C</Radio> <Radio value={4}>D</Radio> </Radio.Group>) } else if (card.type === 'checkbox') { - formItem = (<Checkbox.Group style={{marginTop: '8px'}} value={['A', 'C']}> + let _val = card.initval ? card.initval.split(',') : [] + formItem = card.options && card.options.length > 0 ? (<Checkbox.Group value={_val}> + {card.options.map(cell => <Checkbox key={cell.key} value={cell.Value}>{cell.Text}</Checkbox>)} + </Checkbox.Group>) : (<Checkbox.Group value={['A', 'C']}> <Checkbox value="A">A</Checkbox> <Checkbox value="B">B</Checkbox> <Checkbox value="C">C</Checkbox> diff --git a/src/templates/modalconfig/dragelement/index.scss b/src/templates/modalconfig/dragelement/index.scss index a61965a..d68b01a 100644 --- a/src/templates/modalconfig/dragelement/index.scss +++ b/src/templates/modalconfig/dragelement/index.scss @@ -19,4 +19,9 @@ padding-left: 12px; padding-right: 12px; } + >.ant-col { + display: inline-block; + float: none; + vertical-align: top; + } } \ No newline at end of file diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx index 151df90..759e390 100644 --- a/src/templates/modalconfig/index.jsx +++ b/src/templates/modalconfig/index.jsx @@ -369,13 +369,13 @@ let sublist = group.sublist.filter(item => item.type === 'text' || item.type === 'number') _inputfields = [..._inputfields, ...sublist] - let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link') + let suplist = group.sublist.filter(item => item.type === 'select' || item.type === 'link' || item.type === 'radio') _formfields = [..._formfields, ...suplist] }) } else { _inputfields = config.fields.filter(item => item.type === 'text' || item.type === 'number') - _formfields = config.fields.filter(item => item.type === 'select' || item.type === 'link') + _formfields = config.fields.filter(item => item.type === 'select' || item.type === 'link' || item.type === 'radio') } let uniq = new Map() diff --git a/src/templates/modalconfig/index.scss b/src/templates/modalconfig/index.scss index 2969e25..c4c262f 100644 --- a/src/templates/modalconfig/index.scss +++ b/src/templates/modalconfig/index.scss @@ -218,6 +218,18 @@ width: 100%; margin-top: 4px; } + .ant-checkbox-group { + line-height: 40px; + .ant-checkbox-wrapper { + margin-right: 8px; + } + .ant-checkbox-wrapper + .ant-checkbox-wrapper { + margin-left: 0px; + } + } + .ant-radio-group { + line-height: 40px; + } .ant-calendar-picker { width: 100%; margin-top: 4px; diff --git a/src/templates/zshare/createinterface/index.jsx b/src/templates/zshare/createinterface/index.jsx index 34364f1..e9133b3 100644 --- a/src/templates/zshare/createinterface/index.jsx +++ b/src/templates/zshare/createinterface/index.jsx @@ -1,10 +1,12 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Button, notification, Modal } from 'antd' import moment from 'moment' import MutilForm from './mutilform' import Utils from '@/utils/utils.js' +import options from '@/store/options.js' import Api from '@/api' import './index.scss' @@ -195,7 +197,6 @@ if (type === 'out') { this.FormRef.handleConfirm().then(res => { - this.setState({ type: '', loading: true, @@ -208,7 +209,6 @@ }) } else { this.FormRef.handleConfirm().then(res => { - this.setState({ type: '', btn: null, @@ -217,7 +217,11 @@ visible: false, param: null }) - + + if (res.TryType === 'Y' && res.array_name) { + res.Return = 'N' + } + this.createBtnInterfaceExec({...param, ...res}, config, btn) }) } @@ -253,7 +257,7 @@ delete param.hidden - let _mainParam = JSON.parse(JSON.stringify(param)) + let _mainParam = fromJS(param).toJS() new Promise(resolve => { // 鑾峰彇浜戠瀛樺偍杩囩▼淇℃伅 @@ -335,15 +339,16 @@ Ltextgridparam: '', Ltexttableparam: '', Ltext: '', - menuType: menu.type + menuType: menu.type, + systemType: options.sysType } this.setState({ type: 'inner', param: param, visible: true, - btn: JSON.parse(JSON.stringify(btn)), - config: JSON.parse(JSON.stringify(config)), + btn: fromJS(btn).toJS(), + config: fromJS(config).toJS(), formlist: [{ type: 'text', key: 'KunName', @@ -374,6 +379,7 @@ key: 'Return', label: '鍥炴墽', initval: 'N', + tooltip: '褰撻�夋嫨闇�瑕佷簨鍔★紝涓斿~鍏ヤ簡鏁扮粍鍚嶇О鏃讹紝灏嗕笉瀛樺湪鍥炴墽淇℃伅銆�', required: true, options: [{ value: 'Y', @@ -382,6 +388,13 @@ value: 'N', text: '涓嶉渶瑕�' }] + }, { + type: 'text', + key: 'array_name', + label: '鏁扮粍鍚嶇О', + initval: menu.menuNo + btn.uuid.substr(-4), + tooltip: '鎵归噺鎿嶄綔鏃讹紝闇�瑕佸~鍐欐暟缁勫悕绉般��', + required: false }] }) } @@ -444,6 +457,7 @@ fieldlen: _fieldlen, key: cell.field, required: cell.required === 'true' ? 'required' : '', + writein: cell.required !== 'false', value: cell.initval || '' } @@ -550,7 +564,7 @@ delete param.menuType - _mainParam = JSON.parse(JSON.stringify(param)) + _mainParam = fromJS(param).toJS() return Api.getLocalConfig(param) }).then(res => { @@ -603,12 +617,37 @@ let primaryKey = setting.primaryKey || 'id' let columns = config.columns.filter(col => !!col.field) let verify = btn.verify || {} + + let _initCustomScript = '' // 鍒濆鍖栬剼鏈� + let _prevCustomScript = '' // 榛樿sql鍓嶆墽琛岃剼鏈� + let _backCustomScript = '' // 榛樿sql鍚庢墽琛岃剼鏈� + + verify.scripts && verify.scripts.forEach(item => { + if (item.status === 'false') return + + if (item.position === 'init') { + _initCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${item.sql} + ` + } else if (item.position === 'front') { + _prevCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${item.sql} + ` + } else { + _backCustomScript += ` + /* 鑷畾涔夎剼鏈� */ + ${item.sql} + ` + } + }) + // 闇�瑕佸0鏄庣殑鍙橀噺闆� let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] // 绯荤粺鍙橀噺澹版槑涓庤缃垵濮嬪�� - let _sql = `Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50) - ` + let _sql = '' let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦 let _initfields = [] @@ -671,9 +710,13 @@ // 鍙橀噺澹版槑 _declarefields = _declarefields.join(',') if (_declarefields) { - _sql += `,${_declarefields} - ` + _declarefields = ',' + _declarefields } + _sql = `/* 绯荤粺鐢熸垚 */ + Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} + + select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ + ` // 鍙橀噺璧嬪�� if (_initfields.length > 0) { @@ -704,25 +747,48 @@ } // 鍒濆鍖栧嚟璇佸強鐢ㄦ埛淇℃伅瀛楁 - _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='' + _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='', @BillCode='', @ModularDetailCode='' ` + + if (_initCustomScript) { + _sql += _initCustomScript + } // 鍚敤璐︽湡楠岃瘉 if (verify.accountdate === 'true') { - _sql += `exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT + _sql += ` + /* 璐︽湡楠岃瘉 */ + exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT if @ErrorCode!='' GOTO aaa ` } // 澶辨晥楠岃瘉锛屾坊鍔犳暟鎹椂涓嶇敤 - if (btn.sqlType !== 'insert' && verify.invalid === 'true') { + if (btn.sqlType !== 'insert' && verify.invalid === 'true' && setting.dataresource) { let datasource = setting.dataresource - if (/\s/.test(datasource)) { // 鎷兼帴鍒悕 + if (/\s/.test(datasource) && !/tb$/.test(datasource)) { // 鎷兼帴鍒悕 datasource = '(' + datasource + ') tb' } - _sql += `select @tbid='', @ErrorCode='',@retmsg='' + // 鑷畾涔夎剼鏈� + if (setting.interType === 'system' && setting.scripts && setting.scripts.length > 0) { + let _customScript = '' + setting.scripts.forEach(item => { + if (item.status === 'false') return + _customScript += ` + ${item.sql} + ` + }) + _sql += ` + /* 鏁版嵁婧愯嚜瀹氫箟鑴氭湰锛岃娉ㄦ剰鍙橀噺瀹氫箟鏄惁閲嶅 */ + ${_customScript} + ` + } + + _sql += ` + /* 澶辨晥楠岃瘉 */ + select @tbid='', @ErrorCode='',@retmsg='' select @tbid=${primaryKey} from ${datasource} where ${primaryKey} =@${primaryKey}@ If @tbid='' Begin @@ -735,11 +801,76 @@ // 姣旇緝楠岃瘉 if (verify.contrasts && verify.contrasts.length > 0) { verify.contrasts.forEach(item => { - _sql += `If ${item.frontfield} ${item.operator} ${item.backfield} + _sql += ` + /* 姣旇緝楠岃瘉 */ + If ${item.frontfield} ${item.operator} ${item.backfield} Begin select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' goto aaa end + ` + }) + } + + // 鑷畾涔夐獙璇� + if (verify.customverifys && verify.customverifys.length > 0) { + verify.customverifys.forEach(item => { + _sql += ` + /* 鑷畾涔夐獙璇� */ + select @tbid='', @ErrorCode='',@retmsg='' + select top 1 @tbid='X' from (${item.sql}) a + If @tbid ${item.result === 'true' ? '!=' : '='}'' + Begin + select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' + goto aaa + end + ` + }) + } + + // 鍗曞彿鐢熸垚锛屼娇鐢ㄤ笂绾d锛圔ID锛夋垨鍒楄〃鏁版嵁锛屽0鏄庡彉閲忥紙妫�楠岋級 + if (verify.billcodes && verify.billcodes.length > 0) { + verify.billcodes.forEach(item => { + let _ModularDetailCode = '' + let _lpline = '' + if (item.TypeCharOne === 'Lp') { + if (item.linkField === 'BID' && BID) { // 鏇挎崲bid + _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)` + } else { + _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField}@,48)` + } + _ModularDetailCode = '@ModularDetailCode' + } else if (item.TypeCharOne === 'BN') { + + _ModularDetailCode = `'${item.TypeCharOne + '@' + item.linkField}@'` + } else { + _ModularDetailCode = `'${item.ModularDetailCode}'` + } + + let _declare = '' + let _key = item.field.toLowerCase() + + if (!_vars.includes(_key)) { + _declare = `Declare @${_key} nvarchar(50)` + _vars.push(_key) + } + + _sql += ` + /* 鍗曞彿鐢熸垚 */ + ${_declare} + select @BillCode='', @${_key}='', @ModularDetailCode='' + ${_lpline} + exec s_get_BillCode + @ModularDetailCode=${_ModularDetailCode}, + @Type=${item.Type}, + @TypeCharOne='${item.TypeCharOne}', + @TypeCharTwo ='${item.TypeCharTwo}', + @BillCode =@BillCode output, + @ErrorCode =@ErrorCode output, + @retmsg=@retmsg output + if @ErrorCode!='' + goto aaa + set @${_key}=@BillCode ` }) } @@ -777,65 +908,6 @@ ` }) } - - // 鑷畾涔夐獙璇� - if (verify.customverifys && verify.customverifys.length > 0) { - verify.customverifys.forEach(item => { - _sql += `select @tbid='', @ErrorCode='',@retmsg='' - select top 1 @tbid='X' from (${item.sql}) a - If @tbid ${item.result === 'true' ? '!=' : '='}'' - Begin - select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}' - goto aaa - end - ` - }) - } - - // 鍗曞彿鐢熸垚锛屼娇鐢ㄤ笂绾d锛圔ID锛夋垨鍒楄〃鏁版嵁锛屽0鏄庡彉閲忥紙妫�楠岋級 - if (verify.billcodes && verify.billcodes.length > 0) { - verify.billcodes.forEach(item => { - let _ModularDetailCode = '' - let _lpline = '' - if (item.TypeCharOne === 'Lp') { - if (item.linkField === 'BID' && BID) { // 鏇挎崲bid - _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@BID@,48)` - } else { - _lpline = `set @ModularDetailCode= 'Lp'+ right('${btn.uuid}'+@${item.linkField}@,48)` - } - _ModularDetailCode = '@ModularDetailCode' - } else if (item.TypeCharOne === 'BN') { - - _ModularDetailCode = `'${item.TypeCharOne + '@' + item.linkField}@'` - } else { - _ModularDetailCode = `'${item.ModularDetailCode}'` - } - - let _declare = '' - let _key = item.field.toLowerCase() - - if (!_vars.includes(_key)) { - _declare = `Declare @${_key} nvarchar(50)` - _vars.push(_key) - } - - _sql += `${_declare} - select @BillCode='', @${_key}='', @ModularDetailCode='' - ${_lpline} - exec s_get_BillCode - @ModularDetailCode=${_ModularDetailCode}, - @Type=${item.Type}, - @TypeCharOne='${item.TypeCharOne}', - @TypeCharTwo ='${item.TypeCharTwo}', - @BillCode =@BillCode output, - @ErrorCode =@ErrorCode output, - @retmsg=@retmsg output - if @ErrorCode!='' - goto aaa - set @${_key}=@BillCode - ` - }) - } let hasvoucher = false @@ -864,6 +936,10 @@ ` } + if (_prevCustomScript) { + _sql += _prevCustomScript + } + let _actionType = null let receiptKeys = [] // 鍥炴墽瀛楁 @@ -883,16 +959,14 @@ receiptKeys.push('bid') } - // 鐢ㄤ簬鍙栫敤鎴蜂俊鎭� - let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@ - ` - // 娣诲姞銆佷慨鏀广�侀�昏緫鍒犻櫎銆佺墿鐞嗗垹闄� if (_actionType === 'insert') { let keys = [] let values = [] formlist.forEach(item => { + if (item.writein === false) return + keys.push(item.key.toLowerCase()) values.push('@' + item.key + '@') }) @@ -921,15 +995,17 @@ keys = keys.join(',') values = values.join(',') - _sql += _user - _sql += `insert into ${btn.sql} (${keys}) select ${values};` + _sql += ` + /* 榛樿sql */ + insert into ${btn.sql} (${keys}) select ${values};` } else if (_actionType === 'update') { let _form = [] let _arr = [] formlist.forEach(item => { - _arr.push(item.key.toLowerCase()) + if (item.writein === false) return + _arr.push(item.key.toLowerCase()) _form.push(item.key + `=@${item.key}@`) }) @@ -962,9 +1038,13 @@ } _form = _form.join(',') - _sql += `update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKey}@;` + _sql += ` + /* 榛樿sql */ + update ${btn.sql} set ${_form} where ${primaryKey}=@${primaryKey}@;` } else if (_actionType === 'LogicDelete') { // 閫昏緫鍒犻櫎 - _sql += `update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` + _sql += ` + /* 榛樿sql */ + update ${btn.sql} set deleted=1,modifydate=getdate(),modifyuserid=@userid@ where ${primaryKey}=@${primaryKey}@;` } else if (_actionType === 'delete') { // 鐗╃悊鍒犻櫎 let _msg = '' @@ -977,18 +1057,14 @@ } }) } - _sql += _user - _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKey}@,@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKey}@;` + _sql += ` + /* 榛樿sql */ + insert into snote (remark,createuserid,CreateUser,CreateStaff) select '鍒犻櫎琛�:${btn.sql} 鏁版嵁: ${_msg}${primaryKey}='+@${primaryKey}@,@userid@,@username,@fullname + delete ${btn.sql} where ${primaryKey}=@${primaryKey}@;` } - // 鎷兼帴鑷畾涔夎剼鏈� - if (verify.scripts && verify.scripts.length > 0) { - let _scripts = '' - verify.scripts.forEach(item => { - _scripts += ` - ${item.sql}` - }) - _sql += `${_scripts}` + if (_backCustomScript) { + _sql += _backCustomScript } let _ltext = '' diff --git a/src/templates/zshare/createinterface/mutilform/index.jsx b/src/templates/zshare/createinterface/mutilform/index.jsx index 8914e65..9d53447 100644 --- a/src/templates/zshare/createinterface/mutilform/index.jsx +++ b/src/templates/zshare/createinterface/mutilform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, Select } from 'antd' +import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon } from 'antd' import './index.scss' class MainSearch extends Component { @@ -10,23 +10,34 @@ } state = { - + requireArr: true } - UNSAFE_componentWillMount () { - + onChange = (value, key) => { + if (key === 'TryType' && value === 'N') { + this.setState({requireArr: false}) + } else if (key === 'TryType' && value === 'Y') { + this.setState({requireArr: true}) + } } getFields() { const { getFieldDecorator } = this.props.form - + const { requireArr } = this.state const fields = [] this.props.formlist.forEach((item, index) => { + if (!requireArr && item.key === 'array_name') return + if (item.type === 'text') { fields.push( <Col span={24} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initval, rules: [ @@ -67,7 +78,12 @@ } else if (item.type === 'radio') { fields.push( <Col span={24} key={index}> - <Form.Item label={item.label}> + <Form.Item label={item.tooltip ? + <Tooltip placement="topLeft" title={item.tooltip}> + <Icon type="question-circle" /> + {item.label} + </Tooltip> : item.label + }> {getFieldDecorator(item.key, { initialValue: item.initval, rules: [ @@ -77,7 +93,7 @@ } ] })( - <Radio.Group> + <Radio.Group onChange={(e) => this.onChange(e.target.value, item.key)}> {item.options.map(op => { return <Radio key={op.value} value={op.value}>{op.text}</Radio> })} diff --git a/src/templates/zshare/modalform/datatable/index.jsx b/src/templates/zshare/modalform/datatable/index.jsx index 3d2c6d0..d05be5e 100644 --- a/src/templates/zshare/modalform/datatable/index.jsx +++ b/src/templates/zshare/modalform/datatable/index.jsx @@ -293,6 +293,13 @@ duration: 5 }) return + } else if (this.state.data.length >= 20) { + notification.warning({ + top: 92, + message: '鏈�澶氬彲娣诲姞20椤癸紒', + duration: 5 + }) + return } let item = { key: Utils.getuuid(), $value: `${this.state.data.length + 1}` } diff --git a/src/templates/zshare/modalform/datatable/index.scss b/src/templates/zshare/modalform/datatable/index.scss index a7441d4..212b7ce 100644 --- a/src/templates/zshare/modalform/datatable/index.scss +++ b/src/templates/zshare/modalform/datatable/index.scss @@ -17,6 +17,9 @@ .ant-form-item-control { line-height: 1; } + > td { + padding: 16px 10px; + } .fileupload-form-container .ant-upload-list-picture-card .ant-upload-list-item { width: 70px; height: 70px; diff --git a/src/templates/zshare/modalform/fieldtable/index.jsx b/src/templates/zshare/modalform/fieldtable/index.jsx index 5afa7fd..b11d76b 100644 --- a/src/templates/zshare/modalform/fieldtable/index.jsx +++ b/src/templates/zshare/modalform/fieldtable/index.jsx @@ -289,7 +289,7 @@ return ( <EditableContext.Provider value={this.props.form}> - <div className="modal-card-data-table"> + <div className="modal-card-field-table"> {this.state.data.length < 3 ? <Icon className="add-row" type="plus" onClick={this.handleAdd} /> : null} <Table components={components} diff --git a/src/templates/zshare/modalform/fieldtable/index.scss b/src/templates/zshare/modalform/fieldtable/index.scss index 8d7be74..bf190f5 100644 --- a/src/templates/zshare/modalform/fieldtable/index.scss +++ b/src/templates/zshare/modalform/fieldtable/index.scss @@ -1,4 +1,4 @@ -.modal-card-data-table { +.modal-card-field-table { .add-row { position: absolute; z-index: 1; @@ -17,11 +17,14 @@ .color-sketch-block { width: 200px; position: relative; - top: 2px; + top: 8px; } .ant-select { width: 80px; } + > td { + padding: 16px 10px; + } } .operation-btn { span { diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx index d77c06d..2aaccc7 100644 --- a/src/templates/zshare/modalform/index.jsx +++ b/src/templates/zshare/modalform/index.jsx @@ -23,7 +23,7 @@ multiselect: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'fieldlength', 'entireLine', 'tooltip'], link: ['initval', 'readonly', 'required', 'hidden', 'readin', 'resourceType', 'setAll', 'linkField', 'entireLine', 'tooltip'], fileupload: ['readonly', 'required', 'readin', 'fieldlength', 'maxfile', 'fileType', 'entireLine', 'tooltip'], - switch: ['initval', 'openVal', 'closeVal', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], + switch: ['initval', 'openVal', 'closeVal', 'readonly', 'hidden', 'readin', 'entireLine', 'tooltip'], date: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], datemonth: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'entireLine', 'tooltip'], @@ -311,7 +311,15 @@ } changeField = (data) => { - this.setState({cFields: data}) + this.setState({ + cFields: data, + formlist: this.state.formlist.map(form => { + if (form.key === 'fields') { + form.initVal = data + } + return form + }) + }) } handleSubmit = (e) => { diff --git a/src/templates/zshare/modalform/index.scss b/src/templates/zshare/modalform/index.scss index fe098e2..75706c5 100644 --- a/src/templates/zshare/modalform/index.scss +++ b/src/templates/zshare/modalform/index.scss @@ -7,9 +7,6 @@ .ant-form-item.text-area { >.ant-form-item-control-wrapper { width: 84%; - .ant-table-tbody > tr > td { - padding: 16px 10px; - } } >.ant-form-item-label { width: 16%; diff --git a/src/templates/zshare/modalform/modaleditable/index.scss b/src/templates/zshare/modalform/modaleditable/index.scss index 7400628..851a828 100644 --- a/src/templates/zshare/modalform/modaleditable/index.scss +++ b/src/templates/zshare/modalform/modaleditable/index.scss @@ -12,7 +12,7 @@ padding: 10px 16px; } .ant-table-tbody > tr > td { - padding: 0px 16px; + padding: 5px 16px; } .editable-cell-value-wrap { cursor: pointer; @@ -41,8 +41,6 @@ cursor: pointer; } .ant-form-explain { - .editable-row { - font-size: 12px; - } + font-size: 12px; } } diff --git a/src/utils/utils.js b/src/utils/utils.js index 952b283..02e850e 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -668,8 +668,11 @@ if (item.type === 'link') { arrfield.push(item.linkField) - } else if (item.type === 'select' && item.linkSubField && item.linkSubField.length > 0) { + } else if ((item.type === 'select' || item.type === 'radio') && item.linkSubField && item.linkSubField.length > 0) { arrfield.push(...item.linkSubField) + } else if (item.type === 'checkcard') { + arrfield = item.fields.map(f => f.field) + arrfield.push(item.valueField) } arrfield = Array.from(new Set(arrfield)) @@ -684,9 +687,9 @@ arrfield = arrfield.join(',') if (item.orderBy) { - sql = `select ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}` + sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield},${item.orderBy} as orderfield from ${_datasource} ) a order by orderfield ${item.orderType}` } else { - sql = 'select distinct ' + arrfield + ' from ' + _datasource + sql = `select ${item.type === 'checkcard' ? 'top 20' : ''} ${arrfield} from (select distinct ${arrfield} from ${_datasource})` } return { @@ -1026,18 +1029,14 @@ }) // 闇�瑕佸0鏄庣殑鍙橀噺闆� - // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode'] // 涓婚敭瀛楁 let primaryKey = setting.primaryKey || 'id' - // 绯荤粺鍙橀噺澹版槑涓庤缃垵濮嬪�� - let _sql = `/* 绯荤粺鐢熸垚 */ - Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50) - ` + // sql璇彞 + let _sql = '' - // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 宸茶祴鍊煎瓧娈甸泦 let _initvars = [] // 宸茶祴鍊煎瓧娈甸泦 let _initfields = [] let _declarefields = [] @@ -1140,10 +1139,11 @@ // 鍙橀噺澹版槑 _declarefields = _declarefields.join(',') if (_declarefields) { - _sql = `/* 绯荤粺鐢熸垚 */ - Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50),${_declarefields} - ` + _declarefields = ',' + _declarefields } + _sql = `/* 绯荤粺鐢熸垚 */ + Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields} + ` // 鍙橀噺璧嬪�� _initfields = _initfields.join(',') -- Gitblit v1.8.0