开票申请卡片批量粘贴编辑事件

This commit is contained in:
mzr 2025-05-08 10:32:59 +08:00
parent 68eb002138
commit 6118908f94
2 changed files with 49 additions and 54 deletions

View File

@ -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)) {

View File

@ -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.行号={value10}
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里的数据暂时有propschangedrowsindexs
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);
});
}