Commit 4b45e918 authored by 覃振观's avatar 覃振观 👶

Grid 下拉框

parent 996b5748
......@@ -178,7 +178,10 @@ function checkArrayMapper(str) {
}
/**
* Grid 编辑前触发。 这里记录当前编辑框 对应的 Grid 行 rowIndex 和列 property
*     
* Grid 编辑前触发。 这里记录当前编辑框 对应的 Grid 行 rowIndex 和列 property <br> &nbsp;&nbsp;&nbsp;&nbsp;
* 这里根据 UI ID生成规则封装。 需要根据此规则维护。 <br> &nbsp;&nbsp;&nbsp;&nbsp;
* 编辑前,根据 UI 生成的编辑框命名规则,定位到当前编辑栏目。修改数据时以此栏目位置为定位标准修改对应数据集。只记录当前栏目,使用完后需要清除。
* @param options
* @private
*/
......@@ -187,64 +190,90 @@ function onBeforeEdit_(options) {
options.onBeforeEdit = function(editParm, gg){
let domIds = editParm.column.__domid.split('|'), recordId = editParm.record.__id, colName = editParm.column.name;
let parentDomId = domIds[0]+'|'+2+'|'+recordId; // +'|'+domIds[2];
let domId = domIds[0]+'|'+2+'|'+recordId +'|'+domIds[2];
let rowDOM;
if(!(rowDOM = document.getElementById(parentDomId))) {
parentDomId = domIds[0]+'|'+1+'|'+recordId;
rowDOM = document.getElementById(parentDomId)
}
let mapper = window.dataMapping.mapper;
let rowId = rowDOM.childNodes[0].childNodes[0].innerText;
let rowIndex = rowDOM.childNodes[0].childNodes[0].innerText;
let mapperEntry = mapper[colName];
let currentMapper = checkArrayMapper(domIds[0]);
if(currentMapper.hasOwnProperty("beanName")) {
if(!mapperEntry[currentMapper.beanName]) {
console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
if(mapperEntry[currentMapper.beanName]) {
mapperEntry[currentMapper.beanName]['rowIndex'] = rowIndex;
mapperEntry[currentMapper.beanName]['colName'] = colName;
mapperEntry[currentMapper.beanName]['domId'] = domId;
mapperEntry[currentMapper.beanName][rowIndex] = editParm.rowindex;
} else {
//mapperEntry[currentMapper.beanName]['rowId'] = parentDomId;
mapperEntry[currentMapper.beanName][rowId] = colName;
// mapperEntry[currentMapper.beanName][rowIndex] = colName;
// console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
}
}
originalOnBeforeEdit.call(this, editParm, '11');
}
}
function listeningSearchbox(elId, options) {
/**
* 监听 下拉框初始化 ,使选中值时维护 dataSet。显示值需要自己处理。
* @param elId 需要渲染的下拉框的 DOMId
* @param options
*/
function listeningSearchbox(elId, options, gridId) {
const originalOnChange = options.onChange;
options.onChange = function(value, data) {
let eleName = this.element[0].name;
options.onChange = function(value, data, fillInValue) {
let eleName = this.element[0].name, beanName = '';
let currentMapper = window.dataMapping.mapper[eleName];
if(!currentMapper) {
console.error("找不到该映射,请检查映射配置是否存在该配置: "+ eleName);
}
let fillInValue;
Object.entries(currentMapper).forEach(mapper => {
let property = "";
if(eleName.split('_').length > 1) {
property = eleName.split('_')[1];
} else {
let beanName = mapper[0];
beanName = mapper[0];
property = mapper[1];
if(typeof property== 'string') {
// ------------------ Form 下拉框执行此逻辑 ------------------
window.dataSet.newData[beanName][property] = data[property];
fillInValue = data[property];
} else if(property instanceof Object) {
let entry = Object.entries(property);
let rowIndex = entry[0];
let propertyName = entry[1];
window.dataSet.newData[beanName].compares[rowIndex]
// ------------------ Grid 下拉框执行此逻辑 ------------------
if(property.rowIndex) {
let rowIndex = property.rowIndex;
let propertyName = property.colName;
let domId = property.domId;
window.dataSet.newData[beanName].compares[rowIndex][propertyName] = data[propertyName];
fillInValue = domId;
let gridEdit = window.dataGrid['fronColorsGrid'].editor;
if(gridEdit.editParm.column.editor.type === 'select') {
let showProperty = gridEdit.editParm.column.editor.showProperty
window.dataGrid[gridId].editor.editParm.record[propertyName] = data[showProperty];
}
property.rowIndex = null;
property.colName = null;
property.domId = null;
}
}
}
})
originalOnChange.call(this, value, data, fillInValue);
if(fillInValue) {
originalOnChange.call(this, value, data, fillInValue);
}
}
$(elId).searchbox(options);
}
/**
* &nbsp;&nbsp;&nbsp;&nbsp;
* Gria 中的下拉框 用此方式初始化。此下拉框维护 dataSet, 显示值需要自己处理。
* @param propertyName GridId_propertyName,需要以此定位到需要展开下拉框的栏目(临时)
* @param options
*/
function listeningGridSearchbox(propertyName, options) {
if(!window.gridSearchboxOptions) {
window.gridSearchboxOptions = {};
......@@ -255,7 +284,9 @@ function listeningGridSearchbox(propertyName, options) {
function DropdownTrigger(node) {
let nodeId = node.id;
let tempId = nodeId.slice(0, nodeId.lastIndexOf('_'));
listeningSearchbox('#'+nodeId, window.gridSearchboxOptions[tempId]);
if(node.getAttribute('select')) {
listeningSearchbox('#'+nodeId, window.gridSearchboxOptions[tempId], nodeId.split('_')[0]);
}
}
/**
......@@ -348,6 +379,10 @@ function listeningGrid(elId, options) {
}
addObserver(elId);
var gridManager = UICtrl.grid(elId, options);
if(!window.dataGrid){
window.dataGrid = {};
}
window.dataGrid[elId.slice(1)] = gridManager;
return gridManager;
}
......@@ -384,12 +419,12 @@ function listenerContent(event) {
// Grid 时执行此逻辑
if(control === 'grid') {
debugger;
tryForEach(Object.entries(beanMapping), mapperEntry => {
Object.entries(beanMapping).forEach(mapperEntry => {
let mapperKey = mapperEntry[0], mapperVal = mapperEntry[1];
Object.entries(mapperEntry[1]).forEach(rowEntry => {
let rowId = rowEntry[0];
if(rowEntry[1].rowIndex != undefined) {
if(rowEntry[1].rowIndex === inputIds[2] * 1) {
if(rowEntry[1] !== undefined) {
if(rowEntry[1] === inputIds[2] * 1) {
window.dataSet.newData[mapperKey].compares[rowId][inputIds[1]] = event.target.value;
console.log('Input value changed:', event.target.value);
}
......
......@@ -57,18 +57,18 @@ function initializateSelectC() {
});
}
function initGridSearchbox() {
listeningGridSearchbox('fronColorsGrid_colorId', {
type: "product",
name: "color",
onChange: function (value, data, fillInValue) {
console.log('fillInValue : '+ fillInValue);
debugger;
// $('#selectedTechnology').val(data.productTechnologyName)
}
})
}
function initializeUI() {
UICtrl.layout("#layout",{
heigth:'280px',
......@@ -217,9 +217,9 @@ function faceGrid(elId, data) {
var gridManager = listeningGrid(elId, {
columns: [
{ display: "颜色名称", name: "colorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'select'
type: 'select', showProperty: 'colorName'
}},
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } }
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text'} }
],
toolbar: toolbarOptions,
dataType: "local",
......@@ -232,8 +232,9 @@ function faceGrid(elId, data) {
onBeforeEdit : function(editParm, gg) {
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
}
onAfterEdit: function() {
debugger;
},
});
}
......
......@@ -254,10 +254,10 @@ public class ProductApplicationImpl extends BaseApplication implements ProductAp
}
/**
* description 持久化数据.
* <br>&nbsp;&nbsp;Entity 时,如果 ID 为空执行 Persist,否则执行 Merge
* <br>&nbsp;&nbsp;List 时,要求数据集格式 :
* <br>&nbsp;&nbsp;&nbsp;&nbsp;HashMap { ”add“: List< Entity >, ”up“: List< Entity >, ”del“: List< Entity > }
* description 持久化数据. <br>&nbsp;&nbsp;&nbsp;&nbsp;
* Entity 时,如果 ID 为空执行 Persist,否则执行 Merge <br>&nbsp;&nbsp;&nbsp;&nbsp;
* List 时,要求数据集格式 : <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
* HashMap {”add“: List< Entity >,”up“: List< Entity >,”del“: List< Entity >}
* @param entitys 持久化数据集合 Set { Entity, HashMap }
* @author qinzhenguan
* @createDate 2023/12/26 16:44
......
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