| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 | 
							- /**
 
-  * Standard Ration Lib
 
-  * Created by Mai on 2017/5/16.
 
-  */
 
- /*var rationChapterSpread, sectionRationsSpread;*/
 
- var rationLibObj = {
 
-     rationChapterSpread: null,
 
-     sectionRationsSpread: null,
 
-     rationChapterTreeController: null,
 
-     checkSpread: function () {
 
-         if (!this.rationChapterSpread) {
 
-             this.rationChapterSpread = SheetDataHelper.createNewSpread($('#stdRationChapter')[0]);
 
-         }
 
-         if (!this.sectionRationsSpread) {
 
-             this.sectionRationsSpread = SheetDataHelper.createNewSpread($('#stdSectionRations')[0]);
 
-             this.sectionRationsSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onRationSpreadCellDoubleClick);
 
-         }
 
-     },
 
-     refreshSpread: function () {
 
-         if (this.rationChapterSpread) {
 
-             this.rationChapterSpread.refresh();
 
-         }
 
-         if (this.sectionRationsSpread) {
 
-             this.sectionRationsSpread.refresh();
 
-         }
 
-     },
 
-     loadStdRationLibs: function () {
 
-         let select = $('#stdRationLibSelect');
 
-         select.empty();
 
-         let ration_lib = projectInfoObj.projectInfo.engineeringInfo.ration_lib;
 
-         ration_lib.forEach(function (data) {
 
-             select.append($('<option>').val(data.id).text(data.name));
 
-         });
 
-         if (select[0].options.length !== 0) {
 
-             rationLibObj.loadStdRation(select.val());
 
-         }
 
-     },
 
-     loadStdRation: function (rationLibID) {
 
-         var that = this;
 
-         var showRationChapterTree = function (datas) {
 
-             var rationChapterTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: false});
 
-             var rationChapterTreeController = TREE_SHEET_CONTROLLER.createNew(rationChapterTree, that.rationChapterSpread.getActiveSheet(), that.rationChapterTreeSetting);
 
-             rationChapterTree.loadDatas(datas);
 
-             rationChapterTreeController.showTreeData();
 
-             rationChapterTreeController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, function (node) {
 
-                 rationLibObj.loadSectionRations(node.getID());
 
-             });
 
-             if (rationChapterTree.firstNode()) {
 
-                 rationLibObj.loadSectionRations(rationChapterTree.firstNode().getID());
 
-             } else {
 
-                 rationLibObj.loadSectionRations();
 
-             };
 
-         };
 
-         CommonAjax.postRationLib('/rationRepository/api/getRationTree', {userId: userID, rationRepositoryId: rationLibID}, function (datas) {
 
-             showRationChapterTree(datas);
 
-         }, function () {
 
-             showRationChapterTree([]);
 
-         });
 
-     },
 
-     loadSectionRations: function (sectionID) {
 
-         var showDatas = function (datas, setting) {
 
-             SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
 
-             SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
 
-         };
 
-         if (sectionID) {
 
-             CommonAjax.postRationLib('/rationRepository/api/getRationItems', {userId: userID, sectionID: sectionID}, function (datas) {
 
-                 showDatas(datas, rationLibObj.sectionRationsSetting);
 
-             }, function () {
 
-                 showDatas([], rationLibObj.sectionRationsSetting);
 
-             });
 
-         } else {
 
-             showDatas([], rationLibObj.sectionRationsSetting);
 
-         }
 
-     },
 
-     onRationSpreadCellDoubleClick: function (sender, args) {
 
-         var select = $('#stdRationLibSelect'), rationCode = args.sheet.getText(args.row, 0);
 
-         if (rationCode !== '') {
 
-             CommonAjax.postRationLib('/rationRepository/api/getRationItem', {user_id: userID, rationLibId: select.val(), code: rationCode}, function (data) {
 
-                 ProjectController.addRation(projectObj.project, projectObj.mainController, data);
 
-             });
 
-         }
 
-     },
 
-     rationChapterTreeSetting: {
 
-         "emptyRows":0,
 
-         "headRows":1,
 
-         "headRowHeight":[30],
 
-         "defaultRowHeight": 21,
 
-         "treeCol": 0,
 
-         "cols":[{
 
-             "width":300,
 
-             "readOnly": true,
 
-             "head":{
 
-                 "titleNames":["名称"],
 
-                 "spanCols":[1],
 
-                 "spanRows":[1],
 
-                 "vAlign":[1],
 
-                 "hAlign":[1],
 
-                 "font":["Arial"]
 
-             },
 
-             "data":{
 
-                 "field":"name",
 
-                 "vAlign":1,
 
-                 "hAlign":0,
 
-                 "font":"Arial"
 
-             }
 
-         }]
 
-     },
 
