|
@@ -275,12 +275,27 @@ const showSideTools = function (show) {
|
|
|
if (!setting.searchRangeStr) setting.searchRangeStr = '项目节编号/清单编号/名称';
|
|
|
const resultId = setting.id + '-search-result';
|
|
|
const obj = $(setting.selector);
|
|
|
+ let filter = [];
|
|
|
+ if (setting.searchOver || setting.searchEmpty) {
|
|
|
+ filter.push('<select class="form-control form-control-sm" id="search-filter">');
|
|
|
+ filter.push('<option value="">台账</option>');
|
|
|
+ if (setting.searchOver) filter.push('<option value="over">超计</option>');
|
|
|
+ if (setting.searchEmpty) filter.push('<option value="less">漏计</option>');
|
|
|
+ filter.push('</select>');
|
|
|
+ // filter.push('<div class="input-group-prepend">');
|
|
|
+ // filter.push('<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">台帐</button>');
|
|
|
+ // filter.push('<div class="dropdown-menu">');
|
|
|
+ // filter.push('<a class="dropdown-item" href="javascripty: void(0)" id="search-bills">台账</a>');
|
|
|
+ // filter.push('<a class="dropdown-item" href="javascripty: void(0)" id="search-over">超计</a>');
|
|
|
+ // filter.push('<a class="dropdown-item" href="javascripty: void(0)" id="search-less">漏计</a>');
|
|
|
+ // filter.push('</div>');
|
|
|
+ // filter.push('</div>');
|
|
|
+ }
|
|
|
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' : '') +
|
|
|
+ filter.join('') +
|
|
|
' </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' +
|
|
@@ -297,6 +312,16 @@ const showSideTools = function (show) {
|
|
|
SpreadJsObj.forbiddenSpreadContextMenu('#' + resultId, resultSpread);
|
|
|
const searchSheet = setting.searchSpread.getActiveSheet();
|
|
|
let searchResult = [];
|
|
|
+ const search = function () {
|
|
|
+ const filter = $('#search-filter').val();
|
|
|
+ if (filter === 'over') {
|
|
|
+ searchOver();
|
|
|
+ } else if (filter === 'less') {
|
|
|
+ searchLess();
|
|
|
+ } else {
|
|
|
+ searchBills();
|
|
|
+ }
|
|
|
+ };
|
|
|
const searchBills = function () {
|
|
|
const keyword = $('#searchKeyword', obj).val();
|
|
|
searchResult = [];
|
|
@@ -320,42 +345,60 @@ const showSideTools = function (show) {
|
|
|
}
|
|
|
};
|
|
|
const searchOver = function () {
|
|
|
+ const keyword = $('#searchKeyword', obj).val();
|
|
|
searchResult = [];
|
|
|
const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
for (const node of sortData) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
|
if (setting.checkOver && setting.checkOver(node)) {
|
|
|
- const data = JSON.parse(JSON.stringify(node));
|
|
|
- data.visible = true;
|
|
|
- searchResult.push(data);
|
|
|
+ if (!keyword ||
|
|
|
+ (node.code && node.code.indexOf(keyword) > -1) ||
|
|
|
+ (node.b_code && node.b_code.indexOf(keyword) > -1) ||
|
|
|
+ (node.name && node.name.indexOf(keyword) > -1)) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
calculateCompletePercent(searchResult);
|
|
|
SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
};
|
|
|
const searchEmpty = function () {
|
|
|
+ const keyword = $('#searchKeyword', obj).val();
|
|
|
searchResult = [];
|
|
|
const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
for (const node of sortData) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
|
if (setting.checkEmpty && setting.checkEmpty(node)) {
|
|
|
- const data = JSON.parse(JSON.stringify(node));
|
|
|
- data.visible = true;
|
|
|
- searchResult.push(data);
|
|
|
+ if (!keyword ||
|
|
|
+ (node.code && node.code.indexOf(keyword) > -1) ||
|
|
|
+ (node.b_code && node.b_code.indexOf(keyword) > -1) ||
|
|
|
+ (node.name && node.name.indexOf(keyword) > -1)) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
calculateCompletePercent(searchResult);
|
|
|
SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
|
|
|
};
|
|
|
const searchLess = function () {
|
|
|
+ const keyword = $('#searchKeyword', obj).val();
|
|
|
searchResult = [];
|
|
|
const sortData = SpreadJsObj.getSortData(searchSheet);
|
|
|
for (const node of sortData) {
|
|
|
if (node.children && node.children.length > 0) continue;
|
|
|
if (setting.checkLess && setting.checkLess(node)) {
|
|
|
- const data = JSON.parse(JSON.stringify(node));
|
|
|
- data.visible = true;
|
|
|
- searchResult.push(data);
|
|
|
+ if (!keyword ||
|
|
|
+ (node.code && node.code.indexOf(keyword) > -1) ||
|
|
|
+ (node.b_code && node.b_code.indexOf(keyword) > -1) ||
|
|
|
+ (node.name && node.name.indexOf(keyword) > -1)) {
|
|
|
+ const data = JSON.parse(JSON.stringify(node));
|
|
|
+ data.visible = true;
|
|
|
+ searchResult.push(data);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
calculateCompletePercent(searchResult);
|
|
@@ -363,11 +406,9 @@ const showSideTools = function (show) {
|
|
|
};
|
|
|
|
|
|
$('input', obj).bind('keydown', function (e) {
|
|
|
- if (e.keyCode == 13) searchBills();
|
|
|
+ if (e.keyCode == 13) search();
|
|
|
});
|
|
|
- $('button', obj).bind('click', () => {searchBills()});
|
|
|
- $('#over', obj).bind('change', () => {searchOver()});
|
|
|
- $('#empty', obj).bind('change', () => {searchLess()});
|
|
|
+ $('button', obj).bind('click', () => {search()});
|
|
|
resultSpread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
|
|
|
const sheet = info.sheet;
|
|
|
const data = sheet.zh_data;
|