
import {danxiangdinge_index} from './utils';
import Service from './Service';

function copy(input) {
    return JSON.parse(JSON.stringify(input));
}


export const undo = () => {
    let newData = Service.undo();
    return newData;
};



export const redo = () => {
    let newData = Service.redo();
    return newData;
};

export const shanchu = ( selectedRow) => {
   
    
    
    let newData = Service.shanchu(selectedRow);
    
    return newData;
  };




export const quanbushanchu = (hotRef, selectedRow) => {
    let qdbm = hotRef.current?.hotInstance?.getData()[selectedRow.current][2];
    
    let newData = Service.quanbushanchu(qdbm);
    return newData;
  };


export const danxiangdinge = (selectedRow) => {
    return Service.danxiangdinge(selectedRow);
};

export const updateDercj = (row, data) => {
    return Service.updateDercj(row, data);

};

export const changguidinge = (dingeclick, selectedRow) => {
    return Service.changguidinge(dingeclick, selectedRow);

};

export const handleBeizhu = (beizhuFK, derow, fuzhuSelect, fuzhu ) => {
    console.log(beizhuFK);
    let bianma = [];
    let xuhao = [];
    let fuzhuSelect_ = Array.from(fuzhuSelect);
    let keys = beizhuFK['BZBH'];
    for(let j = 0; j < fuzhuSelect_.length; j++) {
        let entry = fuzhuSelect_[j];
        for(let i = 0; i < fuzhu.length; i++) {
            if (fuzhu[i]['id'] == entry) {
                bianma.push(fuzhu[i]['编号']);
                xuhao.push(fuzhu[i]['序号']);
            }
        }
    }
    let result = [];
    for(let i = 0; i < bianma.length; i++) {
        let bh = bianma[i];
        for(let j = 0; j < Object.keys(keys).length; j++) {
            let BZBH_ = Object.keys(keys)[j];
            let BZBH = keys[BZBH_];
            if (BZBH == bh) {
                result.push([beizhuFK['BH'][BZBH_], beizhuFK['MC'][BZBH_], beizhuFK['LB'][BZBH_], beizhuFK['SL'][BZBH_], beizhuFK['DW'][BZBH_]]);
            }
        }
    }
    console.log(result);
    return Service.updateBeizhu(derow, result, xuhao);
};



