From 53a5b5bea0fb1efae2b1793e6735754e78982d63 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 19 十一月 2021 13:31:27 +0800
Subject: [PATCH] 2021-11-19

---
 src/templates/zshare/modalform/index.jsx |   66 +++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index a210a4b..4860148 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Row, Col, Input, Select, Icon, Radio, notification, InputNumber, Tooltip } from 'antd'
+import { Form, Row, Col, Input, Select, Radio, notification, InputNumber, Tooltip } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
 
 import { formRule } from '@/utils/option.js'
@@ -16,6 +16,7 @@
 const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
 const FieldsTable = asyncComponent(() => import('./fieldtable'))
 const DataTable = asyncComponent(() => import('./datatable'))
+const MkIcon = asyncComponent(() => import('@/components/mkIcon'))
 
 const modalTypeOptions = {
   text: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'regular', 'interception', 'span', 'labelwidth', 'tooltip', 'extra', 'enter', 'cursor', 'scan', 'splitline', 'placeholder', 'place', 'marginTop', 'marginBottom'],
@@ -33,6 +34,7 @@
   datetime: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'declareType', 'mode', 'splitline', 'marginTop', 'marginBottom', 'minDate', 'maxDate'],
   textarea: ['initval', 'readonly', 'required', 'hidden', 'readin', 'fieldlength', 'span', 'labelwidth', 'maxRows', 'encryption', 'interception', 'tooltip', 'extra', 'count', 'placeholder', 'marginTop', 'marginBottom'],
   color: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'tooltip', 'extra', 'marginTop', 'marginBottom'],
+  rate: ['initval', 'readonly', 'required', 'hidden', 'readin', 'span', 'labelwidth', 'splitline', 'tooltip', 'extra', 'marginTop', 'marginBottom', 'allowHalf', 'rateCount', 'character', 'place'],
   hint: ['label', 'type', 'blacklist', 'message', 'span', 'labelwidth', 'splitline', 'marginTop', 'marginBottom'],
   split: ['label', 'type', 'marginTop', 'marginBottom'],
   brafteditor: ['required', 'hidelabel', 'hidden', 'readin', 'fieldlength', 'readonly', 'span', 'labelwidth', 'tooltip', 'extra', 'encryption', 'marginTop', 'marginBottom'],
@@ -112,20 +114,27 @@
       resourceType: resourceType,
       linkSubFields: linkSubFields,
       formlist: formlist.map(form => {
-        if (dateOptions.hasOwnProperty(type) && form.key === 'initval') {
-          form.options = dateOptions[type]
-          form.type = 'select'
-        } else if (type === 'switch' && form.key === 'initval') {
-          form.initVal = !!form.initVal
-          form.options = [
-            {value: true, text: '寮�'},
-            {value: false, text: '鍏�'}
-          ]
-          form.type = 'radio'
-        } else if (type === 'number' && form.key === 'initval') {
-          form.type = 'number'
-          form.initVal = form.initVal || 0
-          form.required = true
+        if (form.key === 'initval') {
+          if (dateOptions.hasOwnProperty(type)) {
+            form.options = dateOptions[type]
+            form.type = 'select'
+          } else if (type === 'switch') {
+            form.initVal = !!form.initVal
+            form.options = [
+              {value: true, text: '寮�'},
+              {value: false, text: '鍏�'}
+            ]
+            form.type = 'radio'
+          }
+          if (type === 'number') {
+            form.type = 'number'
+            form.initVal = form.initVal || 0
+            form.required = true
+          } else if (type === 'rate') {
+            form.type = 'number'
+            form.initVal = form.initVal || 0
+            form.required = false
+          }
         } else if (form.key === 'label') {
           form.required = true
           if (type === 'hint') {
@@ -243,6 +252,10 @@
             } else if (value === 'number') {
               form.type = 'number'
               form.required = true
+              form.initVal = 0
+            } else if (value === 'rate') {
+              form.type = 'number'
+              form.required = false
               form.initVal = 0
             } else {
               form.type = 'text'
@@ -565,7 +578,7 @@
                 >
                   {item.options.map((option, i) =>
                     <Select.Option key={`${i}`} value={option.value || option.field || ''}>
-                      {item.key === 'icon' && <Icon type={option.text} />} {option.text || option.label}
+                      {option.text || option.label}
                     </Select.Option>
                   )}
                 </Select>
@@ -707,6 +720,27 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'icon') {
+        fields.push(
+          <Col span={12} key={index}>
+            <Form.Item label={item.tooltip ?
+              <Tooltip placement="topLeft" title={item.tooltip}>
+                <QuestionCircleOutlined className="mk-form-tip" />
+                {item.label}
+              </Tooltip> : item.label
+            }>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal || '',
+                rules: [{
+                  required: !!item.required,
+                  message: this.props.dict['form.required.select'] + item.label + '!'
+                }]
+              })(
+                <MkIcon allowClear />
+              )}
+            </Form.Item>
+          </Col>
+        )
       }
     })
 

--
Gitblit v1.8.0