From a9ac16fecc0cf9bc66dfaefe4e9b35fa3c722812 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 十一月 2020 16:58:43 +0800 Subject: [PATCH] 2020-11-10 --- src/menu/datasource/verifycard/settingform/index.jsx | 256 +++++++++++++++++++++++++++++--------------------- 1 files changed, 149 insertions(+), 107 deletions(-) diff --git a/src/menu/datasource/verifycard/settingform/index.jsx b/src/menu/datasource/verifycard/settingform/index.jsx index b448831..ac736b0 100644 --- a/src/menu/datasource/verifycard/settingform/index.jsx +++ b/src/menu/datasource/verifycard/settingform/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, InputNumber, Select } from 'antd' +import { Form, Row, Col, Input, Radio, Tooltip, Icon, notification, Select, InputNumber, Cascader } from 'antd' import { formRule } from '@/utils/option.js' import Utils from '@/utils/utils.js' @@ -13,37 +13,83 @@ menu: PropTypes.any, // 鑿滃崟閰嶇疆淇℃伅 config: PropTypes.object, // 缁勪欢閰嶇疆 setting: PropTypes.object, // 鏁版嵁婧愰厤缃� + modules: PropTypes.array, // 鍒楄缃� columns: PropTypes.array, // 鍒楄缃� scripts: PropTypes.array, // 鑷畾涔夎剼鏈� } state = { interType: this.props.setting.interType || 'system', - supModule: '', - modules: [] + laypage: this.props.setting.laypage || 'true', + modules: [], + useMSearch: this.props.setting.useMSearch || 'false' } UNSAFE_componentWillMount () { - const { menu, setting, config } = this.props - let supModule = setting.supModule || '' - let modules = [] + const { menu, config } = this.props - menu.components.forEach(item => { - if (!item.switchable || !item.setting || !item.setting.name || item.uuid === config.uuid) return - - modules.push({ - value: item.uuid, - text: item.setting.name - }) - }) - - if (supModule && supModule !== 'empty') { - if (modules.filter(item => item.value === supModule).length === 0) { - supModule = '' - } + let modules = this.getModules(menu.components, config.uuid) + if (!modules) { + modules = [] } - this.setState({supModule, modules}) + modules.unshift({ + value: 'empty', + label: '鏃�' + }) + + this.setState({modules}) + } + + getModules = (components, selfId) => { + let modules = components.map(item => { + if (item.uuid === selfId) { + return { + children: null + } + } else if (item.switchable) { + return { + value: item.uuid, + label: item.name + } + } else if (item.type === 'tabs') { + let _item = { + value: item.uuid, + label: item.name, + children: item.subtabs.map(f_tab => { + let subItem = { + value: f_tab.uuid, + label: f_tab.label, + children: this.getModules(f_tab.components, selfId) + } + + if (!subItem.children || subItem.children.length === 0) { + return {children: null} + } + return subItem + }) + } + + _item.children = _item.children.filter(t => t.children !== null) + + if (_item.children.length === 0) { + return {children: null} + } + + return _item + } else { + return { + children: null + } + } + }) + + modules = modules.filter(mod => mod.children !== null) + + if (modules.length === 0) { + return null + } + return modules } handleConfirm = () => { @@ -129,7 +175,7 @@ render() { const { setting, menu, columns, config } = this.props const { getFieldDecorator } = this.props.form - const { interType, supModule, modules } = this.state + const { interType, modules, useMSearch, laypage } = this.state const formItemLayout = { labelCol: { @@ -160,49 +206,7 @@ <div className="model-datasource-setting-form-box"> <Form {...formItemLayout} className="model-setting-form"> <Row gutter={24}> - <Col span={8}> - <Form.Item label="鏍囬"> - {getFieldDecorator('title', { - initialValue: setting.title - })(<Input placeholder={''} autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鐢ㄤ簬缁勪欢闂寸殑鍖哄垎銆�"> - <Icon type="question-circle" /> - 缁勪欢鍚嶇О - </Tooltip> - }> - {getFieldDecorator('name', { - initialValue: setting.name, - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '缁勪欢鍚嶇О!' - } - ] - })(<Input placeholder={''} autoComplete="off" />)} - </Form.Item> - </Col> - <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title="鏍呮牸甯冨眬锛屾瘡琛岀瓑鍒�24浠姐��"> - <Icon type="question-circle" /> - 瀹藉害 - </Tooltip> - }> - {getFieldDecorator('span', { - initialValue: setting.span || 12, - rules: [ - { - required: true, - message: this.props.dict['form.required.input'] + '瀹藉害!' - } - ] - })(<InputNumber min={1} max={24} precision={0} />)} - </Form.Item> - </Col> + <Col span={8}> <Form.Item label="琛ㄥ悕"> {getFieldDecorator('tableName', { @@ -234,6 +238,28 @@ </Radio.Group>)} </Form.Item> </Col> + {interType === 'system' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'鑷畾涔夎剼鏈腑鐨勫彉閲忥紙闄ゆ姤閿欏強鍙敤瀛楁澶栵級锛岄渶浠ユ鏍囪瘑寮�澶淬��'}> + <Icon type="question-circle" /> + 鍙橀噺鏍囪瘑 + </Tooltip> + }> + {getFieldDecorator('varMark', { + initialValue: setting.varMark || '', + rules: [ + { + pattern: /^[a-zA-Z_]*$/ig, + message: '璇蜂娇鐢ㄥ瓧姣嶆垨_' + }, + { + max: 3, + message: '鏈�澶氫笁涓瓧绗︺��' + } + ] + })(<Input placeholder={''} autoComplete="off" />)} + </Form.Item> + </Col> : null} {interType === 'inner' ? <Col span={8}> <Form.Item label={tooltip ? <Tooltip placement="topLeft" title={tooltip}> @@ -288,18 +314,6 @@ })(<CodeMirror />)} </Form.Item> </Col> : null} - <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title="楂樺害涓虹┖鏃讹紝浣跨敤绯荤粺鑷�傚簲璁剧疆銆�"> - <Icon type="question-circle" /> - 楂樺害 - </Tooltip> - }> - {getFieldDecorator('height', { - initialValue: setting.height || 400 - })(<InputNumber min={150} max={1500} precision={0} />)} - </Form.Item> - </Col> {interType === 'system' ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鏌ヨ鏃讹紝鎼滅储鏉′欢浠here鏉′欢鎷兼帴杩涘叆sql锛岀粺璁℃椂锛屽皢鏁版嵁婧愪腑浠モ�淍+鎼滅储瀛楁+@鈥濈殑鍐呭锛屼互鎼滅储鏉′欢涓殑鍊艰繘琛屾浛鎹㈠悗锛屾彁浜ゆ煡璇紝娉細鏌ヨ绫诲瀷浠呭湪浣跨敤绯荤粺鍑芥暟鏃舵湁鏁堛��'}> @@ -364,7 +378,7 @@ </Tooltip> }> {getFieldDecorator('supModule', { - initialValue: supModule, + initialValue: setting.supModule || [], rules: [ { required: true, @@ -372,18 +386,41 @@ } ] })( - <Select> - <Select.Option key="empty" value="empty"> 鏃� </Select.Option> - {modules.map((option, i) => - <Select.Option key={i} value={option.value}> - {option.text} - </Select.Option> - )} - </Select> + <Cascader options={modules} expandTrigger="hover" placeholder="" /> )} </Form.Item> </Col> - {!config.pageable ? <Col span={8}> + {config.pageable ? <Col span={8}> + <Form.Item label="鍒嗛〉"> + {getFieldDecorator('laypage', { + initialValue: setting.laypage || 'true' + })( + <Radio.Group onChange={(e) => this.setState({laypage: e.target.value})}> + <Radio value="true">鏄�</Radio> + <Radio value="false">鍚�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> : null} + {config.pageable && laypage !== 'false' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title="閫夋嫨鍒嗛〉鏃舵湁鏁堛��"> + <Icon type="question-circle" /> + 姣忛〉鏁伴噺 + </Tooltip> + }> + {getFieldDecorator('pageSize', { + initialValue: setting.pageSize || 10, + rules: [ + { + required: true, + message: this.props.dict['form.required.input'] + '姣忛〉鏁伴噺!' + } + ] + })(<InputNumber min={1} max={500} precision={0} />)} + </Form.Item> + </Col> : null} + {!config.pageable || (config.pageable && laypage === 'false') ? <Col span={8}> <Form.Item label={ <Tooltip placement="topLeft" title={'鍒濆鍖栧姞杞芥椂锛屾槸鍚︿笌鍏朵粬缁勪欢涓�鍚屽姞杞芥暟鎹紝娉細浠呭湪浣跨敤绯荤粺鍑芥暟锛屼笖鍒濆鍖栧姞杞芥暟鎹椂鏈夋晥锛屽垎椤佃姹傛椂鏃犳晥銆�'}> <Icon type="question-circle" /> @@ -400,10 +437,32 @@ )} </Form.Item> </Col> : null} - {config.pageable ? <Col span={8}> - <Form.Item label="鍒嗛〉"> - {getFieldDecorator('laypage', { - initialValue: setting.laypage || 'false' + <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'浼樺厛浣跨敤鍚岀骇鐨勬悳绱㈡潯浠剁粍浠讹紝鍚岀骇鎼滅储涓嶅瓨鍦ㄦ椂锛屼緷娆″悜涓婇�夊彇锛屼笌褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵竴鍚岀敤浣滄暟鎹繃婊わ紙褰撳墠缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> + <Icon type="question-circle" /> + 澶栧眰鎼滅储 + </Tooltip> + }> + {getFieldDecorator('useMSearch', { + initialValue: setting.useMSearch || 'false' + })( + <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}> + <Radio value="true">浣跨敤</Radio> + <Radio value="false">涓嶄娇鐢�</Radio> + </Radio.Group> + )} + </Form.Item> + </Col> + {useMSearch === 'true' ? <Col span={8}> + <Form.Item label={ + <Tooltip placement="topLeft" title={'澶栧眰鎼滅储鏉′欢鏀瑰彉鏃讹紝鏄惁鍒锋柊褰撳墠缁勪欢鏁版嵁銆�'}> + <Icon type="question-circle" /> + 鍚屾鍒锋柊 + </Tooltip> + }> + {getFieldDecorator('syncRefresh', { + initialValue: setting.syncRefresh || 'true' })( <Radio.Group> <Radio value="true">鏄�</Radio> @@ -412,23 +471,6 @@ )} </Form.Item> </Col> : null} - <Col span={8}> - <Form.Item label={ - <Tooltip placement="topLeft" title={'浣跨敤涓绘悳绱㈡潯浠讹紙瀛樺湪鏃讹級锛屼富鎼滅储鏉′欢涓庣粍浠剁殑鎼滅储鏉′欢浼氫竴鍚岀敤浣滄暟鎹繃婊わ紙缁勪欢鐨勬悳绱㈡潯浠朵紭鍏堬級銆�'}> - <Icon type="question-circle" /> - 涓绘悳绱� - </Tooltip> - }> - {getFieldDecorator('useMSearch', { - initialValue: setting.useMSearch || 'false' - })( - <Radio.Group> - <Radio value="true">浣跨敤</Radio> - <Radio value="false">涓嶄娇鐢�</Radio> - </Radio.Group> - )} - </Form.Item> - </Col> <Col span={8}> <Form.Item label="鍒濆鍖栨暟鎹�"> {getFieldDecorator('onload', { -- Gitblit v1.8.0