|  | @@ -0,0 +1,282 @@
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 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);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +};
 |