From 4c6bdfe1f3557e49a315c1564bcb6164c0bc7faa Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 03 四月 2020 18:27:22 +0800
Subject: [PATCH] 2020-04-03

---
 src/templates/zshare/columnform/index.jsx |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 110 insertions(+), 9 deletions(-)

diff --git a/src/templates/zshare/columnform/index.jsx b/src/templates/zshare/columnform/index.jsx
index 9ce8399..249153a 100644
--- a/src/templates/zshare/columnform/index.jsx
+++ b/src/templates/zshare/columnform/index.jsx
@@ -1,34 +1,44 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
-import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon } from 'antd'
+import { Form, Row, Col, Input, Select, InputNumber, Radio, Tooltip, Icon, Cascader, notification } from 'antd'
+
 import { formRule } from '@/utils/option.js'
+import options from '@/store/options.js'
+import Api from '@/api'
 import './index.scss'
 
 class MainSearch extends Component {
   static propTpyes = {
     dict: PropTypes.object,     // 瀛楀吀椤�
+    MenuID: PropTypes.any,
     formlist: PropTypes.any,
     card: PropTypes.any,
     inputSubmit: PropTypes.any  // 鍥炶溅鎻愪氦浜嬩欢
   }
 
   state = {
-    formlist: null
+    formlist: null,
+    menulist: null
   }
 
   UNSAFE_componentWillMount () {
     let _type = this.props.formlist.filter(form => form.key === 'type')[0].initVal
-    let _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist']
+    let _menulist = this.props.formlist.filter(form => form.key === 'linkmenu')[0] || ''
+
+    let _options = null
 
     if (_type === 'text') {
-      _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist']
+      _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist', 'linkmenu']
     } else if (_type === 'number') {
-      _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist']
+      _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist', 'linkmenu']
     } else if (_type === 'textarea') {
       _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist']
+    } else if (_type === 'picture') {
+      _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale']
     }
 
     this.setState({
+      menulist: _menulist.options || [],
       formlist: this.props.formlist.map(item => {
         item.hidden = !_options.includes(item.key)
         if (item.key === 'matchVal' && (_type === 'text' || _type === 'textarea')) {
@@ -56,14 +66,16 @@
 
   typeChange = (key, value) => {
     if (key === 'type') {
-      let _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist']
+      let _options = null
 
       if (value === 'text') {
-        _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist']
+        _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist', 'linkmenu']
       } else if (value === 'number') {
-        _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist']
+        _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'decimal', 'format', 'prefix', 'postfix', 'match', 'matchVal', 'color', 'blacklist', 'linkmenu']
       } else if (value === 'textarea') {
         _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'prefix', 'postfix', 'matchVal', 'color', 'fieldlength', 'blacklist']
+      } else if (value === 'picture') {
+        _options = ['label', 'field', 'type', 'Align', 'Hide', 'IsSort', 'Width', 'fieldlength', 'blacklist', 'scale']
       }
 
       this.setState({
@@ -242,18 +254,107 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'cascader') { // 澶氶��
+        fields.push(
+          <Col span={12} key={index}>
+            <Form.Item label={item.label}>
+              {getFieldDecorator(item.key, {
+                initialValue: item.initVal || []
+              })(
+                <Cascader
+                  options={this.state.menulist}
+                  loadData={this.loadData}
+                  placeholder=""
+                  getPopupContainer={() => document.getElementById('columnwinter')}
+                />
+              )}
+            </Form.Item>
+          </Col>
+        )
       }
     })
     return fields
   }
 
+  loadData = selectedOptions => {
+    const { MenuID } = this.props
+    const targetOption = selectedOptions[selectedOptions.length - 1]
+    targetOption.loading = true
+
+    let _param = {
+      func: 'sPC_Get_FunMenu',
+      ParentID: targetOption.value,
+      systemType: options.systemType,
+      debug: 'Y'
+    }
+
+    Api.getSystemConfig(_param).then(result => {
+      if (result.status) {
+        targetOption.loading = false
+        targetOption.children = result.data.map(item => {
+          let submenu = {
+            value: item.ParentID,
+            label: item.MenuNameP,
+            children: item.FunMenu.map(cell => {
+              return {
+                value: cell.MenuID,
+                label: cell.MenuName,
+                MenuID: cell.MenuID,
+                MenuName: cell.MenuName,
+                MenuNo: cell.MenuNo,
+                Ot: cell.Ot,
+                PageParam: cell.PageParam,
+                LinkUrl: cell.LinkUrl
+              }
+            })
+          }
+
+          submenu.children = submenu.children.filter(cell => cell.MenuID !== MenuID)
+
+          return submenu
+        })
+
+        this.setState({
+          menulist: [...this.state.menulist]
+        })
+      } else {
+        notification.warning({
+          top: 92,
+          message: result.message,
+          duration: 10
+        })
+        targetOption.loading = false
+      }
+    })
+  }
+
   handleConfirm = () => {
+    const { menulist } = this.state
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
           values.id = this.props.card.id
           values.uuid = this.props.card.uuid
+          
+          if ((values.type === 'text' || values.type === 'number') && values.linkmenu && values.linkmenu.length > 0) {
+            let linkThdMenu = ''
+            menulist.forEach(menu => {
+              if (menu.value === values.linkmenu[0]) {
+                menu.children.forEach(item => {
+                  if (item.value === values.linkmenu[1]) {
+                    item.children.forEach(cell => {
+                      if (cell.value === values.linkmenu[2]) {
+                        linkThdMenu = cell
+                      }
+                    })
+                  }
+                })
+              }
+            })
+            values.linkThdMenu = linkThdMenu
+          }
+          
           resolve(values)
         } else {
           reject(err)
@@ -274,7 +375,7 @@
       }
     }
     return (
-      <Form {...formItemLayout} className="ant-advanced-search-form commontable-column-form" id="columnwinter">
+      <Form {...formItemLayout} className="commontable-column-form" id="columnwinter">
         <Row gutter={24}>{this.getFields()}</Row>
       </Form>
     )

--
Gitblit v1.8.0