|
@@ -125,14 +125,16 @@ var rationLibObj = {
|
|
|
});
|
|
|
args.sheet.repaint();
|
|
|
},
|
|
|
- setTagForHint: function (datas) {
|
|
|
- let sheet = this.sectionRationsSpread.getActiveSheet();
|
|
|
+ setTagForHint: function (sheet, datas) {
|
|
|
sheet.suspendPaint();
|
|
|
sheet.suspendEvent();
|
|
|
for(let i = 0, len = sheet.getRowCount(); i < len; i++){
|
|
|
sheet.setTag(i, 0, '');
|
|
|
}
|
|
|
for(let i = 0, len = datas.length; i < len; i++){
|
|
|
+ if(datas[i].code === 'AA0032'){
|
|
|
+ console.log(datas[i]);
|
|
|
+ }
|
|
|
sheet.setTag(i, 0, datas[i].hint ? datas[i].hint : '');
|
|
|
}
|
|
|
sheet.resumePaint();
|
|
@@ -147,7 +149,7 @@ var rationLibObj = {
|
|
|
});
|
|
|
SheetDataHelper.loadSheetHeader(setting, rationLibObj.sectionRationsSpread.getActiveSheet());
|
|
|
SheetDataHelper.loadSheetData(setting, rationLibObj.sectionRationsSpread.getActiveSheet(), datas);
|
|
|
- rationLibObj.setTagForHint(datas);
|
|
|
+ rationLibObj.setTagForHint(rationSheet, datas);
|
|
|
};
|
|
|
if (sectionID) {
|
|
|
CommonAjax.post('/complementaryRation/api/getRationGljItemsBySection', {user_Id: userID, sectionId: sectionID}, function (datas) {
|
|
@@ -440,8 +442,28 @@ $('#rationSearchKeyword').bind('keypress', function (event) {
|
|
|
$('#rationSearch').click();
|
|
|
}
|
|
|
});
|
|
|
+$('#rationSearchKeyword').keyup(function () {
|
|
|
+ let keyword = $('#rationSearchKeyword').val();
|
|
|
+ if(keyword === ''){
|
|
|
+ if($('#rationSearchResult').is(':visible')){
|
|
|
+ $('#rationSearchResult').hide();
|
|
|
+ $(".main-data-side-search", $('#rationSearchResult')).height(0);
|
|
|
+ autoFlashHeight();
|
|
|
+ rationLibObj.refreshSpread();
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
$('#rationSearch').click(function () {
|
|
|
var keyword = $('#rationSearchKeyword').val(), rationLibID = $('#stdRationLibSelect').val();
|
|
|
+ if(keyword === ''){
|
|
|
+ if($('#rationSearchResult').is(':visible')){
|
|
|
+ $('#rationSearchResult').hide();
|
|
|
+ $(".main-data-side-search", $('#rationSearchResult')).height(0);
|
|
|
+ autoFlashHeight();
|
|
|
+ rationLibObj.refreshSpread();
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
var getResultHtml = function (result) {
|
|
|
var html = [], i, serialNo;
|
|
|
html.push('<div class="d-flex justify-content-between">');
|
|
@@ -455,14 +477,56 @@ $('#rationSearch').click(function () {
|
|
|
html.push('</div>');
|
|
|
return html.join('');
|
|
|
};
|
|
|
+ let bindContextmenuOpr = function (sheet) {
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#rationSearchResult',
|
|
|
+ build: function($triggerElement, e){
|
|
|
+ //控制允许右键菜单在哪个位置出现
|
|
|
+ let offset = $('.main-data-side-search').offset(),
|
|
|
+ x = e.pageX - offset.left,
|
|
|
+ y = e.pageY - offset.top;
|
|
|
+ let target = sheet.hitTest(x, y);
|
|
|
+ if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
|
|
|
+ sheet.setActiveCell(target.row, target.col);
|
|
|
+ return {
|
|
|
+ callback: function(){},
|
|
|
+ items: {
|
|
|
+ "locate": {
|
|
|
+ name: "定位至章节",
|
|
|
+ disabled: function () {
|
|
|
+ return target.row >= rationLibObj.resultCache.length;
|
|
|
+ },
|
|
|
+ icon: "fa-arrow-left",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ let data = rationLibObj.resultCache[target.row];
|
|
|
+ $('#rationSearchResult').hide();
|
|
|
+ $(".main-data-side-search", $('#rationSearchResult')).height(0);
|
|
|
+ autoFlashHeight();
|
|
|
+ rationLibObj.refreshSpread();
|
|
|
+ rationLibObj.locateAtRation(data.rationRepId, data.code);
|
|
|
+ }}
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
var showResult = function (result) {
|
|
|
- let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
|
|
|
- rationLibObj.resultSpread = resultSpread;
|
|
|
- rationLibObj.setTagForHint(result);
|
|
|
- SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
|
|
|
- SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet(), result);
|
|
|
-
|
|
|
- resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
|
|
|
+ rationLibObj.resultCache = result;
|
|
|
+ if(!rationLibObj.resultSpread){
|
|
|
+ let resultSpread = SheetDataHelper.createNewSpread($('.main-data-side-search')[0]);
|
|
|
+ rationLibObj.resultSpread = resultSpread;
|
|
|
+ bindContextmenuOpr(resultSpread.getActiveSheet());
|
|
|
+ SheetDataHelper.loadSheetHeader(rationLibObj.sectionRationsSetting, resultSpread.getActiveSheet());
|
|
|
+ resultSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, rationLibObj.onRationSpreadCellDoubleClick);
|
|
|
+ }else {
|
|
|
+ rationLibObj.resultSpread.refresh();
|
|
|
+ }
|
|
|
+ SheetDataHelper.loadSheetData(rationLibObj.sectionRationsSetting, rationLibObj.resultSpread.getActiveSheet(), result);
|
|
|
+ rationLibObj.setTagForHint(rationLibObj.resultSpread.getActiveSheet(), result);
|
|
|
};
|
|
|
CommonAjax.post('/complementaryRation/api/findRation', {'user_id': userID, 'rationRepId': rationLibID, 'keyword': keyword}, function (result) {
|
|
|
//sort
|
|
@@ -472,14 +536,15 @@ $('#rationSearch').click(function () {
|
|
|
else if(a.code < b.code) rst = -1;
|
|
|
return rst;
|
|
|
});
|
|
|
- var resultObj = $('#rationSearchResult'), resultSpread = null;
|
|
|
- resultObj.empty();
|
|
|
- resultObj.append(getResultHtml(result));
|
|
|
- $('a', resultObj).click(function () {
|
|
|
+ var resultObj = $('#rationSearchResult');
|
|
|
+ /*resultObj.empty();
|
|
|
+ resultObj.append(getResultHtml(result));*/
|
|
|
+ $('#rationSearchCount').text(`搜索结果:${result.length.toString()}`);
|
|
|
+ $('a', result).unbind('click');
|
|
|
+ $('a', resultObj).bind('click', function () {
|
|
|
resultObj.hide();
|
|
|
$(".main-data-side-search", resultObj).height(0);
|
|
|
autoFlashHeight();
|
|
|
- //$(".main-data-side-d").height($(window).height() - $(".header").height() - $(".toolsbar").height() - $(".tools-bar-height-d").height() - 202);
|
|
|
rationLibObj.refreshSpread();
|
|
|
});
|
|
|
resultObj.show();
|