123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- /**
- * Created by Zhong on 2018/1/19.
- **/
- $(document).ready(function () {
- feeItemObj.buildSheet();
- });
- //费用项
- let feeItemObj = {
- rationRepId: null,
- workBook: null,
- sheet: null,
- cache: [],
- currentFeeItem: null,
- setting: {
- header:[
- {headerName:"费用项",headerWidth:200,dataCode:"feeItem", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
- {headerName:"费用类型",headerWidth:80,dataCode:"feeType", dataType: "String", hAlign: "center", vAlign: "center"},
- {headerName:"记取位置",headerWidth:100,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);
- sheetCommonObj.spreadDefaultStyle(this.workBook);
- this.sheet = this.workBook.getActiveSheet();
- this.setOptions(this.workBook, this.setting.options);
- this.bindEvents(this.sheet);
- this.rationRepId = parseInt(getQueryString("repository"));
- CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [this.rationRepId]}, function (rstData) {
- if(rstData.length > 0){
- let libName = rstData[0].dispName;
- if (libName) {
- let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
- $('.header-logo').after($rationName);
- }
- //init sectionSpread
- se.buildSheet();
- //init feeRuleSpread
- fr.buildSheet();
- //init installation
- me.getInstallation(me.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);
- sheetCommonObj.spreadDefaultStyle(this.workBook);
- 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:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center", span:{row: 0, rowCount: 2, colCount: 1}},
- {headerName:"费用规则",headerWidth:280,dataCode:"rule", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center", span:{row: 0, rowCount: 2, colCount: 1}},
- {headerName:"基数",headerWidth:140,dataCode:"base", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center", span:{row: 0, rowCount: 2, colCount: 1}},
- {headerName:"费率(%)",headerWidth:70,dataCode:"feeRate", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center", span:{row: 0, rowCount: 2, colCount: 1}},
- {headerName:"人工(%)",headerWidth:70,dataCode:"labour", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center", span:{row: 1, rowCount: 1, colCount: 1}},
- {headerName:"材料(%)",headerWidth:70,dataCode:"material", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center", span:{row: 1, rowCount: 1, colCount: 1}},
- {headerName:"机械(%)",headerWidth:70,dataCode:"machine", dataType: "String", formatter: "@", hAlign: "center", vAlign: "center", span:{row: 1, rowCount: 1, colCount: 1}}
- ],
- 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];
- }
- },
- buildHeader: function () {
- if(!this.sheet){
- return;
- }
- this.sheet.suspendPaint();
- this.sheet.suspendEvent();
- let ch = GC.Spread.Sheets.SheetArea.colHeader;
- this.sheet.setRowCount(2, ch);
- for(let i = 0; i < this.setting.header.length; i++){
- let header = this.setting.header[i];
- this.sheet.addSpan(header.span.row, i, header.span.rowCount, header.span.colCount, ch);
- this.sheet.setValue(header.span.row, i, header.headerName, ch);
- if(header.dataCode === 'feeRate'){
- this.sheet.addSpan(header.span.row, i + 1, 1, 3, ch);
- this.sheet.setValue(header.span.row, i + 1, '其中', ch);
- }
- }
- this.sheet.resumePaint();
- this.sheet.resumeEvent();
- },
- buildSheet: function () {
- if(!this.isDef(this.workBook)){
- this.workBook = sheetCommonObj.buildSheet($('#instFeeRuleSpread')[0], this.setting, 10);
- sheetCommonObj.spreadDefaultStyle(this.workBook);
- this.sheet = this.workBook.getActiveSheet();
- this.buildHeader();
- 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);
- }
- };
|