From 49f09cc6f8ff8c30a75ed1a9d6f510b69b73962a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 12 十二月 2023 21:05:37 +0800
Subject: [PATCH] 2023-12-12

---
 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx |  280 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 206 insertions(+), 74 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
index 6224ab7..18de67e 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
@@ -17,8 +17,10 @@
 
 const { TabPane } = Tabs
 const { confirm } = Modal
+const { Search } = Input
 const { Paragraph } = Typography
 const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
+const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts'))
 
 class VerifyCard extends Component {
   static propTpyes = {
@@ -30,6 +32,7 @@
     verify: {},
     systemScripts: [],
     activeKey: 'basemsg',
+    searchKey: '',
     excelColumns: [
       {
         title: '瀛楁',
@@ -37,6 +40,9 @@
         width: '14%',
         inputType: 'input',
         unique: true,
+        strict: true,
+        searchable: true,
+        copy: true,
         editable: true
       },
       {
@@ -44,6 +50,7 @@
         dataIndex: 'Text',
         width: '14%',
         inputType: 'input',
+        searchable: true,
         editable: true
       },
       {
@@ -61,13 +68,35 @@
           { value: 'Nvarchar(512)', text: 'Nvarchar(512)' },
           { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' },
           { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' },
+          { value: 'Nvarchar(4000)', text: 'Nvarchar(4000)' },
           { value: 'Nvarchar(max)', text: 'Nvarchar(max)' },
           { value: 'Int', text: 'Int' },
           { value: 'Decimal(18,0)', text: 'Decimal(18,0)' },
           { value: 'Decimal(18,2)', text: 'Decimal(18,2)' },
           { value: 'Decimal(18,4)', text: 'Decimal(18,4)' },
           { value: 'Decimal(18,6)', text: 'Decimal(18,6)' },
-          { value: 'date', text: 'date' }
+          { value: 'date', text: 'date' },
+          { value: 'datetime', text: 'datetime' }
+        ]
+      },
+      {
+        title: '瀵煎叆',
+        dataIndex: 'import',
+        width: '10%',
+        editable: true,
+        inputType: 'radio',
+        render: (text, record) => {
+          if (record.import === 'init') {
+            return '鍒濆鍖�'
+          } else if (record.import === 'false') {
+            return '鍚�'
+          }
+          return '鏄�'
+        },
+        options: [
+          { value: 'true', text: '鏄�' },
+          { value: 'false', text: '鍚�' },
+          { value: 'init', text: '鍒濆鍖�' }
         ]
       },
       {
@@ -77,14 +106,6 @@
         editable: true,
         inputType: 'switch',
         render: (text, record) => record.required === 'true' ? '鏄�' : '鍚�'
-      },
-      {
-        title: '瀵煎叆',
-        dataIndex: 'import',
-        width: '10%',
-        editable: true,
-        inputType: 'switch',
-        render: (text, record) => record.import !== 'false' ? '鏄�' : '鍚�'
       },
       {
         title: '鏈�灏忓��',
@@ -122,7 +143,7 @@
       {
         title: '鎶ラ敊缂栫爜',
         dataIndex: 'errorCode',
-        width: '12%',
+        width: '10%',
         editable: true,
         inputType: 'select',
         options: [
@@ -135,13 +156,24 @@
       {
         title: '楠岃瘉绫诲瀷',
         dataIndex: 'verifyType',
-        width: '12%',
-        render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉',
+        width: '14%',
+        render: (text, record) => {
+          let names = {
+            physical: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級',
+            logic: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級',
+            physical_temp: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級',
+            logic_temp: '閫昏緫楠岃瘉锛堜粎涓存椂琛級',
+          }
+
+          return names[text] || '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級'
+        },
         inputType: 'select',
         editable: true,
         options: [
-          { value: 'physical', text: '鐗╃悊楠岃瘉' },
-          { value: 'logic', text: '閫昏緫楠岃瘉' }
+          { value: 'physical', text: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'logic', text: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'physical_temp', text: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級' },
+          { value: 'logic_temp', text: '閫昏緫楠岃瘉锛堜粎涓存椂琛級' }
         ]
       },
       {
@@ -242,8 +274,6 @@
     let _verify = fromJS(card.verify || {}).toJS()
     let _columns = _verify.columns || []
 
-    delete _verify.dataresource
-
     // 鏃ф暟鎹吋瀹�
     _columns = _columns.map(col => {
       col.required = col.required || 'true'
@@ -272,6 +302,7 @@
     }
 
     this.setState({
+      searchKey: '',
       verify: {
         ..._verify,
         default: _verify.default || 'true',
@@ -313,7 +344,7 @@
     _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
     _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉
     
-    Api.getSystemConfig(_sParam).then(res => {
+    Api.getCloudConfig(_sParam).then(res => {
       if (res.status) {
         let _scripts = res.data.map(item => {
           return {
@@ -363,48 +394,100 @@
     const { verify } = this.state
 
     let _columns = JSON.parse(JSON.stringify(verify.columns))
+    let _names = {}
+    let _cols = _columns.map(item => {
+      let key = item.Column.toLowerCase()
+      _names[key] = item.Text
 
-    let _cols = _columns.map(col => col.Column)
+      return key
+    })
+    let names = {$up: false}
 
     columns.forEach(col => {
-      if (col.field && !_cols.includes(col.field)) {
-        let _type = 'Nvarchar(50)'
-        let _limit = '50'
-        if (col.type === 'number' && !col.decimal) {
-          _type = 'Int'
-          _limit = ''
-        } else if (col.type === 'number') {
-          _type = 'Decimal(18,' + col.decimal + ')'
-          _limit = col.decimal
+      if (!col.field) return
+      let key = col.field.toLowerCase()
+      if (_cols.includes(key)) {
+        if (_names[key] !== col.label) {
+          names.$up = true
+          names[key] = col.label
         }
-
-        let _cell = {
-          uuid: col.uuid,
-          Column: col.field,
-          Text: col.label,
-          type: _type,
-          limit: _limit,
-          import: 'true',
-          required: 'true'
-        }
-
-        if (_type !== 'Nvarchar(50)') {
-          _cell.min = 0
-          _cell.max = 999999
-        }
-
-        _columns.push(_cell)
+        return
       }
+
+      let _type = 'Nvarchar(50)'
+      let _limit = '50'
+      if (col.type === 'number' && !col.decimal) {
+        _type = 'Int'
+        _limit = ''
+      } else if (col.type === 'number') {
+        _type = 'Decimal(18,' + col.decimal + ')'
+        _limit = col.decimal
+      }
+
+      let _cell = {
+        uuid: col.uuid,
+        Column: col.field,
+        Text: col.label,
+        type: _type,
+        limit: _limit,
+        import: 'true',
+        required: 'true'
+      }
+
+      if (_type !== 'Nvarchar(50)') {
+        _cell.min = 0
+        _cell.max = 999999
+      }
+
+      _columns.push(_cell)
     })
 
-    this.setState({
-      verify: {
-        ...verify,
-        columns: _columns
-      }
-    }, () => {
-      this.resetUniqueColumns()
-    })
+    if (names.$up) {
+      const that = this
+
+      confirm({
+        content: '閮ㄥ垎瀛楁鍚嶇О涓庢樉绀哄垪涓嶄竴鑷达紝鏄惁鏇存柊锛�',
+        onOk() {
+          _columns = _columns.map(item => {
+            let key = item.Column.toLowerCase()
+
+            if (names[key]) {
+              item.Text = names[key]
+            }
+
+            return item
+          })
+
+          that.setState({
+            verify: {
+              ...verify,
+              columns: _columns
+            }
+          }, () => {
+            that.resetUniqueColumns()
+          })
+        },
+        onCancel() {
+          that.setState({
+            verify: {
+              ...verify,
+              columns: _columns
+            }
+          }, () => {
+            that.resetUniqueColumns()
+          })
+        }
+      })
+    } else {
+      this.setState({
+        verify: {
+          ...verify,
+          columns: _columns
+        }
+      }, () => {
+        this.resetUniqueColumns()
+      })
+    }
   }
 
   clearField = () => {
@@ -461,13 +544,18 @@
         col.type = 'Decimal(18,2)'
       }
 
+      if (col.import === 'init') {
+        col.required = 'false'
+        col.min = ''
+        col.max = ''
+      }
+
       if (/^Nvarchar/ig.test(col.type)) {
         col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000'
       } else if (/^Decimal/ig.test(col.type)) {
         col.limit = col.type.match(/\d+/ig)[1]
-        col.required = 'true'
       } else if (/^int/ig.test(col.type)) {
-        col.required = 'true'
+
       } else {
         col.limit = ''
       }
@@ -615,7 +703,7 @@
         if (!err) {
           let _verify = {...verify, ...values}
 
-          let cols = _verify.columns.map(col => col.Column)
+          let cols = _verify.columns.map(col => col.Column.toLowerCase())
           cols = Array.from(new Set(cols))
 
           if (_verify.columns.length === 0) {
@@ -643,6 +731,15 @@
               return
             }
           }
+
+          _verify.columns.sort((a, b) => {
+            if (a.import === 'init' && b.import !== 'init') {
+              return 1
+            } else if (a.import !== 'init' && b.import === 'init') {
+              return -1
+            }
+            return 0
+          })
 
           let _loading = false
           if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -742,7 +839,7 @@
   render() {
     const { card } = this.props
     const { getFieldDecorator } = this.props.form
-    const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state
+    const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey, searchKey } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -762,13 +859,18 @@
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col span={8}>
-                  <Form.Item label="琛ㄥ悕">
+                  <Form.Item label={
+                    <Tooltip placement="bottomLeft" title="瀵煎叆鏃跺伐浣滆〃鍚嶄笌excel涓繀椤讳竴鑷达紝娉細宸ヤ綔琛ㄥ悕涓篠heet1涓攅xcel涓粎鏈変竴涓伐浣滆〃鏃朵笉杩涜琛ㄥ悕楠岃瘉銆�">
+                      <QuestionCircleOutlined className="mk-form-tip" />
+                      宸ヤ綔琛�
+                    </Tooltip>
+                  }>
                     {getFieldDecorator('sheet', {
                       initialValue: verify.sheet || '',
                       rules: [
                         {
                           required: true,
-                          message: '璇疯緭鍏ヨ〃鍚�!'
+                          message: '璇疯緭鍏ュ伐浣滆〃鍚�!'
                         }
                       ]
                     })(<Input placeholder="" autoComplete="off" />)}
@@ -805,13 +907,13 @@
           } key="excelcolumn">
             <ColumnForm columnChange={this.columnChange}/>
             <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}>
-              鍚屾鏄剧ず鍒�
+              鍚屾瀛楁闆�
             </Button>
             <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}>
               娓呯┖Excel鍒�
             </Button>
-            <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆�</Col>
-            <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
+            <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col>
+            <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} searchKey={searchKey} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
           </TabPane>
           {card.intertype === 'system' ? <TabPane tab={
             <span>
@@ -828,6 +930,23 @@
               {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
             </span>
           } key="scripts" id="mk-exin-script">
+            <FullScripts
+              scripts={verify.scripts}
+              getScriptsFullForm={() => this.scriptsFullForm}
+              getScriptsForm={() => this.scriptsForm}
+              handleStatus={this.handleStatus}
+              handleDelete={this.handleDelete}
+            >
+              <CustomScript
+                type="fullscreen"
+                btn={this.props.card}
+                usefulfields={verify.columns}
+                scripts={verify.scripts}
+                systemScripts={this.state.systemScripts}
+                scriptsChange={this.scriptsChange}
+                wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
+              />
+            </FullScripts>
             <CustomScript
               btn={this.props.card}
               usefulfields={verify.columns}
@@ -838,11 +957,16 @@
             />
             <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
           </TabPane> : null}
-          <TabPane tab="淇℃伅鎻愮ず" key="tip">
+          <TabPane tab={
+            <span>
+              淇℃伅鎻愮ず
+              {activeKey === 'excelcolumn' ? <span onClick={(e) => {e.stopPropagation()}}><Search className="mk-search-fields" defaultValue={searchKey} allowClear onSearch={(val, e) => {e.stopPropagation();this.setState({searchKey: val})}} /></span> : null}
+            </span>
+          } key="tip">
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> S </span>
                     <Button onClick={() => {this.showError('S')}} type="primary" size="small">
                       鏌ョ湅
@@ -850,14 +974,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> Y </span>
                     <Button onClick={() => {this.showError('Y')}} type="primary" size="small">
                       鏌ョ湅
@@ -867,7 +991,15 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
+                    <span className="errorval"> -1 </span>
+                    鎵ц鎴愬姛鏃犳彁绀恒��
+                  </Form.Item>
+                </Col>
+              </Row>
+              <Row gutter={24}>
+                <Col offset={6} span={6}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> N </span>
                     <Button onClick={() => {this.showError('N')}} type="primary" size="small">
                       鏌ョ湅
@@ -875,14 +1007,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.ntime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> F </span>
                     <Button onClick={() => {this.showError('F')}} type="primary" size="small">
                       鏌ョ湅
@@ -890,14 +1022,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.ftime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> E </span>
                     <Button onClick={() => {this.showError('E')}} type="primary" size="small">
                       鏌ョ湅
@@ -907,7 +1039,7 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> NM </span>
                     <Button onClick={() => {this.showError('NM')}} type="primary" size="small">
                       鏌ョ湅
@@ -917,9 +1049,9 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
-                    <span className="errorval"> -1 </span>
-                    涓嶆彁绀�
+                  <Form.Item label="鎻愮ず缂栫爜">
+                    <span className="errorval"> -2 </span>
+                    鎵ц澶辫触鏃犳彁绀�
                   </Form.Item>
                 </Col>
               </Row>

--
Gitblit v1.8.0