import draftName from '../control/draftName.vue';

export default {
    execute: function (bill, param) {
        if (param) {
            let component = null;
            let columns = []
            let children = [];
            let name = GMS.$hideContainer.addComponent(draftName, {}, function (c) {
                component = c;
                c.bill = bill;
                c.data = bill.getBuillData(param.param);
                let ignoreTempFields = 'id,billCode,billState,flowState,BILLSTATEAUDIT,'
                if ('ignoreFields' in param.param && param.param.ignoreFields.length > 0) {
                    ignoreTempFields += param.param.ignoreFields
                }
                Object.keys(c.data).forEach(e => {
                        if (Array.isArray(c.data[e])) {
                            for (let i = 0; i < c.data[e].length;  i++) {
                                let obj = c.data[e][i]
                                if (ignoreTempFields && ignoreTempFields.length > 0) {
                                    ignoreTempFields.split(',').forEach(temp1 => {
                                        if (temp1 in obj) {
                                            c.data[e][i][temp1] = undefined
                                        }
                                    })
                                }
                            }
                        }
                    }
                );
                if (ignoreTempFields && ignoreTempFields.length > 0) {
                    ignoreTempFields.split(',').forEach(e => {
                        if (e in c.data) {
                            c.data[e] = undefined
                        }
                    })
                }
                c.billDefineName = bill.curForm.content.billdefine;
                c.draftModal = true;
            });
        } else {
            GAMS.Common.messagePrompt('缺少参数');
        }
    }
}
