import _ from 'lodash'

/**
 * 校验公式 检测基础数据中是否加载有拓展字段
 * @author fengjiansheng
 * @data 2021-09-03
 */
export default {
    execute: function () {
        console.log("s1 HasContainExpandFields")
        if (arguments && arguments[0] && arguments[0].length > 1 && arguments[1]) {
            if(arguments[0][0] && arguments[0][0].getResult() &&  arguments[0][0].getResult().Value){
                let baseData = arguments[0][0].getResult().Value
                for (let [index, data] of arguments[0].entries()) {
                    if (index === 0) {
                        continue
                    }
                    let tempField = arguments[0][index].StaticValue
                    if (_.isEmpty(tempField) || !_.isString(tempField)) {
                        console.error("HasContainExpandFields公式配置错误 第", (index+1), "个参数需为字符型参数")
                        return false
                    }
                    let result = baseData[tempField.toUpperCase()]
                    if (!_.isNumber(result) && _.isEmpty(result)) {
                        result = baseData[tempField.toLowerCase()]
                    }
                    if (!_.isNumber(result) && _.isEmpty(result)) {
                        return false;
                    }
                }
                return true
            }
        }else{
            console.error("HasContainExpandFields公式配置错误 参数个数不匹配")
            return false
        }
    },
    getResultType: function () {
        return 1
    }
}