-     sectionRationsSetting: {
 
-         "emptyRows":3,
 
-         "headRows":1,
 
-         "headRowHeight":[20],
 
-         "defaultRowHeight": 21,
 
-         "cols":[{
 
-             "width":100,
 
-             "readOnly": true,
 
-             "head":{
 
-                 "titleNames":["编码"],
 
-                 "spanCols":[1],
 
-                 "spanRows":[1],
 
-                 "vAlign":[1],
 
-                 "hAlign":[1],
 
-                 "font":["Arial"]
 
-             },
 
-             "data":{
 
-                 "field":"code",
 
-                 "vAlign":1,
 
-                 "hAlign":0,
 
-                 "font":"Arial"
 
-             }
 
-         }, {
 
-             "width":180,
 
-             "readOnly": true,
 
-             "head":{
 
-                 "titleNames":["名称"],
 
-                 "spanCols":[1],
 
-                 "spanRows":[1],
 
-                 "vAlign":[1],
 
-                 "hAlign":[1],
 
-                 "font":["Arial"]
 
-             },
 
-             "data":{
 
-                 "field":"name",
 
-                 "vAlign":1,
 
-                 "hAlign":0,
 
-                 "font":"Arial"
 
-             }
 
-         }, {
 
-             "width":50,
 
-             "readOnly":true,
 
-             "head":{
 
-                 "titleNames":["单位"],
 
-                 "spanCols":[1],
 
-                 "spanRows":[1],
 
-                 "vAlign":[1],
 
-                 "hAlign":[1],
 
-                 "font":["Arial"]
 
-             },
 
-             "data":{
 
-                 "field":"unit",
 
-                 "vAlign":1,
 
-                 "hAlign":1,
 
-                 "font":"Arial"
 
-             }
 
-         }, {
 
-             "width":80,
 
-             "readOnly":true,
 
-             "head":{
 
-                 "titleNames":["基价"],
 
-                 "spanCols":[1],
 
-                 "spanRows":[1],
 
-                 "vAlign":[1],
 
-                 "hAlign":[1],
 
-                 "font":["Arial"]
 
-             },
 
-             "data":{
 
-                 "field":"basePrice",
 
-                 "vAlign":1,
 
-                 "hAlign":2,
 
-                 "font":"Arial"
 
-             }
 
-         }]
 
-     }
 
- };
 
- $('#stdRationTab').bind('click', function () {
 
-     refreshSubSpread();//subSpread、jobSpread、itemSpread显示问题
 
-     var select = $('#stdRationLibSelect');
 
-     $(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() -  $(".tools-bar-height-d").height() - 202);
 
-     rationLibObj.refreshSpread();
 
-     rationLibObj.checkSpread();
 
-     if (select[0].options.length === 0) {
 
-         rationLibObj.loadStdRationLibs();
 
-     };
 
- });
 
- $('#stdRationLibSelect').change(function () {
 
-     var select = $(this);
 
-     if (this.children.length !== 0) {
 
-         rationLibObj.loadStdRation(select.val());
 
-     }
 
- });
 
- $('#rationSearch').click(function () {
 
-     var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
 
-     var getResultHtml = function (result) {
 
-         var html = [], i, serialNo;
 
-         html.push('<div class="d-flex justify-content-between">');
 
-         html.push('<span>搜索结果:');
 
-         html.push(result.length.toString());
 
-         html.push('</span>');
 
-         html.push('<a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0)"><i class="fa fa-remove" aria-hidden="true"></i></a>');
 
-         html.push('</div>');
 
-         html.push('<div class="w-100 main-data-side-search">');
 
-         html.push('</div>');
 
-         return html.join('');
 
-     };
 
-     var showResult = function (result) {
 
-         var resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
 
-         SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
 
-         SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet(), result);
 
-         resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
 
-     };
 
-     CommonAjax.postRationLib('/rationRepository/api/findRation', {'user_id': userID, 'rationLibId': rationLibID, 'keyword': keyword}, function (result) {
 
-         var resultObj = $('#rationSearchResult'), resultSpread = null;
 
-         resultObj.empty();
 
-         resultObj.append(getResultHtml(result));
 
-         $('a', resultObj).click(function () {
 
-             resultObj.hide();
 
-             $(".main-data-side-search", resultObj).height(0);
 
-         });
 
-         resultObj.show();
 
-         $(".main-data-side-search", resultObj).height($(window).height() - $(".header").height() - $(".toolsbar").height() - 64);
 
-         showResult(result);
 
-     });
 
- });
 
 
  |