From 063b983daaf51a7f1e8677bde1e9c0e618866c91 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 二月 2020 10:30:19 +0800
Subject: [PATCH] 2020-02-21

---
 src/templates/tableshare/verifycard/billcodeform/index.jsx |   89 ++++++++++++++++++++++++++------------------
 1 files changed, 53 insertions(+), 36 deletions(-)

diff --git a/src/templates/tableshare/verifycard/billcodeform/index.jsx b/src/templates/tableshare/verifycard/billcodeform/index.jsx
index 4ea880c..d140531 100644
--- a/src/templates/tableshare/verifycard/billcodeform/index.jsx
+++ b/src/templates/tableshare/verifycard/billcodeform/index.jsx
@@ -7,12 +7,13 @@
 
 class UniqueForm extends Component {
   static propTpyes = {
-    dict: PropTypes.object,  // 瀛楀吀椤�
-    fields: PropTypes.array,  // 琛ㄥ崟
-    columns: PropTypes.array,  // 琛ㄥ崟
-    modular: PropTypes.array,  // 琛ㄥ崟
-    modularDetail: PropTypes.array,  // 琛ㄥ崟
-    orderChange: PropTypes.func  // 琛ㄥ崟
+    dict: PropTypes.object,         // 瀛楀吀椤�
+    fields: PropTypes.array,        // 琛ㄥ崟
+    billcodes: PropTypes.array,     // 琛ㄥ崟
+    columns: PropTypes.array,       // 琛ㄥ崟
+    modular: PropTypes.array,       // 琛ㄥ崟
+    modularDetail: PropTypes.array, // 琛ㄥ崟
+    orderChange: PropTypes.func     // 琛ㄥ崟
   }
 
   state = {
@@ -44,9 +45,11 @@
       }
     })
 
+    let _usedfields = this.props.billcodes.map(item => item.field)
+
     this.setState({
       modularDetail: _modularDetail,
-      funFields: this.props.fields.filter(field => field.type === 'funcvar'),
+      funFields: this.props.fields.filter(field => field.type === 'funcvar' && !_usedfields.includes(field.field)),
       billFields: _billFields
     })
   }
@@ -62,6 +65,9 @@
   }
 
   edit = (record) => {
+    let _usedfields = this.props.billcodes.map(item => item.field)
+    let _funFields = this.props.fields.filter(field => field.type === 'funcvar' && (!_usedfields.includes(field.field) || field.field === record.field))
+
     if (record.TypeCharOne === 'Y' || record.TypeCharOne === 'n') {
       let _detail = this.props.modularDetail.filter(item => item.BID === record.ModularCode)
       let _modularDetailCode = ''
@@ -72,25 +78,29 @@
 
       this.setState({
         type: '2',
+        funFields: _funFields,
         editItem: record,
         modularDetail: _detail
-      })
-      this.props.form.setFieldsValue({
-        field: record.field,
-        TypeCharOne: record.TypeCharOne,
-        ModularCode: record.ModularCode,
-        ModularDetailCode: _modularDetailCode,
+      }, () => {
+        this.props.form.setFieldsValue({
+          field: record.field,
+          TypeCharOne: record.TypeCharOne,
+          ModularCode: record.ModularCode,
+          ModularDetailCode: _modularDetailCode,
+        })
       })
     } else {
       this.setState({
         type: '1',
+        funFields: _funFields,
         editItem: record,
-      })
-      this.props.form.setFieldsValue({
-        field: record.field,
-        TypeCharOne: record.TypeCharOne,
-        Type: record.Type,
-        linkField: record.linkField,
+      }, () => {
+        this.props.form.setFieldsValue({
+          field: record.field,
+          TypeCharOne: record.TypeCharOne,
+          Type: record.Type,
+          linkField: record.linkField,
+        })
       })
     }
   }
