king
2025-05-13 1a176e4bdba485301385caac1a29102e598d25cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Form, Row, Col, Input, Radio, Tooltip, InputNumber } from 'antd'
import { QuestionCircleOutlined } from '@ant-design/icons'
 
import asyncComponent from '@/utils/asyncComponent'
import './index.scss'
 
const { TextArea } = Input
const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent'))
 
class CustomMenuForm extends Component {
  static propTpyes = {
    config: PropTypes.object,
    MenuId: PropTypes.string,
    adapters: PropTypes.array,
    updateConfig: PropTypes.func
  }
 
  state = {}
 
  componentDidMount() {
    const { config } = this.props
 
    if (config.getLocation === 'true') {
      window.GLOB.getLocation = true
    }
  }
 
  // 一二级菜单切换
  selectChange = (key, value, hex) => {
    if (key === 'cacheTime' || key === 'localCacheTime') {
      if (typeof(value) !== 'number') {
        value = ''
      }
    }
 
    let _config = {...this.props.config, [key]: value}
 
    if (key === 'statusBarbgColor') { // 小程序状态栏
      if (hex) {
        _config.statusBarHexColor = hex
      } else {
        delete _config.statusBarHexColor
      }
    } else if (key === 'getLocation') {
      window.GLOB.getLocation = value === 'true'
    }
 
    this.props.updateConfig(_config)
  }
 
