开票申请卡片批量粘贴编辑事件
This commit is contained in:
parent
68eb002138
commit
6118908f94
|
@ -32,10 +32,12 @@ const headKeys = ['pk_org', 'pk_customer', 'gmf_zh', 'pk_customer_v','gmf_dz','g
|
|||
* zkje:折扣金额
|
||||
* fphxz:发票行性质
|
||||
* taxcode:税码
|
||||
* spbm:税收分类编码
|
||||
*/
|
||||
const bodyKeys = ['xmdj', 'sl', 'xmje', 'se', 'xmsl', 'xmjshj', 'pk_materiel', 'zkje', 'fphxz', 'taxcode'];
|
||||
const bodyKeys = ['xmdj', 'sl', 'xmje', 'se', 'xmsl', 'xmjshj', 'pk_materiel', 'zkje', 'fphxz', 'taxcode', 'spbm'];
|
||||
|
||||
export default function (moduleId, key, value, changedrows, index, record) {
|
||||
// console.log('valueChange', moduleId, key, value, changedrows, index);
|
||||
let hasChange = false;
|
||||
if ((moduleId == presetVar.formAreaId && headKeys.indexOf(key) > -1) ||
|
||||
(moduleId == presetVar.bodyAreaId && bodyKeys.indexOf(key) > -1)) {
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* @Last Modified time: 2025-05-07 16:30:44
|
||||
*/
|
||||
|
||||
import valueChange from "../common/valueChange";
|
||||
import {cloneDeep} from "lodash";
|
||||
import bodyAfterEvent from "./bodyAfterEvent";
|
||||
|
||||
const BATCHITEM = [
|
||||
'spbm', // 税收分类编码
|
||||
|
@ -22,75 +23,67 @@ const BATCHITEM = [
|
|||
'xmjshj' //价税合计
|
||||
];
|
||||
|
||||
export default async function batchEvents(obj) {
|
||||
console.log('obj = ', obj);
|
||||
//循环判断单元格是否可编辑,并注册过滤条件
|
||||
let areaCode = obj.areaCode; //区域编码
|
||||
let column = obj.column; //列信息
|
||||
let newValue = obj.newValue; //变更的行信息
|
||||
let queryValue = [];
|
||||
let changedrows = obj.changedrows; //变更的信息,仅包含newValue和OldValue
|
||||
let currentIndex = obj.currentIndex; //当前行
|
||||
export default async function batchEvents(param) {
|
||||
// console.log('param = ', param);
|
||||
let self = this;
|
||||
let {areaCode, column, newValue, changedrows, allData, currentIndex, pasteData} = param;
|
||||
let attrcode = column.attrcode;
|
||||
let newRows = [];
|
||||
let queryCondition = {}
|
||||
let isManyCondition = false //业务组判断,每行参照过滤条件是否不一样,如果不一样,值为true
|
||||
let indexs = [];
|
||||
let attrcode = column.attrcode; //列code
|
||||
let queryCondition; //统一过滤的过滤条件
|
||||
let isManyCondition = false; //业务组判断,每行参展过滤条件是否不一样,如果不一样,值为true
|
||||
let pasteData = obj.pasteData; //粘贴的值
|
||||
// 表格粘贴前的所有行数据
|
||||
let allData = obj.allData;
|
||||
|
||||
// 不在 BATCHITEM 里面的列,直接返回
|
||||
if (!BATCHITEM.includes(attrcode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (!isManyCondition) {
|
||||
queryCondition = {def1: records[i].data.def1.value}
|
||||
}*/
|
||||
let rowKey = 'rowid';
|
||||
for (let i = 0; i < newValue.length; i++) {
|
||||
let isExist = false;
|
||||
// 查找真正的index(解决筛选问题)
|
||||
let isExit = false;
|
||||
allData.forEach((item, index) => {
|
||||
if (item[rowKey] === newValue[rowKey]) {
|
||||
isExist = true;
|
||||
if (allData[index].values.pk_org == 'a') {
|
||||
//若该单元格不可编辑则跳过
|
||||
return;
|
||||
}
|
||||
|
||||
if (allData[index].values.pk_org == 'b') {//若该单元可编辑
|
||||
queryValue[i] = newValue[i]; //则保留
|
||||
indexs.push(index);
|
||||
|
||||
//若为参照
|
||||
if (column.itemtype === 'refer' && isManyCondition) {
|
||||
//如果每个单元格的过滤条件不一致,则给每个单元格注册过滤条件
|
||||
queryValue[i].queryCondition = {pk_org: records[i].data.def1.value}
|
||||
}
|
||||
}
|
||||
if (newValue[i].rowid && newValue[i].rowid === item['rowid']) {
|
||||
isExit = true;
|
||||
newRows[i] = cloneDeep(allData[index]);
|
||||
}
|
||||
})
|
||||
// allData中没有找到,说明应该是新增的行
|
||||
if (isExist) {
|
||||
// 因为可以粘贴超过当前页面显示数据的行数,则会增行,如果该行还有其他的数据展示,需要业务组来处理,塞到queryValue中
|
||||
// 比如 queryValue[i].values.行号={value:10}
|
||||
if (!isExit) {
|
||||
newRows[i] = cloneDeep(newValue[0]);
|
||||
}
|
||||
if (allData[i] && allData[i].values && allData[i].values[attrcode]) {
|
||||
newRows[i].values[attrcode] = newValue[i].values[attrcode];
|
||||
newRows[i].rowid = newValue[i].rowid;
|
||||
newRows[i].rowId = newValue[i].rowId;
|
||||
newRows[i].key = newValue[i].key;
|
||||
newRows[i].status = newValue[i].status;
|
||||
newRows[i].dataIndex = i + currentIndex;
|
||||
newRows[i].leafIndex = i + currentIndex;
|
||||
newRows[i].viewIndex = i + currentIndex;
|
||||
indexs.push(i + currentIndex)
|
||||
} else {
|
||||
//增的行大于 现有的行
|
||||
newRows[i].values[attrcode] = newValue[i].values[attrcode];
|
||||
newRows[i].rowid = newValue[i].rowid;
|
||||
newRows[i].rowId = newValue[i].rowId;
|
||||
newRows[i].key = newValue[i].key;
|
||||
newRows[i].dataIndex = i + currentIndex;
|
||||
newRows[i].leafIndex = i + currentIndex;
|
||||
newRows[i].viewIndex = i + currentIndex;
|
||||
newRows[i].status = newValue[i].status;
|
||||
indexs.push(i + currentIndex);
|
||||
}
|
||||
}
|
||||
//调用平台方法,更新数据
|
||||
this.props.cardTable.updateAfterBatchChange({
|
||||
self.props.cardTable.updateAfterBatchChange({
|
||||
areaCode,
|
||||
attrcode,
|
||||
queryValue,
|
||||
changedrows,
|
||||
column,
|
||||
queryValue: newRows,
|
||||
changedrows,
|
||||
pasteData,
|
||||
indexs, //过滤后的index的数组例如:[0,1,2,3,5]
|
||||
queryCondition, //如果是参照且参照过滤条件唯一就传,不一致就是前面说的,放到queryValue里
|
||||
queryCondition, //如果是参照且参照过滤条件唯一就传,不一致就是前面说的,放到newData里
|
||||
isManyCondition,// true,代表有多个参照过滤条件,false表示只有一个
|
||||
}).then((res) => {
|
||||
//res里的数据,暂时有props,changedrows,indexs
|
||||
let {props, changedrows, indexs, key} = res
|
||||
//执行业务的批量编辑后事件
|
||||
// afterEvent(this.props, areaCode, attrcode, queryValue, changerows);
|
||||
valueChange.call(this, areaCode, attrcode, newValue);
|
||||
bodyAfterEvent.call(self, areaCode, attrcode, newValue, changedrows);
|
||||
});
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue