|
|
@@ -3,10 +3,10 @@
|
|
|
*/
|
|
|
|
|
|
let gljSelOprObj = {
|
|
|
+ distTypeTree: null,
|
|
|
parentNodeIds: {},
|
|
|
treeObj:null,
|
|
|
rootNode: null,//分类树根节点
|
|
|
- radiosSelected: null,//allGljs, stdGljs, complementaryGljs
|
|
|
workBook: null,
|
|
|
selectedList: [],//选中的工料机
|
|
|
setting: {
|
|
|
@@ -39,23 +39,6 @@ let gljSelOprObj = {
|
|
|
delete glj.ID;
|
|
|
}
|
|
|
},
|
|
|
- getSelGljItems: function(gljData) {
|
|
|
- this.stdGljList = gljData.stdGljs;
|
|
|
- //兼容多单价,计算补充定额价格时,套多单价人材机的时候,默认取第一个价格
|
|
|
- for(let sGlj of this.stdGljList){
|
|
|
- if(sGlj.priceProperty && typeof sGlj.priceProperty.price1 !== 'undefined'){
|
|
|
- sGlj.basePrice = sGlj.priceProperty.price1;
|
|
|
- }
|
|
|
- }
|
|
|
- this.complementaryGljList = gljData.complementaryGljs;
|
|
|
- this.switchToGljId(this.stdGljList);
|
|
|
- this.switchToGljId(this.complementaryGljList);
|
|
|
- this.setProp('type', 'std', this.stdGljList);
|
|
|
- this.setProp('type', 'complementary', this.complementaryGljList);
|
|
|
- this.sortGlj(this.stdGljList);
|
|
|
- this.sortGlj(this.complementaryGljList);
|
|
|
- gljAdjOprObj.gljList = this.stdGljList.concat(this.complementaryGljList);
|
|
|
- },
|
|
|
initClassTree: function (type, treeData) {
|
|
|
let me = this;
|
|
|
if (me.treeObj) {
|
|
|
@@ -75,28 +58,6 @@ let gljSelOprObj = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- getGljClassTree: function (gljLibId, callback) {
|
|
|
- let me = this;
|
|
|
- let url = '/complementartGlj/api/getMixedTree';
|
|
|
- let postData = {gljLibId: gljLibId};
|
|
|
- let sucFunc = function (rstData) {
|
|
|
- me.treeData = rstData;
|
|
|
- me.initClassTree('std', me.treeData.std);
|
|
|
- gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
|
|
|
- if(callback){
|
|
|
- callback();
|
|
|
- }
|
|
|
- };
|
|
|
- let errFunc = function () {
|
|
|
-
|
|
|
- };
|
|
|
- CommonAjax.post(url, postData, sucFunc, errFunc);
|
|
|
- },
|
|
|
- getGljClassTree: function (mixedTreeData) {
|
|
|
- this.treeData = mixedTreeData;
|
|
|
- this.initClassTree('std', this.treeData.std);
|
|
|
- gljSelOprObj.buildSheet($('#gljSelSheet')[0]);
|
|
|
- },
|
|
|
buildSheet: function (container) {
|
|
|
let me = gljSelOprObj;
|
|
|
me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
@@ -107,7 +68,64 @@ let gljSelOprObj = {
|
|
|
me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
|
|
|
me.bindBtnOpr($('#gljSelY'));
|
|
|
- me.radiosChange();
|
|
|
+ },
|
|
|
+ setGLJItems: function(stdGLJs, complementaryGLJs) {
|
|
|
+ this.stdGljList = stdGLJs;
|
|
|
+ //兼容多单价,计算补充定额价格时,套多单价人材机的时候,默认取第一个价格
|
|
|
+ for(let sGlj of this.stdGljList){
|
|
|
+ if(sGlj.priceProperty && typeof sGlj.priceProperty.price1 !== 'undefined'){
|
|
|
+ sGlj.basePrice = sGlj.priceProperty.price1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.complementaryGljList = complementaryGLJs;
|
|
|
+ this.switchToGljId(this.stdGljList);
|
|
|
+ this.switchToGljId(this.complementaryGljList);
|
|
|
+ this.setProp('type', 'std', this.stdGljList);
|
|
|
+ this.setProp('type', 'complementary', this.complementaryGljList);
|
|
|
+ this.sortGlj(this.stdGljList);
|
|
|
+ this.sortGlj(this.complementaryGljList);
|
|
|
+ },
|
|
|
+ initLibOptions: function (libData) {
|
|
|
+ const html = libData.reduce((acc, lib) => acc += `<option ${lib.isDefault ? 'selected="selected"' : ''} value="${lib.gljLibId}">${lib.name}</option>`, '');
|
|
|
+ $('#glj-lib-select').html(html);
|
|
|
+ },
|
|
|
+ // 初始化选择页面
|
|
|
+ initView: async function (gljLibId, isInitial) {
|
|
|
+ try {
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ const { libData, treeData, distTypeTree, stdGLJ, complementaryGLJs } = await this.getViewData(gljLibId);
|
|
|
+ if (isInitial) {
|
|
|
+ this.initLibOptions(libData);
|
|
|
+ $('#gljSearchKeyword').val('');
|
|
|
+ setTimeout(() => $('#selGlj').modal('show'), 200);
|
|
|
+ }
|
|
|
+ if (!this.workBook) {
|
|
|
+ this.buildSheet($('#gljSelSheet')[0]);
|
|
|
+ }
|
|
|
+ this.distTypeTree = distTypeTree;
|
|
|
+ this.setGLJItems(stdGLJ, complementaryGLJs);
|
|
|
+ this.selectedList = [].concat(rationGLJOprObj.cache['_GLJ_' + rationGLJOprObj.currentRationItem.ID]);
|
|
|
+ this.showGljList = [];
|
|
|
+ this.setShowGljList(this.stdGljList, true);
|
|
|
+ if (treeData.std.length) {
|
|
|
+ this.initClassTree('std', treeData.std);
|
|
|
+ } else if (treeData.comple.length) {
|
|
|
+ this.initClassTree('comple', treeData.comple);
|
|
|
+ } else {
|
|
|
+ throw '没有有效的分类树。';
|
|
|
+ }
|
|
|
+ this.filterDatasAndShow();
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ alert(err);
|
|
|
+ } finally {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getViewData: async function (gljLibId) {
|
|
|
+ const url = `/rationGlj/getGLJData/${commonConstants.COMPILATION}/${gljLibId}/true`;
|
|
|
+ const data = await ajaxGet(url);
|
|
|
+ return data.datas;
|
|
|
},
|
|
|
onClipboardPasting: function (sender, args) {
|
|
|
args.cancel = true;
|
|
|
@@ -172,41 +190,16 @@ let gljSelOprObj = {
|
|
|
me.showGljList.push(gljList[i]);
|
|
|
}
|
|
|
},
|
|
|
- //初始默认radio
|
|
|
- initRadio: function () {
|
|
|
- let me = gljSelOprObj;
|
|
|
- $('#gljSearchKeyword').val('');//恢复搜索文本
|
|
|
- me.selectedList = [].concat(rationGLJOprObj.cache['_GLJ_' + rationGLJOprObj.currentRationItem.ID]);
|
|
|
- //默认radio所有工料机
|
|
|
- if(typeof $("input[name='glj']:checked")[0] !== 'undefined'){
|
|
|
- $("input[name='glj']:checked")[0].checked = false;
|
|
|
- }
|
|
|
- $("input[value = 'stdGljs']")[0].checked = true;
|
|
|
- me.radiosSelected = 'stdGljs';
|
|
|
- //初始为标准工料机
|
|
|
- me.showGljList = [];
|
|
|
- if(me.radiosSelected === 'stdGljs'){
|
|
|
- me.setShowGljList(me.stdGljList, true);
|
|
|
- //me.setShowGljList(me.complementaryGljList, true);
|
|
|
- me.sortGlj(me.showGljList);
|
|
|
- }
|
|
|
- },
|
|
|
filterDatasAndShow: function () {
|
|
|
+ const gljLib = $('#glj-lib-select').val();
|
|
|
let me = gljSelOprObj;
|
|
|
- let val = $("input[name='glj']:checked").val();
|
|
|
- me.radiosSelected = val;
|
|
|
//选择改变,数据重新筛选显示
|
|
|
me.showGljList = [];
|
|
|
- if(me.radiosSelected === 'allGljs'){
|
|
|
- me.setShowGljList(me.stdGljList);
|
|
|
+ if (gljLib === commonConstants.COMPLEMENTARY_LIB) {
|
|
|
me.setShowGljList(me.complementaryGljList);
|
|
|
- }
|
|
|
- else if(me.radiosSelected === 'stdGljs'){
|
|
|
+ } else {
|
|
|
me.setShowGljList(me.stdGljList);
|
|
|
}
|
|
|
- else if(me.radiosSelected === 'complementaryGljs'){
|
|
|
- me.setShowGljList(me.complementaryGljList);
|
|
|
- }
|
|
|
//搜索匹配
|
|
|
let searchStr = $('#gljSearchKeyword').val();
|
|
|
if(searchStr && searchStr.trim() != ''){
|
|
|
@@ -215,10 +208,9 @@ let gljSelOprObj = {
|
|
|
return reg.test(data.code) || reg.test(data.name);
|
|
|
});
|
|
|
}
|
|
|
- me.sortGlj(me.showGljList);
|
|
|
+ //me.sortGlj(me.showGljList);
|
|
|
//重新显示
|
|
|
me.showGljItems(me.showGljList, me.gljCurTypeId);
|
|
|
- //切换radio后更新cache
|
|
|
if (me.currentOprParent = 1) {
|
|
|
if(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
|
|
|
me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]);
|
|
|
@@ -230,19 +222,6 @@ let gljSelOprObj = {
|
|
|
me.currentCache = me.getCache();
|
|
|
}
|
|
|
},
|
|
|
- //监听radios选择事件
|
|
|
- radiosChange: function () {
|
|
|
- let me = gljSelOprObj;
|
|
|
- $('.glj-radio').change(function () {
|
|
|
- if($(this).val() === 'stdGljs') {
|
|
|
- me.initClassTree('std', me.treeData.std);
|
|
|
- } else {
|
|
|
- me.initClassTree('comple', me.treeData.comple);
|
|
|
- }
|
|
|
- me.filterDatasAndShow();
|
|
|
- });
|
|
|
- },
|
|
|
-
|
|
|
getParentCache: function (nodes) {
|
|
|
let me = gljSelOprObj, rst = [];
|
|
|
for(let i = 0; i < me.showGljList.length; i++){
|
|
|
@@ -349,6 +328,10 @@ let gljSelTreeOprObj = {
|
|
|
};
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
+ $('#glj-lib-select').change(function () {
|
|
|
+ const gljLibId = $(this).val();
|
|
|
+ gljSelOprObj.initView(gljLibId, false);
|
|
|
+ });
|
|
|
$('#gljSearchKeyword').change(function () {
|
|
|
gljSelOprObj.filterDatasAndShow();
|
|
|
});
|