  render() {
    const { config, adapters } = 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="custom-menu-form">
        <Row>
          <Col span={24}>
            <Form.Item label="菜单名称">
              {getFieldDecorator('MenuName', {
                initialValue: config.MenuName,
                rules: [
                  {
                    required: true,
                    message: '请输入菜单名称!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuName', e.target.value)}}/>)}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="菜单参数">
              {getFieldDecorator('MenuNo', {
                initialValue: config.MenuNo,
                rules: [
                  {
                    required: true,
                    message: '请输入菜单参数!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('MenuNo', e.target.value)}}/>)}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="是否检验后端sql的权限,使用后端sql脚本时有效。">
                <QuestionCircleOutlined className="mk-form-tip" />
                sql验证
              </Tooltip>
            }>
              {getFieldDecorator('sqlperm', {
                initialValue: config.sqlperm || 'true'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('sqlperm', e.target.value)}}>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="数据会缓存到用户本地,方便页面快速呈现。">
                <QuestionCircleOutlined className="mk-form-tip" />
                本地缓存
              </Tooltip>
            }>
              {getFieldDecorator('cacheLocal', {
                initialValue: config.cacheLocal || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('cacheLocal', e.target.value)}}>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {config.cacheLocal === 'true' ? <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="设置本地缓存时长后,在缓存期限内不向后台请求数据,时长最大为5天(即7200分钟)。注:时长为空时缓存数据只用于页面快速呈现,不影响接口请求。">
                <QuestionCircleOutlined className="mk-form-tip" />
                时长(分)
              </Tooltip>
            }>
              {getFieldDecorator('localCacheTime', {
                initialValue: config.localCacheTime
              })(
                <InputNumber min={1} max={7200} precision={0} onChange={(val) => {this.selectChange('localCacheTime', val)}}/>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="对于不经常性变动的信息,缓存数据有助于提高查询效率。">
                <QuestionCircleOutlined className="mk-form-tip" />
                后端缓存
              </Tooltip>
            }>
              {getFieldDecorator('cacheUseful', {
                initialValue: config.cacheUseful || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('cacheUseful', e.target.value)}}>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {/* <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="跳过权限验证时,页面中组件及按钮不在进行权限控制。">
                <QuestionCircleOutlined className="mk-form-tip" />
                权限验证
              </Tooltip>
            }>
              {getFieldDecorator('permission', {
                initialValue: config.permission || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('permission', e.target.value)}}>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> */}
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="使用登录验证后,用户必须登录系统后才可以访问,注:含有登录组件的页面中无效。">
                <QuestionCircleOutlined className="mk-form-tip" />
                登录验证
              </Tooltip>
            }>
              {getFieldDecorator('logincheck', {
                initialValue: config.logincheck || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('logincheck', e.target.value)}}>
                  <Radio value="true">使用</Radio>
                  <Radio value="false">不使用</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {config.cacheUseful === 'true' ? <Col span={24}>
            <Form.Item label="单位">
              {getFieldDecorator('timeUnit', {
                initialValue: config.timeUnit || 'day'
              })(
                <Radio.Group style={{whiteSpace: 'nowrap'}} onChange={(e) => {this.selectChange('timeUnit', e.target.value)}}>
                  <Radio value="day">天</Radio>
                  <Radio value="hour">小时</Radio>
                  <Radio value="minute">分钟</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {config.cacheUseful === 'true' ? <Col span={24}>
            <Form.Item label="时长">
              {getFieldDecorator('cacheTime', {
                initialValue: config.cacheTime,
                rules: [
                  {
                    required: true,
                    message: '请输入时长!'
                  }
                ]
              })(
                <InputNumber min={1} max={config.timeUnit === 'day' ? 7 : (config.timeUnit === 'hour' ? 23 : 59)} precision={0} onChange={(val) => {this.selectChange('cacheTime', val)}}/>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={24}>
            <Form.Item label="下拉刷新">
              {getFieldDecorator('pullRefresh', {
                initialValue: config.pullRefresh || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('pullRefresh', e.target.value)}}>
                  <Radio value="false">关闭</Radio>
                  <Radio value="true">开启</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          <Col span={24}>
            <Form.Item label="屏幕方向">
              {getFieldDecorator('direction', {
                initialValue: config.direction || 'vertical'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('direction', e.target.value)}}>
                  <Radio value="vertical">竖屏</Radio>
                  <Radio value="horizontal">横屏</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {adapters.includes('app') || adapters.includes('wxmini') ? <Col span={24}>
            <Form.Item className="status-bar" label={
              <Tooltip placement="topLeft" title="在明科云APP或小程序中,状态栏的背景色。">
                <QuestionCircleOutlined className="mk-form-tip" />
                状态栏背景
              </Tooltip>
            }>
              <ColorSketch value={config.statusBarbgColor || '#ffffff'} onChange={(val, hex) => {this.selectChange('statusBarbgColor', val, hex)}} />
            </Form.Item>
          </Col> : null}
          {adapters.includes('wxmini') ? <Col span={24}>
            <Form.Item className="status-bar-color" label={
              <Tooltip placement="topLeft" title="在使用小程序时,状态栏的字体颜色。">
                <QuestionCircleOutlined className="mk-form-tip" />
                状态栏字体
              </Tooltip>
            }>
              {getFieldDecorator('statusBarColor', {
                initialValue: config.statusBarColor || 'black'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('statusBarColor', e.target.value)}}>
                  <Radio value="black">黑色</Radio>
                  <Radio value="white">白色</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {adapters.includes('app') ? <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="在明科云APP中有效。">
                <QuestionCircleOutlined className="mk-form-tip" />
                广告页
              </Tooltip>
            }>
              {getFieldDecorator('advertUrl', {
                initialValue: config.advertUrl || ''
              })(
                <SourceComponent type="picture" placement="right" onChange={(val) => {this.selectChange('advertUrl', val)}}/>
              )}
            </Form.Item>
          </Col> : null}
          {adapters.includes('app') && config.advertUrl ? <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="广告页的停留时间。">
                <QuestionCircleOutlined className="mk-form-tip" />
                停留(s)
              </Tooltip>
            }>
              {getFieldDecorator('advertTime', {
                initialValue: config.advertTime || 3,
                rules: [
                  {
                    required: true,
                    message: '请输入停留时间!'
                  }
                ]
              })(
                <InputNumber min={1} max={10} precision={0} onChange={(val) => {this.selectChange('advertTime', val)}}/>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="开启后数据源中将替换 @mk_longitude@、@mk_latitude@,在小程序中将获取用户所在经纬度。">
                <QuestionCircleOutlined className="mk-form-tip" />
                定位
              </Tooltip>
            }>
              {getFieldDecorator('getLocation', {
                initialValue: config.getLocation || 'false'
              })(
                <Radio.Group onChange={(e) => {this.selectChange('getLocation', e.target.value)}}>
                  <Radio value="true">开启</Radio>
                  <Radio value="false">不开启</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col>
          {adapters.includes('weixin') || adapters.includes('wxmini') ? <Col span={24}>
            <Form.Item label={
              <Tooltip placement="topLeft" title="使用默认时请在子应用设置分享信息,使用url参数会使用上页参数替换相应字段(@field@)。注:使用自定义或url参数时会分享当前页面。">
                <QuestionCircleOutlined className="mk-form-tip" />
                分享
              </Tooltip>
            }>
              {getFieldDecorator('share', {
                initialValue: config.share || 'default'
              })(
                <Radio.Group className="mini-radio" onChange={(e) => {this.selectChange('share', e.target.value)}}>
                  <Radio value="default">默认</Radio>
                  <Radio value="custom">自定义</Radio>
                  <Radio value="url">url参数</Radio>
                </Radio.Group>
              )}
            </Form.Item>
          </Col> : null}
          {['custom', 'url'].includes(config.share) && (adapters.includes('weixin') || adapters.includes('wxmini')) ? <Col span={24}>
            <Form.Item label="分享标题">
              {getFieldDecorator('share_title', {
                initialValue: config.share_title || '',
                rules: [
                  {
                    required: true,
                    message: '请输入分享标题!'
                  }
                ]
              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('share_title', e.target.value)}}/>)}
            </Form.Item>
          </Col> : null}
          {['custom', 'url'].includes(config.share) && (adapters.includes('weixin') || adapters.includes('wxmini')) ? <Col span={24}>
            <Form.Item label="分享描述">
              {getFieldDecorator('share_des', {
                initialValue: config.share_des || ''
              })(<Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('share_des', e.target.value)}}/>)}
            </Form.Item>
          </Col> : null}
          {config.share === 'custom' && (adapters.includes('weixin') || adapters.includes('wxmini')) ? <Col span={24}>
            <Form.Item label="分享图片">
              {getFieldDecorator('share_url', {
                initialValue: config.share_url || ''
              })(
                <SourceComponent type="picture" placement="right" onChange={(val) => {this.selectChange('share_url', val)}}/>
              )}
            </Form.Item>
          </Col> : null}
          {config.share === 'url' && (adapters.includes('weixin') || adapters.includes('wxmini')) ? <Col span={24}>
            <Form.Item label="分享图片">
              {getFieldDecorator('share_url', {
                initialValue: config.share_url || ''
              })(
                <Input placeholder="" autoComplete="off" onChange={(e) => {this.selectChange('share_url', e.target.value)}}/>
              )}
            </Form.Item>
          </Col> : null}
          <Col span={24} className="red-font">
            <Form.Item label="备注">
              {getFieldDecorator('Remark', {
                initialValue: config.Remark || '',
                rules: [
                  {
                    max: 512,
                    message: '备注最多512个字符!'
                  }
                ]
              })(<TextArea rows={2} placeholder={''} onChange={(e) => {this.selectChange('Remark', e.target.value)}}/>)}
            </Form.Item>
          </Col>
        </Row>
      </Form>
    )
  }
}
 
export default Form.create()(CustomMenuForm)