import _ from 'lodash'

/**
 * 子表赋值 用于处理子表金额为0不显示的需求
 * @author fengjiansheng
 * @data 2021-08-29
 */
export default {
    execute: function () {
        console.log("s1 SetSubFieldNull")
        if (arguments && arguments[0] && arguments[0].length === 1 && arguments[1]) {
            let context = arguments[1]
            let subField = arguments[0][0]
            let tmpField = subField.FieldCode;
            let subTableObject = context.getTableType(subField.FieldTableCode)
            let oldIndex = context.getSubFocus()
            let focusData = context.getAllSubData()[subTableObject.title][oldIndex].getData()
            if (!_.isEqual(focusData[tmpField]._field_old_value_, focusData[tmpField].value) || !_.isEmpty(focusData[tmpField].value)) {
                focusData[tmpField]._field_old_value_ = focusData[tmpField].value = null
                context.refreshSubDataRow(subTableObject.title);
            }
        }
    },
    getResultType: function () {
        return FMR.ConstDataTypes.Void
    }
}
