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

Grid 下拉框 优化

parent 99907050
......@@ -190,7 +190,6 @@ 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;
......@@ -204,8 +203,7 @@ function onBeforeEdit_(options) {
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;
mapperEntry[currentMapper.beanName][rowIndex] = editParm.rowindex; // input 框定位
} else {
// mapperEntry[currentMapper.beanName][rowIndex] = colName;
// console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
......@@ -222,7 +220,7 @@ function onBeforeEdit_(options) {
*/
function listeningSearchbox(elId, options, gridId) {
const originalOnChange = options.onChange;
options.onChange = function(value, data, fillInValue) {
options.onChange = function(value, data, gridManager) {
let eleName = this.element[0].name, beanName = '';
let currentMapper = window.dataMapping.mapper[eleName];
if(!currentMapper) {
......@@ -238,31 +236,30 @@ function listeningSearchbox(elId, options, gridId) {
if(typeof property== 'string') {
// ------------------ Form 下拉框执行此逻辑 ------------------
window.dataSet.newData[beanName][property] = data[property];
fillInValue = data[property];
gridManager = window.dataGrid[gridId];
} else if(property instanceof Object) {
// ------------------ Grid 下拉框执行此逻辑 ------------------
debugger;
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];
let fillProperty = gridEdit.editParm.column.editor.fillProperty
window.dataSet.newData[beanName].compares[rowIndex][fillProperty] = data[fillProperty];//更新数据
window.dataGrid[gridId].editor.editParm.record[propertyName] = data[propertyName]; //更新显示
}
gridManager = window.dataGrid[gridId];
property.rowIndex = null;
property.colName = null;
property.domId = null;
}
}
}
})
if(fillInValue) {
originalOnChange.call(this, value, data, fillInValue);
if(gridManager) {
originalOnChange.call(this, value, data, gridManager);
}
}
$(elId).searchbox(options);
......@@ -446,7 +443,6 @@ function listenerContent(event) {
window.dataSet.newData[beanName][property] = event.target.value;
console.log('Input value changed:', event.target.value);
}
})
}
}
......
......@@ -31,8 +31,8 @@ function initializateSelectC() {
listeningSearchbox('#selectedFactory', {
type: "product",
name: "productFactoryName",
onChange: function (value, data, fillInValue) {
console.log('fillInValue : '+ fillInValue);
onChange: function (value, data, gridManager) {
console.log('fillInValue : ');
}
});
......@@ -59,7 +59,7 @@ function initializateSelectC() {
function initGridSearchbox() {
listeningGridSearchbox('fronColorsGrid_colorId', {
listeningGridSearchbox('fronColorsGrid_colorName', {
type: "product",
name: "color",
onChange: function (value, data, fillInValue) {
......@@ -179,11 +179,11 @@ var dataMapping = {
},
fronColors: {
id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId" ]
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId", "colorName" ]
},
backColors: {
id: "productFaceColorId",
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId" ]
columns: [ "productFaceColorId", "coverageRate", "productFaceId", "colorId", "colorName" ]
},
processed: {
id: "productTechnologyId",
......@@ -216,8 +216,8 @@ function faceGrid(elId, data) {
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "颜色名称", name: "colorId", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'select', showProperty: 'colorName'
{ display: "颜色名称", name: "colorName", width: 140, minWidth: 60, type: "string", align: "left", editor: {
type: 'select', fillProperty: 'colorId'
}},
{ display: "油墨覆盖率(%)", name: "coverageRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text'} }
],
......
......@@ -5,10 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.huigou.topsun.common.NumberToStringSerializer;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -53,6 +50,9 @@ public class ProductFaceColor implements Serializable {
*/
@Column(name = "sort_order", nullable = true)
private Integer sortOrder;
@Transient
private String colorName;
public BigDecimal getProductFaceColorId() {
return this.productFaceColorId;
......@@ -93,4 +93,12 @@ public class ProductFaceColor implements Serializable {
public void setSortOrder(Integer sortOrder) {
this.sortOrder = sortOrder;
}
public String getColorName() {
return colorName;
}
public void setColorName(String colorName) {
this.colorName = colorName;
}
}
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