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

Grid 下拉框 优化

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