|
@@ -1,7 +1,7 @@
|
|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
- * 台账搜索相关(多个页面均使用:台账分解、台账审批、台账修订)
|
|
|
+ * 台账搜索相关(多个页面均使用:台账分解、台账审批、台账修订、部位台账、期-部位台账)
|
|
|
*
|
|
|
* 搜索基于spreadjs,请放在gc.spread.sheets.all.10.0.1.min.js/spreadjs_zh.js之后
|
|
|
*
|
|
@@ -105,7 +105,7 @@
|
|
|
searchObj.locateNext();
|
|
|
});
|
|
|
return searchObj;
|
|
|
- }
|
|
|
+ };
|
|
|
$.billsSearch = function (setting) {
|
|
|
if (!setting.selector || !setting.searchSpread || !setting.resultSpreadSetting) return;
|
|
|
if (!setting.searchRangeStr) setting.searchRangeStr = '项目节编号/清单编号/名称';
|
|
@@ -114,6 +114,10 @@
|
|
|
obj.html(
|
|
|
' <div class="sjs-bar">\n' +
|
|
|
' <div class="input-group input-group-sm pb-1">\n' +
|
|
|
+ ' <div class="input-group-prepend">\n' +
|
|
|
+ (setting.searchOver ? ' <div class="input-group-text"><input type="radio" name="searchType" id="over"> 超计</div>\n' : '') +
|
|
|
+ (setting.searchEmpty ? ' <div class="input-group-text"><input type="radio" name="searchType" id="empty"> 漏计</div>\n' : '') +
|
|
|
+ ' </div>' +
|
|
|
' <input id="searchKeyword" type="text" class="form-control" placeholder="可查找 ' + setting.searchRangeStr + '" aria-label="Recipient\'s username" aria-describedby="button-addon2">\n' +
|
|
|
' <div class="input-group-append">\n' +
|
|
|
' <button class="btn btn-outline-secondary" type="button"">搜索</button>\n' +
|
|
@@ -130,7 +134,7 @@
|
|
|
const searchSheet = setting.searchSpread.getActiveSheet();
|
|
|
let searchResult = [];
|
|
|
const searchBills = function () {
|
|
|
- const keyword = $('input', obj).val();
|
|
|
+ const keyword = $('#searchKeyword', obj).val();
|
|
|
searchResult = [];
|
|
|
const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
for (const node of sortData) {
|
|
@@ -144,11 +148,86 @@
|
|
|
}
|
|
|
SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
};
|
|
|
+ const calculateCompletePercent = function (searchResult) {
|
|
|
+ if (!searchResult) return;
|
|
|
+ for (const sr of searchResult) {
|
|
|
+ const base = ZhCalc.add(sr.total_price, sr.end_qc_tp);
|
|
|
+ sr.complete_percent = base !== 0 ? ZhCalc.mul(ZhCalc.div(sr.end_gather_tp, base), 100, 2) : 0;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const searchOver = function () {
|
|
|
+ searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
+ for (const node of sortData) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.end_gather_qty) {
|
|
|
+ if (!node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty))) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ } else if (node.end_gather_tp) {
|
|
|
+ if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp))) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ calculateCompletePercent(searchResult);
|
|
|
+ SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
+ };
|
|
|
+ const searchEmpty = function () {
|
|
|
+ searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
+ for (const node of sortData) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.quantity) {
|
|
|
+ if (!node.end_gather_qty || checkZero(node.end_gather_qty)) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ } else if (node.total_price) {
|
|
|
+ if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ calculateCompletePercent(searchResult);
|
|
|
+ SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
+ };
|
|
|
+ const searchLess = function () {
|
|
|
+ searchResult = [];
|
|
|
+ const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
+ for (const node of sortData) {
|
|
|
+ if (node.children && node.children.length > 0) continue;
|
|
|
+ if (node.quantity) {
|
|
|
+ if (ZhCalc.sub(ZhCalc.add(node.quantity, node.end_qc_qty), node.end_gather_qty) > 0) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ } else if (node.total_price) {
|
|
|
+ if (ZhCalc.sub(ZhCalc.add(node.total_price, node.end_qc_tp), node.end_gather_tp) > 0) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ calculateCompletePercent(searchResult);
|
|
|
+ SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
+ }
|
|
|
|
|
|
$('input', this.obj).bind('keydown', function (e) {
|
|
|
if (e.keyCode == 13) searchBills();
|
|
|
});
|
|
|
$('button', this.obj).bind('click', () => {searchBills()});
|
|
|
+ $('#over', this.obj).bind('change', () => {searchOver()});
|
|
|
+ $('#empty', this.obj).bind('change', () => {searchLess()});
|
|
|
resultSpread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
|
|
|
const sheet = info.sheet;
|
|
|
const data = sheet.zh_data;
|
|
@@ -163,5 +242,5 @@
|
|
|
}
|
|
|
});
|
|
|
return {spread: resultSpread};
|
|
|
- }
|
|
|
+ };
|
|
|
})(jQuery);
|