| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 | /** * Created by Zhong on 2017/8/31. * 特征及内容 */let contentOprObj = {    workBook: null,    currentCache: [],//按照serialNo排序    setting: {        header: [            {headerName:"工作内容",headerWidth:160,dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center"},            {headerName:"输出",headerWidth:80,dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}        ]    },    buildSheet: function(container) {        let me = contentOprObj;        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);        me.workBook.options.allowUserDragDrop = false;        me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);        me.workBook.options.allowCopyPasteExcelStyle = false;        me.onContextmenuOpr();//右键菜单        me.bindEvents(me.workBook);    },    bindEvents: function (workBook) {        let sheet = workBook.getActiveSheet(), me = contentOprObj;        const EVENTS = GC.Spread.Sheets.Events;        workBook.bind(EVENTS.ButtonClicked, me.onButtonClicked);        sheet.bind(EVENTS.EditEnded, me.onEditEnded);        sheet.bind(EVENTS.ClipboardPasting, me.onClipboardPasting);        sheet.bind(EVENTS.ClipboardPasted, me.onClipboardPasted);    },    //将从清单库中添加的清单,把标准清单的工作内容转化成清单的工作内容    buildJobContent: function (jobs) {        let jobContent = [];        for(let i = 0, len = jobs.length; i < len; i++){            let newJob = {serialNo: i + 1, content: jobs[i].content, isChecked: true};//从清单库添加过来的默认输出            jobContent.push(newJob);        }        return jobContent;    },    //显示在jobSpread的数据    showContentData: function (sheet, setting, datas) {        sheetCommonObj.showData(sheet, setting, datas);        sheet.suspendPaint();        sheet.suspendEvent();        for(let i = 0, len = datas.length; i < len; i++){            sheet.getCell(i, 0).locked(true);        }        sheet.resumePaint();        sheet.suspendEvent();    },    //显示到清单工作内容列的数据    getColData: function (jobsArr) {        let me = contentOprObj;        let rstStr = "", count = 0;        for(let i = 0, len = jobsArr.length; i < len; i++){            if(jobsArr[i].isChecked === true){                count ++;              /*  if(count === 1){                    rstStr += "“";                }                else{                    rstStr += " ";                }*/                rstStr += count + ". " + jobsArr[i].content + "\n";            }        }        if(rstStr.trim().length > 0){            let reg = /\n+$/g;            let newStr = rstStr.replace(reg, "");            return newStr;        }        return null;    },    //新增行    addRow: function (sheet) {        let checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();        checkBox.isThreeState = false;        sheet.addRows(sheet.getRowCount(), 1);        sheet.getCell(sheet.getRowCount() - 1, 1).cellType(checkBox);    },    upMove: function (rowIdx) {        let me = contentOprObj;        let thisObj = me.currentCache[rowIdx],            preObj = me.currentCache[rowIdx - 1],            temp, contentTxt;        temp = thisObj.serialNo;        thisObj.serialNo = preObj.serialNo;        preObj.serialNo = temp;        me.sortCache(me.currentCache);        me.save();    },    downMove: function (rowIdx) {        let me = contentOprObj;        let thisObj = me.currentCache[rowIdx],            nextObj = me.currentCache[rowIdx + 1],            temp, contentTxt;        temp = thisObj.serialNo;        thisObj.serialNo = nextObj.serialNo;        nextObj.serialNo = temp;        me.sortCache(me.currentCache);        me.save();    },    deleteContent: function (rowIdx) {        let me = contentOprObj;        me.currentCache.splice(rowIdx, 1);        me.save();    },    //更新    updateContent: function (job, newContent) {        job.content = newContent;    },    //新增    insertContent: function (content) {        let me = contentOprObj;        let preObj = me.currentCache.length > 0 ?  me.currentCache[me.currentCache.length - 1] : null;        let newObj = {content: content, isCheceked: false, serialNo: preObj ? preObj.serialNo + 1 : 1};        me.currentCache.push(newObj);    },    save: function () {        let me = contentOprObj;        let contentTxt = me.getColData(me.currentCache);        let txtObj =  {field: 'jobContentText', text: contentTxt ? contentTxt : ''};        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'jobContent', updateArr: me.currentCache}, txtObj, contentOprObj);    },    onEditEnded: function (sender, args) {        let me = contentOprObj;        let preObj = me.currentCache.length > 0 ?  me.currentCache[me.currentCache.length - 1] : null;        let contentTxt;        if(args.editingText && args.editingText.toString().trim().length > 0){            //更新            if(args.row < me.currentCache.length ){                me.updateContent(me.currentCache[args.row], args.editingText);            }            //新增            else{                me.insertContent(args.editingText);            }            //保存            me.save();        }        else{            //恢复            args.sheet.setValue(args.row, args.col, me.currentCache.length > args.row ? me.currentCache[args.row].content + '' : '');        }    },    //复选框控制输出    onButtonClicked: function (sender, args) {        let me = contentOprObj, contentTxt;        if(args.sheet.isEditing()){            args.sheet.endEdit(true);        }        let isChecked = args.sheet.getValue(args.row, args.col);        if(me.currentCache.length > args.row){            me.currentCache[args.row].isChecked = isChecked;            me.save();        }        //else的情况就是新增        else{            //还没数据清空复选框            args.sheet.setValue(args.row, args.col, 0);        }    },    //复制粘贴    onClipboardPasting: function (sender, args) {        if(args.cellRange.colCount > 1 || args.cellRange.col !== 0){            args.cancel = true;        }    },    onClipboardPasted: function (sender, args) {        let me = contentOprObj;        let items = sheetCommonObj.analyzePasteData(me.setting, args);        for(let i = 0, len = items.length; i < len; i++){            let rowIdx = args.cellRange.row + i;            //更新            if(rowIdx < me.currentCache.length){                me.updateContent(me.currentCache[rowIdx], items[i].content);            }            //新增            else{                me.insertContent(items[i].content);            }        }        me.save();    },    sortCache: function (cacheArr) {        cacheArr.sort(function (a, b) {            let rst = 0;            if(a.serialNo > b.serialNo){                rst = 1;            }            else if(a.serialNo < b.serialNo){                rst = -1;            }            return rst;        });    },    onContextmenuOpr: function () {//右键菜单        let me = contentOprObj;        $.contextMenu({            selector: '#jobSpread',            build: function($triggerElement, e){                //控制允许右键菜单在哪个位置出现                let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);                let sheet = me.workBook.getSheet(0);                if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'                    let insertDis = pageCCOprObj.isBillsType() ? false : true, delDis = false, upDis = false, downDis = false;                    if(typeof target.row !== 'undefined'){                        //控制按钮是否可用                        sheet.setActiveCell(target.row, target.col);                        if(!me.currentCache ||target.row >= me.currentCache.length){//右键定位在有数据的行,删除键才显示可用                            delDis = true;                            downDis = true;                            upDis = true;                        }                        else{//有数据                            if(typeof target.col === 'undefined'){//定位不在表格内                                downDis = true;                                upDis = true;                                delDis = true;                            }                            else{//定位在表格内                                if(target.row === me.currentCache.length -1){//定位在最后一行,不可下移                                    downDis = true;                                }                                if(target.row === 0){//定位在第一行,不可上移                                    upDis = true;                                }                            }                        }                    }                    else{                        delDis = true;                        downDis = true;                        upDis = true;                    }                    return {                        callback: function(){},                        items: {                            "insert": {name: "添加", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {                                //插入空行                                me.addRow(sheet);                            }},                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {                                me.deleteContent(target.row);                            }},                            "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {                                me.upMove(target.row);                            }},                            "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {                                me.downMove(target.row);                            }}                        }                    };                }                else{                    return false;                }            }        });    }};let characterOprObj = {    workBook: null,    currentCache: [],    setting: {        header: [            {headerName:"项目特征",headerWidth:160,dataCode:"character", dataType: "String", hAlign: "left", vAlign: "center"},            {headerName:"特征值",headerWidth:160,dataCode:"eigenvalue", dataType: "String", cellType: "comboBox", hAlign: "left", vAlign: "center"},            {headerName:"输出",headerWidth:80,dataCode:"isChecked", cellType:"checkBox", hAlign: "center", vAlign: "center"}        ]    },    buildSheet: function(container) {        let me = characterOprObj;        me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);        me.workBook.options.allowUserDragDrop = false;        me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);        me.workBook.options.allowCopyPasteExcelStyle = false;        me.onContextmenuOpr();        me.bindEvents(me.workBook);    },    bindEvents: function (workBook) {        let sheet = workBook.getActiveSheet(), me = characterOprObj;        const EVENTS = GC.Spread.Sheets.Events;        workBook.bind(EVENTS.ButtonClicked, me.onButtonClicked);        sheet.bind(EVENTS.EditEnded, me.onEditEnded);        sheet.bind(EVENTS.EditStarting, me.onEditStart);        sheet.bind(EVENTS.ClipboardPasting, me.onClipboardPasting);        sheet.bind(EVENTS.ClipboardPasted, me.onClipboardPasted);    },    //将从清单库中添加的清单,把标准清单的项目特征转化成清单的项目特征    buildItemCharactet: function (items) {//从清单库过来的默认不输出        let itemCharacter = [];        for(let i = 0, len = items.length; i < len; i++){            let newItem = {serialNo: i + 1, character: items[i].content, eigenvalue: [], isChecked: false};            let eigenvalues = items[i].itemValue;            for(let j = 0, len = eigenvalues.length; j < len; j++){                let newValue = {value: eigenvalues[j].value, isSelected: false};                newItem.eigenvalue.push(newValue);            }            itemCharacter.push(newItem);        }        return itemCharacter;    },    //显示在itemSpread的数据    showCharacterData: function (sheet, setting, datas) {        let me = characterOprObj;        sheetCommonObj.showData(sheet, setting, datas);        sheet.suspendPaint();        sheet.suspendEvent();        for(let i = 0, len = datas.length; i < len; i++){            let comboObj = me.getComboBox(datas[i]);            comboObj.combo.editable(false);//不可编辑            sheet.getCell(i, 1).cellType(comboObj.combo).value(typeof comboObj.selectedValue !== 'undefined' ? comboObj.selectedValue : '');            sheet.getCell(i, 0).locked(true);        }        sheet.resumePaint();        sheet.suspendEvent();    },    //获得项目特征特征值comboBox    getComboBox: function (characterItem) {        let rst = {};        let combo = new GC.Spread.Sheets.CellTypes.ComboBox();        let comboItems = [], eigenvalues = characterItem.eigenvalue;        for(let i = 0, len = eigenvalues.length; i < len; i++){            comboItems.push(eigenvalues[i].value);            if(eigenvalues[i].isSelected){                rst.selectedValue = eigenvalues[i].value;            }        }        combo.items(comboItems);        rst.combo = combo;        return rst;    },    //获得当前行选中的特征值    getCurrentSelected: function (item) {        let rst = null;        for(let i = 0, len = item.eigenvalue.length; i < len; i++){            if(item.eigenvalue[i].isSelected){                rst = item.eigenvalue[i].value;                break;            }        }        return rst;    },    //显示到清单项目特征列的数据    getColData: function (itemsArr) {        let me = characterOprObj;        let rstStr = "", count = 0;        for(let i = 0, len = itemsArr.length; i < len; i++){            if(itemsArr[i].isChecked === true){                //获取选中的特征值                let eigenvalueStr = "";                let eigenvalue = itemsArr[i].eigenvalue;                for(let j = 0, vLen = eigenvalue.length; j < vLen; j++){                    if(eigenvalue[j].isSelected){                        eigenvalueStr += eigenvalue[j].value;                        break;                    }                }                count ++;                /*if(count === 1){                    rstStr += "“";                }                else{                    rstStr += " ";                }*/                rstStr += count + ". " + itemsArr[i].character + ": " + eigenvalueStr + "\n";            }        }        if(rstStr.trim().length > 0){            let reg = /\n+$/g;            let newStr = rstStr.replace(reg, "");            return newStr;        }        return null;    },    addRow: function (sheet) {        let checkBox = new GC.Spread.Sheets.CellTypes.CheckBox(),            combo = new GC.Spread.Sheets.CellTypes.ComboBox();        checkBox.isThreeState = false;        combo.editable(true);        let rowIdx = sheet.getRowCount();        sheet.addRows(rowIdx, 1);        sheet.getCell(rowIdx, 1).cellType(combo);        sheet.getCell(rowIdx, 2).cellType(checkBox);    },    upMove: function (rowIdx) {        let me = characterOprObj;        let thisObj = me.currentCache[rowIdx],            preObj = me.currentCache[rowIdx - 1],            temp;        temp = thisObj.serialNo;        thisObj.serialNo = preObj.serialNo;        preObj.serialNo = temp;        contentOprObj.sortCache(me.currentCache);        me.save();    },    downMove: function (rowIdx) {        let me = characterOprObj;        let thisObj = me.currentCache[rowIdx],            nextObj = me.currentCache[rowIdx + 1],            temp;        temp = thisObj.serialNo;        thisObj.serialNo = nextObj.serialNo;        nextObj.serialNo = temp;        contentOprObj.sortCache(me.currentCache);        me.save();    },    deleteCharacter: function (rowIdx) {        let me = characterOprObj;        me.currentCache.splice(rowIdx, 1);        me.save();    },    //取消选择的特征值    unsetSelected: function (item) {        for(let i = 0, len = item.eigenvalue.length; i < len; i++){            if(item.eigenvalue[i].isSelected){                item.eigenvalue[i].isSelected = false;            }        }    },    //设置选中的特征值    setSelected: function (item, value) {        for(let i = 0, len = item.eigenvalue.length; i < len; i++){            if(item.eigenvalue[i].value === value){                item.eigenvalue[i].isSelected = true;            }        }    },    //改变选择特征值    changeSelected: function (item, value) {        let me = characterOprObj;        me.unsetSelected(item);        me.setSelected(item, value);    },    insertValue: function (item, value) {        let me = characterOprObj;        me.unsetSelected(item);        let newValue = {value: value, isSelected: true};        item.eigenvalue.push(newValue);    },    updateCharacter: function (item, character, value) {        let me = characterOprObj;        if(character){            item.character = character;        }        if(value){            let isExist = false;            for(let i = 0, len = item.eigenvalue.length; i < len; i++){                if(item.eigenvalue[i].value === value){                    isExist = true;                    break;                }            }            //不存在,新增进eigenvalue,自动打勾输出            if(!isExist){                //更新selected                me.insertValue(item, value);                item.isChecked = true;            }            //存在,选择特征值,自动打勾输出            else{                me.changeSelected(item, value);                item.isChecked = true;            }        }    },    insertCharacter: function (character, value) {        let me = characterOprObj;        let preObj = me.currentCache.length > 0 ?  me.currentCache[me.currentCache.length - 1] : null;        if(character && !value){            let newCharacter = {character: character, eigenvalue: [], isChecked: false, serialNo: preObj ? preObj.serialNo + 1 : 1};            me.currentCache.push(newCharacter);        }        else if(!character && value){            let newValue = {value: value, isSelected: true};            let newCharacter = {character: '', eigenvalue: [newValue], isChecked: false, serialNo: preObj? preObj.serialNo + 1 : 1};            me.currentCache.push(newCharacter);        }        else if(character && value){//有了特征值自动打勾输出            let newValue = {value: value, isSelected: true};            let newCharacter = {character:character , eigenvalue: [newValue], isChecked: true, serialNo: preObj? preObj.serialNo + 1 : 1};            me.currentCache.push(newCharacter);        }    },    save: function () {        let me = characterOprObj;        let characterTxt = me.getColData(me.currentCache);        let txtObj =  {field: 'itemCharacterText', text: characterTxt ? characterTxt : ''};        pageCCOprObj.updateCharacterContent(pageCCOprObj.currentFindSet, {field: 'itemCharacter', updateArr: me.currentCache}, txtObj, characterOprObj);    },    onEditStart: function (sender, args) {        let me = characterOprObj;        if(args.col === 1){//改变选择的特征值            me.currentSelectedValue = me.currentCache.length > args.row ?  me.getCurrentSelected(me.currentCache[args.row]) : null;        }    },    onEditEnded: function (sender, args) {        let me = characterOprObj, characterTxt;        let preObj = me.currentCache.length > 0 ?  me.currentCache[me.currentCache.length - 1] : null;        if(args.editingText && args.editingText.toString().trim().length > 0){            //更新            if(args.row < me.currentCache.length){                let thisCha = me.currentCache[args.row];                if(args.col === 0){//特征                   me.updateCharacter(thisCha, args.editingText, null);                }                else if(args.col === 1){//特征值                    me.updateCharacter(thisCha, null, args.editingText);                }            }            //新增            else{                if(args.col === 0){//特征                    me.insertCharacter(args.editingText, null);                }                else if(args.col === 1){//特征值                    me.insertCharacter(null, args.editingText);                }            }            //保存            me.save();        }        else{//恢复            if(args.col === 0){                args.sheet.setValue(args.row, args.col, me.currentCache.length > args.row ? me.currentCache[args.row].character + '' : '');            }            else if(args.col === 1){                args.sheet.setValue(args.row, args.col, me.currentSelectedValue ? me.currentSelectedValue + '' : '');            }        }    },    onClipboardPasting: function (sender, args) {        if(args.cellRange.col + args.colCount - 1 > 1){            args.cancel = true;        }    },    onClipboardPasted: function (sender, args) {        let me = characterOprObj;        let items = sheetCommonObj.analyzePasteData(me.setting, args);        for(let i = 0, len = items.length; i < len; i++){            //更新            let rowIdx = args.cellRange.row + i;            if(me.currentCache.length > rowIdx){               me.updateCharacter(me.currentCache[rowIdx], items[i].character, items[i].eigenvalue);            }            //新增            else{                me.insertCharacter(items[i].character, items[i].eigenvalue);            }        }        me.save();    },    //复选框控制输出    onButtonClicked: function (sender, args) {        let me = characterOprObj, characterTxt;        if(args.sheet.isEditing()){            args.sheet.endEdit(true);        }        let isChecked = args.sheet.getValue(args.row, args.col);        if(me.currentCache.length > args.row){            me.currentCache[args.row].isChecked = isChecked;            me.save();        }        //else的情况就是新增        else{            args.sheet.setValue(args.row, args.col, 0);        }    },    onContextmenuOpr: function () {//右键菜单        let me = characterOprObj;        $.contextMenu({            selector: '#itemSpread',            build: function($triggerElement, e){                //控制允许右键菜单在哪个位置出现                let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);                let sheet = me.workBook.getSheet(0);                if(target.hitTestType === 3){//在表格内 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'                    let insertDis = pageCCOprObj.isBillsType() ? false : true, delDis = false, upDis = false, downDis = false;                    if(typeof target.row !== 'undefined'){                        //控制按钮是否可用                        sheet.setActiveCell(target.row, target.col);                        if(!me.currentCache ||target.row >= me.currentCache.length){//右键定位在有数据的行,删除键才显示可用                            delDis = true;                            downDis = true;                            upDis = true;                        }                        else{//有数据                            if(typeof target.col === 'undefined'){//定位在表格外                                downDis = true;                                upDis = true;                                delDis = true;                            }                            else{                                if(target.row === me.currentCache.length -1){//定位在最后一行,不可下移                                    downDis = true;                                }                                if(target.row === 0){//定位在第一行,不可上移                                    upDis = true;                                }                            }                        }                    }                    else{                        delDis = true;                        downDis = true;                        upDis = true;                    }                    return {                        callback: function(){},                        items: {                            "insert": {name: "添加", disabled: insertDis, icon: "fa-sign-in", callback: function (key, opt) {                                me.addRow(sheet);                            }},                            "delete": {name: "删除", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {                                me.deleteCharacter(target.row);                            }},                            "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {                                me.upMove(target.row);                            }},                            "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {                                me.downMove(target.row);                            }}                        }                    };                }                else{                    return false;                }            }        });    }};let pageCCOprObj = {    currentFindSet: null,    mainActiveCell: null,//mainSpread焦点单元格    //获得造价书当前焦点行的类型:清单、定额    isBillsType: function () {        let rst = false;        let selectedNode = projectObj.mainController.tree.selected;        if(selectedNode && selectedNode.sourceType === projectObj.project.Bills.getSourceType()){//为清单            rst = true        }        return rst;    },    setItemContentNode: function (node, jobs, items) {        let theCont = contentOprObj, theCha = characterOprObj,            jobContent, itemCharacter, contentTxt, characterTxt;        jobContent = theCont.buildJobContent(jobs);        itemCharacter = theCha.buildItemCharactet(items);        contentTxt = theCont.getColData(jobContent);        characterTxt = theCha.getColData(itemCharacter);        node.data.jobContent = jobContent;        node.data.itemCharacter = itemCharacter;        node.data.jobContentText = contentTxt ? contentTxt : '';        node.data.itemCharacterText = characterTxt ? characterTxt : '';    },    safeItemCharater: function (itemCharater) {        return characterOprObj.buildItemCharactet(itemCharater);    },    //设置特征及内容currentCache    setCacheAndShow: function (node) {        let theCont = contentOprObj, theCha = characterOprObj;        theCont.currentCache = node && typeof node.data.jobContent !== 'undefined' ? node.data.jobContent : [];        theCha.currentCache = node && typeof node.data.itemCharacter !== 'undefined' ? node.data.itemCharacter : [];        this.currentFindSet = node && typeof node.data.ID !== 'undefined' && typeof node.data.projectID ? {ID: node.data.ID, projectID: node.data.projectID} : null;        this.showData(theCont.workBook.getSheet(0), theCont.setting, theCont.currentCache);        this.showData(theCha.workBook.getSheet(0), theCha.setting, theCha.currentCache);    },    //contentSpread、itemSpread展示数据用    showData: function(sheet, setting, data) {        let me = this, ch = GC.Spread.Sheets.SheetArea.viewport;        sheet.suspendPaint();        sheet.suspendEvent();        sheet.clear(0, 0, sheet.getRowCount(), sheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);        sheet.setRowCount(data.length);        for (let col = 0; col < setting.header.length; col++) {            var hAlign = "left", vAlign = "center";            if (setting.header[col].hAlign) {                hAlign = setting.header[col].hAlign;            } else if (setting.header[col].dataType !== "String"){                hAlign = "right";            }            vAlign = setting.header[col].vAlign?setting.header[col].vAlign:vAlign;            sheetCommonObj.setAreaAlign(sheet.getRange(-1, col, -1, 1), hAlign, vAlign);            if (setting.header[col].formatter) {                sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);            }            for (let row = 0; row < data.length; row++) {                sheet.getCell(row, 0).locked(true);//locked                let val = data[row][setting.header[col].dataCode];                if(setting.header[col].cellType === "checkBox"){                    let checkBox = new GC.Spread.Sheets.CellTypes.CheckBox();                    checkBox.isThreeState(false);                    sheet.getCell(row, col).cellType(checkBox).value(val);                }                else if(setting.header[col].cellType === 'comboBox'){                    let comboObj = characterOprObj.getComboBox(data[row]);                    comboObj.combo.editable(true);//可编辑                    sheet.getCell(row, 1).cellType(comboObj.combo).value(typeof comboObj.selectedValue !== 'undefined' ? comboObj.selectedValue : '');                }                else{                    sheet.setValue(row, col, val, ch);                }                sheet.getCell(row, col).wordWrap(true);                sheet.autoFitRow(row);            }        }        sheet.resumeEvent();        sheet.resumePaint();    },    clearData: function () {        let theCon = contentOprObj, theCha = characterOprObj;        theCon.workBook.getSheet(0).setRowCount(0);        theCha.workBook.getSheet(0).setRowCount(0);        sheetCommonObj.cleanSheet(theCon.workBook.getSheet(0), theCon.setting, -1);        sheetCommonObj.cleanSheet(theCha.workBook.getSheet(0), theCha.setting, -1);    },    //更新特征及内容数据    updateCharacterContent: function (findSet, updateObj, txtObj, oprObj) {        let me = pageCCOprObj, updateCol;        if(txtObj){            updateCol = txtObj.field === 'itemCharacterText' ? 4 : 5;//更新清单行特征列或内容列        }        else{            updateCol = null;        }        $.ajax({            type: 'post',            url: '/bills/updateCharacterContent',            dataType: 'json',            data: {findSet: JSON.stringify(findSet), updateObj: JSON.stringify(updateObj), txtObj: JSON.stringify(txtObj)},            success: function (result) {                if(!result.error){                    //更新节点数据                    let selectedNode = projectObj.mainController.tree.selected;                    selectedNode.data[updateObj.field] = updateObj.updateArr;                    selectedNode.data[txtObj.field] = txtObj.text;                    me.showData(oprObj.workBook.getSheet(0), oprObj.setting, oprObj.currentCache);//刷新特征及内容Spread                    if(updateCol){                        projectObj.mainSpread.getActiveSheet().setValue(me.mainActiveCell.row, updateCol, txtObj.text + ''); //刷新输出显示                        projectObj.mainSpread.getActiveSheet().autoFitRow(me.mainActiveCell.row);                    }                }            }        });    }}
 |