Commit a847a051 authored by 覃振观's avatar 覃振观 👶

666

parent 13f1bc9d
......@@ -7,7 +7,8 @@
function mapping(dataMapping, rawData) {
window.dataSet = {};
window.dataSet.tempId = 950366;
if(!rawData) {
debugger;
if(Object.entries(rawData).length / Object.entries(window.dataMapping).length < 0.5) {
window.dataSet.isInsert = true;
var rawData = {};
}else {
......@@ -52,19 +53,7 @@ function mapping(dataMapping, rawData) {
rowData['rowIndex'] = rowId;
listMap[rowId] = rowData;
ids.push(rowId);
settingGridMapper(propertyNames.columns, mapper, rowId, beanName);
// propertyNames.columns.forEach(property => {
// if(!mapper[property]) {
// mapper[property] = {};
// }
// if(!mapper[property][beanName]) {
// mapper[property][beanName] = {};
// }
// let mapperData = {};
// mapperData[rowId] = {};
// mapper[property][beanName].push(mapperData);
// });
})
rawData[beanName] = {};
rawData[beanName].raw = entityData;
......@@ -83,6 +72,14 @@ function mapping(dataMapping, rawData) {
return returnData;
}
/**
* 设置 Grid 映射关系,若是添加行,则需要构建属性
* @param propertyNames
* @param mapper
* @param rowId
* @param beanName
* @param data 若是添加行,需要传入 data 构建属性
*/
function settingGridMapper(propertyNames, mapper, rowId, beanName, data) {
propertyNames.forEach(property => {
if(!mapper[property]) {
......@@ -178,7 +175,7 @@ function checkArrayMapper(str) {
function listeningGrid(elId, options) {
let currentMapper = checkArrayMapper(elId);
if(!currentMapper.property.id) {
if(!currentMapper.property) {
console.error("若需要监听 GridData ,必须在映射配置指定 ID !请检查。");
return;
}
......@@ -214,16 +211,8 @@ function listeningGrid(elId, options) {
let rowId = window.dataSet.tempId += 1
let data = {}, mapperData = {};
// ------------- 设置 mapper -------------
settingGridMapper(currentMapper.property.columns, mapper, rowId, beanName);
settingGridMapper(currentMapper.property.columns, mapper, rowId, beanName, data);
// currentMapper.property.columns.forEach(property => {
// mapperData[rowId] = {};
// if(!mapper[property]) {
// mapper[property] = {};
// }
// mapper[property][beanName] = mapperData;
//
// });
data[idProperty] = rowId;
data['rowIndex'] =rowId
// ------------- 设置 compares -------------
......@@ -251,15 +240,15 @@ function listeningGrid(elId, options) {
let beanName = currentMapper.beanName;
let currentData = window.dataSet.newData[beanName];
let propertyId = window.dataMapping[beanName].id;
let currentId = selectRow[propertyId];
let currentId = selectRow[propertyId] + '';
delete currentData.compares[currentId];
currentData.ids.pop(currentId);
currentData.ids = currentData.ids.filter(x => !currentId.includes(x));
// window.dataMapping[beanName].columns.forEach(property => {
// window.dataMapping.mapper[property][beanName]
// });
currentMapper.property.columns.forEach(property => {
delete window.dataMapping.mapper['productFaceColorId'][beanName][currentId];
});
gridManager.deleteSelectedRow();
debugger;
originalOnClick.call(this, selectRow);
}
}
......@@ -326,7 +315,7 @@ function listenerContent(event) {
let control;
let inputIds = event.target.id.split('_');
let currentMapper = checkArrayMapper(inputIds[0]);
if (currentMapper.property.id) {
if (currentMapper.property) {
control = 'grid';
} else {
control = 'form';
......@@ -435,7 +424,6 @@ function checkUpdata() {
if(!rawCompares) { rawCompares = {}; }
if(!nowCompares) { nowCompares = {}; }
if(!(getHashCode(JSON.stringify(rawCompares)) === getHashCode(JSON.stringify(nowCompares)))) {
debugger;
let rawIds = raw.ids, nowIds = now.ids;
dataSet.upData[beanName] = {};
dataSet.upData[beanName].del = [];
......
......@@ -153,7 +153,7 @@ function faceGrid(elId, data) {
updateHandler();
},
deleteHandler: (rowData) => {
console.log(rawData);
console.log(rowData.rowIndex);
},
});
var gridManager = listeningGrid(elId, {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment