|
@@ -3,10 +3,10 @@
|
|
|
*/
|
|
|
|
|
|
let gljSelOprObj = {
|
|
|
+ distTypeTree: null,
|
|
|
parentNodeIds: {},
|
|
|
treeObj:null,
|
|
|
rootNode: null,//分类树根节点
|
|
|
- radiosSelected: null,//allGljs, stdGljs, complementaryGljs
|
|
|
workBook: null,
|
|
|
selectedList: [],//选中的工料机
|
|
|
setting: {
|
|
@@ -39,7 +39,7 @@ let gljSelOprObj = {
|
|
|
delete glj.ID;
|
|
|
}
|
|
|
},
|
|
|
- getSelGljItems: function(gljData) {
|
|
|
+ /* getSelGljItems: function(gljData) {
|
|
|
this.stdGljList = gljData.stdGljs;
|
|
|
//兼容多单价,计算补充定额价格时,套多单价人材机的时候,默认取第一个价格
|
|
|
for(let sGlj of this.stdGljList){
|
|
@@ -61,7 +61,7 @@ let gljSelOprObj = {
|
|
|
glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
+ }, */
|
|
|
initClassTree: function (type, treeData) {
|
|
|
let me = this;
|
|
|
if (me.treeObj) {
|
|
@@ -81,11 +81,11 @@ let gljSelOprObj = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- getGljClassTree: function (mixedTreeData) {
|
|
|
+ /* 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);
|
|
@@ -96,7 +96,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;
|
|
@@ -162,7 +219,7 @@ let gljSelOprObj = {
|
|
|
}
|
|
|
},
|
|
|
//初始默认radio
|
|
|
- initRadio: function () {
|
|
|
+ /* initRadio: function () {
|
|
|
let me = gljSelOprObj;
|
|
|
$('#gljSearchKeyword').val('');//恢复搜索文本
|
|
|
me.selectedList = [].concat(rationGLJOprObj.cache['_GLJ_' + rationGLJOprObj.currentRationItem.ID]);
|
|
@@ -179,23 +236,17 @@ let gljSelOprObj = {
|
|
|
//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() != ''){
|
|
@@ -204,10 +255,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]);
|
|
@@ -220,7 +270,7 @@ let gljSelOprObj = {
|
|
|
}
|
|
|
},
|
|
|
//监听radios选择事件
|
|
|
- radiosChange: function () {
|
|
|
+ /* radiosChange: function () {
|
|
|
let me = gljSelOprObj;
|
|
|
$('.glj-radio').change(function () {
|
|
|
if($(this).val() === 'stdGljs') {
|
|
@@ -230,7 +280,7 @@ let gljSelOprObj = {
|
|
|
}
|
|
|
me.filterDatasAndShow();
|
|
|
});
|
|
|
- },
|
|
|
+ }, */
|
|
|
|
|
|
getParentCache: function (nodes) {
|
|
|
let me = gljSelOprObj, rst = [];
|
|
@@ -338,15 +388,13 @@ let gljSelTreeOprObj = {
|
|
|
};
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
- $('#gljSearchKeyword').change(function () {
|
|
|
- gljSelOprObj.filterDatasAndShow();
|
|
|
- });
|
|
|
- $('#gljSearchKeyword').bind('keypress', function (e) {
|
|
|
- if(e.keyCode === 13){
|
|
|
- $(this).blur();
|
|
|
- return false;
|
|
|
- }
|
|
|
+ $('#glj-lib-select').change(function () {
|
|
|
+ const gljLibId = $(this).val();
|
|
|
+ gljSelOprObj.initView(gljLibId, false);
|
|
|
});
|
|
|
+ $('#gljSearchKeyword').on('keyup', _.debounce(function () {
|
|
|
+ gljSelOprObj.filterDatasAndShow();
|
|
|
+ }, 300));
|
|
|
$('#selGlj').on('shown.bs.modal', function () {
|
|
|
if (gljSelOprObj.workBook) {
|
|
|
gljSelOprObj.workBook.refresh();
|