// 判断子表是否为空前端公式
export default {
    execute: function () {
        console.log("进入：判断子表是否为空前端公式");
        let size = 0;
        if (arguments && arguments[0] && arguments[0][0] && arguments[1]) {
            let table = arguments[0][0].FieldTableCode, context = arguments[1];
            if (context.getTableType) {
                let _tn = context.getTableType(table);
                let _data = context.getSubData(_tn.title);
                if (_data instanceof Array) {
                    let field = arguments[0][0].FieldCode
                    let matchProp = arguments[0][1].StaticValue
                    let matchValue = arguments[0][2].StaticValue
                    if (matchValue) {
                        for (const iterator of _data) {
                            let _val = iterator.getValue(field)
                            if (_val instanceof Object) {
                                if (_val[matchProp] == matchValue) {
                                    size++;
                                }
                            } else {
                                if (_val == matchValue) {
                                    size++;
                                }
                            }
                        }
                    } else {
                        size = _data.length
                    }
                }
            }
        }
        return size
    },
    getResultType: function () {
        return FMR.ConstDataTypes.General;
    }
}