SetIsOverStandard.js 2.46 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
import _ from 'lodash'

/**
 * 子表赋值 是否超标
 * @author fengjiansheng
 * @data 2021-08-22
 */
export default {
    execute: function () {
        if (arguments && arguments[0] && arguments[0].length === 3 && arguments[1]) {
            let context = arguments[1]
            let targetSubField = arguments[0][0];
            let tmpField = targetSubField.FieldCode
            let comp1 = arguments[0][1].getResult().Value;
            let comp2 = arguments[0][2].getResult().Value;
            let subTableObject = context.getTableType(targetSubField.FieldTableCode)
            let oldIndex = context.getSubFocus()
            let focusData = context.getAllSubData()[subTableObject.title][oldIndex].getData()
            if ((!_.isEmpty(comp1) || _.isNumber(comp1) ) && ( _.isEmpty(comp2) || (_.isNumber(comp2))) && (_.isNumber(_.toNumber(comp1)) && (_.isNumber(_.toNumber(comp2))))) {
                let param = {
                    "limit": 1,
                    "offset": 0,
                    "pagination": true,
                    "tableName": "MD_SF",
                    "code": _.toNumber(comp1) > _.toNumber(comp2) ? "1" : "0",
                    "queryDataStructure": "ALL"
                };
                this.getMDObject(param, (data) => {
                    let newIndex = context.getSubFocus();
                    if (oldIndex !== newIndex) {
                        context.setSubFocus(oldIndex)
                    }
                    focusData[tmpField]._field_old_value_ = focusData[tmpField].value = data.rows[0]
                    if (oldIndex !== newIndex) {
                        context.setSubFocus(newIndex)
                    }
                    context.refreshSubDataRow(subTableObject.title)
                }, (resp) => {
                    GAMS.Common.messagePrompt("子表赋值:是否超标执行失败,请联系管理员")
                    console.error("子表赋值:是否超标执行失败" + resp)
                });
            } else {
                focusData[tmpField]._field_old_value_ = focusData[tmpField].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;
    }
}