|
@@ -641,7 +641,7 @@ $(document).ready(() => {
|
|
|
class ChooseRelaBw {
|
|
|
constructor() {
|
|
|
const self = this;
|
|
|
- this.tree = createNewPathTree('base', {
|
|
|
+ this.tree = createNewPathTree('ledger', {
|
|
|
id: 'ledger_id',
|
|
|
pid: 'ledger_pid',
|
|
|
order: 'order',
|
|
@@ -664,6 +664,23 @@ $(document).ready(() => {
|
|
|
$('#choose-rela-bw').modal('hide');
|
|
|
});
|
|
|
}
|
|
|
+ get locate() {
|
|
|
+ return this._locate;
|
|
|
+ }
|
|
|
+ set locate(value) {
|
|
|
+ if (!this.searchResult || this.searchResult.length === 0) return;
|
|
|
+ this._locate = !value || value >= this.searchResult.length ? 0 : (value < 0 ? this.searchResult.length - 1 : value);
|
|
|
+ SpreadJsObj.locateTreeNode(this.sheet, this.searchResult[this._locate].ledger_id, true);
|
|
|
+ }
|
|
|
+ search(keyword) {
|
|
|
+ this.searchResult = [];
|
|
|
+ for (const node of this.tree.nodes) {
|
|
|
+ const code = node.code || '', name = node.name || '';
|
|
|
+ if (code.indexOf(keyword) >= 0 || name.indexOf(keyword) >= 0) this.searchResult.push(node);
|
|
|
+ }
|
|
|
+ $('#rela-bw-search-result').html(`结果:${this.searchResult.length}`);
|
|
|
+ this.locate = 0;
|
|
|
+ }
|
|
|
initSpread() {
|
|
|
if (this.spread) return;
|
|
|
|
|
@@ -768,6 +785,45 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
|
|
|
+
|
|
|
+ (function (select, sheet) {
|
|
|
+ $(select).click(function () {
|
|
|
+ if (!sheet.zh_tree) return;
|
|
|
+ const tag = $(this).attr('tag');
|
|
|
+ const tree = sheet.zh_tree;
|
|
|
+ setTimeout(() => {
|
|
|
+ showWaitingView();
|
|
|
+ switch (tag) {
|
|
|
+ case "1":
|
|
|
+ case "2":
|
|
|
+ case "3":
|
|
|
+ case "4":
|
|
|
+ case "5":
|
|
|
+ tree.expandByLevel(parseInt(tag));
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ case "last":
|
|
|
+ tree.expandByCustom(() => { return true; });
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ case "leafXmj":
|
|
|
+ tree.expandToLeafXmj();
|
|
|
+ SpreadJsObj.refreshTreeRowVisible(sheet);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ closeWaitingView();
|
|
|
+ }, 100);
|
|
|
+ });
|
|
|
+ })('a[name=showLevel]', this.sheet);
|
|
|
+ $('#rela-bw-search-keyword').change(function () {
|
|
|
+ self.search(this.value);
|
|
|
+ });
|
|
|
+ $('#rela-bw-search-pre').click(function () {
|
|
|
+ self.locate = self.locate - 1;
|
|
|
+ });
|
|
|
+ $('#rela-bw-search-next').click(function () {
|
|
|
+ self.locate = self.locate + 1;
|
|
|
+ });
|
|
|
}
|
|
|
reBind(obj, eventName, fun) {
|
|
|
obj.unbind(eventName);
|