|  | @@ -0,0 +1,409 @@
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * Created by Zhong on 2017/11/24.
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +let projFeatureView = {
 | 
	
		
			
				|  |  | +    orgDatas: [],//for compare
 | 
	
		
			
				|  |  | +    datas: [],//just for view
 | 
	
		
			
				|  |  | +    workBook: null,
 | 
	
		
			
				|  |  | +    firstData: {dispName: '工程特征', key: 'projFeature', items: []},//for show
 | 
	
		
			
				|  |  | +    setting:{
 | 
	
		
			
				|  |  | +        header: [
 | 
	
		
			
				|  |  | +            {name: '属性', dataCode: 'dispName', width: 200, vAlign: 'center', hAlign: 'left'},
 | 
	
		
			
				|  |  | +            {name: '值', dataCode: 'value', width: 120, vAlign: 'center', hAlign: 'left'}
 | 
	
		
			
				|  |  | +        ],
 | 
	
		
			
				|  |  | +        options: {
 | 
	
		
			
				|  |  | +            tabStripVisible:  false,
 | 
	
		
			
				|  |  | +            allowCopyPasteExcelStyle : false,
 | 
	
		
			
				|  |  | +            allowExtendPasteRange: false,
 | 
	
		
			
				|  |  | +            allowUserDragDrop : false,
 | 
	
		
			
				|  |  | +            allowUserDragFill: false,
 | 
	
		
			
				|  |  | +            scrollbarMaxAlign : true
 | 
	
		
			
				|  |  | +        },
 | 
	
		
			
				|  |  | +        combos: [
 | 
	
		
			
				|  |  | +            {row: 1, key: 'projType', items: ['住宅', '公共建筑', '厂房', '办公楼']},
 | 
	
		
			
				|  |  | +            {row: 2, key: 'structureType', items: ['排架结构', '框架结构']},
 | 
	
		
			
				|  |  | +            {row: 3, key: 'baseType', items: ['带基', '框排架柱距6m以内', '框排架柱距6m以外', '满基筏式', '满基板式', '满基箱式', '独立基础']},
 | 
	
		
			
				|  |  | +            {row: 4, key: 'buildingFeature', items: ['点式', '凹式', '凸式', 'Y式', '其他']}
 | 
	
		
			
				|  |  | +        ],
 | 
	
		
			
				|  |  | +        numRows: [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
 | 
	
		
			
				|  |  | +        dateRows: [],
 | 
	
		
			
				|  |  | +        locked: {
 | 
	
		
			
				|  |  | +            rows: [0],
 | 
	
		
			
				|  |  | +            cols: [0]
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    renderSheetFuc: function (sheet, fuc) {
 | 
	
		
			
				|  |  | +        sheet.suspendPaint();
 | 
	
		
			
				|  |  | +        sheet.suspendEvent();
 | 
	
		
			
				|  |  | +        fuc();
 | 
	
		
			
				|  |  | +        sheet.resumePaint();
 | 
	
		
			
				|  |  | +        sheet.resumeEvent();
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    setOptions: function (workbook, opts) {
 | 
	
		
			
				|  |  | +        for(let opt in opts){
 | 
	
		
			
				|  |  | +            workbook.options[opt] = opts[opt];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    setCombo: function (sheet, row, items) {
 | 
	
		
			
				|  |  | +        let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
 | 
	
		
			
				|  |  | +        combo.items(items);
 | 
	
		
			
				|  |  | +        combo.editable(false);
 | 
	
		
			
				|  |  | +        sheet.getCell(row, 1).cellType(combo);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    getComboItemsByRow: function (row) {
 | 
	
		
			
				|  |  | +        for(let i = 0, len = this.setting.combos.length; i < len; i++){
 | 
	
		
			
				|  |  | +            if(this.setting.combos[i].row === row){
 | 
	
		
			
				|  |  | +                return this.setting.combos[i].items;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return null;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    buildHeader: function (sheet, headers) {
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        let fuc = function () {
 | 
	
		
			
				|  |  | +            sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
 | 
	
		
			
				|  |  | +            sheet.setColumnCount(headers.length);
 | 
	
		
			
				|  |  | +            sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
 | 
	
		
			
				|  |  | +            for(let i = 0, len = headers.length; i < len; i++){
 | 
	
		
			
				|  |  | +                sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
 | 
	
		
			
				|  |  | +                sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        me.renderSheetFuc(sheet, fuc);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    buildSheet: function () {
 | 
	
		
			
				|  |  | +        if(!this.workBook){
 | 
	
		
			
				|  |  | +            this.workBook = new GC.Spread.Sheets.Workbook($('#projFeatureSpread')[0], {sheetCount: 1});
 | 
	
		
			
				|  |  | +            this.setOptions(this.workBook, this.setting.options);
 | 
	
		
			
				|  |  | +            this.buildHeader(this.workBook.getActiveSheet(), this.setting.header);
 | 
	
		
			
				|  |  | +            this.bindEvent(this.workBook);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    bindEvent: function (workBook) {
 | 
	
		
			
				|  |  | +        const _events = GC.Spread.Sheets.Events;
 | 
	
		
			
				|  |  | +        let sheet = workBook.getActiveSheet();
 | 
	
		
			
				|  |  | +        sheet.bind(_events.EditStarting, this.onEditStarting);
 | 
	
		
			
				|  |  | +        sheet.bind(_events.EditEnded, this.onEditEnded);
 | 
	
		
			
				|  |  | +        sheet.bind(_events.ClipboardPasting, this.onClipboardPasting);
 | 
	
		
			
				|  |  | +        sheet.bind(_events.ClipboardPasted, this.onClipboardPasted);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    showData(datas){
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        let sheet = this.workBook.getActiveSheet();
 | 
	
		
			
				|  |  | +        let cols = this.setting.header;
 | 
	
		
			
				|  |  | +        let fuc = function () {
 | 
	
		
			
				|  |  | +            sheet.setRowCount(datas.length);
 | 
	
		
			
				|  |  | +            me.initTree(sheet, true, datas);
 | 
	
		
			
				|  |  | +            sheet.setFormatter(-1, 1, '@');
 | 
	
		
			
				|  |  | +            //setCombo
 | 
	
		
			
				|  |  | +            for(let i = 0, len = me.setting.combos.length; i < len; i++){
 | 
	
		
			
				|  |  | +                me.setCombo(sheet, me.setting.combos[i].row, me.setting.combos[i].items);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            for(let col = 0, cLen = cols.length; col < cLen; col++){
 | 
	
		
			
				|  |  | +                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[cols[col]['hAlign']]);
 | 
	
		
			
				|  |  | +                sheet.getRange(-1, col, -1, 1).hAlign(GC.Spread.Sheets.VerticalAlign[cols[col]['vAlign']]);
 | 
	
		
			
				|  |  | +                for(let row = 0, rLen = datas.length; row < rLen; row++){
 | 
	
		
			
				|  |  | +                    sheet.setValue(row, col, datas[row][cols[col]['dataCode']]);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        this.renderSheetFuc(sheet, fuc);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    onEditStarting: function (sender, args) {
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        if(me.setting.locked.cols.indexOf(args.col) !== -1){
 | 
	
		
			
				|  |  | +            args.cancel = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(args.col === 1 && me.setting.locked.rows.indexOf(args.row) !== -1){
 | 
	
		
			
				|  |  | +            args.cancel = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    onEditEnded: function (sender, args) {
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        let v =  args.editingText ? args.editingText.toString().trim() : '';
 | 
	
		
			
				|  |  | +        if(args.row < me.datas.length){
 | 
	
		
			
				|  |  | +            if(me.setting.numRows.indexOf(args.row) !== -1){//控制数值
 | 
	
		
			
				|  |  | +                if(!me.isNum(v)){
 | 
	
		
			
				|  |  | +                    alert('只能输入数值');
 | 
	
		
			
				|  |  | +                    args.sheet.setValue(args.row, args.col, me.datas[args.row].value ? me.datas[args.row].value : '');
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            me.datas[args.row].value = v;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    onClipboardPasting: function (sender, args) {
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        if(me.setting.locked.cols.indexOf(args.cellRange.col) !== -1){
 | 
	
		
			
				|  |  | +            args.cancel = true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    onClipboardPasted: function (sender, args) {
 | 
	
		
			
				|  |  | +        let me = projFeatureView;
 | 
	
		
			
				|  |  | +        let items = sheetCommonObj.analyzePasteData(me.setting, args);
 | 
	
		
			
				|  |  | +        let recRows = [];
 | 
	
		
			
				|  |  | +        console.log(args);
 | 
	
		
			
				|  |  | +        console.log(items);
 | 
	
		
			
				|  |  | +        console.log('enter');
 | 
	
		
			
				|  |  | +        if(items.length === 0){
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(let i = 0, len = items.length; i < len; i++){
 | 
	
		
			
				|  |  | +            let row = i + args.cellRange.row;
 | 
	
		
			
				|  |  | +            let comboItems = me.getComboItemsByRow(row);
 | 
	
		
			
				|  |  | +            if(me.setting.locked.rows.indexOf(row) !== -1){
 | 
	
		
			
				|  |  | +                recRows.push(row);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //粘贴下拉框数据过滤
 | 
	
		
			
				|  |  | +            else if(comboItems && comboItems.indexOf(items[i].value) !== -1){
 | 
	
		
			
				|  |  | +                recRows.push(row);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else if(me.setting.numRows.indexOf(row) !== -1 && !me.isNum(items[i].value)){
 | 
	
		
			
				|  |  | +                recRows.push(row);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            else {
 | 
	
		
			
				|  |  | +                me.datas[row].value = items[i].value;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(recRows.length > 0){
 | 
	
		
			
				|  |  | +            me.renderSheetFuc(args.sheet, function () {
 | 
	
		
			
				|  |  | +                for(let i = 0, len = recRows.length; i < len; i++){
 | 
	
		
			
				|  |  | +                    let staticV = me.datas[recRows[i]].value || '';
 | 
	
		
			
				|  |  | +                    args.sheet.setValue(recRows[i], args.cellRange.col, staticV);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            })
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    isDef: function (v) {
 | 
	
		
			
				|  |  | +        return v !== undefined && v !== null;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +    isNum: function(v){
 | 
	
		
			
				|  |  | +        return this.isDef(v) && !isNaN(v);
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    copyObj: function(obj){
 | 
	
		
			
				|  |  | +        let newObj = {};
 | 
	
		
			
				|  |  | +        for(let attr in obj){
 | 
	
		
			
				|  |  | +            newObj[attr] = obj[attr];
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return newObj;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    initDatas: function (datas) {
 | 
	
		
			
				|  |  | +        this.datas = [];
 | 
	
		
			
				|  |  | +        for(let i = 0, len = datas.length; i < len; i++){
 | 
	
		
			
				|  |  | +            this.datas.push(this.copyObj(datas[i]));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//数据库读到的数据转换为展示的结构
 | 
	
		
			
				|  |  | +    toViewDatas: function (datas) {
 | 
	
		
			
				|  |  | +        let rst = [];
 | 
	
		
			
				|  |  | +        this.firstData.items = datas;
 | 
	
		
			
				|  |  | +        rst.push(this.firstData);
 | 
	
		
			
				|  |  | +        rst = rst.concat(datas);
 | 
	
		
			
				|  |  | +       return rst;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +//展示的结构转换为入库的结构
 | 
	
		
			
				|  |  | +    toSaveDatas: function (datas) {
 | 
	
		
			
				|  |  | +        let rst = [].concat(datas);
 | 
	
		
			
				|  |  | +        rst.splice(0, 1);
 | 
	
		
			
				|  |  | +        return rst;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    toUpdate: function (orgDatas, newDatas) {
 | 
	
		
			
				|  |  | +        if(orgDatas.length !== newDatas.length){
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for(let i = 0, len = orgDatas.length; i < len; i++){
 | 
	
		
			
				|  |  | +            let orgObj = orgDatas[i], newObj = newDatas[i];
 | 
	
		
			
				|  |  | +            if(orgObj.value !== newObj.value){
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    a_updateInfo: function (datas) {
 | 
	
		
			
				|  |  | +        let me = this;
 | 
	
		
			
				|  |  | +        let url = '/pm/api/updateProjects',
 | 
	
		
			
				|  |  | +            updateData = {
 | 
	
		
			
				|  |  | +                updateType: 'update',
 | 
	
		
			
				|  |  | +                updateData: {ID: parseInt(scUrlUtil.GetQueryString('project')), 'property.projectFeature': datas}
 | 
	
		
			
				|  |  | +            },
 | 
	
		
			
				|  |  | +            postData = {
 | 
	
		
			
				|  |  | +                user_id: userID,
 | 
	
		
			
				|  |  | +                updateData: [updateData]
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +        CommonAjax.post(url, postData, function (rstData) {
 | 
	
		
			
				|  |  | +            me.orgDatas = me.toViewDatas(datas);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    initTree:function (sheet, init, datas) {
 | 
	
		
			
				|  |  | +        sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(datas));
 | 
	
		
			
				|  |  | +        for(let i =0, len = datas.length; i < len; i++){
 | 
	
		
			
				|  |  | +            if(datas[i].hasOwnProperty('items')){
 | 
	
		
			
				|  |  | +                let collapsed = false;
 | 
	
		
			
				|  |  | +                if(init){
 | 
	
		
			
				|  |  | +                    datas[i].collapsed=true;
 | 
	
		
			
				|  |  | +                    collapsed = true;
 | 
	
		
			
				|  |  | +                }else {
 | 
	
		
			
				|  |  | +                    collapsed = datas[i].collapsed == undefined ? true : datas[i].collapsed;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                sheet.getRange(i+1, -1, datas[i].items.length, -1).visible(!collapsed);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    getTreeNodeCellType:function (data) {
 | 
	
		
			
				|  |  | +        var ns = GC.Spread.Sheets;
 | 
	
		
			
				|  |  | +        var rectW = 10;
 | 
	
		
			
				|  |  | +        var rectH = 10;
 | 
	
		
			
				|  |  | +        var margin = 3;
 | 
	
		
			
				|  |  | +        function TreeNodeCellType() {
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        function drowRect(ctx,x,y,w,h) {
 | 
	
		
			
				|  |  | +            ctx.save();
 | 
	
		
			
				|  |  | +            ctx.strokeStyle = "gray";
 | 
	
		
			
				|  |  | +            ctx.translate(0.5,0.5);
 | 
	
		
			
				|  |  | +            ctx.beginPath();
 | 
	
		
			
				|  |  | +            var rectX = x+margin;
 | 
	
		
			
				|  |  | +            var rectY =  y+ Math.round(h/2)-rectH/2;
 | 
	
		
			
				|  |  | +            ctx.moveTo(rectX, rectY);
 | 
	
		
			
				|  |  | +            ctx.lineTo(rectX, rectY+rectH);
 | 
	
		
			
				|  |  | +            ctx.lineTo(rectX+rectW, rectY+rectH);
 | 
	
		
			
				|  |  | +            ctx.lineTo(rectX+rectW, rectY);
 | 
	
		
			
				|  |  | +            ctx.lineTo(rectX, rectY);
 | 
	
		
			
				|  |  | +            ctx.moveTo(rectX+rectW, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            ctx.lineTo(rectX+rectW+5, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            ctx.stroke();
 | 
	
		
			
				|  |  | +            ctx.restore();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        function drowSymbol(ctx,x,y,w,h,collapsed) {
 | 
	
		
			
				|  |  | +            ctx.save();
 | 
	
		
			
				|  |  | +            ctx.strokeStyle = "#000000";
 | 
	
		
			
				|  |  | +            ctx.translate(0.5, 0.5);
 | 
	
		
			
				|  |  | +            ctx.beginPath();
 | 
	
		
			
				|  |  | +            ctx.moveTo(x+margin+2, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            ctx.lineTo(x+margin+8, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            var rectY =  y+ Math.round(h/2)-rectH/2;
 | 
	
		
			
				|  |  | +            if(collapsed){
 | 
	
		
			
				|  |  | +                ctx.moveTo(x+margin+rectW/2,rectY+2);
 | 
	
		
			
				|  |  | +                ctx.lineTo(x+margin+rectW/2,rectY+2+6);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ctx.stroke();
 | 
	
		
			
				|  |  | +            ctx.restore();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        function drowSubItem(ctx,x,y,w,h,offset,nextItem) {
 | 
	
		
			
				|  |  | +            offset+=6;
 | 
	
		
			
				|  |  | +            ctx.save();
 | 
	
		
			
				|  |  | +            ctx.strokeStyle = "gray";
 | 
	
		
			
				|  |  | +            ctx.translate(0.5, 0.5);
 | 
	
		
			
				|  |  | +            ctx.beginPath();
 | 
	
		
			
				|  |  | +            ctx.moveTo(x+offset, y);
 | 
	
		
			
				|  |  | +            ctx.lineTo(x+offset, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            offset+=9;
 | 
	
		
			
				|  |  | +            ctx.lineTo(x+offset, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +            if(nextItem&&!nextItem.hasOwnProperty('items')){
 | 
	
		
			
				|  |  | +                ctx.moveTo(x+offset-9, y+Math.round(h/2));
 | 
	
		
			
				|  |  | +                ctx.lineTo(x+offset-9, y+h);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            ctx.stroke();
 | 
	
		
			
				|  |  | +            ctx.restore();
 | 
	
		
			
				|  |  | +            return offset;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        TreeNodeCellType.prototype = new ns.CellTypes.Text();
 | 
	
		
			
				|  |  | +        TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
 | 
	
		
			
				|  |  | +            if(value!=null){
 | 
	
		
			
				|  |  | +                var offset = margin+rectW+6;
 | 
	
		
			
				|  |  | +                var recode = data[options.row];
 | 
	
		
			
				|  |  | +                if(recode&&recode.hasOwnProperty('items')){
 | 
	
		
			
				|  |  | +                    drowRect(ctx,x,y,w,h);
 | 
	
		
			
				|  |  | +                    var collapsed = recode.collapsed==undefined?true:recode.collapsed;//options.sheet.getTag(options.row,options.col);
 | 
	
		
			
				|  |  | +                    drowSymbol(ctx,x,y,w,h,collapsed);
 | 
	
		
			
				|  |  | +                }else if(recode&&!recode.hasOwnProperty('items')){
 | 
	
		
			
				|  |  | +                    offset= drowSubItem(ctx,x,y,w,h,offset,data[options.row+1]);
 | 
	
		
			
				|  |  | +                    offset+=1;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                ctx.fillText(value,x+offset+ctx.measureText(value).width,y+h-5);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        // override getHitInfo to allow cell type get mouse messages
 | 
	
		
			
				|  |  | +        TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
 | 
	
		
			
				|  |  | +            return {
 | 
	
		
			
				|  |  | +                x: x,
 | 
	
		
			
				|  |  | +                y: y,
 | 
	
		
			
				|  |  | +                row: context.row,
 | 
	
		
			
				|  |  | +                col: context.col,
 | 
	
		
			
				|  |  | +                cellStyle: cellStyle,
 | 
	
		
			
				|  |  | +                cellRect: cellRect,
 | 
	
		
			
				|  |  | +                sheetArea: context.sheetArea
 | 
	
		
			
				|  |  | +            };
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
 | 
	
		
			
				|  |  | +            var recode = data[hitinfo.row];
 | 
	
		
			
				|  |  | +            if(recode&&recode.hasOwnProperty('items')){
 | 
	
		
			
				|  |  | +                var hoffset= hitinfo.cellRect.x+3;
 | 
	
		
			
				|  |  | +                if (hitinfo.x > hoffset && hitinfo.x < hoffset + 10){
 | 
	
		
			
				|  |  | +                    var collapsed = recode.collapsed==undefined?true:recode.collapsed;
 | 
	
		
			
				|  |  | +                    collapsed = !collapsed
 | 
	
		
			
				|  |  | +                    recode.collapsed=collapsed;
 | 
	
		
			
				|  |  | +                    //hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,collapsed);
 | 
	
		
			
				|  |  | +                    hitinfo.sheet.getRange(hitinfo.row+1, -1, recode.items.length, -1).visible(!collapsed);
 | 
	
		
			
				|  |  | +                    hitinfo.sheet.invalidateLayout();
 | 
	
		
			
				|  |  | +                    hitinfo.sheet.repaint();
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        return new TreeNodeCellType()
 | 
	
		
			
				|  |  | +    },
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +$(document).ready(function () {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#poj-set').on('shown.bs.modal', function (e) {
 | 
	
		
			
				|  |  | +        //init Spread
 | 
	
		
			
				|  |  | +        projFeatureView.initDatas(projFeatureView.orgDatas);
 | 
	
		
			
				|  |  | +        projFeatureView.buildSheet();
 | 
	
		
			
				|  |  | +        projFeatureView.showData(projFeatureView.datas);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#poj-set').on('hidden.bs.modal', function (e) {
 | 
	
		
			
				|  |  | +        //destroy Spread
 | 
	
		
			
				|  |  | +        if(projFeatureView.workBook){
 | 
	
		
			
				|  |  | +            projFeatureView.workBook.destroy();
 | 
	
		
			
				|  |  | +            projFeatureView.workBook = null;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        projFeatureView.datas = [];
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#tab_poj-settings-projFeature').on('shown.bs.tab', function () {
 | 
	
		
			
				|  |  | +        projFeatureView.workBook.refresh();
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('#property_ok').bind('click', function () {
 | 
	
		
			
				|  |  | +        if(projFeatureView.toUpdate(projFeatureView.orgDatas, projFeatureView.datas)){
 | 
	
		
			
				|  |  | +           projFeatureView.a_updateInfo(projFeatureView.toSaveDatas(projFeatureView.datas));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +});
 |