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

2222

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