|
@@ -230,31 +230,35 @@ let coeOprObj = {
|
|
|
me.workSheet = me.workBook.getSheet(0);
|
|
|
me.workSheet.options.isProtected = true;
|
|
|
me.onDelOpr(me.workBook, me.setting);
|
|
|
+ me.initContextMenu();
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
},
|
|
|
onSelectionChanged: function (sender, info) {
|
|
|
- let me = coeOprObj, that = gljAdjOprObj;
|
|
|
if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
|
|
|
- let row = info.newSelections[0].row;
|
|
|
- if(row < me.currentCoeList.length){
|
|
|
- me.currentCoe = me.currentCoeList[row];
|
|
|
- that.currentGljAdjList = me.currentCoe.coes;
|
|
|
- that.buildDynamicComboBox(that.workSheet);
|
|
|
- }
|
|
|
- else{
|
|
|
- me.currentCoe = null;
|
|
|
- that.currentGljAdjList = [];
|
|
|
- that.buildBaseCell(that.workSheet);
|
|
|
- }
|
|
|
- //refresh & show coes
|
|
|
- sheetCommonObj.cleanSheet(that.workSheet, that.setting, -1);
|
|
|
- me.workBook.focus(true);
|
|
|
- that.show(that.currentGljAdjList);
|
|
|
+ const row = info.newSelections[0].row;
|
|
|
+ coeOprObj.coeSelInit(row);
|
|
|
}
|
|
|
},
|
|
|
+ coeSelInit: function (row) {
|
|
|
+ const me = coeOprObj;
|
|
|
+ const adj = gljAdjOprObj;
|
|
|
+ if(row < me.currentCoeList.length){
|
|
|
+ me.currentCoe = me.currentCoeList[row];
|
|
|
+ adj.currentGljAdjList = me.currentCoe.coes;
|
|
|
+ adj.buildDynamicComboBox(adj.workSheet);
|
|
|
+ } else{
|
|
|
+ me.currentCoe = null;
|
|
|
+ adj.currentGljAdjList = [];
|
|
|
+ adj.buildBaseCell(adj.workSheet);
|
|
|
+ }
|
|
|
+ //refresh & show coes
|
|
|
+ sheetCommonObj.cleanSheet(adj.workSheet, adj.setting, -1);
|
|
|
+ me.workBook.focus(true);
|
|
|
+ adj.show(adj.currentGljAdjList);
|
|
|
+ },
|
|
|
onEditEnded: function (sender, args) {
|
|
|
let me = coeOprObj, addArr = [], updateArr = [], dataCode = me.setting.header[args.col].dataCode;
|
|
|
if(args.editingText && args.editingText.toString().trim().length > 0){
|
|
@@ -411,6 +415,66 @@ let coeOprObj = {
|
|
|
workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
workBook.commandManager().setShortcutKey('coeListDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
},
|
|
|
+ initContextMenu: function () {
|
|
|
+ const me = this;
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#mainSpread',
|
|
|
+ build: function($triggerElement, e){
|
|
|
+ //控制允许右键菜单在哪个位置出现
|
|
|
+ const target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.workBook);
|
|
|
+ const sheet = me.workBook.getSheet(0);
|
|
|
+ if(target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
|
|
|
+ if(typeof target.row !== 'undefined'){
|
|
|
+ //控制按钮是否可用
|
|
|
+ sheet.setActiveCell(target.row, target.col);
|
|
|
+ me.coeSelInit(target.row);
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ callback: function(){},
|
|
|
+ items: {
|
|
|
+ getReference: {
|
|
|
+ name: '查找引用',
|
|
|
+ disabled: function () {
|
|
|
+ return !me.currentCoeList || !me.currentCoeList[target.row];
|
|
|
+ },
|
|
|
+ icon: 'fa-search',
|
|
|
+ callback: function () {
|
|
|
+ const coe = me.currentCoeList[target.row];
|
|
|
+ me.getReference(coe.ID);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getReference: function (coeID) {
|
|
|
+ const $info = $('#info');
|
|
|
+ const $infoBody = $('#infoBody');
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.post('/rationRepository/api/getCoeReference', { rationRepId: pageOprObj.rationLibId, coeID }, function (info) {
|
|
|
+ let htmlArr = [];
|
|
|
+ if (!info || !info.length) {
|
|
|
+ htmlArr.push('<li>无引用数据</li>');
|
|
|
+ } else {
|
|
|
+ htmlArr = info.map(ration => {
|
|
|
+ return `<li>
|
|
|
+ <span>${ration.code}</span>
|
|
|
+ <a data-dismiss="modal" href="javascript:;" onclick="sectionTreeObj.locateToSection('${ration.code}')">定位</a>
|
|
|
+ </li>`;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $infoBody.html(htmlArr.join(''));
|
|
|
+ $info.modal('show');
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ });
|
|
|
+ },
|
|
|
//粘贴的数据,编号唯一化,去除编号重复的项
|
|
|
makeUniqItems: function (items) {
|
|
|
let rst = [];
|