/**
 * 是否业务接待校验 当差旅费业务接待=true时 需填写接待登记单
 * @author fengjiansheng
 * @date 2021-11-30
 */
export default {
    execute: function () {
        console.log("s1 CheckYwjdSave")
        if (arguments && arguments[0] && arguments[0].length > 0 && arguments[1]) {
            let context = arguments[1]
            let sfjdField = arguments[0][0]
            let subBillNameField = arguments[0][1]
            let checkBillName = arguments[0][2].getResult().Value
            let tempSubTableObject = context.getTableType(subBillNameField.FieldTableCode)
            let allSubData = context.getAllSubData()
            let tempArray = []
            let flag = false
            if (allSubData) {
                let tempAllSubData = allSubData[tempSubTableObject.title]
                if (tempAllSubData && tempAllSubData instanceof Array) {
                    tempAllSubData.forEach(e => {
                        if (e.getValue(sfjdField.FieldCode)) {
                            flag = true;
                        }
                        tempArray.push(e.getValue(subBillNameField.FieldCode))
                    })
                }
                return flag ? tempArray.indexOf(checkBillName) > -1 : true
            }
            return true;
        }
    },
    getResultType: function () {
        return FMR.ConstDataTypes.Bool
    }
}
