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

666

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