| | |
| | | |
| | | import { formRule } from '@/utils/option.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import MenuUtils from '@/utils/utils-custom.js' |
| | | import CodeMirror from '@/templates/zshare/codemirror' |
| | | import './index.scss' |
| | | |
| | | const { TextArea } = Input |
| | | |
| | | class SettingForm extends Component { |
| | | static propTpyes = { |
| | |
| | | menu: PropTypes.any, // 菜单配置信息 |
| | | config: PropTypes.object, // 组件配置 |
| | | setting: PropTypes.object, // 数据源配置 |
| | | modules: PropTypes.array, // 列设置 |
| | | modules: PropTypes.array, // 可绑定的上级组件 |
| | | columns: PropTypes.array, // 列设置 |
| | | scripts: PropTypes.array, // 自定义脚本 |
| | | } |
| | |
| | | UNSAFE_componentWillMount () { |
| | | const { menu, config } = this.props |
| | | |
| | | let modules = this.getModules(menu.components, config.uuid) |
| | | let modules = MenuUtils.getSupModules(menu.components, config.uuid) |
| | | if (!modules) { |
| | | modules = [] |
| | | } |
| | |
| | | if (usefulFields) { |
| | | try { |
| | | usefulFields = JSON.parse(usefulFields) |
| | | } catch { |
| | | } catch (e) { |
| | | usefulFields = [] |
| | | } |
| | | } else { |
| | |
| | | } |
| | | |
| | | this.setState({modules, usefulFields}) |
| | | } |
| | | |
| | | 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 = () => { |
| | |
| | | } |
| | | } |
| | | |
| | | onSysInter = (e) => { |
| | | let value = e.target.value |
| | | |
| | | if (value === 'true') { |
| | | this.props.form.setFieldsValue({interface: window.GLOB.mainSystemApi}) |
| | | } |
| | | } |
| | | |
| | | changeSupModule = (val) => { |
| | | this.setState({supModule: val}) |
| | | } |
| | | |
| | | render() { |
| | | const { setting, menu, columns, config } = this.props |
| | | const { setting, columns, config } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { interType, modules, useMSearch, laypage, supModule, usefulFields } = this.state |
| | | |
| | |
| | | required: true, |
| | | message: this.props.dict['form.required.input'] + '表名!' |
| | | }, |
| | | { |
| | | max: 50, |
| | | message: '表名最长为50个字符!' |
| | | } |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | </Form.Item> |
| | |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> |
| | | {interType === 'outer' ? <Col span={8}> |
| | | <Form.Item label="系统接口"> |
| | | {getFieldDecorator('sysInterface', { |
| | | initialValue: setting.sysInterface || 'false' |
| | | })( |
| | | <Radio.Group onChange={this.onSysInter}> |
| | | <Radio value="true">是</Radio> |
| | | <Radio value="false">否</Radio> |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'system' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'自定义脚本中的变量(除报错及可用字段外),需以此标识开头。'}> |
| | |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={8}> |
| | | {interType === 'outer' ? <Col className="outer-interface" span={24}> |
| | | <Form.Item label="接口地址"> |
| | | {getFieldDecorator('interface', { |
| | | initialValue: setting.interface || '', |
| | |
| | | message: this.props.dict['form.required.input'] + '接口地址!' |
| | | } |
| | | ] |
| | | })(<Input placeholder={''} autoComplete="off" />)} |
| | | })(<TextArea rows={2}/>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col className="outer-interface" span={24}> |
| | | <Form.Item label={<Tooltip placement="topLeft" title="正式系统接口地址,为空时使用接口地址"> |
| | | <Icon type="question-circle" /> |
| | | 正式地址 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('proInterface', { |
| | | initialValue: setting.proInterface || '' |
| | | })(<TextArea rows={2}/>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {interType === 'outer' ? <Col span={8}> |
| | |
| | | </Col> : null} |
| | | {interType === 'system' ? <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={'使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 \'\'、 @$ -> */ 或 \'\''}> |
| | | <Tooltip placement="topLeft" title={`使用系统函数时,需填写数据源。注:数据权限替换符 $@ -> /* 或 ''、 @$ -> */ 或 '';查询替换符 $select@ -> /* 或 ''、 @select$ -> */ 或 '';统计替换符 $sum@ -> /* 或 ''、 @sum$ -> */ 或 ''。`}> |
| | | <Icon type="question-circle" /> |
| | | 数据源 |
| | | </Tooltip> |
| | |
| | | {config.format === 'array' ? <Col span={8}> |
| | | <Form.Item label="默认排序"> |
| | | {getFieldDecorator('order', { |
| | | initialValue: setting.order || '', |
| | | initialValue: setting.order || 'ID desc', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | |
| | | </Radio.Group>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' ? <Col span={8}> |
| | | {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'该组件如果受其他组件控制,请选项相应的组件,没有时选“无”。'}> |
| | | <Icon type="question-circle" /> |
| | | 上级模块 |
| | | 上级组件 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('supModule', { |
| | |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: this.props.dict['form.required.select'] + '上级模块!' |
| | | message: this.props.dict['form.required.select'] + '上级组件!' |
| | | } |
| | | ] |
| | | })( |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' && config.pageable ? <Col span={8}> |
| | | {config.pageable ? <Col span={8}> |
| | | <Form.Item label="分页"> |
| | | {getFieldDecorator('laypage', { |
| | | initialValue: setting.laypage || 'true' |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' && config.pageable && laypage !== 'false' ? <Col span={8}> |
| | | {config.pageable && laypage !== 'false' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="选择分页时有效。"> |
| | | <Icon type="question-circle" /> |
| | |
| | | })(<InputNumber min={1} max={500} precision={0} />)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {/* 1、不分页且不存在上级模块 2、打印时 */} |
| | | {((!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty')) || menu.MenuType === 'billPrint' ? <Col span={8}> |
| | | {/* 1、不分页且不存在上级模块 */} |
| | | {config.type !== 'navbar' && (!config.pageable || (config.pageable && laypage === 'false')) && (!supModule || supModule.length === 0 || supModule[0] === 'empty') ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'初始化加载时,是否与其他组件一同加载数据,注:仅在使用系统函数,且初始化加载数据时有效,分页请求时无效。'}> |
| | | <Icon type="question-circle" /> |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' ? <Col span={8}> |
| | | {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'优先使用同级的搜索条件组件,同级搜索不存在时,依次向上选取,与当前组件的搜索条件一同用作数据过滤(当前组件的搜索条件优先)。'}> |
| | | <Icon type="question-circle" /> |
| | | 外层搜索 |
| | | 外部搜索 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('useMSearch', { |
| | | initialValue: setting.useMSearch || 'false' |
| | | initialValue: setting.useMSearch || 'true' |
| | | })( |
| | | <Radio.Group onChange={(e) => this.setState({useMSearch: e.target.value})}> |
| | | <Radio value="true">使用</Radio> |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' && useMSearch === 'true' ? <Col span={8}> |
| | | {config.type !== 'navbar' && config.type !== 'balcony' && useMSearch === 'true' ? <Col span={8}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title={'外层搜索条件改变时,是否刷新当前组件数据。'}> |
| | | <Icon type="question-circle" /> |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {menu.MenuType !== 'billPrint' ? <Col span={8}> |
| | | {config.type !== 'navbar' && config.type !== 'balcony' ? <Col span={8}> |
| | | <Form.Item label="初始化数据"> |
| | | {getFieldDecorator('onload', { |
| | | initialValue: setting.onload || 'true' |