From f36141f3075edf9d41928d64f759ad6bd1b1ac60 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 七月 2020 17:43:34 +0800 Subject: [PATCH] 2020-07-14 --- src/mob/datasource/verifycard/settingform/index.scss | 40 src/views/pay/index.scss | 53 + src/mob/datasource/verifycard/customscript/index.jsx | 13 src/tabviews/zshare/topSearch/index.jsx | 253 ++++- src/mob/datasource/index.jsx | 18 src/templates/sharecomponent/searchcomponent/index.jsx | 14 src/mob/datasource/verifycard/columnform/index.scss | 0 src/mob/components/login/mob-login-2/index.jsx | 78 + src/tabviews/zshare/actionList/index.jsx | 1 src/api/index.js | 2 src/tabviews/zshare/actionList/newpagebutton/index.scss | 12 src/tabviews/zshare/actionList/newpagebutton/index.jsx | 26 src/tabviews/subtable/index.jsx | 205 +--- src/templates/sharecomponent/settingcomponent/settingform/index.jsx | 4 src/tabviews/subtabtable/index.jsx | 195 +-- src/tabviews/commontable/index.jsx | 141 -- src/tabviews/zshare/actionList/normalbutton/index.jsx | 24 src/views/mobdesign/index.jsx | 17 src/mob/components/login/mob-login-2/index.scss | 47 src/mob/controller/index.jsx | 61 src/locales/zh-CN/mob.js | 2 src/mob/datasource/index.scss | 1 src/mob/datasource/verifycard/index.jsx | 880 ++--------------- src/mob/datasource/verifycard/settingform/index.jsx | 394 +++---- src/templates/zshare/formconfig.jsx | 69 src/tabviews/zshare/actionList/printbutton/index.jsx | 20 src/store/options.js | 4 src/views/pay/index.jsx | 171 ++ src/assets/img/weixinpaylogo.jpg | 0 /dev/null | 0 src/mob/contupdate/index.jsx | 23 src/mob/datasource/verifycard/columnform/index.jsx | 137 ++ src/mob/contupdate/index.scss | 8 src/tabviews/zshare/cardcomponent/index.jsx | 1 src/locales/en-US/mob.js | 2 src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 6 36 files changed, 1,304 insertions(+), 1,618 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index d2082ee..0eac63a 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -11,7 +11,7 @@ axios.interceptors.request.use((config) => { config.method = 'post' - if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult')) { + if (config.url.includes('LoginAndRedirect') || config.url.includes('getjsonresult') || config.url.includes('wxNativePay')) { config.data = qs.stringify(config.data) } else if (config.url.includes('Upload') || config.url.includes('doupload') || config.url.includes('dopreload')) { config.headers = { 'Content-Type': 'multipart/form-data' } diff --git a/src/assets/img/weixinpaylogo.jpg b/src/assets/img/weixinpaylogo.jpg new file mode 100644 index 0000000..9ee05f6 --- /dev/null +++ b/src/assets/img/weixinpaylogo.jpg Binary files differ diff --git a/src/locales/en-US/mob.js b/src/locales/en-US/mob.js index 4e8b687..3659cb8 100644 --- a/src/locales/en-US/mob.js +++ b/src/locales/en-US/mob.js @@ -3,7 +3,9 @@ 'mob.confirm': '纭畾', 'mob.submit': '鎻愪氦', 'mob.cancel': '鍙栨秷', + 'mob.edit': '缂栬緫', 'mob.header.logout': '閫�鍑�', + 'mob.query.delete': '纭畾鍒犻櫎鍚楋紵', 'mob.header.logout.hint': '鎮ㄧ‘瀹氳閫�鍑哄悧?', 'mob.required.input': '璇疯緭鍏�', 'mob.required.select': '璇烽�夋嫨', diff --git a/src/locales/zh-CN/mob.js b/src/locales/zh-CN/mob.js index 4e8b687..3659cb8 100644 --- a/src/locales/zh-CN/mob.js +++ b/src/locales/zh-CN/mob.js @@ -3,7 +3,9 @@ 'mob.confirm': '纭畾', 'mob.submit': '鎻愪氦', 'mob.cancel': '鍙栨秷', + 'mob.edit': '缂栬緫', 'mob.header.logout': '閫�鍑�', + 'mob.query.delete': '纭畾鍒犻櫎鍚楋紵', 'mob.header.logout.hint': '鎮ㄧ‘瀹氳閫�鍑哄悧?', 'mob.required.input': '璇疯緭鍏�', 'mob.required.select': '璇烽�夋嫨', diff --git a/src/mob/components/login/mob-login-2/index.jsx b/src/mob/components/login/mob-login-2/index.jsx index d9a4653..6a9e31f 100644 --- a/src/mob/components/login/mob-login-2/index.jsx +++ b/src/mob/components/login/mob-login-2/index.jsx @@ -2,6 +2,7 @@ import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { InputItem, Button } from 'antd-mobile' +import { Icon } from 'antd' import zhCN from '@/locales/zh-CN/mob.js' import enUS from '@/locales/en-US/mob.js' @@ -31,8 +32,15 @@ login: { uuid: Utils.getuuid(), eleType: 'button', content: '鐧诲綍', style: {fontSize: '16px', color: '#ffffff', textAlign: 'center', lineHeight: 2.4, backgroundColor: '#44a8f2'}}, phone: { uuid: Utils.getuuid(), eleType: 'button', content: '鎵嬫満鐭俊鐧诲綍/娉ㄥ唽', style: {fontSize: '16px', color: '#44a8f2', textAlign: 'center', lineHeight: 2.4, border: '1px solid #44a8f2'}}, lose: { uuid: Utils.getuuid(), eleType: 'text', content: '蹇樿瀵嗙爜锛�', style: {fontSize: '12px', color: '#44a8f2', textAlign: 'right', textDecoration: 'underline'}}, - register: { uuid: Utils.getuuid(), eleType: 'text', content: '娉ㄥ唽鏄庣璐﹀彿', style: {fontSize: '16px', color: '#44a8f2', textAlign: 'center', marginTop: '20px', marginBottom: '30px'}}, - copyright: { uuid: Utils.getuuid(), eleType: 'textarea', content: 'Copyright漏2017 鎵�鏈夌浉鍏崇増鏉冨綊 鍖椾含鏄庣鏅崕淇℃伅鎶�鏈湁闄愬叕鍙�', style: {fontSize: '12px', textAlign: 'center'} } + register: { uuid: Utils.getuuid(), eleType: 'text', subItems: [ + {type: 'qq', icon: 'qq', label: 'QQ'}, + {type: 'wechat', icon: 'wechat', label: '寰俊'}, + ], content: '鍏朵粬鐧诲綍鏂瑰紡', style: {fontSize: '14px', color: '#bcbcbc', textAlign: 'center', marginTop: '30px', marginBottom: '20px'}}, + copyright: { uuid: Utils.getuuid(), eleType: 'textarea', content: 'Copyright漏2017 鎵�鏈夌浉鍏崇増鏉冨綊 鍖椾含鏄庣鏅崕淇℃伅鎶�鏈湁闄愬叕鍙�', style: {fontSize: '12px', textAlign: 'center'} }, + links: { uuid: Utils.getuuid(), eleType: 'link', substyle: false, subItems: [ + {eleType: 'link', content: '闅愮鏀跨瓥', url: '', uuid: Utils.getuuid()}, + {eleType: 'link', content: '浣跨敤鏉℃', url: '', uuid: Utils.getuuid()}, + ], style: {fontSize: '12px', textAlign: 'center', color: '#44a8f2', textDecoration: 'underline'} } } } @@ -79,6 +87,19 @@ ...fromJS(card.copyright.style).toJS(), componentId: card.uuid, uuid: card.copyright.uuid, + items: ['font'], + } + this.props.triggerEdit(element) + } + + editLinks = (e, item) => { + const { card } = this.props + e.stopPropagation() + let element = { + ...fromJS(card.links.style).toJS(), + componentId: card.uuid, + classId: card.links.uuid, + uuid: item.uuid, items: ['font'], } this.props.triggerEdit(element) @@ -132,7 +153,39 @@ this.props.triggerEdit(element) } + linkItemAdd = (e) => { + let card = fromJS(this.props.card).toJS() + e.stopPropagation() + + card.links.subItems.push({ + eleType: 'link', + content: 'link', + url: '', + uuid: Utils.getuuid() + }) + + this.props.updateConfig(card) + } + updateContent = (card) => { + this.props.updateConfig(card) + } + + updateLinkItem = (val, item) => { + let card = fromJS(this.props.card).toJS() + + if (!val) { + card.links.subItems = card.links.subItems.filter(cell => cell.uuid !== item.uuid) + } else { + card.links.subItems = card.links.subItems.map(cell => { + if (cell.uuid === item.uuid) { + return val + } else { + return cell + } + }) + } + this.props.updateConfig(card) } @@ -155,7 +208,7 @@ if (view === 'account') return ( <div className="mob-login-2" onClick={this.editBox} style={card.box.style}> <div className="mob-login-body"> - {card.title ? <div className={'plat-name ' + (editId === card.title.uuid ? 'editing' : '')} style={card.title.style} onClick={this.editTitle}> + {card.title ? <div className={'plat-name ' + (editId === card.title.uuid ? 'editing' : '')} style={titleStyle} onClick={this.editTitle}> <ContentUpdate element={card.title} updateContent={(ele) => this.updateContent({...card, title: ele})}/> {card.title.content} </div> : null} @@ -183,7 +236,7 @@ style={card.phone.style} onClick={(e) => this.editLogin(e, 'phone')} > - <ContentUpdate element={card.phone} deletable={false} updateContent={(ele) => this.updateContent({...card, phone: ele})}/> + <ContentUpdate element={card.phone} updateContent={(ele) => this.updateContent({...card, phone: ele})}/> {card.phone.content} </Button> {card.lose ? <div className={'plat-name ' + (editId === card.lose.uuid ? 'editing' : '')} style={card.lose.style} onClick={this.editLose}> @@ -194,11 +247,28 @@ <ContentUpdate element={card.register} updateContent={(ele) => this.updateContent({...card, register: ele})}/> {card.register.content} </div> : null} + {card.register ? <div className="other-register"> + {card.register.subItems.map(cell => ( + <span key={cell.type}> + <Icon type={cell.icon} /> + <p>{cell.label}</p> + </span> + ))} + </div> : null} </div> {card.copyright ? <div className={'company-msg ' + (editId === card.copyright.uuid ? 'editing' : '')} style={card.copyright.style} onClick={this.editMsg}> <ContentUpdate element={card.copyright} updateContent={(ele) => this.updateContent({...card, copyright: ele})}/> {card.copyright.content} </div> : null} + {card.links ? <div className="links" style={card.links.style}> + {card.links.subItems.map(item => ( + <span className={(editId === item.uuid ? 'editing' : '')} key={item.uuid} onClick={(e) => this.editLinks(e, item)}> + <ContentUpdate element={item} updateContent={(val) => this.updateLinkItem(val, item)}/> + {item.content} + </span> + ))} + <Icon type="plus" onClick={this.linkItemAdd} /> + </div> : null} </div> ) } diff --git a/src/mob/components/login/mob-login-2/index.scss b/src/mob/components/login/mob-login-2/index.scss index a833946..1256cf0 100644 --- a/src/mob/components/login/mob-login-2/index.scss +++ b/src/mob/components/login/mob-login-2/index.scss @@ -32,6 +32,23 @@ .plat-name:not(.editing):hover { border-color: #535353; } + .other-register { + text-align: center; + font-size: 26px; + color: rgb(68, 168, 242); + + span { + display: inline-block; + vertical-align: top; + p { + font-size: 12px; + margin-bottom: 10px; + } + } + span:not(:last-child) { + margin-right: 15px; + } + } .am-list-item { position: relative; @@ -119,6 +136,36 @@ .company-msg:not(.editing):hover { border-color: #535353; } + + .links { + min-height: 10px; + font-size: 12px; + text-align: center; + line-height: 1.5; + + span { + display: inline-block; + position: relative; + text-decoration: inherit; + font-style: inherit; + min-width: 40px; + border: 1px dotted transparent; + } + span:not(:last-child) { + margin-right: 10px; + } + span:hover { + border-color: #535353; + } + span.editing { + border: 1px solid #1890ff; + box-shadow: 0px 0px 2px #1890ff; + } + >.anticon-plus { + cursor: pointer; + color: #26C281; + } + } } .am-picker-popup-wrap { left: calc(50vw - 305px); diff --git a/src/mob/controller/index.jsx b/src/mob/controller/index.jsx index 6e822f7..a10efeb 100644 --- a/src/mob/controller/index.jsx +++ b/src/mob/controller/index.jsx @@ -65,61 +65,60 @@ return !is(fromJS(this.state), fromJS(nextState)) } + updateStyle = (style) => { + const { card } = this.state + + this.props.updateStyle({componentId: card.componentId, classId: card.classId, uuid: card.uuid, style}) + } + /** * @description 瀛椾綋澶у皬鍒囨崲锛岃秴鍑鸿寖鍥村拷鐣� */ changeFontSize = (val) => { - const { card } = this.state let value = parseInt(val) if (isNaN(value) || value < 12 || value > 100) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontSize: `${value}px`}}) + this.updateStyle({fontSize: `${value}px`}) } /** * @description 淇敼琛岄棿璺濓紝瓒呭嚭鑼冨洿蹇界暐 */ changeLineHeight = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 1 || value > 10) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {lineHeight: value}}) + this.updateStyle({lineHeight: value}) } /** * @description 瀛椾綋闂磋窛淇敼锛岃秴鍑鸿寖鍥村拷鐣� */ changeLetterSpacing = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 0 || value > 100) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {letterSpacing: `${value}px`}}) + this.updateStyle({letterSpacing: `${value}px`}) } /** * @description 淇敼瀛椾綋绮楃粏 */ boldChange = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontWeight: val}}) + this.updateStyle({fontWeight: val}) } /** * @description 淇敼瀛椾綋棰滆壊 锛岄鑹叉帶浠� */ changeFontColor = (val) => { - const { card } = this.state - this.setState({ fontColor: val }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {color: val}}) + this.updateStyle({color: val}) } /** @@ -135,39 +134,31 @@ * @description 瀛椾綋瀵归綈 */ changeTextAlign = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textAlign: e.target.value}}) + this.updateStyle({textAlign: e.target.value}) } /** * @description 瀛椾綋鏍峰紡锛屽�炬枩 */ changeFontStyle = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontStyle: e.target.value}}) + this.updateStyle({fontStyle: e.target.value}) } /** * @description 瀛椾綋瑁呴グ锛屼笅鍒掔嚎銆佽疮绌跨嚎銆佷笂鍒掔嚎 */ changeTextDecoration = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textDecoration: e.target.value}}) + this.updateStyle({textDecoration: e.target.value}) } /** * @description 淇敼鑳屾櫙棰滆壊 锛岄鑹叉帶浠� */ changeBackgroundColor = (val) => { - const { card } = this.state - this.setState({ backgroundColor: val }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundColor: val}}) + this.updateStyle({backgroundColor: val}) } /** @@ -180,14 +171,12 @@ } imgChange = (list) => { - const { card } = this.state - if (list[0] && list[0].response) { this.setState({ bgimages: [], backgroundImage: list[0].response }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: `url(${list[0].response})`}}) + this.updateStyle({backgroundImage: `url(${list[0].response})`}) } else { this.setState({bgimages: list}) } @@ -200,7 +189,6 @@ } submitBackgroundImage = (e) => { - const { card } = this.state let val = e.target.value val = val.replace(/^\s*|\s*$/ig, '') @@ -210,22 +198,19 @@ val = `linear-gradient(${val})` } - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: val}}) + this.updateStyle({backgroundImage: val}) } submitBorder = (val, type) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {[type]: val}}) + this.updateStyle({[type]: val}) } changeBorderRadius = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 0 || value > 500) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {borderRadius: `${value}px`}}) + this.updateStyle({borderRadius: `${value}px`}) } changeMarginTop = (e) => { @@ -244,12 +229,10 @@ } submitMarginTop = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginTop: val}}) this.setState({ marginTop: val }) + this.updateStyle({marginTop: val}) } changeMarginBottom = (e) => { @@ -268,12 +251,10 @@ } submitMarginBottom = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginBottom: val}}) this.setState({ marginBottom: val }) + this.updateStyle({marginBottom: val}) } render () { diff --git a/src/mob/contupdate/index.jsx b/src/mob/contupdate/index.jsx index bbdf676..1fc2b9a 100644 --- a/src/mob/contupdate/index.jsx +++ b/src/mob/contupdate/index.jsx @@ -35,15 +35,24 @@ onVisibleChange = (visible) => { const { element } = this.props let val = this.props.form.getFieldValue('content') + let _url = this.props.form.getFieldValue('url') this.setState({ visible: visible }) - if (val && element.content !== val) { - this.props.updateContent({...element, content: val}) + if (element.eleType === 'link') { + if ((val && element.content !== val) || (_url && element.url !== _url)) { + this.props.updateContent({...element, content: val, url: _url}) + } else { + this.props.form.setFieldsValue({content: element.content, url: element.url}) + } } else { - this.props.form.setFieldsValue({content: element.content}) + if (val && element.content !== val) { + this.props.updateContent({...element, content: val}) + } else { + this.props.form.setFieldsValue({content: element.content}) + } } } @@ -108,6 +117,14 @@ <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> : <TextArea autosize={{ minRows: 2, maxRows: 3 }} onPressEnter={this.handleSubmit} /> )} + {element.eleType === 'link' ? <div className="link-url"> + <p>閾炬帴鍦板潃:</p> + {getFieldDecorator('url', { + initialValue: element.url + })( + <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> + )} + </div> : null} </div> } overlayClassName="mob-content-update-popover" placement="bottomRight" title="" visible={visible} trigger="click" onVisibleChange={this.onVisibleChange}> <Icon type="edit" /> diff --git a/src/mob/contupdate/index.scss b/src/mob/contupdate/index.scss index 7e15ba9..34a4615 100644 --- a/src/mob/contupdate/index.scss +++ b/src/mob/contupdate/index.scss @@ -8,6 +8,7 @@ display: none; line-height: 1.5; z-index: 1; + white-space: nowrap; i { padding: 2px 5px; @@ -42,4 +43,11 @@ textarea { width: 270px; } + .link-url { + p { + margin: 10px 0px 5px 5px; + font-size: 14px; + color: #959595; + } + } } diff --git a/src/mob/datasource/index.jsx b/src/mob/datasource/index.jsx index 3b1cfd1..f40dd17 100644 --- a/src/mob/datasource/index.jsx +++ b/src/mob/datasource/index.jsx @@ -18,6 +18,7 @@ state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, sourcelist: [], + searches: [], visible: false, source: null } @@ -31,15 +32,21 @@ } editDataSource = (item) => { + // const { config } = this.props + if (!item) { item = { - uuid: Utils.getuuid() + uuid: Utils.getuuid(), + setting: {}, + columns: [], + scripts: [] } } this.setState({ visible: true, - source: item + source: item, + searches: [] }) } @@ -48,7 +55,7 @@ } render () { - const { sourcelist, visible, source, dict } = this.state + const { sourcelist, visible, source, dict, searches } = this.state return ( <div className="mob-datasource"> @@ -78,13 +85,16 @@ maskClosable={false} style={{minWidth: '900px', maxWidth: '1200px'}} okText={dict['mob.submit']} + cancelText={dict['mob.cancel']} onOk={this.verifySubmit} onCancel={() => { this.setState({ visible: false }) }} destroyOnClose > <VerifyCard - card={source} dict={dict} + card={source} + menuId={this.props.config.uuid} + searches={searches} wrappedComponentRef={(inst) => this.verifyRef = inst} /> </Modal> diff --git a/src/mob/datasource/index.scss b/src/mob/datasource/index.scss index 00ba2d7..cd00e3a 100644 --- a/src/mob/datasource/index.scss +++ b/src/mob/datasource/index.scss @@ -2,6 +2,7 @@ width: 100%; height: 100%; overflow: hidden; + padding-top: 15px; .mob-input-group-wrapper { padding: 0 20px; diff --git a/src/mob/datasource/verifycard/billcodeform/index.jsx b/src/mob/datasource/verifycard/billcodeform/index.jsx deleted file mode 100644 index 1c5591a..0000000 --- a/src/mob/datasource/verifycard/billcodeform/index.jsx +++ /dev/null @@ -1,374 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Form, Row, Col, Select, Button, InputNumber, Input, Tooltip, Icon } from 'antd' -import { formRule } from '@/utils/option.js' -import './index.scss' - - -class UniqueForm extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - btn: PropTypes.object, // 鎸夐挳淇℃伅 - fields: PropTypes.array, // 琛ㄥ崟 - billcodes: PropTypes.array, // 琛ㄥ崟 - columns: PropTypes.array, // 琛ㄥ崟 - modular: PropTypes.array, // 琛ㄥ崟 - modularDetail: PropTypes.array, // 琛ㄥ崟 - orderChange: PropTypes.func // 琛ㄥ崟 - } - - state = { - editItem: null, - modularDetail: [], - funFields: [], - billFields: [], - type: '1', - TypeCharOne: 'Lp' - } - - UNSAFE_componentWillMount() { - let _modularDetail = [] - let _billFields = [] - if (this.props.modular.length > 0) { - _modularDetail = this.props.modularDetail.filter(item => item.BID === this.props.modular[0].ID) - } - - let fieldMap = new Map() - this.props.fields.forEach(_field => { - if (_field.type === 'text' && !fieldMap.has(_field.field)) { - _billFields.push(_field) - fieldMap.set(_field.field, true) - } - }) - - if (this.props.btn.Ot !== 'notRequired') { - this.props.columns.forEach(_field => { - if (_field.type === 'text' && !fieldMap.has(_field.field)) { - _billFields.push(_field) - fieldMap.set(_field.field, true) - } - }) - } - - let _usedfields = this.props.billcodes.map(item => item.field) - - this.setState({ - modularDetail: _modularDetail, - funFields: this.props.fields.filter(field => field.type === 'funcvar' && !_usedfields.includes(field.field)), - billFields: _billFields - }) - } - - UNSAFE_componentWillReceiveProps (nextProps) { - if (!is(fromJS(this.props.modular), fromJS(nextProps.modular))) { - let _detail = nextProps.modularDetail.filter(item => item.BID === nextProps.modular[0].ID) - - this.setState({ - modularDetail: _detail - }) - } - } - - edit = (record) => { - let _usedfields = this.props.billcodes.map(item => item.field) - let _funFields = this.props.fields.filter(field => field.type === 'funcvar' && (!_usedfields.includes(field.field) || field.field === record.field)) - - if (record.TypeCharOne === 'Y' || record.TypeCharOne === 'n') { - let _detail = this.props.modularDetail.filter(item => item.BID === record.ModularCode) - let _modularDetailCode = '' - - if (_detail.filter(item => item.ModularDetailCode === record.ModularDetailCode).length > 0) { - _modularDetailCode = record.ModularDetailCode - } - - this.setState({ - type: '2', - funFields: _funFields, - editItem: record, - modularDetail: _detail, - TypeCharOne: record.TypeCharOne - }, () => { - this.props.form.setFieldsValue({ - field: record.field, - TypeCharOne: record.TypeCharOne, - ModularCode: record.ModularCode, - ModularDetailCode: _modularDetailCode, - }) - }) - } else { - this.setState({ - type: '1', - funFields: _funFields, - editItem: record, - TypeCharOne: record.TypeCharOne - }, () => { - let _form = { - field: record.field, - TypeCharOne: record.TypeCharOne, - Type: record.Type, - linkField: record.linkField - } - if (record.TypeCharOne === 'Lp') { - _form.mark = record.mark || '' - } - this.props.form.setFieldsValue(_form) - }) - } - } - - voucherChange = (value) => { - let _detail = this.props.modularDetail.filter(item => item.BID === value) - - this.setState({ - modularDetail: _detail - }) - this.props.form.setFieldsValue({ - ModularDetailCode: _detail[0] ? _detail[0].ModularDetailCode : '' - }) - } - - TypeCharOneChange = (value) => { - if (value === 'Y' || value === 'n') { - this.setState({ - type: '2', - TypeCharOne: value - }) - } else { - this.setState({ - type: '1', - TypeCharOne: value - }) - } - } - - handleConfirm = () => { - const { funFields, billFields } = this.state - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - let _funField = funFields.filter(item => item.field === values.field)[0] - values.fieldName = _funField ? _funField.label : '' - - // 涓�绾ц彍鍗曞�间负20190203125926873D6029A9C511041719420鏃禩ypeCharTwo=TableCode锛屽叾浠栫敤BillCode - if (values.ModularCode === '20190203125926873D6029A9C511041719420') { - values.TypeCharTwo = 'TableCode' - } else { - values.TypeCharTwo = 'BillCode' - } - // 璁剧疆绫诲瀷鍚嶇О锛岀敤浜庡垪琛ㄦ樉绀� - let billType = { - Y: '鍗曞彿', - n: '缂栫爜', - Lp: '琛屽彿', - BN: '鎵规', - } - values.billType = billType[values.TypeCharOne] - - if (values.TypeCharOne === 'Y' || values.TypeCharOne === 'n') { - // 璁剧疆鍑瘉绫诲瀷涓枃鍚� - let ModularCode = this.props.modular.filter(item => item.ID === values.ModularCode)[0] - values.ModularCodeName = ModularCode.NameNO - - // 璁剧疆娴佹按鍙蜂綅鏁� - let _detail = this.state.modularDetail.filter(item => item.ModularDetailCode === values.ModularDetailCode)[0] - values.Type = _detail.Type - } else { - let _billField = billFields.filter(item => item.field === values.linkField)[0] - values.linkFieldName = _billField ? _billField.label : '' - } - - this.setState({ - editItem: null - }, () => { - this.props.orderChange(values) - let _usedfields = this.props.billcodes.map(item => item.field) - - this.setState({ - funFields: this.props.fields.filter(field => field.type === 'funcvar' && !_usedfields.includes(field.field)), - }) - }) - let _form = { - field: '' - } - if (this.state.TypeCharOne === 'Lp') { - _form.mark = '' - } - this.props.form.setFieldsValue(_form) - } - }) - } - - render() { - const { getFieldDecorator } = this.props.form - const { type, TypeCharOne } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 10 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 14 } - } - } - - return ( - <Form {...formItemLayout} className="verify-form"> - <Row gutter={24}> - <Col span={7}> - <Form.Item label={this.props.dict['header.form.funcvar']}> - {getFieldDecorator('field', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + this.props.dict['header.form.funcvar'] + '!' - } - ] - })( - <Select> - {this.state.funFields.map(option => - <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}> - {option.label} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'绫诲瀷'}> - {getFieldDecorator('TypeCharOne', { - initialValue: 'Lp', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '绫诲瀷!' - } - ] - })( - <Select onChange={(value) => {this.TypeCharOneChange(value)}}> - <Select.Option value="Y"> 鍗曞彿 </Select.Option> - <Select.Option value="n"> 缂栫爜 </Select.Option> - <Select.Option value="Lp"> 琛屽彿 </Select.Option> - <Select.Option value="BN"> 鎵规 </Select.Option> - </Select> - )} - </Form.Item> - </Col> - {type === '1' ? <Col span={7}> - <Form.Item label={'鍏宠仈瀛楁'}> - {getFieldDecorator('linkField', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍏宠仈瀛楁!' - } - ] - })( - <Select> - {this.state.billFields.map(option => - <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}> - {option.label} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> : null} - {type === '2' ? <Col span={7}> - <Form.Item label={'鍑瘉绫诲瀷'}> - {getFieldDecorator('ModularCode', { - initialValue: this.props.modular[0] ? this.props.modular[0].ID : '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍑瘉绫诲瀷!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.voucherChange(value)}} - > - {this.props.modular.map(option => - <Select.Option title={option.NameNO} id={option.ID} key={option.ID} value={option.ID}> - {option.NameNO} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> : null} - <Col span={3} className="add"> - <Button onClick={this.handleConfirm} className="mk-green"> - 淇濆瓨 - </Button> - </Col> - {type === '1' ? <Col span={7}> - <Form.Item label={'浣嶆暟'}> - {getFieldDecorator('Type', { - initialValue: 4, - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '浣嶆暟!' - } - ] - })(<InputNumber min={1} max={10} precision={0} />)} - </Form.Item> - </Col> : null} - {type === '2' ? <Col span={7}> - <Form.Item label={'鍑瘉鏍囪瘑'}> - {getFieldDecorator('ModularDetailCode', { - initialValue: this.state.modularDetail[0] ? this.state.modularDetail[0].ModularDetailCode : '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍑瘉鏍囪瘑!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {this.state.modularDetail.map(option => - <Select.Option style={{whiteSpace: 'unset'}} title={option.CodeName} id={option.ModularDetailCode} key={option.ModularDetailCode} value={option.ModularDetailCode}> - {option.CodeName} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> : null} - {TypeCharOne === 'Lp' ? <Col span={7}> - <Form.Item label={ - <Tooltip placement="topLeft" title="璇ユ爣璇嗙敤浜庣敓鎴愯鍙疯鍒欙紝涓虹┖鏃朵娇鐢ㄦ寜閽甀D"> - <Icon type="question-circle" /> - {'鏍囪瘑'} - </Tooltip> - }> - {getFieldDecorator('mark', { - initialValue: '', - rules: [ - { - pattern: /^[a-zA-Z0-9]*$/ig, - message: formRule.input.letternummsg - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> : null} - </Row> - </Form> - ) - } -} - -export default Form.create()(UniqueForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/billcodeform/index.scss b/src/mob/datasource/verifycard/billcodeform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/mob/datasource/verifycard/billcodeform/index.scss +++ /dev/null diff --git a/src/mob/datasource/verifycard/columnform/index.jsx b/src/mob/datasource/verifycard/columnform/index.jsx new file mode 100644 index 0000000..31fbe81 --- /dev/null +++ b/src/mob/datasource/verifycard/columnform/index.jsx @@ -0,0 +1,137 @@ +import React, {Component} from 'react' +import PropTypes from 'prop-types' +import { Form, Row, Col, Select, Button, Input } from 'antd' +import './index.scss' + + +class UniqueForm extends Component { + static propTpyes = { + dict: PropTypes.object, // 瀛楀吀椤� + columnChange: PropTypes.func // 淇敼鍑芥暟 + } + + state = { + editItem: null // 缂栬緫鍏冪礌 + } + + edit = (record) => { + this.setState({ + editItem: record + }) + + this.props.form.setFieldsValue({ + label: record.label, + field: record.field, + datatype: record.datatype + }) + } + + + handleConfirm = () => { + // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + values.uuid = this.state.editItem ? this.state.editItem.uuid : '' + + this.setState({ + editItem: null + }, () => { + this.props.columnChange(values) + }) + this.props.form.setFieldsValue({ + label: '', + field: '' + }) + } + }) + } + + render() { + const { getFieldDecorator } = this.props.form + const formItemLayout = { + labelCol: { + xs: { span: 24 }, + sm: { span: 8 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + } + } + + return ( + <Form {...formItemLayout} className="verify-form" id="verifycard1"> + <Row gutter={24}> + <Col span={7}> + <Form.Item label={'鍚嶇О'}> + {getFieldDecorator('label', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '鍚嶇О!' + } + ] + })(<Input placeholder="" autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={7}> + <Form.Item label={'瀛楁'}> + {getFieldDecorator('field', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '瀛楁!' + } + ] + })(<Input placeholder="" autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={7}> + <Form.Item label={'鏁版嵁绫诲瀷'}> + {getFieldDecorator('datatype', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['form.required.select'] + '鏁版嵁绫诲瀷!' + } + ] + })( + <Select> + <Select.Option value="Nvarchar(10)"> Nvarchar(10) </Select.Option> + <Select.Option value="Nvarchar(20)"> Nvarchar(20) </Select.Option> + <Select.Option value="Nvarchar(50)"> Nvarchar(50) </Select.Option> + <Select.Option value="Nvarchar(100)"> Nvarchar(100) </Select.Option> + <Select.Option value="Nvarchar(512)"> Nvarchar(512) </Select.Option> + <Select.Option value="Nvarchar(1024)"> Nvarchar(1024) </Select.Option> + <Select.Option value="Nvarchar(2048)"> Nvarchar(2048) </Select.Option> + <Select.Option value="Nvarchar(max)"> Nvarchar(max) </Select.Option> + <Select.Option value="Int"> Int </Select.Option> + <Select.Option value="Decimal(18,0)"> Decimal(18,0) </Select.Option> + <Select.Option value="Decimal(18,1)"> Decimal(18,1) </Select.Option> + <Select.Option value="Decimal(18,2)"> Decimal(18,2) </Select.Option> + <Select.Option value="Decimal(18,3)"> Decimal(18,3) </Select.Option> + <Select.Option value="Decimal(18,4)"> Decimal(18,4) </Select.Option> + <Select.Option value="Decimal(18,5)"> Decimal(18,5) </Select.Option> + <Select.Option value="Decimal(18,6)"> Decimal(18,6) </Select.Option> + <Select.Option value="Decimal(18,7)"> Decimal(18,7) </Select.Option> + <Select.Option value="Decimal(18,8)"> Decimal(18,8) </Select.Option> + <Select.Option value="date"> date </Select.Option> + </Select> + )} + </Form.Item> + </Col> + <Col span={3} className="add"> + <Button onClick={this.handleConfirm} type="primary" className="mk-green"> + 淇濆瓨 + </Button> + </Col> + </Row> + </Form> + ) + } +} + +export default Form.create()(UniqueForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/contrastform/index.scss b/src/mob/datasource/verifycard/columnform/index.scss similarity index 100% rename from src/mob/datasource/verifycard/contrastform/index.scss rename to src/mob/datasource/verifycard/columnform/index.scss diff --git a/src/mob/datasource/verifycard/contrastform/index.jsx b/src/mob/datasource/verifycard/contrastform/index.jsx deleted file mode 100644 index 9393dc5..0000000 --- a/src/mob/datasource/verifycard/contrastform/index.jsx +++ /dev/null @@ -1,166 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Select, Button, Input } from 'antd' -import './index.scss' - - -class UniqueForm extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - contrastChange: PropTypes.func // 淇敼鍑芥暟 - } - - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - frontfield: record.frontfield, - operator: record.operator, - backfield: record.backfield, - errmsg: record.errmsg, - errorCode: record.errorCode - }) - } - - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - - this.setState({ - editItem: null - }, () => { - this.props.contrastChange(values) - }) - this.props.form.setFieldsValue({ - frontfield: '', - backfield: '', - errmsg: '' - }) - } - }) - } - - render() { - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="verify-form" id="verifycard1"> - <Row gutter={24}> - <Col span={7}> - <Form.Item label={'鍐呭1'}> - {getFieldDecorator('frontfield', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍐呭1!' - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'杩愮畻绗�'}> - {getFieldDecorator('operator', { - initialValue: '=', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '杩愮畻绗�!' - } - ] - })( - <Select> - <Select.Option value="="> = </Select.Option> - <Select.Option value="!="> != </Select.Option> - <Select.Option value=">"> > </Select.Option> - <Select.Option value="<"> < </Select.Option> - <Select.Option value=">="> >= </Select.Option> - <Select.Option value="<="> <= </Select.Option> - <Select.Option value="in"> in </Select.Option> - <Select.Option value="like"> like </Select.Option> - </Select> - )} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'鍐呭2'}> - {getFieldDecorator('backfield', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍐呭2!' - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={3} className="add"> - <Button onClick={this.handleConfirm} type="primary" className="mk-green"> - 淇濆瓨 - </Button> - </Col> - <Col span={7}> - <Form.Item label={'鎻愮ず淇℃伅'}> - {getFieldDecorator('errmsg', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鎻愮ず淇℃伅!' - }, - { - pattern: /^[^']*$/ig, - message: '鎻愮ず淇℃伅涓嶅厑璁稿寘鍚玕'' - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'鎶ラ敊缂栫爜'}> - {getFieldDecorator('errorCode', { - initialValue: 'E', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!' - } - ] - })( - <Select> - <Select.Option value="E"> E </Select.Option> - <Select.Option value="N"> N </Select.Option> - <Select.Option value="F"> F </Select.Option> - <Select.Option value="NM"> NM </Select.Option> - </Select> - )} - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(UniqueForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/customform/index.jsx b/src/mob/datasource/verifycard/customform/index.jsx deleted file mode 100644 index 39b4d2e..0000000 --- a/src/mob/datasource/verifycard/customform/index.jsx +++ /dev/null @@ -1,232 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Select, Button, notification, Modal } from 'antd' -import moment from 'moment' - -import Utils from '@/utils/utils.js' -import Api from '@/api' -import './index.scss' - -const { TextArea } = Input - -class CustomForm extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - btn: PropTypes.object, // 鎸夐挳 - usefulfields: PropTypes.string, // 鍙敤瀛楁 - initsql: PropTypes.string, // 鍙敤瀛楁 - customChange: PropTypes.func // 琛ㄥ崟 - } - - state = { - editItem: null, - loading: false - } - - edit = (record) => { - this.setState({ - editItem: record - }) - - this.props.form.setFieldsValue({ - sql: record.sql, - result: record.result, - errmsg: record.errmsg, - errorCode: record.errorCode - }) - } - - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - values.resultName = values.result === 'false' ? '涓嶅瓨鍦�' : '瀛樺湪' - - let _quot = values.sql.match(/'{1}/g) - let _lparen = values.sql.match(/\({1}/g) - let _rparen = values.sql.match(/\){1}/g) - - _quot = _quot ? _quot.length : 0 - _lparen = _lparen ? _lparen.length : 0 - _rparen = _rparen ? _rparen.length : 0 - - if (_quot % 2 !== 0) { - notification.warning({ - top: 92, - message: 'sql涓璡'蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (_lparen !== _rparen) { - notification.warning({ - top: 92, - message: 'sql涓�()蹇呴』鎴愬鍑虹幇', - duration: 5 - }) - return - } else if (/--/ig.test(values.sql)) { - notification.warning({ - top: 92, - message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/', - duration: 5 - }) - return - } - - let error = Utils.verifySql(values.sql) - - if (error) { - notification.warning({ - top: 92, - message: 'sql涓笉鍙娇鐢�' + error, - duration: 5 - }) - return - } - - let param = { - func: 's_debug_sql', - LText: this.props.initsql + values.sql - } - - // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/@\$|\$@/ig, '') - - param.LText = Utils.formatOptions(param.LText) - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - this.setState({loading: true}) - Api.getLocalConfig(param).then(res => { - if (res.status) { - this.setState({ - loading: false, - editItem: null - }, () => { - this.props.customChange(values) - }) - this.props.form.setFieldsValue({ - sql: '', - errmsg: '' - }) - } else { - this.setState({loading: false}) - - Modal.error({ - title: res.message - }) - } - }) - } - }) - } - - render() { - const { usefulfields, btn } = this.props - const { getFieldDecorator } = this.props.form - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - return ( - <Form {...formItemLayout} className="verify-form" id="verifycard2"> - <Row gutter={24}> - {usefulfields ? <Col span={21} className="sqlfield"> - <Form.Item label={'鍙敤瀛楁'}> - {usefulfields} - </Form.Item> - </Col> : null} - <Col span={21} className="sql"> - <Form.Item label={'sql'}> - {getFieldDecorator('sql', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + 'sql!' - } - ] - })(<TextArea rows={15} />)} - </Form.Item> - </Col> - <Col span={3} className="add"> - <Button onClick={this.handleConfirm} loading={this.state.loading} className="mk-green"> - 淇濆瓨 - </Button> - {btn.sql ? <div style={{marginTop: '31px'}}> - 琛ㄥ悕: <div style={{wordBreak: 'break-all'}}>{btn.sql}</div> - </div> : null} - </Col> - <Col span={7}> - <Form.Item label={'缁撴灉澶勭悊'}> - {getFieldDecorator('result', { - initialValue: 'true', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '缁撴灉澶勭悊!' - } - ] - })( - <Select> - <Select.Option value="true"> 瀛樺湪 </Select.Option> - <Select.Option value="false"> 涓嶅瓨鍦� </Select.Option> - </Select> - )} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'鎻愮ず淇℃伅'}> - {getFieldDecorator('errmsg', { - initialValue: '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鎻愮ず淇℃伅!' - }, - { - pattern: /^[^']*$/ig, - message: '鎻愮ず淇℃伅涓嶅厑璁稿寘鍚玕'' - } - ] - })(<Input placeholder="" autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={7}> - <Form.Item label={'鎶ラ敊缂栫爜'}> - {getFieldDecorator('errorCode', { - initialValue: 'E', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!' - } - ] - })( - <Select - getPopupContainer={() => document.getElementById('verifycard2')} - > - <Select.Option value="E"> E </Select.Option> - <Select.Option value="N"> N </Select.Option> - <Select.Option value="F"> F </Select.Option> - <Select.Option value="NM"> NM </Select.Option> - </Select> - )} - </Form.Item> - </Col> - - </Row> - </Form> - ) - } -} - -export default Form.create()(CustomForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/customform/index.scss b/src/mob/datasource/verifycard/customform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/mob/datasource/verifycard/customform/index.scss +++ /dev/null diff --git a/src/mob/datasource/verifycard/customscript/index.jsx b/src/mob/datasource/verifycard/customscript/index.jsx index 6c9d489..003bd51 100644 --- a/src/mob/datasource/verifycard/customscript/index.jsx +++ b/src/mob/datasource/verifycard/customscript/index.jsx @@ -4,7 +4,7 @@ import moment from 'moment' import Utils from '@/utils/utils.js' -import SettingUtils from '../utils.jsx' +// import SettingUtils from '../utils.jsx' import Api from '@/api' import './index.scss' @@ -75,7 +75,8 @@ } handleConfirm = () => { - const { setting, arr_field, regoptions, swhere } = this.props + // const { setting, arr_field, regoptions, swhere } = this.props + const { setting } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� this.props.form.validateFieldsAndScroll((err, values) => { @@ -149,11 +150,11 @@ ` } - let _setting = {...setting, customScript: _customScript} + // let _setting = {...setting, customScript: _customScript} let param = { func: 's_debug_sql', - LText: SettingUtils.getDebugSql(_setting, arr_field, regoptions, swhere) + // LText: SettingUtils.getDebugSql(_setting, arr_field, regoptions, swhere) } param.LText = Utils.formatOptions(param.LText) @@ -204,7 +205,7 @@ } render() { - const { systemScripts, setting, type } = this.props + const { systemScripts, setting } = this.props const { getFieldDecorator } = this.props.form const { usefulFields } = this.state const formItemLayout = { @@ -233,7 +234,7 @@ </Col> <Col span={24} className="sqlfield"> <Form.Item label={'鍙敤瀛楁'}> - id, bid, loginuid, sessionuid, userid, appkey, {type === 'main' ? 'out_id, ' : '' }time_id, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} + id, bid, loginuid, sessionuid, userid, appkey, orderBy{setting.laypage !== 'false' ? ', pageSize, pageIndex': ''}{usefulFields ? ', ' + usefulFields : ''} </Form.Item> </Col> <Col span={10}> diff --git a/src/mob/datasource/verifycard/index.jsx b/src/mob/datasource/verifycard/index.jsx index 1731c3c..cb8c091 100644 --- a/src/mob/datasource/verifycard/index.jsx +++ b/src/mob/datasource/verifycard/index.jsx @@ -1,18 +1,15 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { fromJS } from 'immutable' -import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, message, Typography } from 'antd' +import { fromJS } from 'immutable' +import { Form, Tabs, Table, Popconfirm, Icon, notification, Modal, Typography } from 'antd' import moment from 'moment' import Api from '@/api' import Utils from '@/utils/utils.js' -import UniqueForm from './uniqueform' -import ContrastForm from './contrastform' -import CustomForm from './customform' +import ColForm from './columnform' +import CustomScriptsForm from './customscript' import SettingForm from './settingform' -import BillcodeForm from './billcodeform' -import VoucherForm from './voucherform' import './index.scss' const { TabPane } = Tabs @@ -21,60 +18,34 @@ class VerifyCard extends Component { static propTpyes = { - floor: PropTypes.any, // 鏄惁涓哄瓙琛� - btnTab: PropTypes.any, // 琛ㄥ崟鏍囩椤碉紙鎸夐挳锛夊弬鏁� - config: PropTypes.any, // 琛ㄥ崟鏍囩椤靛弬鏁� - dict: PropTypes.object, // 瀛楀吀椤� - card: PropTypes.object, // 鎸夐挳淇℃伅 - columns: PropTypes.array + dict: PropTypes.object, // 瀛楀吀椤� + card: PropTypes.object, // 鏁版嵁婧愪俊鎭� + menuId: PropTypes.string, // 鑿滃崟Id + searches: PropTypes.array, // 鎼滅储鏉′欢 } state = { + columns: [], + activeKey: 'setting', initsql: '', // sql楠岃瘉鏃跺彉閲忓0鏄庡強璧嬪�� - verify: {}, - fields: [], usefulfields: '', defaultsql: '', // 榛樿Sql - orderModular: [], - orderModularDetail: [], - voucher: [], - voucherDetail: [], systemScripts: [], - columnsFields: [], - uniqueColumns: [ + colColumns: [ { - title: '瀛楁鍚�', + title: '鍚嶇О', + dataIndex: 'label', + width: '25%' + }, + { + title: '瀛楁', dataIndex: 'field', - width: '35%' + width: '25%' }, { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '12%' - }, - { - title: '楠岃瘉绫诲瀷', - dataIndex: 'verifyType', - width: '13%', - render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '15%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) + title: '鏁版嵁绫诲瀷', + dataIndex: 'datatype', + width: '25%', }, { title: '鎿嶄綔', @@ -83,191 +54,12 @@ dataIndex: 'operation', render: (text, record) => (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <span className="operation-btn" title={this.props.dict['mob.edit']} onClick={() => this.handleEdit(record, 'columns')} style={{color: '#1890ff'}}><Icon type="edit" /></span> <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - onceUniqueColumns: [ - { - title: '瀛楁鍚�', - dataIndex: 'field', - width: '45%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '30%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '25%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'unique') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - contrastColumns: [ - { - title: '鍐呭1', - dataIndex: 'frontfield', - width: '13%' - }, - { - title: '杩愮畻绗�', - dataIndex: 'operator', - width: '13%' - }, - { - title: '鍐呭2', - dataIndex: 'backfield', - width: '13%', - }, - { - title: '鎻愮ず淇℃伅', - dataIndex: 'errmsg', - width: '13%' - }, - { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '13%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '15%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '20%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'contrast')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'contrast', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'contrast', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'contrast')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'contrast') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - customColumns: [ - { - title: 'SQL', - dataIndex: 'sql', - width: '45%', - render: (text) => ( - <Paragraph copyable ellipsis={{ rows: 5, expandable: true }}>{text}</Paragraph> - ) - }, - { - title: '缁撴灉澶勭悊', - dataIndex: 'resultName', - width: '9%' - }, - { - title: '鎻愮ず淇℃伅', - dataIndex: 'errmsg', - width: '13%' - }, - { - title: '鎶ラ敊缂栫爜', - dataIndex: 'errorCode', - width: '9%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '9%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '15%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'customverify')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'customverify', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'customverify', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'customverify')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'customverify') + title={this.props.dict['mob.query.delete']} + okText={this.props.dict['mob.confirm']} + cancelText={this.props.dict['mob.cancel']} + onConfirm={() => this.deleteColumn(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> </Popconfirm> @@ -284,23 +76,9 @@ ) }, { - title: '鎵ц浣嶇疆', - dataIndex: 'position', - width: '10%', - render: (text, record) => { - if (record.position === 'init') { - return '鍒濆鍖�' - } else if (record.position === 'front') { - return 'sql鍓�' - } else { - return 'sql鍚�' - } - } - }, - { title: '鐘舵��', dataIndex: 'status', - width: '10%', + width: '20%', render: (text, record) => record.status === 'false' ? ( <div> @@ -323,118 +101,14 @@ render: (text, record) => (<div> <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'scripts', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> + <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> + <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> + <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record)} style={{color: '#8E44AD'}}><Icon type="swap" /></span> <Popconfirm title={this.props.dict['header.form.query.delete']} okText={this.props.dict['model.confirm']} cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'scripts') - }> - <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> - </Popconfirm> - </div>) - } - ], - orderColumns: [ - { - title: this.props.dict['header.form.funcvar'], - dataIndex: 'fieldName', - width: '12%', - render: (text, record) => (`${record.fieldName || ''}(${record.field})`) - }, - { - title: '绫诲瀷', - dataIndex: 'billType', - width: '6%', - }, - { - title: '鍑瘉绫诲瀷', - dataIndex: 'ModularCodeName', - width: '11%' - }, - { - title: '鍑瘉鏍囪瘑', - dataIndex: 'ModularDetailCode', - width: '11%' - }, - { - title: '鍏宠仈瀛楁', - dataIndex: 'linkFieldName', - width: '10%', - render: (text, record) => (record.linkField ? `${record.linkFieldName || ''}(${record.linkField})` : '') - }, - { - title: '浣嶆暟', - dataIndex: 'Type', - width: '6%' - }, - { - title: '绀轰緥', - dataIndex: 'example', - width: '13%', - render: (text, record) => { - let _text = '' - - let _type = record.Type - if (_type && typeof(_type) === 'string') { - _type = parseInt(_type) - } else { - _type = 4 - } - - if (record.TypeCharOne === 'n') { - _text = record.ModularDetailCode + Array(_type).join('0') + '1' - } else if (record.TypeCharOne === 'Y') { - _text = record.ModularDetailCode + moment().format('YYYYMMDD') + Array(_type).join('0') + '1' - } else if (record.TypeCharOne === 'Lp') { - _text = Array(_type).join('0') + '10' - } else if (record.TypeCharOne === 'BN') { - _text = moment().format('YYYYMMDD') + Array(_type).join('0') + '1' - } - return _text - } - }, - { - title: '鏍囪瘑', - dataIndex: 'mark', - width: '8%' - }, - { - title: '鐘舵��', - dataIndex: 'status', - width: '8%', - render: (text, record) => record.status === 'false' ? - ( - <div> - {this.props.dict['header.form.status.forbidden']} - <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" /> - </div> - ) : - ( - <div> - {this.props.dict['header.form.status.open']} - <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" /> - </div> - ) - }, - { - title: '鎿嶄綔', - align: 'center', - width: '15%', - dataIndex: 'operation', - render: (text, record) => - (<div> - <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'ordercode')} style={{color: '#1890ff'}}><Icon type="edit" /></span> - <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'ordercode', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span> - <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'ordercode', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span> - <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'ordercode')} style={{color: '#8E44AD'}}><Icon type="swap" /></span> - <Popconfirm - title={this.props.dict['header.form.query.delete']} - okText={this.props.dict['model.confirm']} - cancelText={this.props.dict['header.cancel']} - onConfirm={() => this.handleDelete(record, 'ordercode') + onConfirm={() => this.deleteScript(record) }> <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span> </Popconfirm> @@ -444,7 +118,13 @@ } UNSAFE_componentWillMount() { + const { card } = this.props + this.setState({ + columns: fromJS(card.columns).toJS(), + setting: fromJS(card.setting).toJS(), + scripts: fromJS(card.scripts).toJS() + }) } componentDidMount() { @@ -503,11 +183,11 @@ }) } - uniqueChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + columnChange = (values) => { + let columns = fromJS(this.state.columns).toJS() if (values.uuid) { - verify.uniques = verify.uniques.map(item => { + columns = columns.map(item => { if (item.uuid === values.uuid) { return values } else { @@ -516,61 +196,17 @@ }) } else { values.uuid = Utils.getuuid() - verify.uniques.push(values) + columns.push(values) } - this.setState({ - verify: verify - }) - } - - contrastChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - - if (values.uuid) { - verify.contrasts = verify.contrasts.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.contrasts.push(values) - } - - this.setState({ - verify: verify - }) - } - - customChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - - if (values.uuid) { - verify.customverifys = verify.customverifys.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.customverifys.push(values) - } - - this.setState({ - verify: verify - }) + this.setState({ columns }) } scriptsChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + let scripts = fromJS(this.state.scripts).toJS() if (values.uuid) { - verify.scripts = verify.scripts.map(item => { + scripts = scripts.map(item => { if (item.uuid === values.uuid) { return values } else { @@ -579,76 +215,29 @@ }) } else { values.uuid = Utils.getuuid() - verify.scripts.push(values) + scripts.push(values) } - this.setState({ - verify: verify - }) + this.setState({ scripts }) } - orderChange = (values) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) - if (values.uuid) { - verify.billcodes = verify.billcodes.map(item => { - if (item.uuid === values.uuid) { - return values - } else { - return item - } - }) - } else { - values.uuid = Utils.getuuid() - verify.billcodes.push(values) - } - - this.setState({ - verify: verify - }) + deleteColumn = (record) => { + this.setState({ columns: this.state.columns.filter(item => item.uuid !== record.uuid) }) } - onOptionChange = (e, key) => { - const { verify } = this.state - let value = e.target.value - - this.setState({ - verify: {...verify, [key]: value} - }) - } - - handleDelete = (record, type) => { - const { verify } = this.state - - if (type === 'customverify') { - verify.customverifys = verify.customverifys.filter(item => item.uuid !== record.uuid) - } else if (type === 'unique') { - verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid) - } else if (type === 'ordercode') { - verify.billcodes = verify.billcodes.filter(item => item.uuid !== record.uuid) - } else if (type === 'scripts') { - verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid) - } - - this.setState({ verify: verify }) + deleteScript = (record) => { + this.setState({ scripts: this.state.scripts.filter(item => item.uuid !== record.uuid) }) } handleEdit = (record, type) => { - if (type === 'customverify') { - this.customForm.edit(record) - } else if (type === 'unique') { - this.uniqueForm.edit(record) - } else if (type === 'ordercode') { - this.orderForm.edit(record) - } else if (type === 'scripts') { + if (type === 'scripts') { this.scriptsForm.edit(record) - } else if (type === 'contrast') { + } else if (type === 'columns') { this.contrastForm.edit(record) } - let node = document.getElementById('verify-card-box-tab').parentNode + let node = document.getElementById('mob-verify-card-box-tab').parentNode if (node && node.scrollTop) { let inter = Math.ceil(node.scrollTop / 10) @@ -664,211 +253,52 @@ } } - handleStatus = (record, type) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + handleStatus = (record) => { + let scripts = fromJS(this.state.scripts).toJS() record.status = record.status === 'false' ? 'true' : 'false' - if (type === 'customverify') { - verify.customverifys = verify.customverifys.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'unique') { - verify.uniques = verify.uniques.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'ordercode') { - verify.billcodes = verify.billcodes.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } else if (type === 'scripts') { - verify.scripts = verify.scripts.map(item => { - if (item.uuid === record.uuid) { - return record - } else { - return item - } - }) - } - - this.setState({ - verify: verify + scripts = scripts.map(item => { + if (item.uuid === record.uuid) { + return record + } else { + return item + } }) + + this.setState({ scripts }) } - handleUpDown = (record, type, direction) => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + handleUpDown = (record, direction) => { + let scripts = fromJS(this.state.scripts).toJS() let index = 0 - if (type === 'customverify') { - verify.customverifys = verify.customverifys.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.customverifys.length && direction === 'down')) { - return + scripts = scripts.filter((item, i) => { + if (item.uuid === record.uuid) { + index = i } - if (direction === 'up') { - verify.customverifys.splice(index - 1, 0, record) - } else { - verify.customverifys.splice(index + 1, 0, record) - } - } else if (type === 'unique') { - verify.uniques = verify.uniques.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.uniques.splice(index - 1, 0, record) - } else { - verify.uniques.splice(index + 1, 0, record) - } - } else if (type === 'contrast') { - verify.contrasts = verify.contrasts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.contrasts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.contrasts.splice(index - 1, 0, record) - } else { - verify.contrasts.splice(index + 1, 0, record) - } - } else if (type === 'ordercode') { - verify.billcodes = verify.billcodes.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.billcodes.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.billcodes.splice(index - 1, 0, record) - } else { - verify.billcodes.splice(index + 1, 0, record) - } - } else if (type === 'scripts') { - verify.scripts = verify.scripts.filter((item, i) => { - if (item.uuid === record.uuid) { - index = i - } - - return item.uuid !== record.uuid - }) - if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) { - return - } - - if (direction === 'up') { - verify.scripts.splice(index - 1, 0, record) - } else { - verify.scripts.splice(index + 1, 0, record) - } + return item.uuid !== record.uuid + }) + if ((index === 0 && direction === 'up') || (index === scripts.length && direction === 'down')) { + return } - this.setState({ - verify: verify - }) - } - - voucherChange = (voucher) => { - const { verify } = this.state - - this.setState({ - verify: { - ...verify, - voucher: voucher - } - }) - } - - showError = (errorType) => { - if (errorType === 'S') { - notification.success({ - top: 92, - message: '鎵ц鎴愬姛锛�', - duration: 2 - }) - } else if (errorType === 'Y') { - Modal.success({ - title: '鎵ц鎴愬姛锛�' - }) - } else if (errorType === 'F') { - notification.error({ - className: 'notification-custom-error', - top: 92, - message: '鎵ц澶辫触锛�', - duration: 10 - }) - } else if (errorType === 'N') { - notification.error({ - top: 92, - message: '鎵ц澶辫触锛�', - duration: 10 - }) - } else if (errorType === 'E') { - Modal.error({ - title: '鎵ц澶辫触锛�' - }) - } else if (errorType === 'NM') { - message.error('鎵ц澶辫触锛�') + if (direction === 'up') { + scripts.splice(index - 1, 0, record) + } else { + scripts.splice(index + 1, 0, record) } - } - timeChange = (val, type) => { - const { verify } = this.state - - this.setState({ - verify: {...verify, [type]: val} - }) + this.setState({ scripts }) } handleConfirm = () => { - let verify = JSON.parse(JSON.stringify(this.state.verify)) + const { card } = this.props + const { setting, scripts, columns } = this.state // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { - if (verify.default === 'false' && verify.scripts.length === 0) { + if (setting.default === 'false' && scripts.length === 0) { notification.warning({ top: 92, message: '涓嶆墽琛岄粯璁ql鏃讹紝蹇呴』璁剧疆鑷畾涔夎剼鏈紒', @@ -878,38 +308,48 @@ } let _loading = false - if (this.customForm && this.customForm.state.editItem) { - _loading = true - } else if (this.uniqueForm && this.uniqueForm.state.editItem) { - _loading = true - } else if (this.orderForm && this.orderForm.state.editItem) { - _loading = true - } else if (this.scriptsForm && this.scriptsForm.state.editItem) { - _loading = true - } else if (this.contrastForm && this.contrastForm.state.editItem) { + if (this.scriptsForm && this.scriptsForm.state.editItem) { _loading = true } if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) { - _loading = true - } else if (this.customForm && this.customForm.props.form.getFieldValue('sql')) { _loading = true } if (_loading) { confirm({ content: `瀛樺湪鏈繚瀛橀」锛岀‘瀹氭彁浜ゅ悧锛焋, - okText: this.props.dict['model.confirm'], - cancelText: this.props.dict['header.cancel'], + okText: this.props.dict['mob.confirm'], + cancelText: this.props.dict['mob.cancel'], onOk() { - resolve(verify) + resolve({ + uuid: card.uuid, + setting: setting, + columns: columns, + scripts: scripts + }) }, onCancel() {} }) } else { - resolve(verify) + resolve({ + uuid: card.uuid, + setting: setting, + columns: columns, + scripts: scripts + }) } }) + } + + changeTab = (val) => { + const { activeKey } = this.state + + if (activeKey === 'setting') { + this.settingForm.handleConfirm().then(res => { + console.log(res) + }) + } } /** @@ -922,113 +362,51 @@ } render() { - const { card } = this.props - const { verify, fields, uniqueColumns, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state + const { columns, setting, scripts, colColumns, scriptsColumns, activeKey } = this.state return ( - <div id="verify-card-box-tab"> - <Tabs defaultActiveKey="1" className="verify-card-box"> - <TabPane tab="鏁版嵁婧�" key="1"> - <SettingForm dict={this.props.dict} /> - </TabPane> - <TabPane tab="姣旇緝楠岃瘉" key="2x"> - <ContrastForm + <div id="mob-verify-card-box-tab"> + <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.changeTab}> + <TabPane tab="鏁版嵁婧�" key="setting"> + <SettingForm + menuId={this.props.menuId} dict={this.props.dict} - contrastChange={this.contrastChange} + columns={columns} + setting={setting} + wrappedComponentRef={(inst) => this.settingForm = inst} + /> + </TabPane> + <TabPane tab="瀛楁闆�" key="columns"> + <ColForm + dict={this.props.dict} + columnChange={this.columnChange} wrappedComponentRef={(inst) => this.contrastForm = inst} /> <Table bordered rowKey="uuid" className="custom-table" - dataSource={verify.contrasts} - columns={contrastColumns} + dataSource={columns} + columns={colColumns} pagination={false} /> </TabPane> - <TabPane tab={card.Ot !== 'requiredOnce' ? '鍞竴鎬ч獙璇�' : '鍚岀被鏁版嵁楠岃瘉'} key="2"> - <UniqueForm - btn={card} - fields={card.Ot !== 'requiredOnce' ? fields : columnsFields} - dict={this.props.dict} - uniqueChange={this.uniqueChange} - wrappedComponentRef={(inst) => this.uniqueForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.uniques} - columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鑷畾涔夐獙璇�" key="3"> - <CustomForm - dict={this.props.dict} - btn={this.props.card} - initsql={this.state.initsql} - usefulfields={this.state.usefulfields} - customChange={this.customChange} - wrappedComponentRef={(inst) => this.customForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.customverifys} - columns={customColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鍗曞彿鐢熸垚" key="4"> - <BillcodeForm - fields={fields} - btn={this.props.card} - billcodes={verify.billcodes} - columns={this.props.columns} - dict={this.props.dict} - modular={orderModular} - modularDetail={orderModularDetail} - orderChange={this.orderChange} - wrappedComponentRef={(inst) => this.orderForm = inst} - /> - <Table - bordered - rowKey="uuid" - className="custom-table" - dataSource={verify.billcodes} - columns={orderColumns} - pagination={false} - /> - </TabPane> - <TabPane tab="鍒涘缓鍑瘉" key="5"> - <VoucherForm - dict={this.props.dict} - voucher={voucher} - columns={this.props.columns} - voucherobj={verify.voucher} - voucherDetail={voucherDetail} - voucherChange={this.voucherChange} - wrappedComponentRef={(inst) => this.voucherForm = inst} - /> - </TabPane> - <TabPane tab="鑷畾涔夎剼鏈�" key="6"> - {/* <CustomScript - usefulfields={this.state.usefulfields} + <TabPane tab="鑷畾涔夎剼鏈�" key="scripts"> + <CustomScriptsForm + setting={setting} + searches={this.props.searches} initsql={this.state.initsql} dict={this.props.dict} - btn={this.props.card} - customScripts={verify.scripts} + customScripts={scripts} systemScripts={this.state.systemScripts} scriptsChange={this.scriptsChange} wrappedComponentRef={(inst) => this.scriptsForm = inst} - /> */} + /> <Table bordered rowKey="uuid" className="custom-table" - dataSource={verify.scripts} + dataSource={scripts} columns={scriptsColumns} pagination={false} /> diff --git a/src/mob/datasource/verifycard/settingform/index.jsx b/src/mob/datasource/verifycard/settingform/index.jsx index 9720ab4..361cc5e 100644 --- a/src/mob/datasource/verifycard/settingform/index.jsx +++ b/src/mob/datasource/verifycard/settingform/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, Radio, Select, Tooltip, Icon, notification, InputNumber } from 'antd' +// import { fromJS } from 'immutable' +import { Form, Row, Col, Input, Radio, Select, Tooltip, Icon, notification } from 'antd' import moment from 'moment' import Api from '@/api' @@ -15,18 +15,18 @@ static propTpyes = { type: PropTypes.string, // 鑿滃崟绫诲瀷 dict: PropTypes.object, // 瀛楀吀椤� - menu: PropTypes.object, // 鑿滃崟淇℃伅 - config: PropTypes.object, // 椤甸潰閰嶇疆淇℃伅 + menuId: PropTypes.string, // 鑿滃崟Id + setting: PropTypes.object, // 鏁版嵁婧愰厤缃� formlist: PropTypes.array, // 琛ㄥ崟淇℃伅 } state = { - + interType: 'inner', + structure: 'array' } handleConfirm = (otype) => { - const { menu } = this.props - const { setting } = this.state + const { setting } = this.props // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� return new Promise((resolve, reject) => { this.props.form.validateFieldsAndScroll((err, values) => { @@ -92,12 +92,12 @@ values.interType === 'inner' && !values.innerFunc && values.default !== 'false' && /[^\s]+\s+[^\s]+/ig.test(values.dataresource) && - this.props.config.setting.dataresource !== values.dataresource + setting.dataresource !== values.dataresource ) { let param = { func: 's_DataSrc_Save', LText: values.dataresource, - MenuID: menu.MenuID + MenuID: this.props.menuId } param.LText = Utils.formatOptions(param.LText) @@ -127,217 +127,23 @@ onRadioChange = (e, key) => { let value = e.target.value - let _formlist = fromJS(this.state.formlist).toJS() if (key === 'interType') { this.setState({ - formlist: _formlist.map(item => { - item.hidden = false - - if (value === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { - item.initVal = this.props.form.getFieldValue(item.key) - item.hidden = true - } - - return item - }) + interType: value }) - } else if (key === 'sysInterface') { - if (value === 'true') { - this.props.form.setFieldsValue({ - interface: window.GLOB.mainSystemApi || '' - }) - } + } else if (key === 'structure') { this.setState({ - formlist: _formlist.map(item => { - if (item.key === 'interface') { - item.readonly = value === 'true' - } - - return item - }) + structure: value }) } } - getFields(formlist) { - const { getFieldDecorator } = this.props.form - const fields = [] - - formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { // 鏂囨湰鎼滅储 - let rules = item.rules || [] - - fields.push( - <Col span={8} key={index}> - <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: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - }, - ...rules - ] - })(<Input placeholder={item.placeholder || ''} autoComplete="off" disabled={item.readonly} onPressEnter={this.handleSubmit} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <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 || 6, - rules: [ - { - required: item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<InputNumber min={item.min} max={item.max} precision={0} />)} - </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) => { - return option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 || - option.props.value.toLowerCase().indexOf(input.toLowerCase()) >= 0 - }} - onChange={(value) => {this.selectChange(item.key, value)}} - getPopupContainer={() => document.getElementById('model-table-setting-form')} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <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: [ - { - required: !!item.required, - message: this.props.dict['form.required.select'] + item.label + '!' - } - ] - })( - <Radio.Group onChange={(e) => {this.onRadioChange(e, item.key)}}> - { - item.options.map((option, i) => { - return ( - <Radio key={i} value={option.value}>{option.text}</Radio> - ) - }) - } - </Radio.Group>, - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'datasource') { - fields.push( - <Col span={24} key={index} style={{paddingLeft: '7px'}}> - <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } help={item.help} label={ - <Tooltip placement="topLeft" title={item.tooltip}> - <Icon type="question-circle" /> - {item.label} - </Tooltip> - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })(<TextArea rows={4} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'textarea') { - fields.push( - <Col span={20} offset={4} key={index}> - <Form.Item className="text-area"> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: this.props.dict['form.required.input'] + item.label + '!' - } - ] - })(<TextArea rows={4} />)} - </Form.Item> - </Col> - ) - } else if (item.type === 'multiselect') { // 澶氶�� - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.label}> - {getFieldDecorator(item.key, { - initialValue: item.initVal || [] - })( - <Select - showSearch - mode="multiple" - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - > - {item.options.map((option, i) => - <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } - }) - - return fields - } - render() { + const { columns } = this.props const { getFieldDecorator } = this.props.form - // const { formlist } = this.state + const { interType, structure } = this.state + const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -350,22 +156,184 @@ } return ( - <div className="model-table-setting-form-box"> - <Form {...formItemLayout} className="model-table-setting-form"> + <div className="mob-datasource-setting-form-box"> + <Form {...formItemLayout} className="mob-setting-form"> <Row gutter={24}> <Col span={8}> <Form.Item label="鍚嶇О"> - {getFieldDecorator('label', { + {getFieldDecorator('name', { initialValue: '', rules: [ { required: true, - message: this.props.dict['form.required.input'] + '鍚嶇О!' + message: this.props.dict['mob.required.input'] + '鍚嶇О!' }, ] })(<Input placeholder={''} autoComplete="off" />)} </Form.Item> </Col> + <Col span={8}> + <Form.Item label="琛ㄥ悕"> + {getFieldDecorator('tableName', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['mob.required.input'] + '琛ㄥ悕!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label="鏁版嵁缁撴瀯"> + {getFieldDecorator('structure', { + initialValue: structure, + rules: [ + { + required: true, + message: this.props.dict['mob.required.select'] + '琛ㄥ悕!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'structure')}}> + <Radio value="array">鏁扮粍</Radio> + <Radio value="field">瀛楁</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + <Col span={8}> + <Form.Item label="鎺ュ彛绫诲瀷"> + {getFieldDecorator('interType', { + initialValue: interType, + rules: [ + { + required: true, + message: this.props.dict['mob.required.select'] + '鎺ュ彛绫诲瀷!' + }, + ] + })( + <Radio.Group onChange={(e) => {this.onRadioChange(e, 'interType')}}> + <Radio value="inner">鍐呴儴</Radio> + <Radio value="outer">澶栭儴</Radio> + </Radio.Group>)} + </Form.Item> + </Col> + {interType === 'inner' ? <Col span={8}> + <Form.Item label="鍐呴儴鍑芥暟"> + {getFieldDecorator('innerFunc', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="鎺ュ彛鍦板潃"> + {getFieldDecorator('interface', { + initialValue: '', + rules: [ + { + required: true, + message: this.props.dict['mob.required.input'] + '鎺ュ彛鍦板潃!' + }, + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {interType === 'outer' ? <Col span={8}> + <Form.Item label="澶栭儴鍑芥暟"> + {getFieldDecorator('outerFunc', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} + <Col span={24} className="data-source" style={{paddingLeft: '7px'}}> + <Form.Item labelCol={{xs: { span: 24 }, sm: { span: 2 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 22 }} } label={ + <Tooltip placement="topLeft" title={'浣跨敤绯荤粺鍑芥暟鏃讹紝闇�濉啓鏁版嵁婧愩�傛敞锛氭暟鎹潈闄愭浛鎹㈢ $@ -> /* 鎴� \'\'銆� @$ -> */ 鎴� \'\''}> + <Icon type="question-circle" /> + 鏁版嵁婧� + </Tooltip> + }> + {getFieldDecorator('dataresource', { + initialValue: '' + })(<TextArea rows={4} />)} + </Form.Item> + </Col> + {structure === 'array' ? <Col span={8}> + <Form.Item label="涓婚敭"> + {getFieldDecorator('primaryKey', { + initialValue: '', + rules: [ + + ] + })( + <Select onChange={(value) => {this.selectChange('primaryKey', value)}}> + {columns.map((option, i) => + <Select.Option key={i} value={option.value}> + {option.text} + </Select.Option> + )} + </Select> + )} + </Form.Item> + </Col> : null} + {structure === 'array' ? <Col span={8}> + <Form.Item label="榛樿鎺掑簭"> + {getFieldDecorator('order', { + initialValue: '', + rules: [ + + ] + })(<Input placeholder={'ID asc, UID desc'} autoComplete="off" />)} + </Form.Item> + </Col> : null} + {structure === 'array' ? <Col span={8}> + <Form.Item label="鍒嗛〉"> + {getFieldDecorator('laypage', { + initialValue: '', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + {interType === 'inner' ? <Col span={8}> + <Form.Item label="榛樿sql"> + {getFieldDecorator('execute', { + initialValue: 'true', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鎵ц</Radio> + <Radio value="false">涓嶆墽琛�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> : null} + <Col span={8}> + <Form.Item label="鎼滅储鏉′欢"> + {getFieldDecorator('search', { + initialValue: 'true', + rules: [ + + ] + })( + <Radio.Group> + <Radio value="true">鎺ユ敹</Radio> + <Radio value="false">涓嶆帴鏀�</Radio> + </Radio.Group>)} + </Form.Item> + </Col> </Row> </Form> </div> diff --git a/src/mob/datasource/verifycard/settingform/index.scss b/src/mob/datasource/verifycard/settingform/index.scss index d79c9f6..1b8226b 100644 --- a/src/mob/datasource/verifycard/settingform/index.scss +++ b/src/mob/datasource/verifycard/settingform/index.scss @@ -1,12 +1,13 @@ -.model-table-setting-form-box { +.mob-datasource-setting-form-box { position: relative; - .model-table-setting-form { - .textarea { + + .mob-setting-form { + .data-source { .ant-form-item-label { - width: 16.3%; + width: 11%; } .ant-form-item-control-wrapper { - width: 83.33333333%; + width: 89%; } } .anticon-question-circle { @@ -14,32 +15,5 @@ margin-right: 3px; } } - .operation-btn { - display: inline-block; - font-size: 16px; - padding: 0 5px; - cursor: pointer; - } - td { - word-break: break-all; - } - .setting-custom-back { - position: absolute; - top: -20px; - left: -10px; - font-size: 16px; - z-index: 1; - cursor: pointer; - padding: 10px; - color: rgb(24, 144, 255); - } - .to-custom-script { - float: right; - color: #1890ff; - margin-right: 12px; - margin-top: 15px; - cursor: pointer; - border: 0; - box-shadow: unset; - } + } \ No newline at end of file diff --git a/src/mob/datasource/verifycard/uniqueform/index.jsx b/src/mob/datasource/verifycard/uniqueform/index.jsx deleted file mode 100644 index 5468de8..0000000 --- a/src/mob/datasource/verifycard/uniqueform/index.jsx +++ /dev/null @@ -1,157 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { Form, Row, Col, Select, Button } from 'antd' -import './index.scss' - - -class UniqueForm extends Component { - static propTpyes = { - btn: PropTypes.object, // 瀛楀吀椤� - dict: PropTypes.object, // 瀛楀吀椤� - fields: PropTypes.array, // 琛ㄥ崟瀛楁 - uniqueChange: PropTypes.func // 淇敼鍑芥暟 - } - - state = { - editItem: null // 缂栬緫鍏冪礌 - } - - edit = (record) => { - const { btn } = this.props - - this.setState({ - editItem: record - }) - - let _value = { - field: record.field.split(',') - } - - if (btn.Ot !== 'requiredOnce') { - _value.errorCode = record.errorCode - _value.verifyType = record.verifyType || 'physical' - } - - this.props.form.setFieldsValue(_value) - } - - - handleConfirm = () => { - const { fields } = this.props - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.uuid = this.state.editItem ? this.state.editItem.uuid : '' - values.fieldlabel = values.field.map(field => { - let item = fields.filter(cell => cell.field === field)[0] - let label = '' - if (item) { - label = item.label - } - return label - }) - - values.fieldlabel = values.fieldlabel.join(',') - values.field = values.field.join(',') - - this.setState({ - editItem: null - }, () => { - this.props.uniqueChange(values) - }) - this.props.form.setFieldsValue({ - field: [], - }) - } - }) - } - - render() { - const { getFieldDecorator } = this.props.form - const { fields, btn } = this.props - - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 8 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 16 } - } - } - - return ( - <Form {...formItemLayout} className="verify-form" id="verifycard1"> - <Row gutter={24}> - <Col span={8}> - <Form.Item label={'瀛楁鍚�'}> - {getFieldDecorator('field', { - initialValue: [], - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '瀛楁鍚�!' - } - ] - })( - <Select - mode="multiple" - > - {fields.map(item => ( - <Select.Option key={item.uuid} value={item.field}>{item.field}</Select.Option> - ))} - </Select> - )} - </Form.Item> - </Col> - {btn.Ot !== 'requiredOnce' ? <Col span={6}> - <Form.Item label={'鎶ラ敊缂栫爜'}> - {getFieldDecorator('errorCode', { - initialValue: 'E', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!' - } - ] - })( - <Select> - <Select.Option value="E"> E </Select.Option> - <Select.Option value="N"> N </Select.Option> - <Select.Option value="F"> F </Select.Option> - <Select.Option value="NM"> NM </Select.Option> - </Select> - )} - </Form.Item> - </Col> : null} - {btn.Ot !== 'requiredOnce' ? <Col span={6}> - <Form.Item label={'楠岃瘉绫诲瀷'}> - {getFieldDecorator('verifyType', { - initialValue: 'physical', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '楠岃瘉绫诲瀷!' - } - ] - })( - <Select> - <Select.Option value="physical"> 鐗╃悊楠岃瘉 </Select.Option> - <Select.Option value="logic"> 閫昏緫楠岃瘉 </Select.Option> - </Select> - )} - </Form.Item> - </Col> : null} - <Col span={4} className="add"> - <Button onClick={this.handleConfirm} className="mk-green"> - 淇濆瓨 - </Button> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(UniqueForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/uniqueform/index.scss b/src/mob/datasource/verifycard/uniqueform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/mob/datasource/verifycard/uniqueform/index.scss +++ /dev/null diff --git a/src/mob/datasource/verifycard/voucherform/index.jsx b/src/mob/datasource/verifycard/voucherform/index.jsx deleted file mode 100644 index 6341055..0000000 --- a/src/mob/datasource/verifycard/voucherform/index.jsx +++ /dev/null @@ -1,269 +0,0 @@ -import React, {Component} from 'react' -import PropTypes from 'prop-types' -import { is, fromJS } from 'immutable' -import { Form, Row, Col, Select, Switch, notification } from 'antd' -import './index.scss' - -class UniqueForm extends Component { - static propTpyes = { - dict: PropTypes.object, // 瀛楀吀椤� - voucherobj: PropTypes.object, // 鍑瘉淇℃伅 - voucher: PropTypes.array, // 琛ㄥ崟 - columns: PropTypes.array, // 琛ㄥ崟 - voucherDetail: PropTypes.array, // 琛ㄥ崟 - voucherChange: PropTypes.func // 琛ㄥ崟 - } - - state = { - voucher: [], - voucherDetail: [], - columns: [] - } - - UNSAFE_componentWillMount() { - let _voucher = [] - let _voucherDetail = [] - if (this.props.voucherobj.BVoucherType && this.props.voucher.length > 0) { - _voucher = this.props.voucher.filter(item => item.TypeCharOne === this.props.voucherobj.BVoucherType) - _voucherDetail = this.props.voucherDetail.filter(item => item.BID === this.props.voucherobj.VoucherType) - } else if (this.props.voucher.length > 0) { - _voucher = this.props.voucher.filter(item => item.TypeCharOne === 'MES') - _voucherDetail = this.props.voucherDetail.filter(item => _voucher[0] && item.BID === _voucher[0].ID) - } - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail, - columns: this.props.columns.filter(col => col.type === 'text') - }) - } - - UNSAFE_componentWillReceiveProps (nextProps) { - if (!is(fromJS(this.props.voucher), fromJS(nextProps.voucher)) && nextProps.voucher.length > 0) { - if (this.props.voucherobj.BVoucherType) { - let _voucher = nextProps.voucher.filter(item => item.TypeCharOne === this.props.voucherobj.BVoucherType) - let _voucherDetail = nextProps.voucherDetail.filter(item => item.BID === this.props.voucherobj.VoucherType) - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail - }) - } else { - let _voucher = nextProps.voucher.filter(item => item.TypeCharOne === 'MES') - let _voucherDetail = nextProps.voucherDetail.filter(item => _voucher[0] && item.BID === _voucher[0].ID) - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail - }) - this.props.form.setFieldsValue({ - VoucherType: _voucher[0] ? _voucher[0].ID : '', - VoucherTypeOne: _voucherDetail[0] ? _voucherDetail[0].ModularDetailCode : '' - }) - } - } - } - - voucherTypeChange = (value) => { - const { voucherobj } = this.props - - let _voucher = this.props.voucher.filter(item => item.TypeCharOne === value) - let _voucherDetail = this.props.voucherDetail.filter(item => _voucher[0] && item.BID === _voucher[0].ID) - - this.setState({ - voucher: _voucher, - voucherDetail: _voucherDetail - }) - this.props.form.setFieldsValue({ - VoucherType: _voucher[0] ? _voucher[0].ID : '', - VoucherTypeOne: _voucherDetail[0] ? _voucherDetail[0].ModularDetailCode : '' - }) - - if (voucherobj.enabled) { - this.props.voucherChange({...voucherobj, enabled: false}) - } - } - - voucherSChange = (value) => { - const { voucherobj } = this.props - let _detail = this.props.voucherDetail.filter(item => item.BID === value) - - this.setState({ - voucherDetail: _detail - }) - this.props.form.setFieldsValue({ - VoucherTypeOne: _detail[0] ? _detail[0].ModularDetailCode : '' - }) - - if (voucherobj.enabled) { - this.props.voucherChange({...voucherobj, enabled: false}) - } - } - - contentChange = () => { - const { voucherobj } = this.props - - if (voucherobj.enabled) { - this.props.voucherChange({...voucherobj, enabled: false}) - } - } - - onEnabledChange = () => { - const { voucherobj } = this.props - - if (voucherobj.enabled) { - this.props.voucherChange({...voucherobj, enabled: false}) - } else { - this.handleConfirm() - } - } - - - handleConfirm = () => { - // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭� - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - values.enabled = true - let _detail = this.state.voucherDetail.filter(item => item.ModularDetailCode === values.VoucherTypeOne)[0] - - if (!_detail) { - notification.warning({ - top: 92, - message: '鍑瘉绫诲瀷鎴栧嚟璇佹爣璇嗕笉瀛樺湪锛�', - duration: 5 - }) - return - } - values.VoucherTypeTwo = _detail.VoucherTypeTwo - values.Type = _detail.IDefine1 - - this.props.voucherChange(values) - } - }) - } - - render() { - const { getFieldDecorator } = this.props.form - const { voucherobj } = this.props - const { columns } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 10 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 14 } - } - } - - return ( - <Form {...formItemLayout} className="verify-form"> - <Row gutter={24}> - <Col span={11}> - <Form.Item label={'涓荤被鍨�'}> - {getFieldDecorator('BVoucherType', { - initialValue: voucherobj.BVoucherType || 'MES', - rules: [ - { - required: true, - message: this.props.dict['form.required.select'] + '涓荤被鍨�!' - } - ] - })( - <Select onChange={(value) => {this.voucherTypeChange(value)}}> - <Select.Option value="MES"> 涓氬姟绫诲嚟璇� </Select.Option> - <Select.Option value="FCC"> 璐㈠姟绫诲嚟璇� </Select.Option> - <Select.Option value="WMS"> 鐗╂祦绫诲嚟璇� </Select.Option> - <Select.Option value="Z"> 鑷畾涔� </Select.Option> - </Select> - )} - </Form.Item> - </Col> - <Col span={11}> - <Form.Item label={'鍑瘉绫诲瀷'}> - {getFieldDecorator('VoucherType', { - initialValue: voucherobj.VoucherType || (this.state.voucher[0] && this.state.voucher[0].ID) || '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍑瘉绫诲瀷!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={(value) => {this.voucherSChange(value)}} - > - {this.state.voucher.map(option => - <Select.Option title={option.NameNO} id={option.ID} key={option.ID} value={option.ID}> - {option.NameNO} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={11}> - <Form.Item label={'鍑瘉鏍囪瘑'}> - {getFieldDecorator('VoucherTypeOne', { - initialValue: voucherobj.VoucherTypeOne || (this.state.voucherDetail[0] && this.state.voucherDetail[0].ModularDetailCode) || '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍑瘉鏍囪瘑!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={this.contentChange} - > - {this.state.voucherDetail.map(option => - <Select.Option title={option.CodeName} id={option.ModularDetailCode} key={option.ModularDetailCode} value={option.ModularDetailCode}> - {option.CodeName} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={11}> - <Form.Item label={'鍏宠仈瀛楁'}> - {getFieldDecorator('linkField', { - initialValue: voucherobj.linkField || (columns[0] && columns[0].field) || '', - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '鍏宠仈瀛楁!' - } - ] - })( - <Select - showSearch - filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0} - onChange={this.contentChange} - > - {columns.map((option, index) => - <Select.Option title={option.label} id={index + option.uuid} key={index + option.uuid} value={option.field}> - {option.label} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - <Col span={11}> - <Form.Item label={'鏄惁鍚敤'}> - <Switch checkedChildren="鍚�" unCheckedChildren="鍋�" checked={voucherobj.enabled} onChange={this.onEnabledChange} /> - </Form.Item> - </Col> - </Row> - </Form> - ) - } -} - -export default Form.create()(UniqueForm) \ No newline at end of file diff --git a/src/mob/datasource/verifycard/voucherform/index.scss b/src/mob/datasource/verifycard/voucherform/index.scss deleted file mode 100644 index e69de29..0000000 --- a/src/mob/datasource/verifycard/voucherform/index.scss +++ /dev/null diff --git a/src/store/options.js b/src/store/options.js index 22b1228..c14a975 100644 --- a/src/store/options.js +++ b/src/store/options.js @@ -1,7 +1,7 @@ // 绯荤粺閰嶇疆 export default { sysType: 'bG9j$mkYWw=', // yun ( Y2xv$mkdWQ= ) 銆� dandian ( U1$mkNP ) 銆� yewu ( bG9j$mkYWw= ) - caId: 'MjAyMDAxMTYxMjMzMzU1MDd$mkGQzkyMzI1Rjk4MDY0QUNGQjQ2Mg==', // mk - cakey: 'MjAyMDAxMTYxMjQwMDQ2NDM$mk2N0QzODE2MjExNUI0MTc4OTVDMQ==', // mk + caId: 'MjAyMDAxMTYxMjMzMzU1MDd$mkGQzkyMzI1Rjk4MDY0QUNGQjQ2Mg==', + cakey: 'MjAyMDAxMTYxMjQwMDQ2NDM$mk2N0QzODE2MjExNUI0MTc4OTVDMQ==', cdomain: 'aHR0cDovL2Nsb3V$mkkLm1rOWguY24=' // window.btoa('') } \ No newline at end of file diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx index 7a1935c..eb32253 100644 --- a/src/tabviews/commontable/index.jsx +++ b/src/tabviews/commontable/index.jsx @@ -220,32 +220,41 @@ let chartId = config.charts[0] ? config.charts[0].uuid : '' // 瀛楁鏉冮檺榛戝悕鍗� - config.search = config.search.filter(item => { - if (!item.blacklist || item.blacklist.length === 0) return true + config.search = config.search.map(item => { + item.oriInitval = item.initval + if (['text', 'select', 'link'].includes(item.type) && param) { + if (param.searchkey === item.field) { + item.initval = param.searchval + } else if (param.BID && item.field === 'BID') { + item.initval = param.BID + } + } + + if (!item.blacklist || item.blacklist.length === 0) return item let _black = item.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + item.Hide = 'true' } + + return item }) - config.columns = config.columns.filter(col => { - if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true + config.columns = config.columns.map(col => { + if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return col let _black = col.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + col.Hide = 'true' } + + return col }) // 鏍囪涓婚〉闈紝鐢ㄤ簬鎸夐挳鍥哄畾鍙婅〃鍗曟寕杞借缃� @@ -334,7 +343,7 @@ col.sort = index if (col.type === 'colspan' && col.sublist) { - let _col = JSON.parse(JSON.stringify(col)) + let _col = fromJS(col).toJS() let subColumn = [] _col.sublist.forEach(sub => { if (colMap.has(sub)) { @@ -355,10 +364,7 @@ let valid = true // 鎼滅储鏉′欢蹇呭~楠岃瘉, 鍒濆鎼滅储鏉′欢, 濡傞�氳繃涓婄骇閫忚锛屽啓鍏ユ悳绱㈡潯浠� let initSearch = config.search.map(item => { - let _item = JSON.parse(JSON.stringify(item)) - if (_item.type === 'text' && param && param.searchkey === _item.field) { - _item.initval = param.searchval - } + let _item = fromJS(item).toJS() if (_item.required === 'true' && !_item.initval) { valid = false @@ -396,7 +402,6 @@ arr_field: _arrField.join(','), search: Utils.initMainSearch(initSearch) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { - this.improveSearch() if (config.setting.onload !== 'false' && valid) { // 鍒濆鍖栧彲鍔犺浇 this.loadmaindata() } @@ -509,107 +514,6 @@ }) }) } - } - - /** - * @description 鎼滅储鏉′欢涓嬫媺閫夐」棰勫姞杞� - */ - improveSearch = () => { - let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) - let deffers = [] - searchlist.forEach(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.state.BID) { - param.BID = this.state.BID - } - - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - notification.warning({ - top: 92, - message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], - duration: 5 - }) - } - }) - - if (deffers.length === 0) { - this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) - return - } - - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - searchlist = searchlist.map(item => { - if (item.uuid === res.search.uuid) { - res.data.forEach(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - _item.parentId = cell[res.search.linkField] - } - - item.options.push(_item) - }) - } - return item - }) - } else { - notification.warning({ - top: 92, - message: res.search.label + ':' + res.message, - duration: 5 - }) - } - }) - - this.setState({searchlist}) - }) } /** @@ -1133,8 +1037,11 @@ {loadingview && <Spin size="large" />} {searchlist && searchlist.length > 0 ? <MainSearch + BID={BID} dict={this.state.dict} searchlist={searchlist} + menuType={this.props.menuType} + dataManager={this.props.dataManager} refreshdata={this.refreshbysearch} /> : null } diff --git a/src/tabviews/subtable/index.jsx b/src/tabviews/subtable/index.jsx index a918fc9..83c7b13 100644 --- a/src/tabviews/subtable/index.jsx +++ b/src/tabviews/subtable/index.jsx @@ -179,55 +179,53 @@ // 鏉冮檺杩囨护 if (this.props.menuType !== 'HS') { config.action = config.action.filter(item => permAction[item.uuid]) - - // 瀛楁鏉冮檺榛戝悕鍗� - config.search = config.search.filter(item => { - if (!item.blacklist || item.blacklist.length === 0) return true - - let _black = item.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - - config.columns = config.columns.filter(col => { - if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true - - let _black = col.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - - // 瑙嗗浘鏉冮檺 - config.charts = config.charts.filter(item => { - if (item.Hide === 'true') return false - if (!item.blacklist || item.blacklist.length === 0) return true - - let _black = item.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0 || item.Hide === 'true') { - return false - } else { - return true - } - }) - } else { - // 闅愯棌瑙嗗浘 - config.charts = config.charts.filter(item => item.Hide !== 'true') } + + // 瀛楁鏉冮檺榛戝悕鍗� + config.search = config.search.map(item => { + item.oriInitval = item.initval + if (!item.blacklist || item.blacklist.length === 0) return item + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + item.Hide = 'true' + } + + return item + }) + + config.columns = config.columns.map(col => { + if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return col + + let _black = col.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + col.Hide = 'true' + } + + return col + }) + + // 瑙嗗浘鏉冮檺 + config.charts = config.charts.filter(item => { + if (item.Hide === 'true') return false + if (!item.blacklist || item.blacklist.length === 0) return true + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0 || item.Hide === 'true') { + return false + } else { + return true + } + }) if (config.charts.length <= 1) { config.expand = true @@ -361,7 +359,6 @@ arr_field: _arrField.join(','), search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { - this.improveSearch() if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 鍒濆鍖栧彲鍔犺浇 this.loadmaindata() } @@ -379,109 +376,6 @@ duration: 5 }) } - } - - /** - * @description 鎼滅储鏉′欢涓嬫媺閫夐」棰勫姞杞� - */ - improveSearch = () => { - let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) - let deffers = [] - searchlist.forEach(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' - - notification.warning({ - top: 92, - message: prex + item.label + ': ' + this.state.dict['main.datasource.settingerror'], - duration: 5 - }) - } - }) - - if (deffers.length === 0) { - this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) - return - } - - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - searchlist = searchlist.map(item => { - if (item.uuid === res.search.uuid) { - res.data.forEach(cell => { - let _item = { - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - } - - if (res.search.type === 'link') { - _item.parentId = cell[res.search.linkField] - } - - item.options.push(_item) - }) - } - return item - }) - } else { - let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : '' - - notification.warning({ - top: 92, - message: prex + res.search.label + ':' + res.message, - duration: 5 - }) - } - }) - this.setState({searchlist}) - }) } /** @@ -908,9 +802,12 @@ {loadingview && <Spin />} {searchlist && searchlist.length > 0 ? <SubSearch - refreshdata={this.refreshbysearch} - searchlist={searchlist} + BID={this.props.BID} dict={this.state.dict} + searchlist={searchlist} + menuType={this.props.menuType} + dataManager={this.props.dataManager} + refreshdata={this.refreshbysearch} /> : null } {config ? <div className="chart-view"> diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx index a8280ed..35b8d5a 100644 --- a/src/tabviews/subtabtable/index.jsx +++ b/src/tabviews/subtabtable/index.jsx @@ -140,55 +140,53 @@ // 鏉冮檺杩囨护 if (this.props.menuType !== 'HS') { config.action = config.action.filter(item => permAction[item.uuid]) - - // 瀛楁鏉冮檺榛戝悕鍗� - config.search = config.search.filter(item => { - if (!item.blacklist || item.blacklist.length === 0) return true - - let _black = item.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - - config.columns = config.columns.filter(col => { - if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true - - let _black = col.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0) { - return false - } else { - return true - } - }) - - // 瑙嗗浘鏉冮檺 - config.charts = config.charts.filter(item => { - if (item.Hide === 'true') return false - if (!item.blacklist || item.blacklist.length === 0) return true - - let _black = item.blacklist.filter(v => { - return this.props.permRoles.indexOf(v) !== -1 - }) - - if (_black.length > 0 || item.Hide === 'true') { - return false - } else { - return true - } - }) - } else { - // 闅愯棌瑙嗗浘 - config.charts = config.charts.filter(item => item.Hide !== 'true') } + + // 瀛楁鏉冮檺榛戝悕鍗� + config.search = config.search.filter(item => { + item.oriInitval = item.initval + if (!item.blacklist || item.blacklist.length === 0) return item + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + item.Hide = 'true' + } + + return item + }) + + config.columns = config.columns.filter(col => { + if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return col + + let _black = col.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0) { + col.Hide = 'true' + } + + return col + }) + + // 瑙嗗浘鏉冮檺 + config.charts = config.charts.filter(item => { + if (item.Hide === 'true') return false + if (!item.blacklist || item.blacklist.length === 0) return true + + let _black = item.blacklist.filter(v => { + return this.props.permRoles.indexOf(v) !== -1 + }) + + if (_black.length > 0 || item.Hide === 'true') { + return false + } else { + return true + } + }) if (config.charts.length <= 1) { config.expand = true @@ -276,8 +274,6 @@ arr_field: _arrField.join(','), search: Utils.initMainSearch(config.search) // 鎼滅储鏉′欢鍒濆鍖栵紙鍚湁鏃堕棿鏍煎紡锛岄渶瑕佽浆鍖栵級 }, () => { - this.improveSearch() - if (config.setting.onload !== 'false' && valid) { // 鍒濆鍖栧彲鍔犺浇 this.loadmaindata() } @@ -293,98 +289,6 @@ duration: 5 }) } - } - - /** - * @description 鎼滅储鏉′欢涓嬫媺閫夐」棰勫姞杞� - */ - improveSearch = () => { - let searchlist = JSON.parse(JSON.stringify(this.state.searchlist)) - let deffers = [] - searchlist.forEach(item => { - if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.setAll === 'true') { - item.options.unshift({ - key: Utils.getuuid(), - Value: '', - Text: this.state.dict['main.all'] - }) - } - - if (item.resourceType === '1' && item.dataSource) { - let _option = Utils.getSelectQueryOptions(item) - let _sql = Utils.formatOptions(_option.sql) - let isSSO = item.database === 'sso' - - let param = { - func: 'sPC_Get_SelectedList', - LText: _sql, - obj_name: 'data', - arr_field: _option.field - } - - if (this.props.BID) { - param.BID = this.props.BID - } - if (this.props.dataManager) { // 鏁版嵁鏉冮檺 - param.LText = param.LText.replace(/\$@/ig, '/*') - param.LText = param.LText.replace(/@\$/ig, '*/') - } else { - param.LText = param.LText.replace(/@\$|\$@/ig, '') - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' - param.secretkey = Utils.encrypt(param.LText, param.timestamp) - - if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 - param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) - } - - let defer = new Promise(resolve => { - Api.getSystemCacheConfig(param, isSSO).then(res => { - res.search = item - resolve(res) - }) - }) - deffers.push(defer) - } else if (item.resourceType === '1' && !item.dataSource) { - notification.warning({ - top: 92, - message: item.label + ': ' + this.state.dict['main.datasource.settingerror'], - duration: 5 - }) - } - }) - - this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))}) - - if (deffers.length === 0) return - - Promise.all(deffers).then(result => { - result.forEach(res => { - if (res.status) { - searchlist = searchlist.map(item => { - if (item.uuid === res.search.uuid) { - res.data.forEach(cell => { - item.options.push({ - key: Utils.getuuid(), - Value: cell[res.search.valueField], - Text: cell[res.search.valueText] - }) - }) - } - return item - }) - } else { - notification.warning({ - top: 92, - message: res.search.label + ':' + res.message, - duration: 5 - }) - } - }) - this.setState({searchlist}) - }) } /** @@ -730,9 +634,12 @@ {loadingview && <Spin />} {searchlist && searchlist.length > 0 ? <SubSearch - refreshdata={this.refreshbysearch} - searchlist={searchlist} + BID={this.props.BID} dict={this.state.dict} + searchlist={searchlist} + menuType={this.props.menuType} + dataManager={this.props.dataManager} + refreshdata={this.refreshbysearch} /> : null } {config ? <div className="chart-view"> diff --git a/src/tabviews/zshare/actionList/index.jsx b/src/tabviews/zshare/actionList/index.jsx index 4fd5296..ddc7bca 100644 --- a/src/tabviews/zshare/actionList/index.jsx +++ b/src/tabviews/zshare/actionList/index.jsx @@ -154,6 +154,7 @@ btn={item} setting={setting} selectedData={selectedData} + updateStatus={this.updateStatus} triggerBtn={this.state.triggerBtn} /> ) diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.jsx b/src/tabviews/zshare/actionList/newpagebutton/index.jsx index a323132..c6b298a 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.jsx +++ b/src/tabviews/zshare/actionList/newpagebutton/index.jsx @@ -1,11 +1,13 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Button, notification } from 'antd' +import { Button, notification, Modal } from 'antd' import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import './index.scss' + +const { confirm } = Modal class NewPageButton extends Component { static propTpyes = { @@ -13,11 +15,13 @@ btn: PropTypes.object, // 鎸夐挳 selectedData: PropTypes.any, // 瀛愯〃涓�夋嫨鏁版嵁 setting: PropTypes.any, // 椤甸潰閫氱敤璁剧疆 + updateStatus: PropTypes.func, // 鎸夐挳鐘舵�佹洿鏂� triggerBtn: PropTypes.any, } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS + dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, + visible: false } /** @@ -82,9 +86,25 @@ let src = '#/print/' + window.btoa('ID=' + Id + msg + cloudmsg) window.open(src) } else if (btn.pageTemplate === 'pay') { - let _p = `ID=${Id}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID')}&logo=${window.GLOB.mainlogo}&name=${sessionStorage.getItem('Full_Name')}&suid=${sessionStorage.getItem('SessionUid')}&icp=${window.GLOB.ICP}©Right=${window.GLOB.copyRight}` + let _p = `ID=${Id}&userid=${sessionStorage.getItem('UserID')}&LoginUID=${sessionStorage.getItem('LoginUID')}&logo=${window.GLOB.doclogo}&name=${sessionStorage.getItem('Full_Name')}&suid=${sessionStorage.getItem('SessionUid')}&icp=${window.GLOB.ICP}©Right=${window.GLOB.copyRight}` let url = '#/pay/' + window.btoa(window.encodeURIComponent(_p)) + let _this = this + _this.props.updateStatus('start') + confirm({ + title: '璇峰湪浠樻椤甸潰瀹屾垚璁㈠崟鏀粯銆�', + content: '', + className: 'pay-query', + okText: '鏀粯鎴愬姛', + cancelText: '鏀粯閬囧埌闂', + onOk() { + _this.props.updateStatus('refresh', 'grid') + }, + onCancel() { + _this.props.updateStatus('refresh', 'grid') + // _this.props.updateStatus('over') + }, + }) window.open(url) } else if (btn.pageTemplate === 'custom') { let url = btn.url diff --git a/src/tabviews/zshare/actionList/newpagebutton/index.scss b/src/tabviews/zshare/actionList/newpagebutton/index.scss index e9a2a7d..94c3ba6 100644 --- a/src/tabviews/zshare/actionList/newpagebutton/index.scss +++ b/src/tabviews/zshare/actionList/newpagebutton/index.scss @@ -8,3 +8,15 @@ display: none!important; } } + +.pay-query { + .ant-modal-confirm-btns { + width: 100%; + text-align: center; + margin-bottom: 24px; + + button:first-child { + margin-right: 20px; + } + } +} diff --git a/src/tabviews/zshare/actionList/normalbutton/index.jsx b/src/tabviews/zshare/actionList/normalbutton/index.jsx index f56f4e5..3627805 100644 --- a/src/tabviews/zshare/actionList/normalbutton/index.jsx +++ b/src/tabviews/zshare/actionList/normalbutton/index.jsx @@ -834,8 +834,8 @@ } else { if (_LongParam.groups.length > 0) { _LongParam.groups.forEach(group => { - group.sublist = group.sublist.filter(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + group.sublist = group.sublist.map(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛� 鏉冮檺榛戝悕鍗曞瓧娈佃缃负闅愯棌琛ㄥ崟 if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) @@ -851,22 +851,22 @@ } // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return true + if (!cell.blacklist || cell.blacklist.length === 0) return cell let _black = cell.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + cell.hidden = 'true' } + + return cell }) }) } else { - _LongParam.fields = _LongParam.fields.filter(cell => { - // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 + _LongParam.fields = _LongParam.fields.map(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) @@ -882,17 +882,17 @@ } // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return true + if (!cell.blacklist || cell.blacklist.length === 0) return cell let _black = cell.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + cell.hidden = 'true' } + + return cell }) } diff --git a/src/tabviews/zshare/actionList/printbutton/index.jsx b/src/tabviews/zshare/actionList/printbutton/index.jsx index e96cfd5..692bc69 100644 --- a/src/tabviews/zshare/actionList/printbutton/index.jsx +++ b/src/tabviews/zshare/actionList/printbutton/index.jsx @@ -1035,7 +1035,7 @@ } else { if (_LongParam.groups.length > 0) { _LongParam.groups.forEach(group => { - group.sublist = group.sublist.filter(cell => { + group.sublist = group.sublist.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) @@ -1052,21 +1052,21 @@ } // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return true + if (!cell.blacklist || cell.blacklist.length === 0) return cell let _black = cell.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + cell.hidden = 'true' } + + return cell }) }) } else { - _LongParam.fields = _LongParam.fields.filter(cell => { + _LongParam.fields = _LongParam.fields.map(cell => { // 鏁版嵁婧恠ql璇彞锛岄澶勭悊 if (['select', 'link', 'multiselect'].includes(cell.type) && cell.resourceType === '1') { let _option = Utils.getSelectQueryOptions(cell) @@ -1083,17 +1083,17 @@ } // 瀛楁鏉冮檺榛戝悕鍗� - if (!cell.blacklist || cell.blacklist.length === 0) return true + if (!cell.blacklist || cell.blacklist.length === 0) return cell let _black = cell.blacklist.filter(v => { return this.props.permRoles.indexOf(v) !== -1 }) if (_black.length > 0) { - return false - } else { - return true + cell.hidden = 'true' } + + return cell }) } diff --git a/src/tabviews/zshare/cardcomponent/index.jsx b/src/tabviews/zshare/cardcomponent/index.jsx index 0190941..46e9799 100644 --- a/src/tabviews/zshare/cardcomponent/index.jsx +++ b/src/tabviews/zshare/cardcomponent/index.jsx @@ -181,6 +181,7 @@ show={show} setting={setting} selectedData={[data]} + updateStatus={this.updateStatus} /> ) } else if (item.OpenType === 'funcbutton') { diff --git a/src/tabviews/zshare/topSearch/index.jsx b/src/tabviews/zshare/topSearch/index.jsx index 60baa3b..478a1a4 100644 --- a/src/tabviews/zshare/topSearch/index.jsx +++ b/src/tabviews/zshare/topSearch/index.jsx @@ -1,8 +1,10 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' +import { fromJS } from 'immutable' import { Form, Row, Col, Input, Button, Select, DatePicker, notification } from 'antd' import moment from 'moment' +import Api from '@/api' import DateGroup from '@/tabviews/zshare/dategroup' import Utils from '@/utils/utils.js' import './index.scss' @@ -11,8 +13,11 @@ class MainSearch extends Component { static propTpyes = { + BID: PropTypes.any, // 鐖剁骇Id锛岀敤浜庢煡璇笅鎷夐�夋嫨椤� + dataManager: PropTypes.any, // 鏁版嵁鏉冮檺 + menuType: PropTypes.any, // 鑿滃崟鏉冮檺锛屾槸鍚︿负HS searchlist: PropTypes.array, // 鎼滅储鏉′欢鍒楄〃 - dict: PropTypes.object // 瀛楀吀椤� + dict: PropTypes.object // 瀛楀吀椤� } state = { @@ -26,7 +31,7 @@ } UNSAFE_componentWillMount () { - let searchlist = JSON.parse(JSON.stringify(this.props.searchlist)) + let searchlist = fromJS(this.props.searchlist).toJS() let match = {} let label = {} let style = {} @@ -46,7 +51,14 @@ required[item.field] = item.required === 'true' if (item.type === 'select' || item.type === 'link') { - item.oriOptions = JSON.parse(JSON.stringify(item.options)) + if (item.setAll === 'true') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: this.props.dict['main.all'] + }) + } + item.oriOptions = fromJS(item.options).toJS() } _list.push(item) @@ -66,8 +78,8 @@ } else { item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) } - } else if (item.type === 'group') { - _groups.push(JSON.parse(JSON.stringify(item))) + } else if (item.type === 'group' && item.Hide !== 'true') { + _groups.push(fromJS(item).toJS()) } return item @@ -80,45 +92,138 @@ required: required, searchlist: _list, groups: _groups + }, () => { + this.improveSearch() }) } - UNSAFE_componentWillReceiveProps(nextProps) { - let searchlist = JSON.parse(JSON.stringify(nextProps.searchlist)) - let _list = [] - let fieldMap = new Map() - + improveSearch = () => { + let searchlist = fromJS(this.props.searchlist).toJS() + let deffers = [] searchlist.forEach(item => { - if (fieldMap.has(item.field)) { - item.field = item.field + '@tail@' - } - fieldMap.set(item.field, true) + if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return - if (item.type === 'select' || item.type === 'link') { - item.oriOptions = JSON.parse(JSON.stringify(item.options)) + if (item.setAll === 'true') { + item.options.unshift({ + key: Utils.getuuid(), + Value: '', + Text: this.props.dict['main.all'] + }) } - _list.push(item) - }) + if (item.resourceType === '1' && item.dataSource) { + let _option = Utils.getSelectQueryOptions(item) + let _sql = Utils.formatOptions(_option.sql) + let isSSO = item.database === 'sso' - _list = _list.map(item => { - if (item.type === 'link') { - let supItem = _list.filter(form => form.field === item.linkField)[0] - - if (supItem) { - item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) + let param = { + func: 'sPC_Get_SelectedList', + LText: _sql, + obj_name: 'data', + arr_field: _option.field } - } - return item + if (this.props.BID) { + param.BID = this.props.BID + } + + if (this.props.dataManager) { // 鏁版嵁鏉冮檺 + param.LText = param.LText.replace(/\$@/ig, '/*') + param.LText = param.LText.replace(/@\$/ig, '*/') + } else { + param.LText = param.LText.replace(/@\$|\$@/ig, '') + } + + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + + if (this.props.menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true) + } + + let defer = new Promise(resolve => { + Api.getSystemCacheConfig(param, isSSO).then(res => { + res.search = item + resolve(res) + }) + }) + deffers.push(defer) + } else if (item.resourceType === '1' && !item.dataSource) { + notification.warning({ + top: 92, + message: item.label + ': ' + this.props.dict['main.datasource.settingerror'], + duration: 5 + }) + } }) - this.setState({ - searchlist: _list + if (deffers.length === 0) { + return + } + + Promise.all(deffers).then(result => { + result.forEach(res => { + if (res.status) { + searchlist = searchlist.map(item => { + if (item.uuid === res.search.uuid) { + res.data.forEach(cell => { + let _item = { + key: Utils.getuuid(), + Value: cell[res.search.valueField], + Text: cell[res.search.valueText] + } + + if (res.search.type === 'link') { + _item.parentId = cell[res.search.linkField] + } + + item.options.push(_item) + }) + } + return item + }) + } else { + notification.warning({ + top: 92, + message: res.search.label + ':' + res.message, + duration: 5 + }) + } + }) + + let _list = [] + let fieldMap = new Map() + + searchlist.forEach(item => { + if (fieldMap.has(item.field)) { + item.field = item.field + '@tail@' + } + fieldMap.set(item.field, true) + + if (item.type === 'select' || item.type === 'link') { + item.oriOptions = fromJS(item.options).toJS() + } + + _list.push(item) + }) + + _list = _list.map(item => { + if (item.type === 'link') { + let supItem = _list.filter(form => form.field === item.linkField)[0] + + if (supItem) { + item.options = item.oriOptions.filter(option => option.parentId === supItem.initval) + } + } + + return item + }) + + this.setState({searchlist: _list}) }) } - resetform = (formlist, supfields, index) => { + resetform = (formlist, supfields, index, fieldsvalue) => { index++ let subfields = [] @@ -127,7 +232,10 @@ if (item.type === 'link' && item.linkField === supfield.field) { item.options = item.oriOptions.filter(option => option.parentId === supfield.initval) item.initval = item.options[0] ? item.options[0].Value : '' - item.hiden = true + + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } subfields.push(item) } @@ -138,19 +246,23 @@ if (subfields.length === 0 || index > 6) { return formlist } else { - return this.resetform(formlist, subfields, index) + return this.resetform(formlist, subfields, index, fieldsvalue) } } selectChange = (_field, value) => { - let formlist = JSON.parse(JSON.stringify(this.state.searchlist)) + let formlist = fromJS(this.state.searchlist).toJS() let subfields = [] + let fieldsvalue = {} formlist = formlist.map(item => { if (item.type === 'link' && item.linkField === _field.field) { item.options = item.oriOptions.filter(option => option.parentId === value) item.initval = item.options[0] ? item.options[0].Value : '' - item.hiden = true + + if (this.props.form.getFieldValue(item.field) !== undefined) { + fieldsvalue[item.field] = item.initval + } subfields.push(item) } @@ -162,19 +274,16 @@ return } - formlist = this.resetform(formlist, subfields, 0) + formlist = this.resetform(formlist, subfields, 0, fieldsvalue) + + if (Object.keys(fieldsvalue).length > 0) { + this.props.form.setFieldsValue(fieldsvalue) + } this.setState({ searchlist: formlist }, () => { - this.setState({ - searchlist: formlist.map(item => { - item.hiden = false - return item - }) - }, () => { - this.searchChange() - }) + this.searchChange() }) } @@ -183,7 +292,7 @@ const fields = [] this.state.searchlist.forEach((item, index) => { - if (item.hidden) return + if (item.Hide === 'true') return if (item.type === 'text') { // 鏂囨湰鎼滅储 fields.push( @@ -373,10 +482,46 @@ return fields } + addHideFieldValue = (values) => { + const { searchlist } = this.state + let hideValue = {} + searchlist.forEach(item => { + if (item.Hide === 'true') { + let value = '' + + if (item.type === 'multiselect') { // 涓嬫媺澶氶�� + value = item.initval ? item.initval.split(',').filter(Boolean) : [] + } else if (item.type === 'date') { // 鏃堕棿鎼滅储 + value = item.initval ? moment().subtract(item.initval, 'days') : '' + } else if (item.type === 'datemonth') { + value = item.initval ? moment().subtract(item.initval, 'month') : '' + } else if (item.type === 'dateweek') { + value = item.initval ? moment().subtract(item.initval * 7, 'days') : '' + } else if (item.type === 'daterange') { + if (item.initval) { + try { + let _initval = JSON.parse(item.initval) + value = [moment().subtract(_initval[0], 'days'), moment().subtract(_initval[1], 'days')] + } catch { + value = '' + } + } + } else { + value = item.initval + } + + hideValue[item.field] = value + } + }) + + return {...hideValue, ...values} + } + handleSearch = (e) => { // 鍥炶溅鎴栫偣鍑绘悳绱� e.preventDefault() this.props.form.validateFields((err, values) => { + values = this.addHideFieldValue(values) let searches = this.getFieldsValues(values) this.props.refreshdata(searches) }) @@ -385,6 +530,7 @@ searchChange = () => { this.setState({}, () => { this.props.form.validateFields((err, values) => { + values = this.addHideFieldValue(values) let searches = this.getFieldsValues(values) this.props.refreshdata(searches) }) @@ -402,12 +548,21 @@ this.refs[item.uuid].reset() }) } - this.props.form.resetFields() - this.props.form.validateFields((err, values) => { - // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁� - this.setState({}, () => { - let searches = this.getFieldsValues(values) - this.props.refreshdata(searches) + + let searchlist = this.state.searchlist.map(item => { + item.initval = item.oriInitval + return item + }) + + this.setState({searchlist}, () => { + this.props.form.resetFields() + this.props.form.validateFields((err, values) => { + // 寮傛鑾峰彇鏇存柊鍚庣殑鏃堕棿缁� + this.setState({}, () => { + values = this.addHideFieldValue(values) + let searches = this.getFieldsValues(values) + this.props.refreshdata(searches) + }) }) }) } diff --git a/src/templates/sharecomponent/searchcomponent/index.jsx b/src/templates/sharecomponent/searchcomponent/index.jsx index bcb9015..d8855cd 100644 --- a/src/templates/sharecomponent/searchcomponent/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/index.jsx @@ -77,10 +77,22 @@ * @description 鎼滅储鏉′欢缂栬緫锛岃幏鍙栨悳绱㈡潯浠惰〃鍗曚俊鎭� */ handleSearch = (card) => { + const { searchlist } = this.state + let linkableFields = [] + + searchlist.forEach(item => { + if (item.uuid !== card.uuid && (item.type === 'select' || item.type === 'link')) { + linkableFields.push({ + value: item.field, + text: item.label + }) + } + }) + this.setState({ visible: true, card: card, - formlist: getSearchForm(card, this.props.sysRoles) + formlist: getSearchForm(card, this.props.sysRoles, linkableFields) }) } diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index 253f6e0..91c2f67 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -108,7 +108,7 @@ let type = formlist.filter(cell => cell.key === 'type')[0].initVal let _items = formlist.filter(cell => cell.key === 'items')[0].initVal let resourceType = formlist.filter(cell => cell.key === 'resourceType')[0].initVal - let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required'] // 榛樿鏄剧ず椤� + let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide'] // 榛樿鏄剧ず椤� if ((type === 'multiselect' || type === 'select' || type === 'link') && resourceType === '0') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮 _options = [..._options, 'resourceType', 'options', 'display', 'quick'] @@ -191,7 +191,7 @@ const { resourceType, items } = this.state if (key === 'type') { - let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required'] + let _options = ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide'] if ((value === 'multiselect' || value === 'select' || value === 'link') && resourceType === '0') { // 涓嬫媺閫夋嫨绫诲瀷銆侀�夐」涓鸿嚜瀹氫箟璧勬簮 _options = [..._options, 'resourceType', 'options', 'display', 'quick'] @@ -284,7 +284,7 @@ let value = e.target.value if (key === 'resourceType') { - let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display', 'ratio', 'blacklist', 'required'] + let _options = ['label', 'field', 'initval', 'type', 'match', 'resourceType', 'display', 'ratio', 'blacklist', 'required', 'Hide'] if (value === '0') { _options = [..._options, 'options', 'quick'] diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx index 5bcbb10..66d00bf 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx @@ -132,7 +132,7 @@ formlist: _formlist.map(item => { if (interType === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { item.hidden = true - } else if (interType === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { + } else if (interType === 'outer' && ['innerFunc', 'dataresource', 'queryType', 'default'].includes(item.key)) { item.hidden = true } @@ -398,7 +398,7 @@ if (value === 'inner' && ['sysInterface', 'interface', 'outerFunc'].includes(item.key)) { item.initVal = this.props.form.getFieldValue(item.key) item.hidden = true - } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType'].includes(item.key)) { + } else if (value === 'outer' && ['innerFunc', 'dataresource', 'queryType', 'default'].includes(item.key)) { item.initVal = this.props.form.getFieldValue(item.key) item.hidden = true } diff --git a/src/templates/zshare/formconfig.jsx b/src/templates/zshare/formconfig.jsx index a040eef..3511138 100644 --- a/src/templates/zshare/formconfig.jsx +++ b/src/templates/zshare/formconfig.jsx @@ -620,10 +620,11 @@ /** * @description 鑾峰彇鎼滅储鏉′欢琛ㄥ崟閰嶇疆淇℃伅 - * @param {object} card // 鎼滅储鏉′欢瀵硅薄 - * @param {Array} roleList // 瑙掕壊鍒楄〃 + * @param {object} card // 鎼滅储鏉′欢瀵硅薄 + * @param {Array} roleList // 瑙掕壊鍒楄〃 + * @param {Array} linkableFields // 鍙叧鑱斿瓧娈� */ -export function getSearchForm (card, roleList) { +export function getSearchForm (card, roleList, linkableFields) { return [ { type: 'text', @@ -763,12 +764,13 @@ }] }, { - type: 'text', + type: 'select', key: 'linkField', label: Formdict['header.form.linkField'], initVal: card.linkField || '', required: true, - readonly: false + readonly: false, + options: linkableFields }, { type: 'text', @@ -839,9 +841,9 @@ options: [{ value: 'dropdown', text: Formdict['header.form.dropdown'] - }, { - value: 'button', - text: Formdict['header.form.button'] + // }, { + // value: 'button', + // text: Formdict['header.form.button'] }] }, { @@ -855,19 +857,6 @@ }, { value: 'sso', text: Formdict['header.form.database.sso'] - }] - }, - { - type: 'radio', - key: 'required', - label: Formdict['model.required'], - initVal: card.required || 'false', - options: [{ - value: 'true', - text: Formdict['model.true'] - }, { - value: 'false', - text: Formdict['model.false'] }] }, { @@ -889,12 +878,30 @@ options: [] }, { - type: 'multiselect', - key: 'blacklist', - label: Formdict['header.form.blacklist'], - initVal: card.blacklist || [], - required: false, - options: roleList || [] + type: 'radio', + key: 'required', + label: Formdict['model.required'], + initVal: card.required || 'false', + options: [{ + value: 'true', + text: Formdict['model.true'] + }, { + value: 'false', + text: Formdict['model.false'] + }] + }, + { + type: 'radio', + key: 'Hide', + label: Formdict['model.hidden'], + initVal: card.Hide || 'false', + options: [{ + value: 'true', + text: Formdict['model.true'] + }, { + value: 'false', + text: Formdict['model.false'] + }] }, { type: 'radio', @@ -909,6 +916,14 @@ value: 'false', text: Formdict['model.false'] }] + }, + { + type: 'multiselect', + key: 'blacklist', + label: Formdict['header.form.blacklist'], + initVal: card.blacklist || [], + required: false, + options: roleList || [] } ] } diff --git a/src/views/mobdesign/index.jsx b/src/views/mobdesign/index.jsx index 744fa84..bf5cf99 100644 --- a/src/views/mobdesign/index.jsx +++ b/src/views/mobdesign/index.jsx @@ -131,12 +131,17 @@ config.components = config.components.map(component => { if (component.uuid === proper.componentId) { Object.keys(component).forEach(key => { - if (component[key].uuid === proper.uuid) { - component[key].style = {...component[key].style, ...proper.style} - // eslint-disable-next-line - for (let index in component[key].style) { - if (component[key].style[index] === '') { - delete component[key].style[index] + let _uuid = component[key].uuid + if (_uuid && (_uuid === proper.uuid || _uuid === proper.classId)) { + if (component[key].substyle) { + + } else { + component[key].style = {...component[key].style, ...proper.style} + // eslint-disable-next-line + for (let index in component[key].style) { + if (component[key].style[index] === '') { + delete component[key].style[index] + } } } } diff --git a/src/views/pay/index.jsx b/src/views/pay/index.jsx index 44c1372..30c32d2 100644 --- a/src/views/pay/index.jsx +++ b/src/views/pay/index.jsx @@ -2,25 +2,32 @@ import moment from 'moment' import md5 from 'md5' import QRCode from 'qrcode.react' -import { notification, Radio } from 'antd' +import { notification, Tabs } from 'antd' import Api from '@/api' import Utils from '@/utils/utils.js' import WeiXinPay from '@/assets/img/weixinpay.jpg' +import WeiXinPayLogo from '@/assets/img/weixinpaylogo.jpg' import WeiXinScan from '@/assets/img/weixinscan.png' import './index.scss' + +const { TabPane } = Tabs class Pay extends Component { state = { orderId: '', orderNo: '', + appid: '', logo: '', name: '', copyRight: '', icp: '', total: '', unit: '', - qrcode: '' + qrcode: '', + second: 60, + overdue: false, + overdone: false } UNSAFE_componentWillMount () { @@ -64,7 +71,7 @@ let param = { func: 's_get_weixin_pay_native', ID: Id, - sandbox: 'Y' + // sandbox: 'Y' } param.LTextOut = md5(param.ID + window.GLOB.appkey) @@ -73,11 +80,28 @@ Api.getLocalConfig(param).then(res => { if (res.status) { + let _total = res.amount ? parseFloat(res.amount.total) : '' + + if (isNaN(_total)) { + _total = '' + } else if (_total !== '') { + _total = _total.toFixed(2) + } + this.setState({ + appid: res.appid, orderNo: res.out_trade_no, - total: res.amount ? res.amount.total : '', + total: _total, unit: res.amount && res.amount.currency === 'CNY' ? '鍏�' : '鍏�', }) + + // 褰撳墠璁㈠崟鏀粯鎴愬姛 + if (res.pay_status) { + this.setState({ + overdone: true + }) + return + } if (!res.out_trade_no) { notification.warning({ @@ -100,7 +124,11 @@ this.setState({ qrcode: result.qrcode }) + setTimeout(this.resetSecond, 1000) } else { + this.setState({ + overdue: true + }) notification.warning({ top: 10, message: result.msg || '鏈幏鍙栧埌鏀粯鐮侊紒', @@ -109,9 +137,79 @@ } }) } else { + this.setState({ + overdue: true + }) notification.warning({ top: 10, message: res.message, + duration: 5 + }) + } + }) + } + + resetSecond = () => { + const { second, orderNo, overdone } = this.state + + if (overdone) return + + if (second >= 1) { + this.setState({ + second: second - 1 + }) + setTimeout(this.resetSecond, 1000) + + if ((second - 1) % 5 === 0) { + let param = { + func: 's_get_weixin_pay_native_status', + out_trade_no: orderNo, + // sandbox: 'Y' + } + + param.LTextOut = md5(orderNo + window.GLOB.appkey) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000' + param.secretkey = Utils.encrypt(param.LTextOut, param.timestamp) + + Api.getLocalConfig(param).then(res => { + if (res.pay_status) { + this.setState({ + overdone: true + }) + } + }) + } + } else { + this.setState({ + overdue: true + }) + } + } + + resetQrcode = () => { + const { appid, orderNo } = this.state + + if (!orderNo) { + notification.warning({ + top: 10, + message: '鏈幏鍙栧埌璁㈠崟鍙凤紒', + duration: 5 + }) + return + } + + Api.getWxNativePay({ 'out_biz_no': orderNo, 'out_open_id': appid }).then(result => { + if (result.qrcode) { + this.setState({ + qrcode: result.qrcode, + overdue: false, + second: 60 + }) + setTimeout(this.resetSecond, 1000) + } else { + notification.warning({ + top: 10, + message: result.msg || '鏈幏鍙栧埌鏀粯鐮侊紒', duration: 5 }) } @@ -123,7 +221,7 @@ } render () { - const { logo, name, orderNo, icp, copyRight, total, unit, qrcode } = this.state + const { logo, name, orderNo, icp, copyRight, total, unit, qrcode, second, overdue, overdone } = this.state return ( <div className="mk-pay-container"> @@ -133,38 +231,49 @@ <div className="user-name">{name}</div> </header> <div className="pay-tip"> - <span>璇锋偍灏藉揩鏀粯锛屼互渚胯鍗曞揩閫熷鐞嗭紒璁㈠崟鍙凤細{orderNo}</span> - <span className="pay-total">搴斾粯閲戦<span>{total}</span>{unit}</span> + <span>璇锋偍灏藉揩鏀粯锛屼互渚胯鍗曞揩閫熷鐞嗭紒{orderNo ? `璁㈠崟鍙凤細${orderNo}` : ''}</span> + {total !== '' ? <span className="pay-total">搴斾粯閲戦<span>{total}</span>{unit}</span> : null} </div> <div className="mk-pay-content"> - <div className="mk-pay-type"> + <Tabs defaultActiveKey="weixin"> + <TabPane tab={<img src={WeiXinPayLogo} alt=""/>} key="weixin"> + {!overdone ? <div className="qrcode-box"> + {!overdue ? <p>璺濈浜岀淮鐮佽繃鏈熻繕鍓�<span>{second}</span>绉掞紝杩囨湡鍚庤鍒锋柊椤甸潰閲嶆柊鑾峰彇浜岀淮鐮併��</p> : null} + {overdue ? <p className="overdue">浜岀淮鐮佸凡杩囨湡锛�<span onClick={this.resetQrcode}>鍒锋柊</span>椤甸潰閲嶆柊鑾峰彇浜岀淮鐮併��</p> : null} + <QRCode + value={qrcode} + size={250} + fgColor="#000000" + // imageSettings={{ + // src: '', + // height: 60, + // width: 60, + // excavate: true + // }} + /> + {overdue ? <div className="overdue-mask"><p onClick={this.resetQrcode}>鑾峰彇澶辫触 鐐瑰嚮閲嶆柊鑾峰彇浜岀淮鐮�</p></div> : null} + <div className="qrcode-tip"> + <img src={WeiXinScan} alt=""/> + <div> + <p>璇蜂娇鐢ㄥ井淇℃壂涓�鎵�</p> + <p>鎵弿浜岀淮鐮佹敮浠�</p> + </div> + </div> + </div> : null} + {overdone ? <div className="overdone"> + <p>鏀粯鎴愬姛锛�</p> + <p>璇峰埛鏂拌鍗曢〉闈紝鏌ョ湅璁㈠崟鐘舵�併��</p> + </div> : null} + {!overdone ? <img className="weixin-scan" src={WeiXinPay} alt=""/> : null} + </TabPane> + </Tabs> + {/* <div className="mk-pay-type"> <span className="tip">鏀粯鏂瑰紡锛�</span> <Radio.Group onChange={this.onChange} value="weixin"> <Radio value="weixin">寰俊鏀粯</Radio> </Radio.Group> - </div> - <div className="qrcode-box"> - <p>浜岀淮鐮佹湁鏁堟椂闀�5鍒嗛挓锛岃繃鏈熷悗璇峰埛鏂伴〉闈㈤噸鏂拌幏鍙栦簩缁寸爜銆�</p> - <QRCode - value={qrcode} - size={230} - fgColor="#000000" - // imageSettings={{ - // src: '', - // height: 60, - // width: 60, - // excavate: true - // }} - /> - <div className="qrcode-tip"> - <img src={WeiXinScan} alt=""/> - <div> - <p>璇蜂娇鐢ㄥ井淇℃壂涓�鎵�</p> - <p>鎵弿浜岀淮鐮佹敮浠�</p> - </div> - </div> - </div> - <img className="weixin-scan" src={WeiXinPay} alt=""/> + </div> */} + </div> <div className="mk-pay-bottom"> {copyRight ? <p dangerouslySetInnerHTML={{ __html: copyRight.replace(/\s/ig, ' ') }}></p> : null} diff --git a/src/views/pay/index.scss b/src/views/pay/index.scss index 9431c9d..b69ffac 100644 --- a/src/views/pay/index.scss +++ b/src/views/pay/index.scss @@ -47,24 +47,63 @@ } .mk-pay-content { - min-height: 470px; + min-height: 500px; box-shadow: 0px 0px 40px #dfdfdf; margin-bottom: 6vh; + + .ant-tabs-bar { + .ant-tabs-tab { + padding: 12px 16px 8px; + img { + width: 80px; + } + } + } .qrcode-box { + position: relative; display: inline-block; width: 50%; text-align: center; p { font-size: 12px; margin-top: 10px; + span { + color: #e31613; + font-weight: bold; + } + } + p.overdue { + color: #e31613; + span { + color: #67a4ff; + cursor: pointer; + font-weight: normal; + } } canvas { padding: 15px; border: 1px solid #dddddd; } + .overdue-mask { + display: inline-block; + width: 250px; + height: 250px; + position: absolute; + top: 40px; + left: calc(50% - 125px); + background: rgba(0, 0, 0, .4); + p { + margin-top: 110px; + background: #ffffff; + display: inline-block; + font-size: 13px; + padding: 5px 10px; + cursor: pointer; + } + } .qrcode-tip { background: #ff7674; - width: 230px; + width: 250px; margin: 10px auto; img { width: 40px; @@ -84,6 +123,16 @@ } } } + .overdone { + text-align: center; + padding-top: 150px; + font-size: 16px; + p:first-child { + color: #26C281; + margin-bottom: 5px; + font-size: 18px; + } + } .weixin-scan { vertical-align: top; width: 280px; -- Gitblit v1.8.0