From 3ecc98d6ba3fe31b9694bad348cbbb08c1b0dd81 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 22 五月 2024 22:52:02 +0800
Subject: [PATCH] 2024-05-22

---
 src/menu/components/form/simple-form/index.jsx   |   31 +------
 src/tabviews/zshare/mutilform/index.jsx          |    8 +-
 src/templates/zshare/modalform/index.jsx         |   21 +++--
 src/tabviews/zshare/mutilform/mkSelect/index.jsx |   19 ++--
 src/templates/modalconfig/index.jsx              |   27 ------
 src/menu/components/form/step-form/index.jsx     |   31 +------
 src/menu/modalconfig/index.jsx                   |   27 ------
 src/mob/modalconfig/index.jsx                    |   20 ----
 src/menu/components/form/tab-form/index.jsx      |   31 +------
 9 files changed, 48 insertions(+), 167 deletions(-)

diff --git a/src/menu/components/form/simple-form/index.jsx b/src/menu/components/form/simple-form/index.jsx
index 2d1855a..974b624 100644
--- a/src/menu/components/form/simple-form/index.jsx
+++ b/src/menu/components/form/simple-form/index.jsx
@@ -41,8 +41,7 @@
     visible: false,
     editform: null,
     formlist: null,
-    sqlVerifing: false,
-    standardform: null
+    sqlVerifing: false
   }
 
   UNSAFE_componentWillMount () {
@@ -346,23 +345,17 @@
    * @description 琛ㄥ崟缂栬緫
    */
   handleForm = (_item) => {
-    const { card, appType } = this.state
+    const { card } = this.state
     let _form = fromJS(_item).toJS()
     let _inputfields = []
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     card.subcards[0].fields.forEach((item, i) => {
-      if (_form.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || _form.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -397,14 +390,6 @@
       })
     })
 
-    if (index !== null) {
-      if (index === 0) {
-        standardform = card.subcards[0].fields[index + 1] || null
-      } else {
-        standardform = card.subcards[0].fields[index - 1] || null
-      }
-    }
-
     let _fields = _linkableFields.map(cell => cell.field)
     card.columns.forEach(col => {
       if (col.field && !_fields.includes(col.field)) {
@@ -420,13 +405,7 @@
       _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item))
     }
 
-    if (appType !== 'mob' && !_form.span && standardform && standardform.span) {
-      _form.span = standardform.span
-      _form.labelwidth = standardform.labelwidth
-    }
-
     this.setState({
-      standardform,
       visible: true,
       editform: _form,
       formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns)
@@ -442,7 +421,7 @@
   handleSubmit = () => {
     let _config = fromJS(this.state.card).toJS()
 
-    this.formRef.handleConfirm(_config.subcards[0].fields).then(res => {
+    this.formRef.handleConfirm().then(res => {
       _config.subcards[0].fields = _config.subcards[0].fields.map(item => {
         delete item.focus
 
@@ -687,7 +666,7 @@
             card={this.state.editform}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={card.subcards[0].fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/menu/components/form/step-form/index.jsx b/src/menu/components/form/step-form/index.jsx
index 8704f5e..700588a 100644
--- a/src/menu/components/form/step-form/index.jsx
+++ b/src/menu/components/form/step-form/index.jsx
@@ -42,8 +42,7 @@
     visible: false,
     editform: null,
     formlist: null,
-    sqlVerifing: false,
-    standardform: null
+    sqlVerifing: false
   }
 
   UNSAFE_componentWillMount () {
@@ -447,23 +446,17 @@
    * @description 琛ㄥ崟缂栬緫
    */
   handleForm = (_item) => {
-    const { card, group, appType } = this.state
+    const { card, group } = this.state
     let _form = fromJS(_item).toJS()
     let _inputfields = []
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     group.fields.forEach((item, i) => {
-      if (_form.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || _form.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -499,14 +492,6 @@
       })
     })
 
-    if (index !== null) {
-      if (index === 0) {
-        standardform = group.fields[index + 1] || null
-      } else {
-        standardform = group.fields[index - 1] || null
-      }
-    }
-
     let _fields = _linkableFields.map(cell => cell.field)
     card.columns.forEach(col => {
       if (col.field && !_fields.includes(col.field)) {
@@ -522,13 +507,7 @@
       _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item))
     }
 
-    if (appType !== 'mob' && !_form.span && standardform && standardform.span) {
-      _form.span = standardform.span
-      _form.labelwidth = standardform.labelwidth
-    }
-
     this.setState({
-      standardform,
       visible: true,
       editform: _form,
       formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns)
@@ -544,7 +523,7 @@
   handleSubmit = () => {
     let _config = fromJS(this.state.group).toJS()
 
-    this.formRef.handleConfirm(_config.fields).then(res => {
+    this.formRef.handleConfirm().then(res => {
       _config.fields = _config.fields.map(item => {
         delete item.focus
 
@@ -803,7 +782,7 @@
             card={this.state.editform}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={group.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/menu/components/form/tab-form/index.jsx b/src/menu/components/form/tab-form/index.jsx
index 8ee36a7..e9af1d4 100644
--- a/src/menu/components/form/tab-form/index.jsx
+++ b/src/menu/components/form/tab-form/index.jsx
@@ -42,8 +42,7 @@
     visible: false,
     editform: null,
     formlist: null,
-    sqlVerifing: false,
-    standardform: null
+    sqlVerifing: false
   }
 
   UNSAFE_componentWillMount () {
@@ -453,23 +452,17 @@
    * @description 琛ㄥ崟缂栬緫
    */
   handleForm = (_item) => {
-    const { card, group, appType } = this.state
+    const { card, group } = this.state
     let _form = fromJS(_item).toJS()
     let _inputfields = []
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     group.fields.forEach((item, i) => {
-      if (_form.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || _form.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -504,14 +497,6 @@
       })
     })
 
-    if (index !== null) {
-      if (index === 0) {
-        standardform = group.fields[index + 1] || null
-      } else {
-        standardform = group.fields[index - 1] || null
-      }
-    }
-
     let _fields = _linkableFields.map(cell => cell.field)
     card.columns.forEach(col => {
       if (col.field && !_fields.includes(col.field)) {
@@ -527,13 +512,7 @@
       _form.linkSubField = _form.linkSubField.filter(item => fields.includes(item))
     }
 
-    if (appType !== 'mob' && !_form.span && standardform && standardform.span) {
-      _form.span = standardform.span
-      _form.labelwidth = standardform.labelwidth
-    }
-
     this.setState({
-      standardform,
       visible: true,
       editform: _form,
       formlist: getModalForm(_form, _inputfields, _tabfields, _linkableFields, _linksupFields, card.columns)
@@ -549,7 +528,7 @@
   handleSubmit = () => {
     let _config = fromJS(this.state.group).toJS()
 
-    this.formRef.handleConfirm(_config.fields).then(res => {
+    this.formRef.handleConfirm().then(res => {
       _config.fields = _config.fields.map(item => {
         delete item.focus
 
@@ -805,7 +784,7 @@
             card={this.state.editform}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={group.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/menu/modalconfig/index.jsx b/src/menu/modalconfig/index.jsx
index 3ffa871..65a7158 100644
--- a/src/menu/modalconfig/index.jsx
+++ b/src/menu/modalconfig/index.jsx
@@ -40,7 +40,6 @@
     originConfig: null,    // 鍘熷鑿滃崟
     sqlVerifing: false,    // sql楠岃瘉
     showField: false,      // 鏄剧ず琛ㄥ崟瀛楁鍊�
-    standardform: null,
     saving: false
   }
 
@@ -110,17 +109,11 @@
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     config.fields.forEach((item, i) => {
-      if (card.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || card.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -154,13 +147,6 @@
         label: item.label + '-琛ㄥ崟'
       })
     })
-    if (index !== null) {
-      if (index === 0) {
-        standardform = config.fields[index + 1] || null
-      } else {
-        standardform = config.fields[index - 1] || null
-      }
-    }
 
     let columns = componentConfig.columns
     if (btn.$sub) {
@@ -182,16 +168,7 @@
       card.linkSubField = card.linkSubField.filter(item => fields.includes(item))
     }
 
-    if (!card.span && standardform && standardform.span) {
-      card.span = standardform.span
-      card.labelwidth = standardform.labelwidth
-    } else if (!card.span) {
-      card.span = 12
-      card.labelwidth = 33.3
-    }
-
     this.setState({
-      standardform,
       visible: true,
       card: card,
       formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns)
@@ -533,7 +510,7 @@
             card={card}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={config.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/mob/modalconfig/index.jsx b/src/mob/modalconfig/index.jsx
index 1fe5aaf..4c20d8e 100644
--- a/src/mob/modalconfig/index.jsx
+++ b/src/mob/modalconfig/index.jsx
@@ -38,7 +38,6 @@
     originConfig: null,    // 鍘熷鑿滃崟
     sqlVerifing: false,    // sql楠岃瘉
     showField: false,      // 鏄剧ず琛ㄥ崟瀛楁鍊�
-    standardform: null,
     saving: false
   }
 
@@ -112,17 +111,11 @@
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     config.fields.forEach((item, i) => {
-      if (card.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || card.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -157,14 +150,6 @@
       })
     })
 
-    if (index !== null) {
-      if (index === 0) {
-        standardform = config.fields[index + 1] || null
-      } else {
-        standardform = config.fields[index - 1] || null
-      }
-    }
-
     let columns = componentConfig.columns
     if (btn.$sub) {
       columns = componentConfig.subColumns || []
@@ -186,7 +171,6 @@
     }
 
     this.setState({
-      standardform,
       visible: true,
       card: card,
       formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields, columns)
@@ -468,7 +452,7 @@
             card={card}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={config.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/tabviews/zshare/mutilform/index.jsx b/src/tabviews/zshare/mutilform/index.jsx
index 1017e55..33ca96c 100644
--- a/src/tabviews/zshare/mutilform/index.jsx
+++ b/src/tabviews/zshare/mutilform/index.jsx
@@ -547,7 +547,7 @@
           item.subFields = []
           item.linkSubField.forEach(m => {
             let n = fieldMap.get(m)
-            if (n && ['text', 'number', 'textarea'].includes(n.type)) {
+            if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) {
               item.subFields.push({
                 uuid: n.uuid,
                 field: m
@@ -570,7 +570,7 @@
           item.subFields = []
           item.linkSubField.forEach(m => {
             let n = fieldMap.get(m)
-            if (n && ['text', 'number', 'textarea'].includes(n.type)) {
+            if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) {
               item.subFields.push({
                 uuid: n.uuid,
                 field: m
@@ -590,7 +590,7 @@
           item.subFields = []
           item.linkSubField.forEach(m => {
             let n = fieldMap.get(m)
-            if (n && ['text', 'number', 'textarea'].includes(n.type)) {
+            if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) {
               item.subFields.push({
                 uuid: n.uuid,
                 field: m
@@ -602,7 +602,7 @@
           item.subFields = []
           item.linkSubField.forEach(m => {
             let n = fieldMap.get(m)
-            if (n && ['text', 'number', 'textarea'].includes(n.type)) {
+            if (n && ['text', 'number', 'textarea', 'select'].includes(n.type)) {
               item.subFields.push({
                 uuid: n.uuid,
                 field: m
diff --git a/src/tabviews/zshare/mutilform/mkSelect/index.jsx b/src/tabviews/zshare/mutilform/mkSelect/index.jsx
index 6f94b5d..c08ba6f 100644
--- a/src/tabviews/zshare/mutilform/mkSelect/index.jsx
+++ b/src/tabviews/zshare/mutilform/mkSelect/index.jsx
@@ -79,12 +79,15 @@
     MKEmitter.removeListener('mkFC', this.mkFormFocus)
   }
 
-  mkFormFocus = (type, uuid) => {
+  mkFormFocus = (type, uuid, val, level) => {
     if (uuid !== this.props.config.uuid) return
-    if (type !== 'focus') return
-
-    let _div = document.getElementById(uuid)
-    _div && _div.click && _div.click()
+    if (type === 'focus') {
+      let _div = document.getElementById(uuid)
+      _div && _div.click && _div.click()
+    } else if (type === 'input' && (!level || level < 10)) {
+      let _level = level || 1
+      this.selectChange(val, _level++)
+    }
   }
 
   mkFormHandle = (uuid, parentId, level) => {
@@ -123,7 +126,7 @@
     }
   }
 
-  selectChange = (val) => {
+  selectChange = (val, level) => {
     const { config } = this.state
     let other = {}
 
@@ -132,7 +135,7 @@
       option && config.subFields.forEach((n, i) => {
         other[n.field] = option[n.field]
         setTimeout(() => {
-          MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field])
+          MKEmitter.emit('mkFC', 'input', n.uuid, option[n.field], level)
         }, i * 5)
       })
     }
@@ -177,7 +180,7 @@
           value={value}
           dropdownMatchSelectWidth={config.dropdown !== 'false'}
           filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
-          onSelect={this.selectChange}
+          onSelect={(val) => this.selectChange(val)}
           onChange={(val) => val === undefined && this.selectChange('')}
           disabled={config.readonly}
         >
diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx
index 6887eca..f0fb90d 100644
--- a/src/templates/modalconfig/index.jsx
+++ b/src/templates/modalconfig/index.jsx
@@ -221,17 +221,11 @@
     let _tabfields = []
     let _linkableFields = []
     let _linksupFields = []
-    let standardform = null
-    let index = null
 
     config.fields.forEach((item, i) => {
-      if (card.uuid === item.uuid) {
-        index = i
-      }
-
       if (!item.field || card.field === item.field) return
 
-      if (['text', 'number', 'textarea', 'color'].includes(item.type)) {
+      if (['text', 'number', 'textarea', 'select'].includes(item.type)) {
         _inputfields.push({
           field: item.field,
           label: item.label
@@ -265,14 +259,6 @@
         label: item.label + '-琛ㄥ崟'
       })
     })
-
-    if (index !== null) {
-      if (index === 0) {
-        standardform = config.fields[index + 1] || null
-      } else {
-        standardform = config.fields[index - 1] || null
-      }
-    }
 
     let _fields = _linkableFields.map(cell => cell.field)
     if (subTabConfig) {
@@ -309,16 +295,7 @@
       card.linkSubField = card.linkSubField.filter(item => fields.includes(item))
     }
 
-    if (!card.span && standardform && standardform.span) {
-      card.span = standardform.span
-      card.labelwidth = standardform.labelwidth
-    } else if (!card.span) {
-      card.span = 12
-      card.labelwidth = 33.3
-    }
-
     this.setState({
-      standardform,
       visible: true,
       card: card,
       formlist: getModalForm(card, _inputfields, _tabfields, _linkableFields, _linksupFields)
@@ -752,7 +729,7 @@
             card={this.state.card}
             formlist={this.state.formlist}
             inputSubmit={this.handleSubmit}
-            standardform={this.state.standardform}
+            fields={config.fields}
             wrappedComponentRef={(inst) => this.formRef = inst}
           />
         </Modal>
diff --git a/src/templates/zshare/modalform/index.jsx b/src/templates/zshare/modalform/index.jsx
index 17b3585..7b515e6 100644
--- a/src/templates/zshare/modalform/index.jsx
+++ b/src/templates/zshare/modalform/index.jsx
@@ -51,7 +51,7 @@
 class MainSearch extends Component {
   static propTpyes = {
     formlist: PropTypes.any,
-    standardform: PropTypes.any,
+    fields: PropTypes.array,
     card: PropTypes.object,
     inputSubmit: PropTypes.any
   }
@@ -537,18 +537,21 @@
   changeVal = (val, type) => {
     if (type !== 'span' || ![24, 12, 8, 6].includes(val)) return
 
-    const { standardform } = this.props
+    const { card, fields } = this.props
 
-    if (!standardform || ![24, 12, 8, 6].includes(standardform.span) || !standardform.labelwidth) return
+    let index = fields.findIndex(item => card.uuid === item.uuid)
+    let stform = fields[index - 1]
+    
+    if (!stform || ![24, 12, 8, 6].includes(stform.span) || !stform.labelwidth) return
 
     let labelwidth = null
 
-    if (standardform.span === val) {
-      labelwidth = standardform.labelwidth
-    } else if (standardform.span > val) {
+    if (stform.span === val) {
+      labelwidth = stform.labelwidth
+    } else if (stform.span > val) {
       labelwidth = 33.3
     } else {
-      switch(standardform.span) {
+      switch(stform.span) {
         case 12:
           labelwidth = 16.2
           break;
@@ -930,8 +933,8 @@
     }
   }
 
-  handleConfirm = (fields) => {
-    const { card } = this.props
+  handleConfirm = () => {
+    const { card, fields } = this.props
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
     return new Promise((resolve, reject) => {
       this.props.form.validateFieldsAndScroll((err, values) => {

--
Gitblit v1.8.0