import { InvoiceControllerState } from '..'; /** * 删除一个货物运输 */ export default async (state: InvoiceControllerState, $index?: string) => { if (!$index) return; // 查下要删除的货物 const goods = state.freightListState.goodsList.filter((e) => e.$index === $index)[0]; if (!goods) return; // 如果正在编辑 就取消编辑 if (state.freightListState.editGood && state.freightListState.editGood.$index === $index) { state.freightListState.editGood = undefined; } const goodsList = state.freightListState.goodsList; const goodsMap = state.freightListState.goodsMap; goodsMap.delete($index); for (let i = 0; i < goodsList.length; i++) { if (goodsList[i].$index === $index) { // const good = goodsList[i]; // if (good.lineAttribute === LineAttributeType.折扣行 && goodsList[i - 1] && goodsList[i - 1].lineAttribute === LineAttributeType.被折扣行) { // goodsList[i - 1].lineAttribute = LineAttributeType.正常; // } goodsList.splice(i, 1); break; } } state.freightListState.goodsList = [...goodsList]; state.freightListState.goodsMap = new Map(goodsMap); };