Browse Source

【u审批】sm类型组件关联dbfinds

samhoo 4 năm trước cách đây
mục cha
commit
31be821069

+ 6 - 6
uas-office-web/wxuasapproval/src/components/approvalAdd/FormInput.jsx

@@ -346,9 +346,9 @@ export default class FormInput extends Component {
           this.setState({
             billModel,
           }, () => {
-            this.props.onTextChange &&
-            this.props.onTextChange(this.props.groupIndex, this.props.childIndex,
-              location.title)
+            this.props.onMapChange &&
+            this.props.onMapChange(this.props.groupIndex, this.props.childIndex,
+              location, billModel)
           })
         },
       },
@@ -358,9 +358,9 @@ export default class FormInput extends Component {
           this.setState({
             billModel,
           }, () => {
-            this.props.onTextChange &&
-            this.props.onTextChange(this.props.groupIndex, this.props.childIndex,
-              value)
+            this.props.onMapChange &&
+            this.props.onMapChange(this.props.groupIndex, this.props.childIndex,
+              location, billModel)
           })
         },
       },

+ 44 - 0
uas-office-web/wxuasapproval/src/pages/approval/ApprovalAdd.jsx

@@ -130,6 +130,7 @@ export default class ApprovalAdd extends Component {
                       <FormInput billModel={billModel} groupIndex={g}
                                  childIndex={i}
                                  baseUrl={mBaseUrl}
+                                 onMapChange={this.onMapChange.bind(this)}
                                  onTextChange={this.onTextChange.bind(this)}
                                  onInputClick={this.onInputClick.bind(this)}/>,
                     )
@@ -773,6 +774,49 @@ export default class ApprovalAdd extends Component {
     })
   }
 
+  onMapChange = (groupIndex, childIndex, info, billModel) => {
+    //获取关联关系dbfinds
+    const { billGroupModelList } = this.state
+    if (!isObjNull(billGroupModelList) &&
+    !isObjNull(billGroupModelList[groupIndex])) {
+      let billGroup = billGroupModelList[groupIndex]
+      let condition = '1=1'
+      let params = {
+        which: billGroup.isForm == true ? 'form' : 'grid',
+        caller: billGroup.billCaller,
+        field: billModel.field,
+        condition: condition,
+        page: 1,
+        pageSize: 0,
+      }
+      fetchGet(mBaseUrl + '/uapproval/common/dbfind.action',
+      params).then(response => {
+        Toast.hide()
+        let dbfinds = response.dbfinds || response.gridDbfinds;
+        dbfinds.forEach((item, index) => {
+          if(item.field != billModel.field){
+            if(!isObjNull(billGroup.showBillFields)){
+              billGroup.showBillFields.forEach((detail, index) => {
+                if(detail.field == item.field && info.address){
+                  detail.value = info.address;
+                  this.setState({
+                    billGroupModelList,
+                  })
+                }
+              })
+            }
+          }
+        })
+      }).catch(error => {
+        if (typeof error === 'string') {
+          message.error(error)
+        } else {
+          message.error('无关联数据')
+        }
+      })
+    }
+  }
+
   onSubmitClick = () => {
     const { billGroupModelList } = this.state
     if (!isObjEmpty(billGroupModelList)) {