|
@@ -29,7 +29,7 @@ var gljContextMenu = {
|
|
|
return true;
|
|
|
},
|
|
|
callback: function () {
|
|
|
- getGLJData('replace');
|
|
|
+ getGLJData('replace', null, true, null);
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
return subSpread.getActiveSheet().name()=='ration_glj';
|
|
@@ -56,7 +56,7 @@ var gljContextMenu = {
|
|
|
return false;
|
|
|
},
|
|
|
callback:function () {
|
|
|
- getGLJData('add');
|
|
|
+ getGLJData('add', null, true, null);
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
return subSpread.getActiveSheet().name()=='ration_glj';
|
|
@@ -108,7 +108,7 @@ var gljContextMenu = {
|
|
|
return true;
|
|
|
},
|
|
|
callback: function () {
|
|
|
- getGLJData('m_replace');
|
|
|
+ getGLJData('m_replace', null, true, null);
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
return subSpread.getActiveSheet().name()=='ration_glj';
|
|
@@ -145,7 +145,7 @@ var gljContextMenu = {
|
|
|
projectGljObject.selectedProjectGLJ = t;
|
|
|
projectGljObject.subList = t.subList;
|
|
|
}
|
|
|
- getGLJData('addMix');
|
|
|
+ getGLJData('addMix', null, true, null);
|
|
|
},
|
|
|
visible: function(key, opt){
|
|
|
return subSpread.getActiveSheet().name()=='ration_glj';
|
|
@@ -432,10 +432,64 @@ var gljContextMenu = {
|
|
|
}
|
|
|
//controller.setTreeSelected(controller.tree.items[target.row]);
|
|
|
return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
+ initGLJSelectView: function () {
|
|
|
+ if (gljOprObj.gljLibSpresd == undefined) {
|
|
|
+ gljOprObj.gljLibSpresd = sheetCommonObj.buildSheet($('#gljLibSheet')[0], gljOprObj.gljLibSheetSetting, gljOprObj.stdGLJ.length + gljOprObj.complementaryGLJs.length);
|
|
|
+ sheetCommonObj.spreadDefaultStyle(gljOprObj.gljLibSpresd);
|
|
|
+ gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked, gljOprObj.onButtonClick);
|
|
|
+ gljOprObj.gljLibSheet = gljOprObj.gljLibSpresd.getSheet(0);
|
|
|
+ gljOprObj.gljLibSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, gljOprObj.onSelectionChanged);
|
|
|
+ gljOprObj.gljLibSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, _.debounce(gljOprObj.onTopRowChanged, 100));
|
|
|
+ gljOprObj.gljLibSheet.setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
+ gljOprObj.gljLibSheet.options.isProtected = true;
|
|
|
+ gljOprObj.gljLibSheet.name('glj_lib');
|
|
|
+ sheetCommonObj.setSheetBySetting(gljOprObj.gljLibSheet, gljOprObj.gljLibSheetSetting);
|
|
|
+ }
|
|
|
+ let gljClass = 0,
|
|
|
+ selected,
|
|
|
+ connect_key;
|
|
|
+ const actionType = $('#actionType').val();
|
|
|
+ const addActions = ['add', 'insert', 'addMix','unitPriceAddMix'];
|
|
|
+ const replaceActions = ['m_replace', 'replace'];
|
|
|
+ if (addActions.includes(actionType)) {//插入,添加,添加组成物(项目人材机页面)
|
|
|
+ gljOprObj.GLJSelection = [];
|
|
|
+ } else if(replaceActions.includes(actionType)){//替换、批量替换
|
|
|
+ selected = gljOprObj.sheetData[gljContextMenu.selectedRow];
|
|
|
+ connect_key = gljOprObj.getIndex(selected, gljKeyArray);
|
|
|
+ gljOprObj.GLJSelection = [connect_key];
|
|
|
+ // 找到定位的分类树
|
|
|
+ const locatedItem = gljOprObj.AllRecode.find(item => gljOprObj.getIndex(item, gljLibKeyArray) === connect_key);
|
|
|
+ if (locatedItem) {
|
|
|
+ gljClass = locatedItem.gljClass;
|
|
|
+ locatedItem.select = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //替换,焦点定位至当前选中人材机
|
|
|
+ if (replaceActions.includes(actionType)) {
|
|
|
+ gljOprObj.locateZTree(gljClass);
|
|
|
+ sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
|
|
|
+ const index = gljOprObj.AllRecode.findIndex(item => gljOprObj.getIndex(item, gljLibKeyArray) === connect_key);
|
|
|
+ gljOprObj.gljLibSheet.showRow(index, GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ gljOprObj.gljLibSheet.setActiveCell(index, 0);
|
|
|
+ gljOprObj.initSelection({row: index});
|
|
|
+ gljOprObj.gljLibSpresd.focus(true);
|
|
|
+ } else if (actionType === 'add' || actionType === 'addMix'|| actionType === 'unitPriceAddMix') {
|
|
|
+ gljOprObj.locateZTree(null);
|
|
|
+ sheetCommonObj.appendData(gljOprObj.gljLibSheet, 0, 0, gljOprObj.gljLibSheetSetting, gljOprObj.AllRecode);
|
|
|
+ gljOprObj.gljLibSheet.showRow(0, GC.Spread.Sheets.VerticalPosition.top);
|
|
|
+ gljOprObj.gljLibSheet.setActiveCell(0, 0);
|
|
|
+ gljOprObj.initSelection({row: 0});
|
|
|
+ } else {
|
|
|
+ gljOprObj.showLibGLJSheetData();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function getGLJData(actionType,getLibFunc) {
|
|
|
+function getGLJData(actionType,getLibFunc, initLibs, gljLibID) {
|
|
|
+ if (actionType === 'change') {
|
|
|
+ actionType = $('#actionType').val();
|
|
|
+ }
|
|
|
$('#actionType').val(actionType);
|
|
|
// 清除选中人材机缓存数据
|
|
|
gljOprObj.GLJSelection = [];
|
|
@@ -448,28 +502,40 @@ function getGLJData(actionType,getLibFunc) {
|
|
|
}
|
|
|
const init = true;
|
|
|
const reset = true;
|
|
|
- const condition = gljOprObj.getPagingCondition(init, reset, location, 0);
|
|
|
- console.time('getGLJData');
|
|
|
+ const condition = gljOprObj.getPagingCondition(init, reset, location, 0, initLibs, gljLibID);
|
|
|
if(!getLibFunc)getLibFunc = projectObj.project.ration_glj.getGLJDataPaging;
|
|
|
- getLibFunc(condition, function (result) {
|
|
|
- gljOprObj.initClassTree('std', gljOprObj.treeData.std);
|
|
|
- $('#modalCon').width($(window).width()*0.5);
|
|
|
- $("input[name='glj']").get(0).checked=true;
|
|
|
- $.bootstrapLoading.end();
|
|
|
- if(actionType == "m_replace"){
|
|
|
- $('#glj_selected_conf').hide();
|
|
|
- $('#replace_next_btn').show();
|
|
|
+ getLibFunc(condition, function (gljData, result) {
|
|
|
+ if (gljOprObj.treeData.std.length) {
|
|
|
+ gljOprObj.initClassTree(gljOprObj.treeData.std);
|
|
|
+ } else if (gljOprObj.treeData.comple.length) {
|
|
|
+ gljOprObj.initClassTree(gljOprObj.treeData.comple);
|
|
|
+ }
|
|
|
+ if (initLibs) {
|
|
|
+ initLibOptions(result.libData);
|
|
|
+ $('#modalCon').width($(window).width()*0.5);
|
|
|
+ if(actionType == "m_replace"){
|
|
|
+ $('#glj_selected_conf').hide();
|
|
|
+ $('#replace_next_btn').show();
|
|
|
+ } else {
|
|
|
+ $('#glj_selected_conf').show();
|
|
|
+ $('#replace_next_btn').hide();
|
|
|
+ }
|
|
|
+ $("#glj_tree_div").modal({show:true});
|
|
|
+ setTimeout(function(){
|
|
|
+ gljOprObj.gljLibSpresd ? gljOprObj.gljLibSpresd.refresh() : '';
|
|
|
+ }, 200);
|
|
|
} else {
|
|
|
- $('#glj_selected_conf').show();
|
|
|
- $('#replace_next_btn').hide();
|
|
|
+ gljContextMenu.initGLJSelectView();
|
|
|
}
|
|
|
- $("#glj_tree_div").modal({show:true});
|
|
|
- setTimeout(function(){
|
|
|
- gljOprObj.gljLibSpresd ? gljOprObj.gljLibSpresd.refresh() : '';
|
|
|
- }, 200);
|
|
|
+ $.bootstrapLoading.end();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function initLibOptions(libData) {
|
|
|
+ const html = libData.reduce((acc, lib) => acc += `<option ${lib.isDefault ? 'selected="selected"' : ''} value="${lib.gljLibId}">${lib.name}</option>`, '');
|
|
|
+ $('#glj-lib-select').html(html);
|
|
|
+}
|
|
|
+
|
|
|
function showGLJClassTree(record) {
|
|
|
let engineerID = projectObj.project.projectInfo.property.engineering_id;
|
|
|
CommonAjax.post('/rationGlj/getGLJClass/'+engineerID,record, function (data) {
|