Commit 2b170650 authored by 覃振观's avatar 覃振观 👶

2222

parent cd4c7384
......@@ -55,10 +55,12 @@ function mapping(dataMapping, rawData) {
listMap[rowId] = rowData;
ids.push(rowId);
tryForEach(propertyNames.columns, (property) => {
if(!mapper[property]) {
mapper[property] = {};
}
let data = {};
data['beanName'] = beanName;
mapper[property][rowId] = data;
data['listeningKey'] = rowId;
mapper[property][beanName] = data;
});
})
rawData[beanName] = {};
......@@ -131,6 +133,23 @@ function isExist(obj, property, objName) {
return true;
}
/**
* 检查是否存在此 Grid 的映射 返回匹配到的映射
* @param str Grid Id
* @returns {{}}
*/
function checkArrayMapper(str) {
let retrunData = {};
Object.entries(window.dataMapping).forEach(entry => {
let beanName = entry[0], property = entry[1];
if(str.indexOf(beanName) >= 0) {
retrunData['beanName'] = beanName;
retrunData['property'] = property;
}
});
return retrunData;
}
/**
* 若需要监听 Grid 数据,必须在此调用组件初始化,此处获取元素 ID
* @param elId
......@@ -138,11 +157,9 @@ function isExist(obj, property, objName) {
* @returns {*}
*/
function listeningGrid(elId, options) {
let dataMapping = window.dataMapping;
let mappingEntry = Object.entries(dataMapping);
tryForEach(mappingEntry, entry => {
tryForEach(Object.entries(window.dataMapping), entry => {
let beanName = entry[0], property = entry[1];
if(!(property instanceof Array) && elId.indexOf(beanName) > 0) {
if(elId.indexOf(beanName) >= 0) {
let gridId = property.id;
if(!gridId) {
console.error("若需要监听 GridData ,必须在映射配置指定 ID !请检查。");
......@@ -151,6 +168,7 @@ function listeningGrid(elId, options) {
options.columns.unshift({ name: gridId, hide: true });
}
});
debugger;
let data = {};
if(!options.data){
console.error('listeningGrid 必须传入 Data !请检查');
......@@ -160,7 +178,6 @@ function listeningGrid(elId, options) {
// ------------------ 编辑框打开前记录当前行 ------------------
const originalOnBeforeEdit = options.onBeforeEdit;
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 rowDOM;
......@@ -171,15 +188,17 @@ function listeningGrid(elId, options) {
let mapper = window.dataMapping.mapper;
let rowId = rowDOM.childNodes[0].childNodes[0].innerText;
let mapperEntry = mapper[colName];
if(!mapperEntry[rowId]) {
let currentMapper = checkArrayMapper(domIds[0]);
debugger;
if(currentMapper.hasOwnProperty("beanName")) {
if(!mapperEntry[currentMapper.beanName]) {
console.error("dataMapping 中,无法找到该 DOMId 的映射。请检查!");
} else {
mapperEntry[rowId]['rowId'] = parentDomId;
mapperEntry[rowId]['rowIndex'] = editParm.rowindex;
//mapperEntry[currentMapper.beanName]['rowId'] = parentDomId;
mapperEntry[currentMapper.beanName]['rowIndex'] = editParm.rowindex;
}
}
originalOnBeforeEdit.call(this, editParm, '11');
debugger;
}
const toolbar = options.toolbar;
if(toolbar) {
......@@ -266,9 +285,7 @@ function listenerContent(event) {
if(!beanMapping) {
console.error("The configuration was not found in the 'dataMapping' : '"+property+"'")
}
let newData = window.dataSet.newData;
let control = getControlType(beanMapping);
// Grid 时执行此逻辑
if(control === 'grid') {
let inputIds = editId.split('_');
......@@ -276,8 +293,10 @@ function listenerContent(event) {
tryForEach(Object.entries(beanMapping), mapperEntry => {
let mapperVal = mapperEntry[1], mapperKey = mapperEntry[0];
if(mapperVal.rowIndex === inputIds[2] * 1) {
newData[mapperVal.beanName].compares[mapperKey][event.target.getAttribute('name')] = event.target.value;
window.dataSet.newData[mapperVal.beanName].compares[mapperKey][event.target.getAttribute('name')] = event.target.value;
console.log('Input value changed:', event.target.value);
} else {
console.error('当前输入框 '+ event.target.id+ '无法与数据行'+ mapperKey + ':' + mapperVal.rowIndex + '匹配!');
}
})
return;
......@@ -288,7 +307,7 @@ function listenerContent(event) {
tryForEach(mappings, (entry) => {
let beanName = entry[0];
let property = entry[1];
newData[beanName][property] = event.target.value;
window.dataSet.newData[beanName][property] = event.target.value;
console.log('Input value changed:', event.target.value);
})
}
......@@ -297,7 +316,7 @@ function listenerContent(event) {
function getControlType(beanMapping) {
let control;
// 这里根据 grid 与 form 的 mapper 数据结构差异判定。 需要优化
if(Object.entries(beanMapping)[0][1]['beanName']) {
if(Object.entries(beanMapping)[0][1]['listeningKey']) {
control = 'grid';
} else {
control = 'form';
......
......@@ -2,12 +2,22 @@ $(document).ready(function() {
loadDataTest();
initializeUI();
initializeToobarContainer();
$('#pageTab').tab();
initializeTab();
// initializateSelectC();
// runObserver();
});
function initializeTab() {
$('#pageTab').tab({
onClick:function(item){
var _id=item.data('id');
var gm=UICtrl.getGridManager('#'+_id);
UICtrl.onGridResize(gm);
}
});
}
function initializateSelectC() {
$('#productId').searchbox({
type: "product",
......@@ -25,6 +35,8 @@ function initializeUI() {
allowRightCollapse: false,
allowRightResize: false
});
var gm=UICtrl.getGridManager("#layout");
UICtrl.onGridResize(gm);
}
function deleteHandler(){
......@@ -72,7 +84,6 @@ function loadDataTest() {
var showData = mapping(dataMapping, data.rawData);
$('#submitForm').formSet(showData);
var fronData = {};
debugger;
if(window.dataSet.isInsert) {
data.rawData = {};
data.rawData.fronColors = {};
......@@ -82,6 +93,7 @@ function loadDataTest() {
faceGrid("#fronColorsGrid", data.rawData.fronColors);
faceGrid("#backColorsGrid", data.rawData.backColors);
processedGrid('#processedGrid', data.rawData.processed);
productLossGrid('#productLossGrid', data.rawData.productLoss);
inputEventListener();
});
}
......@@ -106,10 +118,13 @@ var dataMapping = {
],
ProductTechnology: [
"beerPlateNo", "goldPlateNo" , "dieCutPlateNo", "copperpResinLateNo", "netPlateNo",
"productTechnologyRequire", "packageStyle", "packageStyle", "physicalTest"
"productTechnologyRequire", "packageStyle", "packageStyle", "physicalTest", "chemistryTest"
, "productMaterial"
, "copperpNo", "colorNoCard", "plateNo", "plasticBagStructure"
],
ProductPublishedConf: [
"modulus" , "columnNum", "rowNum"
"modulus" , "columnNum", "rowNum", "contactNum", "columnDoubleBlade", "rowDoubleBlade"
, "dispatchMultiple", "sheetLength", "sheetWidth", "productSheetConf"
],
fronColors: {
id: "productFaceColorId",
......@@ -122,6 +137,10 @@ var dataMapping = {
processed: {
id: "productTechnologyId",
columns: [ "productionSequence", "processName", "isScheduleProcess", "isFinishedProcess", "processRemark", "finishedTime", "signed" ]
},
productLoss: {
id: "productLossId",
columns: [ "productId", "customerName", "productLossMax", "productLossRate", "productLossRedundance", "productLossRemark" ]
}
}
......@@ -153,7 +172,6 @@ function faceGrid(elId, data) {
width: "100%",
height: 150,
onBeforeEdit : function(editParm, gg) {
debugger;
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
......@@ -162,16 +180,16 @@ function faceGrid(elId, data) {
}
function processedGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(){
},
updateHandler: function(){
updateHandler();
},
deleteHandler: () => {
gridManager.deleteSelectedRow();
},
});
// var toolbarOptions = UICtrl.getDefaultToolbarOptions({
// addHandler: function(){
// },
// updateHandler: function(){
// updateHandler();
// },
// deleteHandler: () => {
// gridManager.deleteSelectedRow();
// },
// });
var gridManager = listeningGrid(elId, {
columns: [
{ display: "生成顺序", name: "productionSequence", width: 140, minWidth: 60, type: "string", align: "left"},
......@@ -182,13 +200,13 @@ function processedGrid(elId, data) {
{ display: "完成时间", name: "finishedTime", width: 120, minWidth: 60, type: "string", align: "left" },
{ display: "签字", name: "signed", width: 120, minWidth: 60, type: "string", align: "left" },
],
toolbar: toolbarOptions,
// toolbar: toolbarOptions,
dataType: "local",
data: data, // data 数据结构 data: ("Rows": [ {}, {} ])
enabledEdit: true,
checkbox: true,
usePager: false,
width: "100%",
width: "98%",
height: 150,
onAfterEdit: function(editParm) {
// 后备方案: 表格遍历完成时
......@@ -202,6 +220,39 @@ function processedGrid(elId, data) {
});
}
function productLossGrid(elId, data) {
var toolbarOptions = UICtrl.getDefaultToolbarOptions({
addHandler: function(rawData){
},
deleteHandler: () => {
gridManager.deleteSelectedRow();
},
});
var gridManager = listeningGrid(elId, {
columns: [
{ display: "客户名称", name: "customerName", width: 140, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true }},
{ display: "产品最大loss数量", name: "productLossMax", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } },
{ display: "loss比率", name: "productLossRate", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } },
{ display: "备注信息", name: "productLossRedundance", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } },
{ display: "产品最大loss数量", name: "productLossRemark", width: 120, minWidth: 60, type: "string", align: "left", editor: { type: 'text', required: true } },
],
toolbar: toolbarOptions,
dataType: "local",
data: data, // data 数据结构 data: ("Rows": [ {}, {} ])
enabledEdit: true,
checkbox: true,
usePager: false,
width: "98%",
height: 500,
onBeforeEdit : function(editParm, gg) {
debugger;
console.log('original run onBeforeEdit()');
},
onDblClickRow : function(data, rowindex, rowobj) {
}
});
}
// if(!isExist(rawData, entity[0])) {
// throw {};
......
......@@ -43,6 +43,7 @@
/*background: none repeat scroll 0 0 #fff;*/
}
.panel-footerX > div { margin: 2px; }
.ui-layout-content { height: 319px; }
</style>
</head>
......@@ -121,49 +122,59 @@
<x:inputC name="modulus" label="模数" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="columnNum" label="列数" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="rowNum" label="行数" labelCol="1" fieldCol="1" maxLength="64" />
<div id="layout" style="height: 280px; display: contents;">
<div position="left" title="正面颜色" >
<div id="fronColorsGrid" style="margin: 2px; height: 280px;"></div>
</div>
<div position="right" title="反面颜色">
<div id="backColorsGrid" style="margin: 2px; height: 280px;"></div>
</div>
</div>
<x:inputC name="contactNum" label="搭版数" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="columnDoubleBlade" label="列双刀位" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="rowDoubleBlade" label="行双刀位" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="dispatchMultiple" label="派工倍数" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="sheetLength" label="印张长度" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="sheetWidth" label="印张宽度" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="productSheetConf" label="产品印张设置" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="beerPlateNo" required="false" label="啤版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="goldPlateNo" required="false" label="烫金版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="dieCutPlateNo" required="false" label="模切版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="copperpResinLateNo" required="false" label="铜版及树脂版编号" labelCol="1" fieldCol="1" maxLength="64" />
<x:inputC name="netPlateNo" required="false" label="网版编号" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="netPlateNo" required="false" label="网版编号" labelCol="1" fieldCol="3" maxLength="64" />
<x:inputC name="productProperty" required="false" label="产品性质" labelCol="1" fieldCol="3" maxLength="64" />
<x:inputC name="productTechnologyName" required="false" label="制程工艺" labelCol="2" fieldCol="7"
maxLength="64" />
<x:inputC name="productProperty" required="false" label="产品性质" labelCol="1" fieldCol="2" maxLength="64" />
<div position="center" title="产品工序">
<div id="processedGrid" style="margin: 2px;"></div>
</div>
<x:inputC name="productTechnologyRequire" required="false" label="工艺要求" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="packageStyle" required="false" label="包装方式" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="packageStyle" required="false" label="包装方式" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="physicalTest" required="false" label="物性测试" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="productTechnologyRequire" label="工艺要求" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="packageStyle" label="包装方式" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="physicalTest" label="物性测试" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="chemistryTest" label="化性测试" labelCol="1" fieldCol="2" maxLength="64" />
<x:title title="产品材质" name="group" hideTable="#info" />
<x:inputC name="productMaterial" label="产品材质" labelCol="1" fieldCol="11" maxLength="64" />
<x:inputC name="copperpNo" label="铜版编号" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="colorNoCard" label="色号卡" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="plateNo" label="模具编号" labelCol="1" fieldCol="2" maxLength="64" />
<x:inputC name="plasticBagStructure" label="塑胶袋结构" labelCol="1" fieldCol="2" maxLength="64" />
<div id="layout" style="height: 360px; display: contents;">
<div position="left" title="正面颜色" >
<div id="fronColorsGrid" style="margin: 2px; height: 280px;"></div>
</div>
<div position="right" title="反面颜色">
<div id="backColorsGrid" style="margin: 2px; height: 280px;"></div>
</div>
</div>
<x:title title="产品材质" name="group" hideTable="#info" />
</div>
<div class="layout" id='lossFormDiv'>
<div id="productLossGrid" style="margin: 2px; height: 500px;"></div>
</div>
<div class="layout" id='materialListDiv'>
</div>
</div>
</div>
</form>
<div id="toolBarCenter" class="panel-footerX" >
......
......@@ -101,11 +101,11 @@ public class ProductApplicationImpl implements ProductApplication {
entitys.add(productDetail);
entitys.add(productTechnology == null ? new ProductTechnology() : productTechnology);
entitys.add(product);
entitys.add(loss);
entitys.add(material);
Map<String, Object> assemble = assembleResultOfForm(entitys);
resultMap.put("rawData", assemble);
assemble.put("productLoss", loss);
// --------------------------------- 版面查询 ---------------------------------
if(productDetail != null) {
......
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