123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- /**
- * Created by Zhong on 2018/1/19.
- **/
- $("#gongliao").click(function(){
- $(this).attr('href', "/complementaryRation/lmm" + "?repository=" + getQueryString("repository"))
- });
- $("#fuzhu").click(function(){
- $(this).attr('href', "/complementaryRation/coeList" + "?repository=" + getQueryString("repository"))
- });
- $("#dinge").click(function(){
- $(this).attr('href', "/complementaryRation/ration" + "?repository=" + getQueryString("repository"))
- });
- $(document).ready(function () {
- feeItemObj.buildSheet();
- });
- //费用项
- let feeItemObj = {
- rationRepId: null,
- workBook: null,
- sheet: null,
- cache: [],
- currentFeeItem: null,
- setting: {
- header:[
- {headerName:"费用项",headerWidth:120,dataCode:"feeItem", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
- {headerName:"费用类型",headerWidth:260,dataCode:"feeType", dataType: "String", hAlign: "center", vAlign: "center"},
- {headerName:"记取位置",headerWidth:260,dataCode:"position", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"}
- ],
- view: {lockColumns: []},
- options: {
- tabStripVisible: false,
- allowCopyPasteExcelStyle : false,
- allowExtendPasteRange: false,
- allowUserDragDrop : false,
- allowUserDragFill: false,
- scrollbarMaxAlign : true
- }
- },
- isDef: function (v) {
- return v !== undefined && v !== null;
- },
- //sheet things
- setOptions: function (workbook, opts) {
- for(let opt in opts){
- workbook.options[opt] = opts[opt];
- }
- },
- buildSheet: function () {
- let me = this, se = sectionObj, fr = feeRuleObj;
- if(!this.isDef(this.workBook)){
- this.workBook = sheetCommonObj.buildSheet($('#feeItemSpread')[0], this.setting, 10);
- this.sheet = this.workBook.getActiveSheet();
- this.setOptions(this.workBook, this.setting.options);
- this.bindEvents(this.sheet);
- this.rationRepId = parseInt(getQueryString("repository"));
- let libName = storageUtil.getSessionCache("RationGrp","repositoryID_" + this.rationRepId);
- if (libName) {
- let html = $("#rationname")[0].outerHTML;
- html = html.replace("XXX定额库", libName);
- $("#rationname")[0].outerHTML = html;
- }
- //init sectionSpread
- se.buildSheet();
- //init feeRuleSpread
- fr.buildSheet();
- //init installation
- this.getInstallation(this.rationRepId, function (rstData) {
- me.cache = rstData;
- sheetCommonObj.showData(me.sheet, me.setting, me.cache);
- me.initSelection(me.cache[0]);
- });
- //init batchSectionSpread
- }
- },
- bindEvents: function (sheet) {
- let me = this;
- const Events = GC.Spread.Sheets.Events;
- sheet.bind(Events.SelectionChanged, me.onSelectionChanged);
- sheet.bind(Events.EditStarting, me.onEditStarting);
- sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
- me.feeItemDelOpr();
- },
- initSelection: function (feeItem) {
- let me = this, se = sectionObj, fr = feeRuleObj;
- sheetCommonObj.cleanSheet(se.sheet, se.setting, -1);
- sheetCommonObj.cleanSheet(fr.sheet, fr.setting, -1);
- me.workBook.focus(true);
- if(!me.isDef(feeItem)){
- me.currentFeeItem = null;
- return;
- }
- fr.addObj = null;
- fr.updateObj = null;
- me.currentFeeItem = feeItem;
- se.cache = feeItem.section;
- sheetCommonObj.showData(se.sheet, se.setting, se.cache);
- se.initSelection(se.cache[0]);
- },
- onSelectionChanged: function (sender, info) {
- let me = feeItemObj;
- if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
- let row = info.newSelections[0].row;
- let node = me.cache[row];
- me.initSelection(node);
- }
- },
- onEditStarting: function (sender, args) {
- args.cancel = true;
- },
- onClipboardPasting: function (sender, info) {
- info.cancel = true;
- },
- feeItemDelOpr: function () {
- let me = this;
- me.workBook.commandManager().register('feeItemDel', function () {
- });
- me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
- me.workBook.commandManager().setShortcutKey('feeItemDel', GC.Spread.Commands.Key.del, false, false, false, false);
- },
- getInstallation: function (rationRepId, callback) {
- let me = this;
- CommonAjax.post('/complementaryRation/api/getInstallation', {rationRepId: rationRepId}, function (rstData) {
- me.cache = rstData;
- if(callback){
- callback(rstData);
- }
- });
- }
- };
- //分册章节
- let sectionObj = {
- workBook: null,
- sheet: null,
- cache: [],
- currentSection: null,
- setting: {
- header:[
- {headerName:"分册章节",headerWidth:800,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"}
- ],
- view: {lockColumns: []},
- options: {
- tabStripVisible: false,
- allowCopyPasteExcelStyle : false,
- allowExtendPasteRange: false,
- allowUserDragDrop : false,
- allowUserDragFill: false,
- scrollbarMaxAlign : true
- }
- },
- isDef: function (v) {
- return v !== undefined && v !== null;
- },
- //sheet things
- setOptions: function (workbook, opts) {
- for(let opt in opts){
- workbook.options[opt] = opts[opt];
- }
- },
- buildSheet: function () {
- if(!this.isDef(this.workBook)){
- this.workBook = sheetCommonObj.buildSheet($('#instSectionSpread')[0], this.setting, 10);
- this.sheet = this.workBook.getActiveSheet();
- this.setOptions(this.workBook, this.setting.options);
- this.sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
- this.bindEvents(this.sheet);
- }
- },
- bindEvents: function (sheet) {
- let me = sectionObj;
- const Events = GC.Spread.Sheets.Events;
- sheet.bind(Events.SelectionChanged, me.onSelectionChanged);
- sheet.bind(Events.EditStarting, me.onEditStarting);
- sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
- me.sectionDelOpr();
- },
- initSelection: function (section) {
- let me = sectionObj, fr = feeRuleObj;
- sheetCommonObj.cleanSheet(fr.sheet, fr.setting, -1);
- this.workBook.focus(true);
- if(!this.isDef(section)){
- me.currentSection = null;
- return;
- }
- me.currentSection = section;
- fr.addObj = null;
- fr.updateObj = null;
- fr.cache = section.feeRule;
- sheetCommonObj.showData(fr.sheet, fr.setting, fr.cache);
- },
- onSelectionChanged: function (sender, info) {
- let me = sectionObj;
- if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
- let row = info.newSelections[0].row;
- let section = me.cache[row];
- me.initSelection(section);
- }
- },
- onEditStarting: function (sender, args) {
- args.cancel = true;
- },
- onClipboardPasting: function (sender, info) {
- info.cancel = true;
- },
- sectionDelOpr: function () {
- let me = this;
- me.workBook.commandManager().register('sectionDel', function () {
- });
- me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
- me.workBook.commandManager().setShortcutKey('sectionDel', GC.Spread.Commands.Key.del, false, false, false, false);
- }
- };
- //费用规则
- let feeRuleObj = {
- workBook: null,
- sheet: null,
- addObj: null,
- updateObj: null,
- cache: [],
- setting: {
- header:[
- {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
- {headerName:"费用规则",headerWidth:240,dataCode:"rule", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
- {headerName:"基数",headerWidth:120,dataCode:"base", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
- {headerName:"费率(%)",headerWidth:120,dataCode:"feeRate", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
- {headerName:"其中人工(%)",headerWidth:120,dataCode:"labour", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
- {headerName:"其中材料(%)",headerWidth:120,dataCode:"material", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"},
- {headerName:"其中机械(%)",headerWidth:120,dataCode:"machine", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center"}
- ],
- view: {lockColumns: []},
- options: {
- tabStripVisible: false,
- allowCopyPasteExcelStyle : false,
- allowExtendPasteRange: false,
- allowUserDragDrop : false,
- allowUserDragFill: false,
- scrollbarMaxAlign : true
- }
- },
- isDef: function (v) {
- return v !== undefined && v !== null;
- },
- //sheet things
- setOptions: function (workbook, opts) {
- for(let opt in opts){
- workbook.options[opt] = opts[opt];
- }
- },
- buildSheet: function () {
- if(!this.isDef(this.workBook)){
- this.workBook = sheetCommonObj.buildSheet($('#instFeeRuleSpread')[0], this.setting, 10);
- this.sheet = this.workBook.getActiveSheet();
- this.setOptions(this.workBook, this.setting.options);
- this.bindEvents(this.sheet);
- }
- },
- bindEvents: function (sheet) {
- let me = feeRuleObj;
- const Events = GC.Spread.Sheets.Events;
- sheet.bind(Events.EditStarting, me.onEditStarting);
- sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
- me.feeRuleDelOpr();
- },
- onEditStarting: function (sender, args) {
- args.cancel = true;
- },
- onClipboardPasting: function (sender, info) {
- info.cancel = true;
- },
- feeRuleDelOpr: function () {
- let me = feeRuleObj, se = sectionObj;
- me.workBook.commandManager().register('feeRuleDel', function () {
- });
- me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
- me.workBook.commandManager().setShortcutKey('feeRuleDel', GC.Spread.Commands.Key.del, false, false, false, false);
- }
- };
|