| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Form, Row, Col, Select, Radio, Input, Tooltip, notification, InputNumber, Checkbox } from 'antd' |
| | | import { Form, Row, Col, Select, Radio, Input, Tooltip, InputNumber, Checkbox } from 'antd' |
| | | import { QuestionCircleOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import './index.scss' |
| | | |
| | | const ColorSketch = asyncComponent(() => import('@/mob/colorsketch')) |
| | | const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) |
| | | |
| | | class MainSearch extends Component { |
| | |
| | | inputSubmit: PropTypes.func // input回车提交 |
| | | } |
| | | |
| | | state = {msgs: [], typename: 'mob', user_binding: []} |
| | | state = {typename: 'mob', adapters: []} |
| | | |
| | | UNSAFE_componentWillMount() { |
| | | const { card } = this.props |
| | | let msgs = sessionStorage.getItem('msgTemplate') |
| | | let user_binding = [] |
| | | let adapters = [] |
| | | let typename = 'mob' |
| | | |
| | | if (card) { |
| | | typename = card.typename || 'mob' |
| | | user_binding = card.user_binding ? card.user_binding.split(',') : [] |
| | | adapters = card.adapter ? card.adapter.split(',') : [] |
| | | } |
| | | |
| | | this.setState({msgs: JSON.parse(msgs), typename, user_binding}) |
| | | this.setState({typename, adapters}) |
| | | } |
| | | |
| | | /** |
| | |
| | | return new Promise(resolve => { |
| | | this.props.form.validateFieldsAndScroll((err, values) => { |
| | | if (!err) { |
| | | values.user_binding = values.user_binding ? values.user_binding.join(',') : '' |
| | | if (values.user_binding.indexOf('sms_vcode') > -1 && !values.sms_id) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '手机号绑定时,需要短信模板!', |
| | | duration: 5 |
| | | }) |
| | | return |
| | | } |
| | | // values.user_binding = values.user_binding ? values.user_binding.join(',') : '' |
| | | values.adapter = values.adapter ? values.adapter.join(',') : '' |
| | | // if (values.user_binding.indexOf('sms_vcode') > -1 && !values.sms_id) { |
| | | // notification.warning({ |
| | | // top: 92, |
| | | // message: '手机号绑定时,需要短信模板!', |
| | | // duration: 5 |
| | | // }) |
| | | // return |
| | | // } |
| | | resolve(values) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | onChange = (vals) => { |
| | | this.setState({user_binding: vals}) |
| | | // onChange = (vals) => { |
| | | // this.setState({user_binding: vals}) |
| | | // } |
| | | |
| | | onAdapterChange = (vals) => { |
| | | this.setState({adapters: vals}) |
| | | // if (!vals.includes('weixin') && !vals.includes('wxmini')) { |
| | | // this.setState({user_binding: []}) |
| | | // } |
| | | } |
| | | |
| | | /** |
| | |
| | | render() { |
| | | const { card, type } = this.props |
| | | const { getFieldDecorator } = this.props.form |
| | | const { msgs, typename, user_binding } = this.state |
| | | const { typename, adapters } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | initialValue: typename |
| | | })( |
| | | <Select disabled={type === 'edit'} onChange={(val) => this.setState({typename: val})}> |
| | | <Select.Option value="mob">移动端(包括android、ios)</Select.Option> |
| | | <Select.Option value="mob">移动端</Select.Option> |
| | | <Select.Option value="pad">Pad端</Select.Option> |
| | | <Select.Option value="pc">PC端</Select.Option> |
| | | </Select> |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {/* <Col span={12}> |
| | | <Form.Item label="登录"> |
| | | {getFieldDecorator('login_types', { |
| | | initialValue: card ? card.login_types || 'true' : 'true' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="true">需要</Radio> |
| | | <Radio value="false">不需要</Radio> |
| | | </Radio.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> */} |
| | | <Col span={12}> |
| | | <Form.Item label="权限管理"> |
| | | {getFieldDecorator('role_type', { |
| | |
| | | </Form.Item> |
| | | </Col> |
| | | {typename !== 'pc' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="使用公众号授权登录或使用小程序时,是否需要绑定用户。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 用户绑定 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('user_binding', { |
| | | initialValue: user_binding |
| | | <Form.Item label="适配"> |
| | | {getFieldDecorator('adapter', { |
| | | initialValue: adapters |
| | | })( |
| | | <Checkbox.Group onChange={this.onChange}> |
| | | <Checkbox value="uname_pwd">账号</Checkbox> |
| | | <Checkbox value="sms_vcode">手机短信</Checkbox> |
| | | <Checkbox.Group onChange={this.onAdapterChange}> |
| | | <Checkbox value="app">app</Checkbox> |
| | | <Checkbox value="weixin">公众号</Checkbox> |
| | | <Checkbox value="wxmini">小程序</Checkbox> |
| | | </Checkbox.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {typename !== 'pc' && user_binding.includes('sms_vcode') ? <Col span={12}> |
| | | {typename !== 'pc' && (adapters.includes('weixin') || adapters.includes('wxmini')) ? <Col span={12}> |
| | | <Form.Item label="用户绑定"> |
| | | {getFieldDecorator('user_binding', { |
| | | initialValue: card ? card.user_binding : 'false' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="true">需要</Radio> |
| | | <Radio value="false">不需要</Radio> |
| | | </Radio.Group> |
| | | // <Checkbox.Group onChange={this.onChange}> |
| | | // <Checkbox value="uname_pwd">账号</Checkbox> |
| | | // <Checkbox value="sms_vcode">手机短信</Checkbox> |
| | | // </Checkbox.Group> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {/* {typename !== 'pc' && user_binding.includes('sms_vcode') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="短信模板可在管理系统 HS-奇云短信模板 处添加。"> |
| | | <Tooltip placement="topLeft" title="短信模板可在 云系统->应用服务->开发者中心->短信模板 处添加。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 短信模板 |
| | | </Tooltip> |
| | |
| | | </Select> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> : null} */} |
| | | <Col span={12}> |
| | | <Form.Item label="标题"> |
| | | {getFieldDecorator('title', { |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> |
| | | {typename !== 'pc' && user_binding.length > 0 ? <Col span={12}> |
| | | {/* {typename !== 'pc' && user_binding.length > 0 ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="使用微信授权登录时,绑定用户页面的版权声明,注:可添加html标签。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | <SourceComponent type="picture" placement="right"/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {typename !== 'pc' ? <Col span={12}> |
| | | </Col> : null} */} |
| | | {typename !== 'pc' && adapters.includes('app') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="在使用明科云APP时,页面的切换模式"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | </Col> : null} |
| | | {typename !== 'pc' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="在使用明科云APP时,且在app模式中无效"> |
| | | <Tooltip placement="topLeft" title="在使用小程序或明科云APP时(app模式中)无效"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 延迟加载(ms) |
| | | </Tooltip> |
| | |
| | | })(<InputNumber min={0} max={5000} precision={0} onPressEnter={this.handleSubmit}/>)} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {typename !== 'pc' ? <Col span={12}> |
| | | {typename !== 'pc' && adapters.includes('app') ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="在使用明科云APP时,状态栏的字体颜色。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | {typename !== 'pc' ? <Col span={12}> |
| | | <Form.Item label={ |
| | | <Tooltip placement="topLeft" title="请确认当前应用是否在小程序中使用。"> |
| | | <Col span={12}> |
| | | <Form.Item className="sys-bgcolor" label={ |
| | | <Tooltip placement="topLeft" title="子应用通用的背景色,子应用页面创建时会默认添加此背景色。"> |
| | | <QuestionCircleOutlined className="mk-form-tip" /> |
| | | 小程序 |
| | | 背景色 |
| | | </Tooltip> |
| | | }> |
| | | {getFieldDecorator('adapter', { |
| | | initialValue: card ? card.adapter || 'false' : 'false' |
| | | {getFieldDecorator('sysBgColor', { |
| | | initialValue: card ? card.sysBgColor || '#ffffff' : '#ffffff' |
| | | })( |
| | | <Radio.Group> |
| | | <Radio value="false">不适配</Radio> |
| | | <Radio value="true">适配</Radio> |
| | | </Radio.Group> |
| | | <ColorSketch/> |
| | | )} |
| | | </Form.Item> |
| | | </Col> : null} |
| | | </Col> |
| | | </Row> |
| | | </Form> |
| | | ) |