| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 | 
							- /**
 
-  * Created by Zhong on 2017/8/25.
 
-  */
 
- /*
 
-    弹出组成物窗口 组成物表
 
-  * */
 
- let componentOprObj = {
 
-     treeObj: null,
 
-     rootNode: null,//分类树根节点
 
-     parentNodeIds: {},
 
-     radiosSelected: null,//allGljs, stdGljs, complementaryGljs
 
-     workBook: null,
 
-     selectedList: [],//选中的组成物
 
-     setting: {
 
-         owner: "components",
 
-         header: [
 
-             { headerName: "选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center" },
 
-             { headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center" },
 
-             { headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String", hAlign: "left", vAlign: "center" },
 
-             { headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String", hAlign: "center", vAlign: "center" },
 
-             { headerName: "单位", headerWidth: 80, dataCode: "unit", dataType: "String", hAlign: "center", vAlign: "center" },
 
-             { headerName: "单价", headerWidth: 80, dataCode: "basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center" },
 
-             { headerName: "类型", headerWidth: 80, dataCode: "gljType", dataType: "String", hAlign: "center", vAlign: "center" }
 
-         ]
 
-     },
 
-     //生成列头(多单价)
 
-     initHeaders: function (priceProperties) {
 
-         let headers = [
 
-             { headerName: "选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center" },
 
-             { headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center" },
 
-             { headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String", hAlign: "left", vAlign: "center" },
 
-             { headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String", hAlign: "center", vAlign: "center" },
 
-             { headerName: "单位", headerWidth: 80, dataCode: "unit", dataType: "String", hAlign: "center", vAlign: "center" },
 
-             { headerName: "类型", headerWidth: 80, dataCode: "gljType", dataType: "String", hAlign: "center", vAlign: "center" }
 
-         ];
 
-         //生成单价列
 
-         if (!priceProperties || priceProperties.length === 0) {
 
-             headers.push({ headerName: "定额价", headerWidth: 80, dataCode: "basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center" });
 
-         }
 
-         else {
 
-             for (let priceProp of priceProperties) {
 
-                 let colData = {
 
-                     headerName: priceProp.price.dataName,
 
-                     headerWidth: 90,
 
-                     dataCode: priceProp.price.dataCode,
 
-                     dataType: 'Number',
 
-                     formatter: '0.00',
 
-                     hAlign: 'right',
 
-                     vAlign: 'center'
 
-                 };
 
-                 headers.push(colData);
 
-             }
 
-         }
 
-         let tailHeaders = [
 
-         ];
 
-         headers = headers.concat(tailHeaders);
 
-         return headers;
 
-     },
 
-     buildSheet: function (container) {
 
-         let me = componentOprObj;
 
-         //生成人材机组成物表格列头
 
-         me.setting.header = me.initHeaders(priceProperties);
 
-         //生成人材机组成物列映射
 
-         sheetCommonObj.initColMapping(me, me.setting.header);
 
-         repositoryGljObj.initPriceCols.call(me, priceProperties, me.colMapping);
 
-         me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
 
-         if (priceProperties && priceProperties.length > 0) {
 
-             me.workBook.getSheet(0).frozenColumnCount(6);
 
-         }
 
-         sheetCommonObj.spreadDefaultStyle(me.workBook);
 
-         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
 
-         me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
 
-         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
 
-         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
 
-         me.workBook.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClicked);//复选框点击事件
 
-         me.componentsBtnOpr($('#componentsConf'));
 
-         me.radiosChange();
 
-     },
 
-     onClipboardPasting: function (sender, args) {
 
-         args.cancel = true;
 
-     },
 
-     onCellEditStart: function (sender, args) {
 
-         args.cancel = true;
 
-     },
 
-     onButtonClicked: function (sender, args) {
 
-         let me = componentOprObj, re = repositoryGljObj;
 
-         let val = args.sheet.getValue(args.row, args.col);
 
-         let thisComponent = me.currentCache[args.row];
 
-         thisComponent.isChecked = val;
 
-         if (args.sheet.isEditing()) {
 
-             args.sheet.endEdit(true);
 
-         }
 
-         else {
 
-             //维护选中组成物列表
 
-             if (val === true) {
 
-                 let isExist = false;
 
-                 for (let i = 0, len = me.selectedList.length; i < len; i++) {
 
-                     if (me.selectedList[i].ID === thisComponent.ID) {
 
-                         isExist = true;
 
-                         break;
 
-                     }
 
-                 }
 
-                 if (!isExist) {
 
-                     me.selectedList.push(thisComponent);
 
-                 }
 
-             }
 
-             else if (val === false) {
 
-                 for (let i = 0, len = me.selectedList.length; i < len; i++) {
 
-                     if (me.selectedList[i].ID === thisComponent.ID) {
 
-                         me.selectedList.splice(i, 1);
 
-                         break;
 
-                     }
 
-                 }
 
-             }
 
-         }
 
-     },
 
-     setShowGljList: function (gljList, clearChecked) {
 
-         let that = repositoryGljObj, me = componentOprObj;
 
-         for (let i = 0; i < gljList.length; i++) {
 
-             if (machineAllowComponent.includes(that.currentGlj.gljType) && machineComponent.includes(gljList[i].gljType) ||
 
-                 materialAllowComponent.includes(that.currentGlj.gljType) && gljList[i].gljType === 201 ||
 
-                 that.currentGlj.gljType === 4 && gljList[i].gljType === 4 && (!gljList[i].component || gljList[i].component.length === 0) && gljList[i].ID !== that.currentGlj.ID) {
 
-                 //去除与已添加的组成物重复的条目
 
-                 let isExist = false;
 
-                 for (let j = 0; j < that.currentComponent.length; j++) {
 
-                     if (that.currentComponent[j].ID === gljList[i].ID) {
 
-                         isExist = true;
 
-                         break;
 
-                     }
 
-                 }
 
-                 if (!isExist) {
 
-                     gljList[i].isChecked = false;
 
-                 }
 
-                 else {
 
-                     gljList[i].isChecked = true;
 
-                 }
 
-                 me.showGljList.push(gljList[i]);
 
-             }
 
-         }
 
-     },
 
-     //初始化分类树
 
-     //@param {String}type(标准或补充) {Array}treeData(树数据)
 
-     initClassTree: function (type, treeData) {
 
-         let me = this;
 
-         if (me.treeObj) {
 
-             me.treeObj.destroy();
 
-             me.parentNodeIds = {};
 
-         }
 
-         zTreeHelper.createTree(treeData, componentSetting, "componentTree", componentOprObj);
 
-         let rootNode = componentOprObj.treeObj.getNodes()[0];
 
-         if (rootNode && rootNode.isParent && rootNode.isFirstNode) {
 
-             componentOprObj.rootNode = rootNode;
 
-         }
 
-         if (me.rootNode) {
 
-             me.treeObj.selectNode(me.rootNode);
 
-             componentTypeTreeOprObj.onClick(null, 'componentTree', me.rootNode);
 
-         }
 
-     },
 
-     //初始默认radio
 
-     initRadio: function () {
 
-         let that = repositoryGljObj, me = componentOprObj;
 
-         $('#gljSearchKeyword').val('');//恢复搜索文本
 
-         //初始化组成物列表
 
-         me.selectedList = [].concat(that.currentComponent);
 
-         //默认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(that.stdGljList, true);
 
-             //me.setShowGljList(that.complementaryGljList, true);
 
-             that.sortGlj(me.showGljList);
 
-         }
 
-     },
 
-     filterDatasAndShow: function () {
 
-         let me = componentOprObj, re = repositoryGljObj;
 
-         let val = $("input[name='glj']:checked").val();
 
-         me.radiosSelected = val;
 
-         //选择改变,数据重新筛选显示
 
-         me.showGljList = [];
 
-         if (me.radiosSelected === 'allGljs') {
 
-             me.setShowGljList(re.stdGljList);
 
-             me.setShowGljList(re.complementaryGljList);
 
-         }
 
-         else if (me.radiosSelected === 'stdGljs') {
 
-             me.setShowGljList(re.stdGljList);
 
-         }
 
-         else if (me.radiosSelected === 'complementaryGljs') {
 
-             me.setShowGljList(re.complementaryGljList);
 
-         }
 
-         //搜索匹配
 
-         let searchStr = $('#gljSearchKeyword').val();
 
-         if (searchStr && searchStr.trim() != '') {
 
-             let reg = new RegExp(searchStr);
 
-             me.showGljList = _.filter(me.showGljList, function (data) {
 
-                 return reg.test(data.code) || reg.test(data.name);
 
-             });
 
-         }
 
-         re.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]);
 
-             }
 
-             else {
 
-                 me.currentCache = [];
 
-             }
 
-         } else {
 
-             me.currentCache = me.getCache();
 
-         }
 
-     },
 
-     //监听radios选择事件
 
-     radiosChange: function () {
 
-         let me = componentOprObj, gc = gljClassTreeObj;
 
-         $('.glj-radio').change(function () {
 
-             me.filterDatasAndShow();
 
-             if ($(this).val() === 'stdGljs') {
 
-                 me.initClassTree('std', gc.treeData.std);
 
-             } else {
 
-                 me.initClassTree('comple', gc.treeData.comple);
 
-             }
 
-             //me.filterDatasAndShow();
 
-         });
 
-     },
 
-     getParentCache: function (nodes) {
 
-         let me = componentOprObj, rst = [];
 
-         for (let i = 0; i < me.showGljList.length; i++) {
 
-             if (nodes.indexOf(me.showGljList[i].gljClass) !== -1) {
 
-                 rst.push(me.showGljList[i]);
 
-             }
 
-         }
 
-         rst.sort(function (a, b) {
 
-             let rst = 0;
 
-             if (a.code > b.code) rst = 1;
 
-             else if (a.code < b.code) rst = -1;
 
-             return rst;
 
-         });
 
-         return rst;
 
-     },
 
-     getCache: function () {
 
-         let me = componentOprObj, rst = [];
 
-         for (let i = 0; i < me.showGljList.length; i++) {
 
-             if (me.showGljList[i].gljClass == me.gljCurTypeId) {
 
-                 rst.push(me.showGljList[i]);
 
-             }
 
-         }
 
-         return rst;
 
-     },
 
-     showGljItems: function (data, type) {
 
-         let me = componentOprObj, re = repositoryGljObj;
 
-         if (me.workBook) {
 
-             let cacheSection = [];
 
-             let pArr = me.parentNodeIds["_pNodeId_" + type];
 
-             for (let i = 0; i < data.length; i++) {
 
-                 if (pArr && pArr.indexOf(data[i].gljClass) >= 0) {
 
-                     cacheSection.push(data[i]);
 
-                 } else if (type == data[i].gljClass) {
 
-                     cacheSection.push(data[i]);
 
-                 }
 
-             }
 
-             sheetOpr.showData(me, me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
 
-             me.workBook.getSheet(0).setRowCount(cacheSection.length);
 
-             cacheSection = null;
 
-         }
 
-     },
 
-     //组成物窗口按钮操作
 
-     componentsBtnOpr: function (conf) {//确定、取消、关闭按钮
 
-         let me = componentOprObj, that = gljComponentOprObj, re = repositoryGljObj;
 
-         conf.click(function () {
 
-             //添加选择添加的组成物
 
-             let updateArr = [];
 
-             let newComponent = [];
 
-             //re.currentGlj.component = [];
 
-             for (let i = 0, len = me.selectedList.length; i < len; i++) {
 
-                 let isExist = false;
 
-                 for (let j = 0, jLen = re.currentGlj.component.length; j < jLen; j++) {
 
-                     if (me.selectedList[i].ID === re.currentGlj.component[j].ID) {
 
-                         let newComponentObj = { isStd: typeof me.selectedList[i].isStd !== 'undefined' ? me.selectedList[i].isStd : false, ID: me.selectedList[i].ID }
 
-                         that.copyConsumeAmt(newComponentObj, re.currentGlj.component[j]);
 
-                         newComponent.push(newComponentObj);
 
-                         /* newComponent.push({
 
-                             isStd: typeof me.selectedList[i].isStd !== 'undefined' ? me.selectedList[i].isStd : false
 
-                             , ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt
 
-                         }); */
 
-                         isExist = true;
 
-                         break;
 
-                     }
 
-                 }
 
-                 if (!isExist) {
 
-                     let newComponentObj = { isStd: typeof me.selectedList[i].isStd !== 'undefined' ? me.selectedList[i].isStd : false, ID: me.selectedList[i].ID };
 
-                     that.initConsumeAmt(newComponentObj);
 
-                     newComponent.push(newComponentObj);
 
-                 }
 
-                 //re.currentGlj.component.push({ID: me.selectedList[i].ID, consumeAmt: 0});
 
-             }
 
-             re.currentGlj.component = newComponent;
 
-             let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(re.currentGlj.component));
 
-             if (re.isGljPriceChange(re.currentGlj, gljBasePrc)) {
 
-                 re.setPrice(re.currentGlj, gljBasePrc);
 
-                 re.reshowGljBasePrc(re.currentGlj);
 
-                 //updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
 
-             }
 
-             updateArr.push(re.currentGlj);
 
-             that.updateComponent(updateArr);
 
-             $('#componentsCacnel').click();
 
-         });
 
-     }
 
- };
 
- let componentTypeTreeOprObj = {
 
-     onClick: function (event, treeId, treeNode) {
 
-         let me = componentOprObj, re = repositoryGljObj, that = gljComponentOprObj, gljTypeId = treeNode.ID;
 
-         if (me.gljCurTypeId !== treeNode.ID) {
 
-             me.gljCurTypeId = treeNode.ID;
 
-             if (me.parentNodeIds["_pNodeId_" + treeNode.ID]) {
 
-                 me.currentOprParent = 1;
 
-                 me.currentCache = me.getParentCache(me.parentNodeIds["_pNodeId_" + treeNode.ID]);
 
-             } else {
 
-                 me.currentCache = me.getCache();
 
-             }
 
-         }
 
-         me.showGljItems(me.showGljList, gljTypeId);
 
-     }
 
- }
 
- $(document).ready(function () {
 
-     $('#gljSearchKeyword').bind('keyup', function () {
 
-         componentOprObj.filterDatasAndShow();
 
-     });
 
-     /*$('#gljSearchKeyword').bind('keypress', function (e) {
 
-         if(e.keyCode === 13){
 
-             $(this).blur();
 
-             return false;
 
-         }
 
-     });*/
 
- });
 
 
  |