|
@@ -492,6 +492,7 @@ $(document).ready(function() {
|
|
|
selectionChanged: function (e, info) {
|
|
|
if (info.newSelections[0].row !== info.oldSelections[0].row) {
|
|
|
posOperationObj.loadCurPosData();
|
|
|
+ posSearch.search($('#pos-keyword').val());
|
|
|
}
|
|
|
},
|
|
|
};
|
|
@@ -659,6 +660,58 @@ $(document).ready(function() {
|
|
|
}
|
|
|
treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
|
|
|
|
|
|
+ const posSearch = (function () {
|
|
|
+ let resultArr = [];
|
|
|
+ const search = function (keyword) {
|
|
|
+ if (keyword && keyword !== '') {
|
|
|
+ resultArr = [];
|
|
|
+ const sortData = posSpread.getActiveSheet().zh_data;
|
|
|
+ if (sortData) {
|
|
|
+ for (let i = 0, iLength = sortData.length; i < iLength; i++) {
|
|
|
+ const sd = sortData[i];
|
|
|
+ if (sd.name && sd.name.indexOf(keyword) > -1) {
|
|
|
+ resultArr.push({index: i, data: sd});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#pos-search-hint').html(' ' + resultArr.length + '个匹配').show();
|
|
|
+ } else {
|
|
|
+ resultArr = [];
|
|
|
+ $('#pos-search-hint').hide();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const locateNext = function () {
|
|
|
+ if (resultArr.length > 0) {
|
|
|
+ const sheet = posSpread.getActiveSheet();
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const curRow = sel ? sel.row : 0;
|
|
|
+ let next = _.find(resultArr, function (d) {
|
|
|
+ return d.index > curRow;
|
|
|
+ });
|
|
|
+ if (!next) next = resultArr[0];
|
|
|
+ if (next.index !== curRow) {
|
|
|
+ sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
|
|
|
+ sheet.showRow(next.index, spreadNS.VerticalPosition.center);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const locatePre = function () {
|
|
|
+ if (resultArr.length > 0) {
|
|
|
+ const sheet = posSpread.getActiveSheet();
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const curRow = sel ? sel.row : 0;
|
|
|
+ let next = _.find(resultArr, function (d) {
|
|
|
+ return d.index < curRow;
|
|
|
+ });
|
|
|
+ if (!next) next = resultArr[resultArr.length - 1];
|
|
|
+ if (next.index !== curRow) {
|
|
|
+ sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
|
|
|
+ sheet.showRow(next.index, spreadNS.VerticalPosition.center);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return {search, locateNext, locatePre};
|
|
|
+ })();
|
|
|
// 台账模式加载部位明细数据
|
|
|
if (checkTzMeasureType()) {
|
|
|
$.divResizer({
|
|
@@ -674,6 +727,15 @@ $(document).ready(function() {
|
|
|
postData('/tender/' + getTenderId() + '/pos', null, function (data) {
|
|
|
pos.loadDatas(data);
|
|
|
});
|
|
|
+ $('#pos-keyword').bind('input propertychange', function () {
|
|
|
+ posSearch.search(this.value);
|
|
|
+ });
|
|
|
+ $('#search-pre-pos').click(function () {
|
|
|
+ posSearch.locatePre();
|
|
|
+ });
|
|
|
+ $('#search-next-pos').click(function () {
|
|
|
+ posSearch.locateNext();
|
|
|
+ });
|
|
|
}
|
|
|
// 绑定部位明细编辑事件
|
|
|
const posOperationObj = {
|
|
@@ -1351,16 +1413,22 @@ $(document).ready(function() {
|
|
|
constructor(obj, spreadSetting) {
|
|
|
const self = this;
|
|
|
this.obj = obj;
|
|
|
- this.url = '/ledger/search';
|
|
|
this.spreadSetting = spreadSetting;
|
|
|
this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
|
|
|
SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
|
|
|
|
|
|
$('#searchLedger', this.obj).bind('click', function () {
|
|
|
- const data = { keyword: $('input', self.obj).val() };
|
|
|
- postData(preUrl + '/ledger/search', data, function (result) {
|
|
|
- SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', result);
|
|
|
- });
|
|
|
+ const keyword = $('input', self.obj).val();
|
|
|
+ this.searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(ledgerSpread.getActiveSheet());
|
|
|
+ for (const node of sortData) {
|
|
|
+ if ((node.code && node.code.indexOf(keyword) > -1) ||
|
|
|
+ node.b_code && node.b_code.indexOf(keyword) > -1 ||
|
|
|
+ node.name && node.name.indexOf(keyword) > -1) {
|
|
|
+ this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
|
|
|
});
|
|
|
this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
|
|
|
const sheet = info.sheet;
|
|
@@ -1370,13 +1438,7 @@ $(document).ready(function() {
|
|
|
const curBills = data[info.row];
|
|
|
if (!curBills) { return }
|
|
|
|
|
|
- const mainSheet = ledgerSpread.getActiveSheet();
|
|
|
- const mainTree = mainSheet.zh_tree;
|
|
|
- mainTree.postData('locate', null, {id: curBills.ledger_id}, function (result) {
|
|
|
- treeOperationObj.refreshTree(mainSheet, result);
|
|
|
- treeOperationObj.refreshOperationValid(mainSheet);
|
|
|
- SpreadJsObj.locateTreeNode(mainSheet, curBills.ledger_id);
|
|
|
- });
|
|
|
+ SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), curBills.ledger_id);
|
|
|
});
|
|
|
}
|
|
|
}
|