@@ -159,6 +169,13 @@
         this.props.orderChange(values)
         this.setState({
           editItem: null
+        }, () => {
+
+          let _usedfields = this.props.billcodes.map(item => item.field)
+
+          this.setState({
+            funFields: this.props.fields.filter(field => field.type === 'funcvar' && !_usedfields.includes(field.field)),
+          })
         })
         this.props.form.setFieldsValue({
           field: '',
@@ -184,20 +201,20 @@
     return (
       <Form {...formItemLayout} className="verify-form">
         <Row gutter={24}>
-          <Col span={5}>
-            <Form.Item label={'鍑芥暟鍙橀噺'}>
+          <Col span={10}>
+            <Form.Item label={this.props.dict['header.form.funcvar']}>
               {getFieldDecorator('field', {
                 initialValue: '',
                 rules: [
                   {
                     required: true,
-                    message: this.props.dict['form.required.input'] + '鍑芥暟鍙橀噺!'
+                    message: this.props.dict['form.required.input'] + this.props.dict['header.form.funcvar'] + '!'
                   }
                 ]
               })(
                 <Select>
                   {this.state.funFields.map(option =>
-                    <Select.Option id={option.uuid} key={option.uuid} value={option.field}>
+                    <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}>
                       {option.label}
                     </Select.Option>
                   )}
@@ -205,7 +222,7 @@
               )}
             </Form.Item>
           </Col>
-          <Col span={5}>
+          <Col span={10}>
             <Form.Item label={'绫诲瀷'}>
               {getFieldDecorator('TypeCharOne', {
                 initialValue: 'Lp',
@@ -225,7 +242,12 @@
               )}
             </Form.Item>
           </Col>
-          {type === '1' ? <Col span={5}>
+          <Col span={4} className="add">
+            <Button onClick={this.handleConfirm} type="primary">
+              纭畾
+            </Button>
+          </Col>
+          {type === '1' ? <Col span={10}>
             <Form.Item label={'鍏宠仈瀛楁'}>
               {getFieldDecorator('linkField', {
                 initialValue: '',
@@ -238,7 +260,7 @@
               })(
                 <Select>
                   {this.state.billFields.map(option =>
-                    <Select.Option id={option.uuid} key={option.uuid} value={option.field}>
+                    <Select.Option title={option.label} id={option.uuid} key={option.uuid} value={option.field}>
                       {option.label}
                     </Select.Option>
                   )}
@@ -246,7 +268,7 @@
               )}
             </Form.Item>
           </Col> : null}
-          {type === '1' ? <Col span={5}>
+          {type === '1' ? <Col span={10}>
             <Form.Item label={'浣嶆暟'}>
               {getFieldDecorator('Type', {
                 initialValue: 4,
@@ -259,7 +281,7 @@
               })(<InputNumber min={1} max={10} precision={0} />)}
             </Form.Item>
           </Col> : null}
-          {type === '2' ? <Col span={5}>
+          {type === '2' ? <Col span={10}>
             <Form.Item label={'鍑瘉绫诲瀷'}>
               {getFieldDecorator('ModularCode', {
                 initialValue: this.props.modular[0] ? this.props.modular[0].ID : '',
@@ -276,7 +298,7 @@
                   onChange={(value) => {this.voucherChange(value)}}
                 >
                   {this.props.modular.map(option =>
-                    <Select.Option id={option.ID} key={option.ID} value={option.ID}>
+                    <Select.Option title={option.NameNO} id={option.ID} key={option.ID} value={option.ID}>
                       {option.NameNO}
                     </Select.Option>
                   )}
@@ -284,7 +306,7 @@
               )}
             </Form.Item>
           </Col> : null}
-          {type === '2' ? <Col span={5}>
+          {type === '2' ? <Col span={10}>
             <Form.Item label={'鍑瘉鏍囪瘑'}>
               {getFieldDecorator('ModularDetailCode', {
                 initialValue: this.state.modularDetail[0] ? this.state.modularDetail[0].ModularDetailCode : '',
@@ -300,7 +322,7 @@
                   filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                 >
                   {this.state.modularDetail.map(option =>
-                    <Select.Option id={option.ModularDetailCode} key={option.ModularDetailCode} value={option.ModularDetailCode}>
+                    <Select.Option title={option.CodeName} id={option.ModularDetailCode} key={option.ModularDetailCode} value={option.ModularDetailCode}>
                       {option.CodeName}
                     </Select.Option>
                   )}
@@ -308,11 +330,6 @@
               )}
             </Form.Item>
           </Col> : null}
-          <Col span={4} className="add">
-            <Button onClick={this.handleConfirm} type="primary">
-              纭畾
-            </Button>
-          </Col>
         </Row>
       </Form>
     )

--
Gitblit v1.8.0