|
@@ -551,8 +551,11 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
selectionChanged: function (e, info) {
|
|
|
- stagePosSpreadObj.loadCurPosData();
|
|
|
- SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
|
|
|
+ if (!info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
|
|
|
+ stagePosSpreadObj.loadCurPosData();
|
|
|
+ SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
|
|
|
+ posSearch.search();
|
|
|
+ }
|
|
|
SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
|
|
|
},
|
|
|
deletePress(sheet) {
|
|
@@ -1227,6 +1230,115 @@ $(document).ready(() => {
|
|
|
}
|
|
|
}
|
|
|
let searchLedger;
|
|
|
+
|
|
|
+ const posSearch = (function () {
|
|
|
+ let resultArr = [];
|
|
|
+ const search = function () {
|
|
|
+ resultArr = [];
|
|
|
+ const keyword = $('#pos-search-keyword').val();
|
|
|
+ const checkOver = $('#pos-over-search')[0].checked;
|
|
|
+ const checkEmpty = $('#pos-empty-search')[0].checked;
|
|
|
+ const sortData = spSpread.getActiveSheet().zh_data;
|
|
|
+ if (checkOver || checkEmpty) {
|
|
|
+ if (sortData) {
|
|
|
+ for (let i = 0, iLength = sortData.length; i < iLength; i++) {
|
|
|
+ const sd = sortData[i];
|
|
|
+ let match = false;
|
|
|
+ if (checkOver) {
|
|
|
+ if (sd.end_gather_qty) {
|
|
|
+ if (!sd.quantity || Math.abs(sd.end_gather_qty) > Math.abs(sd.quantity)) match = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (checkEmpty) {
|
|
|
+ if (sd.quantity) {
|
|
|
+ if (!sd.end_gather_qty || checkZero(sd.end_gather_qty)) match = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (keyword && keyword !== '' && sd.name && sd.name.indexOf(keyword) === -1) match = false;
|
|
|
+ if (match) {
|
|
|
+ resultArr.push({index: i, data: sd});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (keyword && keyword !== '') {
|
|
|
+ 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-result').html('结果:' + resultArr.length);
|
|
|
+ };
|
|
|
+ const searchAndLocate = function () {
|
|
|
+ search();
|
|
|
+ if (resultArr.length > 0) {
|
|
|
+ const sheet = spSpread.getActiveSheet();
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const curRow = sel ? sel.row : 0;
|
|
|
+ const pos = resultArr[0];
|
|
|
+ if (pos.index !== curRow) {
|
|
|
+ sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
|
|
|
+ sheet.showRow(next.index, spreadNS.VerticalPosition.center);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const locateNext = function () {
|
|
|
+ if (resultArr.length > 0) {
|
|
|
+ const sheet = spSpread.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 = spSpread.getActiveSheet();
|
|
|
+ const sel = sheet.getSelections()[0];
|
|
|
+ const curRow = sel ? sel.row : 0;
|
|
|
+ let next = _.findLast(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, searchAndLocate, locateNext, locatePre};
|
|
|
+ })();
|
|
|
+ $('#pos-search-keyword').bind('keydown', function(e){
|
|
|
+ if (e.keyCode == 13) posSearch.searchAndLocate();
|
|
|
+ });
|
|
|
+ $('#pos-empty-search').click(function () {
|
|
|
+ if (this.checked) {
|
|
|
+ $('[for=' + this.id +']').addClass('text-warning');
|
|
|
+ } else {
|
|
|
+ $('[for=' + this.id +']').removeClass('text-warning');
|
|
|
+ }
|
|
|
+ posSearch.searchAndLocate();
|
|
|
+ });
|
|
|
+ $('#pos-over-search').click(function () {
|
|
|
+ if (this.checked) {
|
|
|
+ $('[for=' + this.id +']').addClass('text-danger');
|
|
|
+ } else {
|
|
|
+ $('[for=' + this.id +']').removeClass('text-danger');
|
|
|
+ }
|
|
|
+ posSearch.searchAndLocate();
|
|
|
+ });
|
|
|
+ $('#pos-search-next').click(() => {posSearch.locateNext()});
|
|
|
+ $('#pos-search-pre').click(() => {posSearch.locatePre()});
|
|
|
+
|
|
|
$.divResizer({
|
|
|
select: '#right-spr',
|
|
|
callback: function () {
|