From 20185ab64a165df51515d9fa1c9b12a7a8c55f59 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 07 四月 2023 23:11:04 +0800
Subject: [PATCH] 2023-04-07

---
 src/templates/sharecomponent/fieldscomponent/index.jsx |   76 +++++++++++++++++++++++++------------
 1 files changed, 51 insertions(+), 25 deletions(-)

diff --git a/src/templates/sharecomponent/fieldscomponent/index.jsx b/src/templates/sharecomponent/fieldscomponent/index.jsx
index 74c72a4..4d8d96f 100644
--- a/src/templates/sharecomponent/fieldscomponent/index.jsx
+++ b/src/templates/sharecomponent/fieldscomponent/index.jsx
@@ -4,8 +4,6 @@
 import { Button, Modal, Empty, notification } from 'antd'
 
 import Utils from '@/utils/utils.js'
-import zhCN from '@/locales/zh-CN/model.js'
-import enUS from '@/locales/en-US/model.js'
 import EditCard from './editcard'
 
 import MKEmitter from '@/utils/events.js'
@@ -19,7 +17,6 @@
   }
 
   state = {
-    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
     appType: sessionStorage.getItem('appType'),
     fields: [],             // 瀛楁闆�
     visible: false,         // 妯℃�佹鎺у埗
@@ -109,13 +106,13 @@
       selectCards.forEach(item => {
         let _match = ''
         let initval = ''
-        if (item.type === 'select') {
+        let _type = item.type
+        if (item.type === 'date') {
+          _type = 'daterange'
+        } else if (item.type === 'select') {
           _match = '='
-        } else if (item.type === 'daterange') {
-          initval = '[30, 0]'
-          _match = 'between'
         } else {
-          item.type = 'text'
+          _type = 'text'
           _match = 'like'
         }
 
@@ -124,13 +121,11 @@
           label: item.label,
           field: item.field,
           initval: initval,
-          type: item.type,
+          type: _type,
           resourceType: '0',
-          setAll: 'false',
           options: [],
           orderType: 'asc',
           match: _match,
-          display: 'dropdown'
         }
 
         items.push(newcard)
@@ -145,9 +140,9 @@
           label: item.label,
           field: item.field,
           Hide: 'false',
-          IsSort: item.type === 'picture' ? 'false' : 'true',
+          IsSort: 'true',
           type: item.type,
-          Width: 120
+          Width: item.type === 'number' ? 80 : 120
         }
 
         if (item.type === 'number') {
@@ -171,35 +166,59 @@
           field: item.field,
           datatype: _t
         }
-        items.push(newcard)
+        items.unshift(newcard)
         keys.push(item.field.toLowerCase())
       })
 
       this.props.updatefield(items)
     } else if (type === 'form') {
-      let lastItem = config.fields[config.fields.length - 1]
+      let firstItem = config.fields[0]
       let span = this.state.appType === 'mob' ? 24 : 12
-      if (lastItem && lastItem.span) {
-        span = lastItem.span
+      let labelwidth = 33.3
+      if (firstItem && firstItem.span) {
+        span = firstItem.span
+        labelwidth = firstItem.labelwidth || 33.3
       }
-
       selectCards.forEach(item => { // 寰幆娣诲姞鏂板瀛楁
         let newcard = {
           uuid: Utils.getuuid(),
           label: item.label,
           field: item.field,
-          initval: '',
+          initval: item.type === 'number' ? 0 : '',
           type: item.type,
           resourceType: '0',
-          setAll: 'false',
           span: span,
-          labelwidth: 33.3,
+          labelwidth: labelwidth,
           options: [],
           dataSource: '',
           decimal: item.decimal,
           orderType: 'asc',
           readonly: 'false',
           required: 'true'
+        }
+
+        if (item.type === 'text' && item.length >= 256) {
+          newcard.type = 'textarea'
+          newcard.required = 'false'
+          newcard.fieldlength = item.length
+          if (firstItem) {
+            if (firstItem.type === newcard.type) {
+              newcard.span = firstItem.span
+              newcard.labelwidth = firstItem.labelwidth
+            } else {
+              newcard.span = 24
+              if (firstItem.span === 12) {
+                newcard.labelwidth = 16.2
+              } else if (firstItem.span === 8) {
+                newcard.labelwidth = 10.5
+              } else if (firstItem.span === 6) {
+                newcard.labelwidth = 7.7
+              }
+            }
+          } else {
+            newcard.span = 24
+            newcard.labelwidth = 16.2
+          }
         }
 
         items.push(newcard)
@@ -245,19 +264,26 @@
 
   render() {
     const { type } = this.props
-    const { dict, fields } = this.state
+    const { fields } = this.state
+
+    let label = '鎵归噺娣诲姞'
+    if (type === 'search') {
+      label = '娣诲姞鎼滅储'
+    } else if (type === 'columns') {
+      label = '娣诲姞鏄剧ず鍒�'
+    }
 
     return (
       <div className="quickly-add">
-        <Button type="primary" block onClick={this.queryField}>{dict['model.batchAdd']}</Button>
+        <Button type="primary" block onClick={this.queryField}>{label}</Button>
         {/* 鏍规嵁瀛楁鍚嶆坊鍔犳樉绀哄垪鍙婃悳绱㈡潯浠� */}
         <Modal
           wrapClassName="model-table-fieldmanage-modal"
-          title={dict['model.edit']}
+          title="缂栬緫"
           visible={this.state.visible}
           width={'65vw'}
           maskClosable={false}
-          cancelText={dict['model.close']}
+          cancelText="鍏抽棴"
           onOk={this.addFieldSubmit}
           onCancel={() => this.setState({ visible: false })}
           destroyOnClose

--
Gitblit v1.8.0