SetBaseDataForPay.js 4.71 KB
Newer Older
wangcong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
import _ from 'lodash'

/**
 * 报销单的支付明细表的收款账户省份和收款账户地区赋值
 * @author raojiaguan
 * @data 2021年8月24日18:07:32
 */
export default {
    execute: function () {
        console.log("s1 SetInternalAccommodation")
        if (arguments && arguments[0] && arguments[0].length > 1 && arguments[1]) {
            // TODO 参数校验
            let context = arguments[1]
            let targetSubField = arguments[0][0];
            let targetSubField2=arguments[0][1];
            let targetSubField3=arguments[0][2].getResult().Value;
            let subTableObject = context.getTableType(targetSubField.FieldTableCode)
            let oldIndex = context.getSubFocus()
            let focusData = context.getAllSubData()[subTableObject.title][oldIndex].getData()
            if (_.isString(targetSubField3.skzhsf) && targetSubField3.skzhsf.length > 0 && targetSubField3.skzhds &&   targetSubField3.skzhds.length > 0) {
                if(!(_.isEqual(focusData[arguments[0][2].FieldCode]._field_old_value_ ,focusData[arguments[0][2].FieldCode].value ))){
                    let param = {
                        "code": targetSubField3.skzhsf,
                        "tableName" :"MD_SKZHSF",
                        "queryDataStructure": "ALL",
                        "limit": 1,
                        "offset": 0,
                        "pagination": true
                    }
                    this.getMDObject(param, (data) => {
                        let newIndex = context.getSubFocus();
                        if (oldIndex !== newIndex) {
                            context.setSubFocus(oldIndex)
                        }
                        focusData[arguments[0][2].FieldCode]._field_old_value_ = focusData[arguments[0][2].FieldCode].value
                        // focusData.ZJ._field_old_value_ = focusData.ZJ.value
                        // focusData.RZRQ._field_old_value_ = focusData.RZRQ.value
                        // focusData.LDRQ._field_old_value_ = focusData.LDRQ.value
//                      targetSubField.dynamicNodeFactory.methodJson.SetFieldData('', linkId, data.cSontent, '')
                        focusData[targetSubField.FieldCode]._field_old_value_ = focusData[targetSubField.FieldCode].value = data.rows[0]
                        if (oldIndex !== newIndex) {
                            context.setSubFocus(newIndex)
                        }
                        context.refreshSubDataRow(subTableObject.title)
                    }, (resp) => {
                        GAMS.Common.messagePrompt("境内住宿标准金额获取接口请求失败,请联系管理员")
                        console.error("获取境内住宿标准公式直接失败"+resp)
                    });

                    let param1 = {
                        "code": targetSubField3.skzhds,
                        "tableName" :"MD_SKZHDS",
                        "queryDataStructure": "ALL",
                        "limit": 1,
                        "offset": 0,
                        "pagination": true
                    }
                    this.getMDObject(param1, (data) => {
                        let newIndex1 = context.getSubFocus();
                        if (oldIndex !== newIndex1) {
                            context.setSubFocus(oldIndex)
                        }
                        focusData[arguments[0][2].FieldCode]._field_old_value_ = focusData[arguments[0][2].FieldCode].value
                        focusData[targetSubField2.FieldCode]._field_old_value_ = focusData[targetSubField2.FieldCode].value = data.rows[0]
                        if (oldIndex !== newIndex1) {
                            context.setSubFocus(newIndex1)
                        }
                        context.refreshSubDataRow(subTableObject.title)
                    }, (resp) => {
                        GAMS.Common.messagePrompt("境内住宿标准金额获取接口请求失败,请联系管理员")
                        console.error("获取境内住宿标准公式直接失败"+resp)
                    });
                }
          
                }
            }else{
                focusData[targetSubField.FieldCode]._field_old_value_ = focusData[targetSubField.FieldCode].value = null
                focusData[targetSubField2.FieldCode]._field_old_value_ = focusData[targetSubField2.FieldCode].value = null
                context.refreshSubDataRow(subTableObject.title)
        }
    },
    getMDObject(param, callBack, errorCallBack) {
        GMS.$http.post("/baseData/data/list", param).then(data => {
            callBack(data.data);
        }).catch((resp) => {
            errorCallBack(resp);
        });
    },
    getResultType: function () {
        return FMR.ConstDataTypes.Void;
    }
}