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