king
2023-01-07 5b66fe77e55767eabbf1df66a026157356dd807d
src/views/appmanage/submutilform/index.jsx
@@ -1,11 +1,12 @@
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 {
@@ -15,20 +16,29 @@
    inputSubmit: PropTypes.func  // input回车提交
  }
  state = {msgs: [], typename: 'mob', user_binding: []}
  state = {typename: 'mob', adapters: [], exts: []}
  UNSAFE_componentWillMount() {
    const { card } = this.props
    let msgs = sessionStorage.getItem('msgTemplate')
    let user_binding = []
    let adapters = []
    let exts = []
    let typename = 'mob'
    if (card) {
      typename = card.typename || 'mob'
      user_binding = card.user_binding ? card.user_binding.split(',') : []
      adapters = card.adapter ? card.adapter.split(',') : []
      if (typename !== 'pc') {
        if (card.user_binding === 'true') {
          exts.push('user_binding')
        }
        if (card.share === 'true') {
          exts.push('share')
        }
      }
    }
    this.setState({msgs: JSON.parse(msgs), typename, user_binding})
    this.setState({typename, adapters, exts})
  }
  /**
@@ -38,23 +48,25 @@
    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.adapter = values.adapter ? values.adapter.join(',') : ''
          if (values.exts) {
            values.user_binding = values.exts.includes('user_binding') ? 'true' : 'false'
            values.share = values.exts.includes('share') ? 'true' : 'false'
            delete values.exts
          }
          resolve(values)
        }
      })
    })
  }
  onChange = (vals) => {
    this.setState({user_binding: vals})
  onAdapterChange = (vals) => {
    if (!vals.includes('weixin') && !vals.includes('wxmini')) {
      this.setState({exts: []})
    }
    this.setState({adapters: vals})
  }
  /**
@@ -68,7 +80,7 @@
  render() {
    const { card, type } = this.props
    const { getFieldDecorator } = this.props.form
    const { msgs, typename, user_binding } = this.state
    const { typename, adapters, exts } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -89,7 +101,7 @@
                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>
@@ -108,18 +120,6 @@
              )}
            </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', {
@@ -138,70 +138,122 @@
                initialValue: card ? card.css : 'bg_black_style_blue'
              })(
                <Select>
                  <Select.Option value="bg_black_style_blue">蓝色</Select.Option>
                  <Select.Option value="bg_black_style_red">红色</Select.Option>
                  <Select.Option value="bg_black_style_orange_red">橙红色</Select.Option>
                  <Select.Option value="bg_black_style_orange">橙色</Select.Option>
                  <Select.Option value="bg_black_style_orange_yellow">橙黄色</Select.Option>
                  <Select.Option value="bg_black_style_yellow">黄色</Select.Option>
                  <Select.Option value="bg_black_style_yellow_green">黄绿色</Select.Option>
                  <Select.Option value="bg_black_style_green">绿色</Select.Option>
                  <Select.Option value="bg_black_style_cyan">青色</Select.Option>
                  <Select.Option value="bg_black_style_blue_purple">蓝紫色</Select.Option>
                  <Select.Option value="bg_black_style_purple">紫色</Select.Option>
                  <Select.Option value="bg_black_style_magenta">洋红色</Select.Option>
                  <Select.Option value="bg_black_style_grass_green">草绿色</Select.Option>
                  <Select.Option value="bg_black_style_deep_red">深红色</Select.Option>
                  <Select.Option value="bg_black_style_blue"><span className="color-block" style={{background: '#1890ff'}}></span>蓝色(#1890ff)</Select.Option>
                  <Select.Option value="bg_black_style_red"><span className="color-block" style={{background: '#f5222d'}}></span>红色(#f5222d)</Select.Option>
                  <Select.Option value="bg_black_style_orange_red"><span className="color-block" style={{background: '#fa541c'}}></span>橙红色(#fa541c)</Select.Option>
                  <Select.Option value="bg_black_style_orange"><span className="color-block" style={{background: '#fa8c16'}}></span>橙色(#fa8c16)</Select.Option>
                  <Select.Option value="bg_black_style_orange_yellow"><span className="color-block" style={{background: '#faad14'}}></span>橙黄色(#faad14)</Select.Option>
                  <Select.Option value="bg_black_style_yellow"><span className="color-block" style={{background: '#fadb14'}}></span>黄色(#fadb14)</Select.Option>
                  <Select.Option value="bg_black_style_yellow_green"><span className="color-block" style={{background: '#a0d911'}}></span>黄绿色(#a0d911)</Select.Option>
                  <Select.Option value="bg_black_style_green"><span className="color-block" style={{background: '#52c41a'}}></span>绿色(#52c41a)</Select.Option>
                  <Select.Option value="bg_black_style_cyan"><span className="color-block" style={{background: '#13c2c2'}}></span>青色(#13c2c2)</Select.Option>
                  <Select.Option value="bg_black_style_blue_purple"><span className="color-block" style={{background: '#2f54eb'}}></span>蓝紫色(#2f54eb)</Select.Option>
                  <Select.Option value="bg_black_style_purple"><span className="color-block" style={{background: '#722ed1'}}></span>紫色(#722ed1)</Select.Option>
                  <Select.Option value="bg_black_style_magenta"><span className="color-block" style={{background: '#eb2f96'}}></span>洋红色(#eb2f96)</Select.Option>
                  <Select.Option value="bg_black_style_grass_green"><span className="color-block" style={{background: '#aeb303'}}></span>草绿色(#aeb303)</Select.Option>
                  <Select.Option value="bg_black_style_deep_red"><span className="color-block" style={{background: '#c32539'}}></span>深红色(#c32539)</Select.Option>
                  <Select.Option value="bg_black_style_deep_blue"><span className="color-block" style={{background: '#1d3661'}}></span>深蓝色(#1d3661)</Select.Option>
                </Select>
              )}
            </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={
              <Tooltip placement="topLeft" title="短信模板可在管理系统 HS-奇云短信模板 处添加。">
              <Tooltip placement="topLeft" title="在公众号或小程序中,可添加绑定系统用户、自定义分享等功能,自定义分享设置后,当前子应用将默认使用此分享链接。">
                <QuestionCircleOutlined className="mk-form-tip" />
                短信模板
                扩展功能
              </Tooltip>
            }>
              {getFieldDecorator('sms_id', {
                initialValue: card ? card.sms_id || '' : '',
                rules: [{
                  required: true,
                  message: '使用手机短信时请选择短信模板!'
                }]
              {getFieldDecorator('exts', {
                initialValue: exts
              })(
                <Select allowClear>
                  {msgs.map(option =>
                    <Select.Option key={option.ID} value={option.ID}>{option.SignName + ' - ' + option.TemplateCode}</Select.Option>
                  )}
                </Select>
                <Checkbox.Group onChange={(vals) => this.setState({exts: vals})}>
                  <Checkbox value="user_binding">用户绑定</Checkbox>
                  <Checkbox value="share">分享</Checkbox>
                </Checkbox.Group>
              )}
            </Form.Item>
          </Col> : null}
          {/* {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>
              )}
            </Form.Item>
          </Col> : null} */}
          <Col span={12}>
            <Form.Item label="标题">
            <Form.Item label={
              exts.includes('share') ?
              <Tooltip placement="topLeft" title="子应用及分享时的标题。">
                <QuestionCircleOutlined className="mk-form-tip" />
                标题
              </Tooltip> : '标题'
            }>
              {getFieldDecorator('title', {
                initialValue: card ? card.title || '' : ''
                initialValue: card ? card.title || '' : '',
                rules: exts.includes('share') ? [{
                  required: true,
                  message: '请填写标题!'
                }] : []
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
            </Form.Item>
          </Col>
          {exts.includes('share') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="分享时的描述信息。">
                <QuestionCircleOutlined className="mk-form-tip" />
                分享描述
              </Tooltip>
            }>
              {getFieldDecorator('share_des', {
                initialValue: card ? card.share_des || '' : ''
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
            </Form.Item>
          </Col> : null}
          {exts.includes('share') ? <Col span={12}>
            <Form.Item label="分享图片">
              {getFieldDecorator('share_url', {
                initialValue: card ? card.share_url : ''
              })(
                <SourceComponent type="picture" placement="right"/>
              )}
            </Form.Item>
          </Col> : null}
          {exts.includes('share') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="分享的链接为用户浏览的页面地址或当前应用的入口地址。注:可在页面中自定义设置。">
                <QuestionCircleOutlined className="mk-form-tip" />
                分享链接
              </Tooltip>
            }>
              {getFieldDecorator('share_link', {
                initialValue: card ? card.share_link || 'main' : 'main'
              })(
                <Radio.Group>
                  <Radio value="main">应用入口</Radio>
                  <Radio value="view">页面链接</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={12}>
            <Form.Item label="网站头像">
              {getFieldDecorator('favicon', {
@@ -211,35 +263,9 @@
              )}
            </Form.Item>
          </Col>
          {typename !== 'pc' && user_binding.length > 0 ? <Col span={12}>
          {typename !== 'pc' && adapters.includes('app') ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="使用微信授权登录时,绑定用户页面的版权声明,注:可添加html标签。">
                <QuestionCircleOutlined className="mk-form-tip" />
                版权
              </Tooltip>
            }>
              {getFieldDecorator('copyright', {
                initialValue: card ? card.copyright || '' : ''
              })(<Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />)}
            </Form.Item>
          </Col> : null}
          {typename !== 'pc' && user_binding.length > 0 ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="使用微信授权登录时,绑定用户页面的LOGO。">
                <QuestionCircleOutlined className="mk-form-tip" />
                LOGO
              </Tooltip>
            }>
              {getFieldDecorator('logo', {
                initialValue: card ? card.logo : ''
              })(
                <SourceComponent type="picture" placement="right"/>
              )}
            </Form.Item>
          </Col> : null}
          {typename !== 'pc' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="在使用明科云APP时,页面的切换模式">
              <Tooltip placement="topLeft" title="在使用明科云APP时,页面的切换模式。注:苹果APP暂不支持H5模式。">
                <QuestionCircleOutlined className="mk-form-tip" />
                应用模式
              </Tooltip>
@@ -256,17 +282,17 @@
          </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>
            }>
              {getFieldDecorator('delay', {
                initialValue: card ? card.delay || 0 : 0
                initialValue: card ? card.delay || 0 : 200
              })(<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" />
@@ -283,6 +309,37 @@
              )}
            </Form.Item>
          </Col> : null}
          <Col span={12}>
            <Form.Item className="sys-bgcolor" label={
              <Tooltip placement="topLeft" title="子应用通用的背景色,子应用页面创建时会默认添加此背景色。">
                <QuestionCircleOutlined className="mk-form-tip" />
                背景色
              </Tooltip>
            }>
              {getFieldDecorator('sysBgColor', {
                initialValue: card ? card.sysBgColor || '#ffffff' : '#ffffff'
              })(
                <ColorSketch/>
              )}
            </Form.Item>
          </Col>
          {typename === 'pad' ? <Col span={12}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="系统默认屏幕方向,单个页面方向请在页面中配置。">
                <QuestionCircleOutlined className="mk-form-tip" />
                屏幕方向
              </Tooltip>
            }>
              {getFieldDecorator('direction', {
                initialValue: card ? card.direction || 'vertical' : 'vertical'
              })(
                <Radio.Group>
                  <Radio value="vertical">竖屏</Radio>
                  <Radio value="horizontal">横屏</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
        </Row>
      </Form>
    )