revise.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  1. 'use strict';
  2. /**
  3. * 台账修订页面js
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const ckBillsSpread = window.location.pathname + '-billsSelect';
  10. function transExpr(expr) {
  11. return $.trim(expr).replace('\t', '').replace('=', '').replace('%', '/100');
  12. }
  13. $(document).ready(() => {
  14. let stdXmj, stdGcl, searchLedger;
  15. autoFlashHeight();
  16. // 初始化spread
  17. const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
  18. const billsSheet = billsSpread.getActiveSheet();
  19. SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
  20. const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
  21. const posSheet = posSpread.getActiveSheet();
  22. SpreadJsObj.initSheet(posSheet, posSpreadSetting);
  23. const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
  24. // 初始化 节点树结构
  25. const treeSetting = {
  26. id: 'ledger_id',
  27. pid: 'ledger_pid',
  28. order: 'order',
  29. level: 'level',
  30. rootId: -1,
  31. keys: ['id', 'tender_id', 'ledger_id'],
  32. calcFields: ['sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price'],
  33. };
  34. if (!isTz) {
  35. treeSetting.calcFields.push('deal_tp');
  36. }
  37. treeSetting.calcFun = function (node) {
  38. node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
  39. };
  40. const billsTree = createNewPathTree('revise', treeSetting);
  41. billsTree.loadDatas(billsData);
  42. treeCalc.calculateAll(billsTree);
  43. // 加载至spread
  44. SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, billsTree);
  45. SpreadJsObj.loadTopAndSelect(billsSheet, ckBillsSpread);
  46. // 初始化 计量单元
  47. const pos = new PosData({ id: 'id', ledgerId: 'lid' });
  48. pos.loadDatas(posData);
  49. const billsTreeSpreadObj = {
  50. loadExprToInput(sheet) {
  51. const sel = sheet.getSelections()[0];
  52. const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
  53. if (col.type === 'Number') {
  54. const data = SpreadJsObj.getSelectObject(sheet);
  55. if (data) {
  56. $('#bills-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
  57. .attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
  58. } else {
  59. $('#bills-expr').val('').attr('readOnly', true);
  60. }
  61. } else {
  62. $('#bills-expr').val('').attr('readOnly', true);
  63. }
  64. },
  65. getDefaultSelectInfo: function (sheet) {
  66. const tree = sheet.zh_tree;
  67. if (!tree) return;
  68. const sel = sheet.getSelections()[0];
  69. const node = sheet.zh_tree.nodes[sel.row];
  70. if (!node) return;
  71. let count = 1;
  72. if (sel.rowCount > 1) {
  73. for (let r = 1; r < sel.rowCount; r++) {
  74. const rNode = sheet.zh_tree.nodes[sel.row + r];
  75. if (rNode.level > node.level) continue;
  76. if ((rNode.level < node.level) || (rNode.level === node.level && rNode.pid !== node.pid)) {
  77. toastr.warning('请选择同一节点下的节点,进行该操作');
  78. return;
  79. }
  80. count += 1;
  81. }
  82. }
  83. return [tree, node, count];
  84. },
  85. /**
  86. * 刷新顶部按钮是否可用
  87. * @param sheet
  88. * @param selections
  89. */
  90. refreshOperationValid: function (sheet, selection) {
  91. const setObjEnable = function (obj, enable) {
  92. if (enable) {
  93. obj.removeClass('disabled');
  94. } else {
  95. obj.addClass('disabled');
  96. }
  97. };
  98. const invalidAll = function () {
  99. setObjEnable($('a[type=add]'), false);
  100. setObjEnable($('a[type=delete]'), false);
  101. setObjEnable($('a[type=up-move]'), false);
  102. setObjEnable($('a[type=down-move]'), false);
  103. setObjEnable($('a[type=up-level]'), false);
  104. setObjEnable($('a[type=down-level]'), false);
  105. };
  106. const sel = selection ? selection[0] : sheet.getSelections()[0];
  107. const row = sel ? sel.row : -1;
  108. const tree = sheet.zh_tree;
  109. if (!tree) {
  110. invalidAll();
  111. return;
  112. }
  113. const first = sheet.zh_tree.nodes[row];
  114. if (!first) {
  115. invalidAll();
  116. return;
  117. }
  118. let last = first, sameParent = true, nodeUsed = first.used;
  119. if (sel.rowCount > 1 && first) {
  120. for (let r = 1; r < sel.rowCount; r++) {
  121. const rNode = tree.nodes[sel.row + r];
  122. if (!rNode) {
  123. sameParent = false;
  124. break;
  125. }
  126. nodeUsed = nodeUsed || rNode.used;
  127. if (rNode.level > first.level) continue;
  128. if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
  129. sameParent = false;
  130. break;
  131. }
  132. last = rNode;
  133. }
  134. }
  135. const preNode = tree.getPreSiblingNode(first);
  136. const valid = !sheet.zh_setting.readOnly;
  137. setObjEnable($('a[type=add]'), valid && first && first.level > 1);
  138. setObjEnable($('a[type=delete]'), valid && first && sameParent && first.level > 1 && !nodeUsed);
  139. setObjEnable($('a[type=up-move]'), valid && first && sameParent && first.level > 1 && preNode);
  140. setObjEnable($('a[type=down-move]'), valid && first && sameParent && first.level > 1 && !tree.isLastSibling(last));
  141. if (isTz) {
  142. const posRange = last ? pos.getLedgerPos(last.id) : [];
  143. setObjEnable($('a[type=up-level]'), valid && first && sameParent && tree.getParent(first) && !nodeUsed
  144. && first.level > 2 && ((!posRange || posRange.length === 0) || tree.isLastSibling(last)));
  145. const preNodePosRange = preNode ? pos.getLedgerPos(preNode.id) : [];
  146. setObjEnable($('a[type=down-level]'), valid && first && sameParent && !nodeUsed
  147. && first.level > 1 && preNode && (!preNodePosRange || preNodePosRange.length === 0));
  148. } else {
  149. setObjEnable($('#up-level'), valid && first && sameParent && first.level > 2 && tree.getParent(first));
  150. setObjEnable($('#down-level'), valid && first && sameParent && first.level > 1 && preNode);
  151. }
  152. setObjEnable($('#cut'), valid);
  153. setObjEnable($('#paste'), valid);
  154. },
  155. /**
  156. *
  157. * @param sheet
  158. * @param data
  159. */
  160. refreshTree: function (sheet, data) {
  161. SpreadJsObj.massOperationSheet(sheet, function () {
  162. const tree = sheet.zh_tree;
  163. // 处理删除
  164. if (data.delete) {
  165. data.delete.sort(function (a, b) {
  166. return b.deleteIndex - a.deleteIndex;
  167. });
  168. for (const d of data.delete) {
  169. sheet.deleteRows(d.deleteIndex, 1);
  170. }
  171. }
  172. // 处理新增
  173. if (data.create) {
  174. const newNodes = data.create;
  175. if (newNodes) {
  176. newNodes.sort(function (a, b) {
  177. return a.index - b.index;
  178. });
  179. for (const node of newNodes) {
  180. sheet.addRows(node.index, 1);
  181. SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
  182. }
  183. }
  184. }
  185. // 处理更新
  186. if (data.update) {
  187. const rows = [];
  188. for (const u of data.update) {
  189. rows.push(tree.nodes.indexOf(u));
  190. }
  191. SpreadJsObj.reLoadRowsData(sheet, rows);
  192. }
  193. // 处理展开
  194. if (data.expand) {
  195. const expanded = [];
  196. for (const e of data.expand) {
  197. if (expanded.indexOf(e) === -1) {
  198. const posterity = tree.getPosterity(e);
  199. for (const p of posterity) {
  200. sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
  201. expanded.push(p);
  202. }
  203. }
  204. }
  205. }
  206. });
  207. },
  208. selectionChanged: function (e, info) {
  209. if (info.newSelections[0].row !== info.oldSelections[0].row) {
  210. billsTreeSpreadObj.refreshOperationValid(info.sheet);
  211. posSpreadObj.loadCurPosData();
  212. SpreadJsObj.saveTopAndSelect(billsSheet, ckBillsSpread);
  213. posSearch.search($('#pos-keyword').val());
  214. }
  215. billsTreeSpreadObj.loadExprToInput(info.sheet);
  216. },
  217. /**
  218. * 新增节点
  219. * @param spread
  220. */
  221. baseOpr: function (sheet, type) {
  222. const self = this;
  223. const [tree, node, count] = this.getDefaultSelectInfo(sheet);
  224. if (!tree || !node || !count) return;
  225. if (type === 'delete') {
  226. const parent = tree.getParent(node);
  227. const children = parent ? parent.children : tree.children;
  228. const index = children.indexOf(node);
  229. for (let i = 0; i < count; i++) {
  230. const child = children[i+index];
  231. if (tree.checkNodeUsed(child, pos)) {
  232. toastr.warning('选中的节点已计量,不可删除');
  233. return;
  234. }
  235. }
  236. } else if (type === 'up-level') {
  237. const parent = tree.getParent(node);
  238. const children = parent ? parent.children : tree.children;
  239. const index = children.indexOf(node);
  240. for (let i = index; i < children.length; i++) {
  241. const child = children[index];
  242. if (tree.checkNodeUsed(child, pos)) {
  243. if (i >= index + count) {
  244. toastr.warning('其后节点已计量,选中的节点不可升级');
  245. } else {
  246. toastr.warning('选中的节点已计量,不可升级');
  247. }
  248. return;
  249. }
  250. }
  251. } else if (type === 'down-level') {
  252. const parent = tree.getParent(node);
  253. const children = parent ? parent.children : tree.children;
  254. const index = children.indexOf(node);
  255. for (let i = 0; i < count; i++) {
  256. const child = children[i+index];
  257. if (tree.checkNodeUsed(child, pos)) {
  258. toastr.warning('选中的节点已计量,不可降级');
  259. return;
  260. }
  261. }
  262. }
  263. postData(window.location.pathname + '/update', {
  264. postType: type,
  265. postData: {
  266. id: node.ledger_id,
  267. count: count,
  268. }
  269. }, function (result) {
  270. const refreshData = tree.loadPostData(result);
  271. self.refreshTree(sheet, refreshData);
  272. if (type === 'delete') {
  273. const sel = sheet.getSelections()[0];
  274. if (sel) {
  275. sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
  276. }
  277. } else if (['up-move', 'down-move'].indexOf(type) > -1) {
  278. const sel = sheet.getSelections()[0];
  279. if (sel) {
  280. sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
  281. }
  282. } else if (type === 'add') {
  283. const sel = sheet.getSelections()[0];
  284. if (sel) {
  285. sheet.setSelection(tree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  286. }
  287. }
  288. self.refreshOperationValid(sheet);
  289. });
  290. },
  291. /**
  292. * 编辑单元格响应事件
  293. * @param {Object} e
  294. * @param {Object} info
  295. */
  296. editEnded: function (e, info) {
  297. if (info.sheet.zh_setting) {
  298. const col = info.sheet.zh_setting.cols[info.col];
  299. const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
  300. const node = sortData[info.row];
  301. const data = {
  302. id: node.id,
  303. tender_id: node.tender_id,
  304. ledger_id: node.ledger_id
  305. };
  306. // 未改变值则不提交
  307. const orgValue = node[col.field];
  308. const newValue = trimInvalidChar(info.editingText);
  309. if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
  310. return;
  311. }
  312. // 台账模式,检查计量单元相关
  313. if (isTz) {
  314. if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
  315. col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
  316. col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
  317. if (!node.children || node.children.length ===0) {
  318. const lPos = pos.getLedgerPos(node.id);
  319. if (lPos && lPos.length > 0) {
  320. toastr.error('清单含有计量单元,不可修改施工图复核数量');
  321. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  322. return;
  323. }
  324. }
  325. }
  326. if (col.field === 'b_code' && (newValue === '' || !newValue)) {
  327. const lPos = pos.getLedgerPos(node.id);
  328. if (lPos && lPos.length > 0) {
  329. toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
  330. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  331. return;
  332. }
  333. }
  334. }
  335. // 获取更新数据
  336. if (info.editingText) {
  337. const text = newValue;
  338. if (node.used && (col.field === 'code' || col.field ==='b_code') && orgValue !== '' && text === '') {
  339. toastr.error('节点已计量,请勿删除编号');
  340. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  341. return;
  342. }
  343. if (col.type === 'Number') {
  344. const num = _.toNumber(text);
  345. if (_.isFinite(num)) {
  346. data[col.field] = num;
  347. } else {
  348. try {
  349. data[col.field] = math.evaluate(transExpr(text));
  350. } catch(err) {
  351. toastr.error('输入的表达式非法');
  352. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  353. return;
  354. }
  355. }
  356. } else {
  357. data[col.field] = text;
  358. }
  359. } else {
  360. if (node.used && (col.field === 'code' || col.field ==='b_code') && orgValue !== '') {
  361. toastr.error('节点已计量,请勿删除编号');
  362. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  363. return;
  364. }
  365. data[col.field] = null;
  366. }
  367. // 更新至服务器
  368. postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
  369. const refreshNode = billsTree.loadPostData(result);
  370. billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
  371. });
  372. }
  373. },
  374. clipboardPasting: function (e, info) {
  375. if (info.sheet.zh_setting) {
  376. const range = info.cellRange;
  377. for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
  378. const node = info.sheet.zh_tree.nodes[iRow];
  379. if (info.sheet.zh_tree.checkNodeUsed(node, pos)) {
  380. toastr.warning('"' + node.code + node.b_code + ' ' + node.name +'"已计量,请勿修改');
  381. info.cancel = true;
  382. return;
  383. }
  384. }
  385. }
  386. },
  387. clipboardPasted: function (e, info) {
  388. const hint = {
  389. usedUp: {type: 'error', msg: '节点已计量,不可修改单价'},
  390. usedCode: {type: 'error', msg: '节点已计量,编号不可修改为空值'},
  391. invalidExpr: {type: 'error', msg: '粘贴的表达式非法'},
  392. posCode: {type: 'error', msg: '清单含有计量单元,请先删除计量单元,再修改清单编号为空'},
  393. posQty: {type: 'error', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可修改'},
  394. };
  395. const tree = info.sheet.zh_tree;
  396. if (!tree) { return; }
  397. const sortData = info.sheet.zh_tree.nodes;
  398. const datas = [], filterNodes = [];
  399. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
  400. let bPaste = false;
  401. const curRow = info.cellRange.row + iRow;
  402. const node = sortData[curRow];
  403. if (node) {
  404. const data = info.sheet.zh_tree.getNodeKeyData(node);
  405. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  406. const curCol = info.cellRange.col + iCol;
  407. const colSetting = info.sheet.zh_setting.cols[curCol];
  408. const value = trimInvalidChar(info.sheet.getText(curRow, curCol));
  409. const lPos = pos.getLedgerPos(node.id);
  410. if (lPos && lPos.length > 0) {
  411. if (value === '' && colSetting.field === 'b_code') {
  412. toastMessageUniq(hint.posCode);
  413. continue;
  414. }
  415. if (colSetting.field === 'sgfh_qty' || colSetting.field === 'sgfh_tp' ||
  416. colSetting.field === 'sjcl_qty' || colSetting.field === 'sjcl_tp' ||
  417. colSetting.field === 'qtcl_qty' || colSetting.field === 'qtcl_tp') {
  418. toastMessageUniq(hint.posQty);
  419. continue;
  420. }
  421. }
  422. if (node.used && col.field === 'unit_price') {
  423. toastMessageUniq (hint.usedUp);
  424. continue;
  425. }
  426. if (colSetting.type === 'Number') {
  427. const num = _.toNumber(value);
  428. if (num) {
  429. data[colSetting.field] = num;
  430. } else {
  431. try {
  432. data[colSetting.field] = math.evaluate(transExpr(value));
  433. } catch (err) {
  434. toastMessageUniq(hint.invalidExpr);
  435. continue;
  436. }
  437. }
  438. } else {
  439. if (node.used && (col.field === 'code' || col.field ==='b_code')
  440. && data[colSetting.field] !== '' && value === '') {
  441. toastMessageUniq(hint.usedCode);
  442. continue;
  443. }
  444. data[colSetting.field] = value;
  445. }
  446. bPaste = true;
  447. }
  448. if (bPaste) {
  449. datas.push(data);
  450. } else {
  451. filterNodes.push(node);
  452. }
  453. }
  454. }
  455. if (datas.length > 0) {
  456. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  457. const refreshNode = tree.loadPostData(result);
  458. if (refreshNode.update) {
  459. refreshNode.update = refreshNode.update.concat(filterNodes);
  460. }
  461. billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
  462. }, function () {
  463. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  464. });
  465. } else {
  466. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  467. }
  468. },
  469. deletePress: function (sheet) {
  470. if (!sheet.zh_setting) return;
  471. const sel = sheet.getSelections()[0], datas = [];
  472. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  473. const node = sheet.zh_tree.nodes[iRow];
  474. if (sheet.zh_tree.checkNodeUsed(node, pos)) {
  475. toastr.warning('"' + node.code + node.b_code + ' ' + node.name +'"已计量,请勿修改');
  476. return;
  477. }
  478. const data = sheet.zh_tree.getNodeKeyData(node);
  479. for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
  480. const col = sheet.zh_setting.cols[iCol];
  481. data[col.field] = null;
  482. }
  483. datas.push(data);
  484. }
  485. if (datas.length > 0) {
  486. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  487. const refreshNode = sheet.zh_tree.loadPostData(result);
  488. billsTreeSpreadObj.refreshTree(sheet, refreshNode);
  489. });
  490. }
  491. },
  492. pasteBlock: function (spread, copyInfo) {
  493. const self = this;
  494. const sheet = spread.getActiveSheet();
  495. const [tree, node] = this.getDefaultSelectInfo(spread.getActiveSheet());
  496. postData(window.location.pathname + '/update', {
  497. postType: 'paste-block',
  498. postData: {
  499. id: tree.getNodeKey(node),
  500. tid: copyInfo.tid,
  501. block: copyInfo.block,
  502. }
  503. }, function (data) {
  504. pos.updateDatas(data.pos);
  505. const result = tree.loadPostData(data.ledger);
  506. self.refreshTree(sheet, result);
  507. const sel = sheet.getSelections()[0];
  508. if (sel) {
  509. sheet.setSelection(tree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  510. }
  511. self.refreshOperationValid(sheet);
  512. removeLocalCache(copyBlockTag);
  513. }, null, true);
  514. },
  515. topRowChanged: function (e, info) {
  516. SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
  517. },
  518. editStarting(e, info) {
  519. if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
  520. const col = info.sheet.zh_setting.cols[info.col];
  521. const node = info.sheet.zh_tree.nodes[info.row];
  522. switch (col.field) {
  523. case 'unit_price':
  524. info.cancel = (node.children && node.children.length > 0) || node.used;
  525. break;
  526. case 'sgfh_qty':
  527. case 'sgfh_tp':
  528. case 'sjcl_qty':
  529. case 'sjcl_tp':
  530. case 'qtcl_qty':
  531. case 'qtcl_tp':
  532. case 'deal_qty':
  533. case 'deal_tp':
  534. info.cancel = (node.children && node.children.length > 0);
  535. break;
  536. case 'dgn_qty1':
  537. case 'dgn_qty2':
  538. info.cancel = !_.isEmpty(node.b_code);
  539. break;
  540. }
  541. }
  542. };
  543. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  544. billsTreeSpreadObj.loadExprToInput(billsSheet);
  545. billsSpread.bind(spreadNS.Events.SelectionChanged, billsTreeSpreadObj.selectionChanged);
  546. billsSpread.bind(spreadNS.Events.topRowChanged, billsTreeSpreadObj.topRowChanged);
  547. if (!readOnly) {
  548. // 增删上下移升降级
  549. $('a[name="base-opr"]').click(function () {
  550. billsTreeSpreadObj.baseOpr(billsSheet, this.getAttribute('type'));
  551. });
  552. $('#bills-expr').bind('change mouseleave', function () {
  553. if (this.readOnly) return;
  554. const expr = $(this);
  555. const select = SpreadJsObj.getSelectObject(billsSheet);
  556. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
  557. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  558. const data = {
  559. id: select.id,
  560. tender_id: select.tender_id,
  561. ledger_id: select.ledger_id
  562. };
  563. const num = _.toNumber(newValue);
  564. if (num) {
  565. data[field] = num;
  566. } else {
  567. try {
  568. data[field] = math.evaluate(transExpr(newValue));
  569. } catch (err) {
  570. toastr.error('输入的表达式非法');
  571. return;
  572. }
  573. }
  574. // 更新至服务器
  575. postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
  576. const refreshNode = billsTree.loadPostData(result);
  577. expr.val(select[field]);
  578. billsTreeSpreadObj.refreshTree(billsSheet, refreshNode);
  579. });
  580. });
  581. billsSpread.bind(spreadNS.Events.EditStarting, billsTreeSpreadObj.editStarting);
  582. billsSpread.bind(spreadNS.Events.EditEnded, billsTreeSpreadObj.editEnded);
  583. billsSpread.bind(spreadNS.Events.ClipboardPasting, billsTreeSpreadObj.clipboardPasting);
  584. billsSpread.bind(spreadNS.Events.ClipboardPasted, billsTreeSpreadObj.clipboardPasted);
  585. SpreadJsObj.addDeleteBind(billsSpread, billsTreeSpreadObj.deletePress);
  586. let batchInsertObj;
  587. // 右键菜单
  588. $.contextMenu({
  589. selector: '#bills-spread',
  590. build: function ($trigger, e) {
  591. const target = SpreadJsObj.safeRightClickSelection($trigger, e, billsSpread);
  592. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  593. },
  594. items: {
  595. 'create': {
  596. name: '新增',
  597. icon: 'fa-sign-in',
  598. callback: function (key, opt) {
  599. billsTreeSpreadObj.baseOpr(billsSheet, 'add');
  600. },
  601. disabled: function (key, opt) {
  602. const sheet = billsSheet;
  603. const selection = sheet.getSelections();
  604. const sel = selection ? selection[0] : sheet.getSelections()[0];
  605. const row = sel ? sel.row : -1;
  606. const tree = sheet.zh_tree;
  607. if (!tree) return true;
  608. const first = sheet.zh_tree.nodes[row];
  609. const valid = !sheet.zh_setting.readOnly;
  610. return !(valid && first && first.level > 1);
  611. }
  612. },
  613. 'delete': {
  614. name: '删除',
  615. icon: 'fa-remove',
  616. callback: function (key, opt) {
  617. billsTreeSpreadObj.baseOpr(billsSheet, 'delete');
  618. },
  619. disabled: function (key, opt) {
  620. const sheet = billsSheet;
  621. const selection = sheet.getSelections();
  622. const sel = selection ? selection[0] : sheet.getSelections()[0];
  623. const row = sel ? sel.row : -1;
  624. const tree = sheet.zh_tree;
  625. if (!tree) return true;
  626. const first = sheet.zh_tree.nodes[row];
  627. let last = first, sameParent = true, nodeUsed = first.used;
  628. if (sel.rowCount > 1 && first) {
  629. for (let r = 1; r < sel.rowCount; r++) {
  630. const rNode = tree.nodes[sel.row + r];
  631. if (!rNode) {
  632. sameParent = false;
  633. break;
  634. }
  635. nodeUsed = nodeUsed || rNode.used;
  636. if (rNode.level > first.level) continue;
  637. if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
  638. sameParent = false;
  639. break;
  640. }
  641. last = rNode;
  642. }
  643. }
  644. const valid = !sheet.zh_setting.readOnly;
  645. return !(valid && first && sameParent && !(first.level === 1 && first.node_type) && !nodeUsed);
  646. }
  647. },
  648. 'batchInsertBillsPos': {
  649. name: '批量插入节点-部位',
  650. icon: 'fa-sign-in',
  651. disabled: function (key, opt) {
  652. const select = SpreadJsObj.getSelectObject(billsSheet);
  653. if (select) {
  654. if (select.code && select.code !== '') {
  655. return !billsTree.isLeafXmj(select);
  656. } else {
  657. const parent = billsTree.getParent(select);
  658. return !(parent && billsTree.isLeafXmj(parent));
  659. }
  660. } else {
  661. return false;
  662. }
  663. },
  664. callback: function (key, opt) {
  665. if (!batchInsertObj) {
  666. batchInsertObj = new BatchInsertBillsPosObj($('#batch'));
  667. } else {
  668. batchInsertObj.initView();
  669. }
  670. $('#batch').modal('show');
  671. }
  672. }
  673. }
  674. });
  675. }
  676. const posSpreadObj = {
  677. /**
  678. * 加载计量单元 根据当前台账选择节点
  679. */
  680. loadCurPosData: function () {
  681. const node = SpreadJsObj.getSelectObject(billsSheet);
  682. if (node) {
  683. const posData = pos.getLedgerPos(node.id) || [];
  684. SpreadJsObj.loadSheetData(posSheet, 'data', posData);
  685. } else {
  686. SpreadJsObj.loadSheetData(posSheet, 'data', []);
  687. }
  688. SpreadJsObj.resetFieldReadOnly(posSheet);
  689. },
  690. editStarting: function (e, info) {
  691. posSpreadObj.billsNode = SpreadJsObj.getSelectObject(billsSheet);
  692. },
  693. /**
  694. * 编辑单元格响应事件
  695. * @param {Object} e
  696. * @param {Object} info
  697. */
  698. editEnded: function (e, info) {
  699. if (!info.sheet.zh_setting) {
  700. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  701. return;
  702. }
  703. const posData = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
  704. const col = info.sheet.zh_setting.cols[info.col];
  705. const orgText = posData ? posData[col.field] : null;
  706. const newText = trimInvalidChar(info.sheet.getCell(info.row, info.col).text());
  707. if (orgText === newText || ((!orgText || orgText === '') && (newText === ''))) return;
  708. const node = posSpreadObj.billsNode;
  709. if (!node) {
  710. toastr.error('数据错误,请选择台账节点后再试');
  711. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  712. return;
  713. } else if (newText && newText !== '' && node.children && node.children.length > 0) {
  714. toastr.error('父节点不可插入计量单元');
  715. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  716. return;
  717. } else if (newText && newText !== '' && (!node.b_code || node.b_code === '')) {
  718. toastr.error('项目节不可插入计量单元');
  719. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  720. return;
  721. }
  722. const data = {postType: 'pos'};
  723. if (col.field === 'name') {
  724. if (newText === '' && posData) {
  725. toastr.error('部位名称不可为空', 'error');
  726. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  727. return;
  728. } else if (!posData) {
  729. if (newText && newText !== '') {
  730. data.posPostType = 'add';
  731. const sortData = info.sheet.zh_data;
  732. const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
  733. data.postData = { name: newText, lid: node.id, porder: order};
  734. } else {
  735. return;
  736. }
  737. } else {
  738. data.posPostType = 'update';
  739. data.postData = {id: posData.id, name: newText};
  740. }
  741. } else if (!posData) {
  742. toastr.warning('新增部位请先输入名称');
  743. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  744. return;
  745. } else {
  746. data.posPostType = 'update';
  747. data.postData = {id: posData.id};
  748. if (col.type === 'Number') {
  749. const num = _.toNumber(newText);
  750. if (_.isFinite(num)) {
  751. data.postData[col.field] = num;
  752. } else {
  753. try {
  754. data.postData[col.field] = math.evaluate(transExpr(newText));
  755. } catch(err) {
  756. toastr.error('输入的表达式非法');
  757. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  758. return;
  759. }
  760. }
  761. } else {
  762. data.postData[col.field] = newText;
  763. }
  764. }
  765. postData(window.location.pathname + '/update', data, function (result) {
  766. const updateRst = pos.updateDatas(result.pos);
  767. // 刷新当前行, 不适用于新增(在非下一空白行新增)
  768. if (updateRst.create.length > 0) {
  769. posSpreadObj.loadCurPosData();
  770. } else {
  771. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  772. }
  773. const loadResult = billsTree.loadPostData(result.ledger);
  774. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  775. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  776. }, function () {
  777. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  778. });
  779. },
  780. /**
  781. * 删除按钮响应事件
  782. * @param sheet
  783. */
  784. deletePress: function (sheet) {
  785. if (!sheet.zh_settting) return;
  786. const sortData = sheet.zh_data;
  787. const datas = [], posSelects = [];
  788. const sel = sheet.getSelections()[0];
  789. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  790. let bDel = false;
  791. const node = sortData[iRow];
  792. if (node) {
  793. const data = {id: node.id};
  794. for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
  795. const colSetting = sheet.zh_setting.cols[iCol];
  796. if (colSetting.field === 'name') {
  797. toastr.error('部位名称不能为空');
  798. return;
  799. }
  800. const style = sheet.getStyle(iRow, iCol);
  801. if (!style.locked) {
  802. const colSetting = sheet.zh_setting.cols[iCol];
  803. data[colSetting.field] = null;
  804. bDel = true;
  805. }
  806. }
  807. if (bDel) {
  808. datas.push(data);
  809. posSelects.push(node);
  810. }
  811. }
  812. }
  813. if (datas.length > 0) {
  814. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: datas}, function (result) {
  815. pos.updateDatas(result.pos);
  816. posSpreadObj.loadCurPosData();
  817. const loadResult = billsTree.loadPostData(result.ledger);
  818. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  819. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  820. }, function () {
  821. posSpreadObj.loadCurPosData();
  822. });
  823. }
  824. },
  825. /**
  826. * 删除 计量单元
  827. * @param sheet
  828. */
  829. deletePos: function (sheet) {
  830. const selection = sheet.getSelections();
  831. const data = {
  832. postType: 'pos',
  833. posPostType: 'delete',
  834. postData: [],
  835. };
  836. const row = selection[0].row, count = selection[0].rowCount;
  837. const sortData = sheet.zh_data;
  838. for (let iRow = 0; iRow < count; iRow++) {
  839. const posData = sortData[iRow + row];
  840. if (posData) {
  841. if (posData.used) {
  842. toastr.error('"' + posData.name + '"已计量,请勿删除');
  843. return;
  844. }
  845. data.postData.push(sortData[iRow + row].id);
  846. }
  847. }
  848. if (data.postData.length > 0) {
  849. postData(window.location.pathname + '/update', data, function (result) {
  850. pos.removeDatas(result.pos);
  851. sheet.deleteRows(row, count);
  852. const loadResult = billsTree.loadPostData(result.ledger);
  853. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  854. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  855. });
  856. }
  857. },
  858. clipboardPasting: function (e, info) {
  859. if (!info.sheet.zh_setting) {
  860. info.cancel = true;
  861. return;
  862. }
  863. const range = info.cellRange;
  864. for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
  865. const posData = info.sheet.zh_data[iRow];
  866. if (posData && posData.used) {
  867. toastr.warning('"' + pos.name +'"已计量,请勿修改');
  868. info.cancel = true;
  869. return;
  870. }
  871. }
  872. },
  873. /**
  874. * 粘贴单元格响应事件
  875. * @param e
  876. * @param info
  877. */
  878. clipboardPasted: function (e, info) {
  879. const node = SpreadJsObj.getSelectObject(billsSheet);
  880. if (node.code && (node.code !== '')) {
  881. toastr.error('项目节不可含有节点明细');
  882. posSpreadObj.loadCurPosData();
  883. return;
  884. }
  885. if (node.children && (node.children.length > 0)) {
  886. toastr.error('仅节点子项可以含有计量单元');
  887. posSpreadObj.loadCurPosData();
  888. return;
  889. }
  890. if (!info.sheet.zh_setting) {
  891. posSpreadObj.loadCurPosData();
  892. return;
  893. }
  894. const data = [];
  895. const sortData = info.sheet.zh_data || [];
  896. if (sortData.length === 0 || info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  897. if (info.cellRange.col !== 0) {
  898. toastr.warning('新增部位请先输入名称');
  899. posSpreadObj.loadCurPosData();
  900. return;
  901. }
  902. }
  903. let bHint = false;
  904. const lastOrder = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
  905. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  906. let bPaste = true;
  907. const curRow = info.cellRange.row + iRow;
  908. const posData = curRow >= sortData.length ? {lid: node.id, porder: lastOrder + curRow - sortData.length} : {id: sortData[curRow].id, lid: node.id};
  909. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  910. const curCol = info.cellRange.col + iCol;
  911. const colSetting = info.sheet.zh_setting.cols[curCol];
  912. posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
  913. if (colSetting.type === 'Number') {
  914. const num = _.toNumber(posData[colSetting.field]);
  915. if (num) {
  916. posData[colSetting.field] = num;
  917. } else {
  918. try {
  919. posData[colSetting.field] = math.evaluate(transExpr(posData[colSetting.field]));
  920. } catch (err) {
  921. if (!bHint) {
  922. toastr.warning('粘贴了非法表达式,已过滤');
  923. bHint = true;
  924. }
  925. bPaste = false;
  926. }
  927. }
  928. }
  929. }
  930. if (bPaste) {
  931. data.push(posData);
  932. }
  933. }
  934. if (data.length === 0) {
  935. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  936. return;
  937. }
  938. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: data}, function (result) {
  939. pos.updateDatas(result.pos);
  940. posSpreadObj.loadCurPosData();
  941. const loadResult = billsTree.loadPostData(result.ledger);
  942. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  943. posSpreadObj.loadCurPosData();
  944. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  945. }, function () {
  946. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  947. });
  948. },
  949. selectionChanged: function (e, info) {
  950. const col = info.sheet.zh_setting.cols[info.newSelections[0].col];
  951. const cell = info.sheet.getCell(info.newSelections[0].col, info.newSelections[0].col);
  952. if (col.type === 'Number') {
  953. const data = SpreadJsObj.getSelectObject(info.sheet);
  954. if (data) {
  955. $('#pos-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
  956. .attr('row', info.newSelections[0].row).attr('readOnly', readOnly || cell.locked());
  957. } else {
  958. $('#pos-expr').val('').attr('readOnly', true);
  959. }
  960. } else {
  961. $('#pos-expr').val('').attr('readOnly', true);
  962. }
  963. },
  964. };
  965. posSpreadObj.loadCurPosData();
  966. SpreadJsObj.resetTopAndSelect(posSheet);
  967. posSpread.bind(spreadNS.Events.SelectionChanged, posSpreadObj.selectionChanged);
  968. if (!readOnly) {
  969. $('#pos-expr').bind('change mouseleave', function () {
  970. if (this.readOnly) return;
  971. const expr = $(this);
  972. const select = SpreadJsObj.getSelectObject(posSheet);
  973. const row = posSheet.getSelections()[0].row;
  974. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
  975. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  976. const data = {id: select.id};
  977. const num = _.toNumber(newValue);
  978. if (num) {
  979. data[field] = num;
  980. } else {
  981. try {
  982. data[field] = math.evaluate(transExpr(newValue));
  983. } catch (err) {
  984. toastr.error('输入的表达式非法');
  985. return;
  986. }
  987. }
  988. // 更新至服务器
  989. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: data}, function (result) {
  990. const updateRst = pos.updateDatas(result.pos);
  991. expr.val(select[field]);
  992. // 刷新当前行, 不适用于新增(在非下一空白行新增)
  993. SpreadJsObj.reLoadRowData(posSheet, row);
  994. const loadResult = billsTree.loadPostData(result.ledger);
  995. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  996. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  997. });
  998. });
  999. posSpread.bind(spreadNS.Events.EditStarting, posSpreadObj.editStarting);
  1000. posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
  1001. posSpread.bind(spreadNS.Events.ClipboardPasting, posSpreadObj.clipboardPasting);
  1002. posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
  1003. SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
  1004. $.contextMenu({
  1005. selector: '#pos-spread',
  1006. build: function ($trigger, e) {
  1007. const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
  1008. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  1009. },
  1010. items: {
  1011. 'delete': {
  1012. name: '删除',
  1013. icon: 'fa-remove',
  1014. disabled: function (key, opt) {
  1015. if (posSheet.zh_data) {
  1016. const selection = posSheet.getSelections();
  1017. return posSheet.zh_data.length < selection[0].row + selection[0].rowCount;
  1018. } else {
  1019. return true;
  1020. }
  1021. },
  1022. callback: function (key, opt) {
  1023. posSpreadObj.deletePos(posSheet);
  1024. }
  1025. }
  1026. }
  1027. });
  1028. }
  1029. $.divResizer({
  1030. select: '#revise-resize',
  1031. callback: function () {
  1032. billsSpread.refresh();
  1033. let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
  1034. $(".sp-wrap").height(bcontent-40);
  1035. posSpread.refresh();
  1036. }
  1037. });
  1038. class stdLib {
  1039. constructor(selector, stdType, treeSetting, spreadSetting) {
  1040. const self = this;
  1041. this.obj = $(selector + '-spread')[0];
  1042. this.stdType = stdType;
  1043. this.treeSetting = treeSetting;
  1044. treeSetting.preUrl = this.url;
  1045. this.spreadSetting = spreadSetting;
  1046. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1047. SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
  1048. if (!readOnly) {
  1049. this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
  1050. const stdSheet = info.sheet;
  1051. const mainSheet = billsSheet;
  1052. if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
  1053. const stdTree = stdSheet.zh_tree;
  1054. const stdNode = stdTree.nodes[info.row];
  1055. const mainTree = mainSheet.zh_tree;
  1056. const sel = mainSheet.getSelections()[0];
  1057. const mainNode = mainTree.nodes[sel.row];
  1058. if (!stdNode) return;
  1059. if (stdType === 'gcl') {
  1060. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1061. toastr.warning('非最底层项目下,不应添加节点');
  1062. return;
  1063. }
  1064. }
  1065. postData(window.location.pathname + '/update', {
  1066. postType: 'add-std',
  1067. postData: {
  1068. id: mainTree.getNodeKey(mainNode),
  1069. tender_id: mainNode.tender_id,
  1070. stdType: stdType,
  1071. stdLibId: stdNode.list_id,
  1072. stdNode: stdTree.getNodeKey(stdNode)
  1073. }
  1074. }, function (result) {
  1075. const refreshNode = mainTree.loadPostData(result);
  1076. billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
  1077. if (sel) {
  1078. if (refreshNode.create && refreshNode.create.length > 0) {
  1079. mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
  1080. } else {
  1081. const node = _.find(mainTree.nodes, {code: stdNode.code, name: stdNode.name});
  1082. if (node) {
  1083. mainSheet.setSelection(mainTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
  1084. }
  1085. }
  1086. }
  1087. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1088. billsSpread.focus();
  1089. posSpreadObj.loadCurPosData();
  1090. });
  1091. });
  1092. }
  1093. this.pathTree = createNewPathTree('base', this.treeSetting);
  1094. this.cacheLib = [];
  1095. $('select', selector).change(function () {
  1096. self.loadLib(parseInt(this.value));
  1097. });
  1098. }
  1099. loadLib (listId) {
  1100. const cacheData = this.cacheLib.find(function (lib) {
  1101. return lib.id === listId;
  1102. });
  1103. if (cacheData) {
  1104. this.pathTree.loadDatas(cacheData.data);
  1105. SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
  1106. } else {
  1107. const self = this;
  1108. postData('/std-lib/get-data', {stdType: this.stdType, list_id: listId}, function (data) {
  1109. self.cacheLib.push({id: listId, data: data});
  1110. self.pathTree.loadDatas(data);
  1111. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
  1112. });
  1113. }
  1114. }
  1115. }
  1116. class DealBills {
  1117. constructor (selector, spreadSetting) {
  1118. const self = this;
  1119. this.loaded = false;
  1120. this.obj = $(selector)[0];
  1121. this.url = '/tender/' + window.location.pathname.split('/')[2] + '/deal';
  1122. this.spreadSetting = spreadSetting;
  1123. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1124. SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
  1125. if (!readOnly) {
  1126. this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
  1127. const dealSheet = info.sheet;
  1128. const mainSheet = billsSheet;
  1129. const dealBills = SpreadJsObj.getSelectObject(dealSheet);
  1130. if (!dealBills) { return; }
  1131. const mainTree = mainSheet.zh_tree;
  1132. const mainNode = SpreadJsObj.getSelectObject(mainSheet);
  1133. if (!mainNode || !mainTree) { return; }
  1134. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1135. toastr.warning('非最底层项目下,不应添加节点');
  1136. return;
  1137. }
  1138. postData(window.location.pathname + '/update', {
  1139. postType: 'add-deal',
  1140. postData: {
  1141. id: mainNode.ledger_id,
  1142. type: mainNode.code ? 'child' : 'next',
  1143. dealBills: {
  1144. b_code: dealBills.code, name: dealBills.name, unit: dealBills.unit,
  1145. unit_price: dealBills.unit_price,
  1146. }
  1147. },
  1148. }, function (result) {
  1149. const refreshData = mainTree.loadPostData(result);
  1150. billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
  1151. const sel = mainSheet.getSelections()[0];
  1152. if (sel && refreshData.create[0]) {
  1153. mainSheet.setSelection(mainTree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  1154. }
  1155. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1156. billsSpread.focus();
  1157. posSpreadObj.loadCurPosData();
  1158. });
  1159. });
  1160. }
  1161. SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
  1162. }
  1163. loadData () {
  1164. if (this.loaded) return;
  1165. const self = this;
  1166. postData(this.url+'/get-data', {}, function (data) {
  1167. self.data = data;
  1168. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
  1169. self.loaded = true;
  1170. });
  1171. }
  1172. calculateData () {
  1173. if (this.data) {
  1174. for (const d of this.data) {
  1175. d.total_price = _.multiply(d.quantity, d.unit_price);
  1176. }
  1177. }
  1178. }
  1179. }
  1180. class BatchInsertBillsPosObj {
  1181. constructor (obj) {
  1182. const self = this;
  1183. this.obj = obj;
  1184. this.billsCount = 6;
  1185. this.posCount = 1000;
  1186. // 初始化 清单编号窗口 参数
  1187. this.qdSpreadSetting = {
  1188. cols: [
  1189. {title: '编号', field: 'code', hAlign: 0, width: 80, formatter: '@'},
  1190. {title: '名称', field: 'name', hAlign: 0, width: 120, formatter: '@'},
  1191. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@'},
  1192. {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
  1193. {title: '图册号', field: 'name', hAlign: 0, width: 60, formatter: '@'},
  1194. ],
  1195. emptyRows: this.billsCount,
  1196. headRows: 1,
  1197. headRowHeight: [32],
  1198. headerFont: '12px 微软雅黑',
  1199. font: '12px 微软雅黑',
  1200. };
  1201. this.qdSpread = SpreadJsObj.createNewSpread($('.batch-l-t', this.obj)[0]);
  1202. // 初始化 部位数量复核表 参数
  1203. this.posSpreadSetting = {
  1204. cols: [
  1205. {title: '部位', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
  1206. {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
  1207. ],
  1208. emptyRows: this.posCount,
  1209. headRows: 1,
  1210. headRowHeight: [32],
  1211. headerFont: '12px 微软雅黑',
  1212. font: '12px 微软雅黑',
  1213. };
  1214. for (let iNum = 1; iNum <= this.billsCount; iNum++) {
  1215. this.posSpreadSetting.cols.push(
  1216. {title: '节点' + iNum, field: 'bills' + iNum, hAlign: 2, width: 50}
  1217. )
  1218. }
  1219. this.posSpread = SpreadJsObj.createNewSpread($('.batch-l-b', this.obj)[0]);
  1220. // 初始化 签约节点 参数
  1221. this.dealSpreadSetting = {
  1222. cols: [
  1223. {title: '清单编号', field: 'code', width: 80, formatter: '@', readOnly: true},
  1224. {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true},
  1225. {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
  1226. {title: '单价', field: 'unit_price', width: 50, readOnly: true},
  1227. ],
  1228. emptyRows: 0,
  1229. headRows: 1,
  1230. headRowHeight: [32],
  1231. headerFont: '12px 微软雅黑',
  1232. font: '12px 微软雅黑',
  1233. };
  1234. this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r', this.obj)[0]);
  1235. // 初始化 清单编号、部位数量复核表 表格
  1236. this.initView();
  1237. SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);
  1238. SpreadJsObj.refreshColumnAlign(this.dealSpread.getActiveSheet());
  1239. // 拉取签约节点数据
  1240. dealBills.loadData();
  1241. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  1242. // 双击签约节点,自动添加到清单编号窗口
  1243. this.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
  1244. const deal = info.sheet.zh_data[info.row];
  1245. const qdSheet = self.qdSpread.getActiveSheet(), posSheet = self.posSpread.getActiveSheet();
  1246. const sel = qdSheet.getSelections()[0];
  1247. qdSheet.getCell(sel.row, 0).value(deal.code);
  1248. qdSheet.getCell(sel.row, 1).value(deal.name);
  1249. qdSheet.getCell(sel.row, 2).value(deal.unit);
  1250. qdSheet.getCell(sel.row, 3).value(deal.unit_price);
  1251. if (sel.row + 1 === qdSheet.getRowCount()) {
  1252. const count = sel.row + 2;
  1253. qdSheet.setRowCount(count);
  1254. qdSheet.getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('节点' + count);
  1255. const colCount = posSheet.getColumnCount() + 1;
  1256. posSheet.setColumnCount(colCount);
  1257. posSheet.getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('数量' + count);
  1258. }
  1259. qdSheet.setSelection(sel.row + 1, sel.col, 1, 1);
  1260. qdSheet.getParent().focus();
  1261. });
  1262. this.obj.bind('shown.bs.modal', function () {
  1263. self.qdSpread.refresh();
  1264. self.posSpread.refresh();
  1265. self.dealSpread.refresh();
  1266. });
  1267. $('#batch-ok').click(function () {
  1268. const selection = billsSheet.getSelections();
  1269. const row = selection[0].row;
  1270. const select = billsTree.nodes[row];
  1271. if (select) {
  1272. const insertData = {};
  1273. insertData.batchType = (select.code && select.code !== '') ? 'child' : 'next';
  1274. insertData.id = select[billsTree.setting.id];
  1275. insertData.batchData = self.getBatchData();
  1276. postData(window.location.pathname + '/update', {postType: 'batch-insert', postData: insertData}, function (data) {
  1277. pos.updateDatas(data.pos);
  1278. const result = billsTree.loadPostData(data.ledger);
  1279. billsTreeSpreadObj.refreshTree(sheet, result);
  1280. billsTreeSpreadObj.refreshOperationValid(sheet, selection);
  1281. self.obj.modal('hide');
  1282. }, null, true);
  1283. }
  1284. });
  1285. }
  1286. // 初始化左侧表格
  1287. initView () {
  1288. // 初始化 清单编号
  1289. const qdSheet = this.qdSpread.getActiveSheet();
  1290. SpreadJsObj.initSheet(qdSheet, this.qdSpreadSetting);
  1291. SpreadJsObj.refreshColumnAlign(qdSheet);
  1292. // 清理原有数据
  1293. SpreadJsObj.beginMassOperation(qdSheet);
  1294. qdSheet.clear(0, 0, qdSheet.getRowCount(), qdSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  1295. for (let iRow = 1; iRow <= this.billsCount; iRow++) {
  1296. qdSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('节点' + iRow);
  1297. }
  1298. qdSheet.setSelection(0, 0, 1 ,1);
  1299. SpreadJsObj.endMassOperation(qdSheet);
  1300. // 初始化 部位数量复核表
  1301. const posSheet = this.posSpread.getActiveSheet();
  1302. SpreadJsObj.initSheet(posSheet, this.posSpreadSetting);
  1303. SpreadJsObj.refreshColumnAlign(posSheet);
  1304. // 清理原有数据
  1305. SpreadJsObj.beginMassOperation(posSheet);
  1306. posSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
  1307. posSheet.clear(0, 0, posSheet.getRowCount(), posSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  1308. posSheet.setSelection(0, 0, 1 ,1);
  1309. SpreadJsObj.endMassOperation(posSheet);
  1310. // 检查签约节点数据,以工具栏数据为准
  1311. if (dealBills) {
  1312. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  1313. }
  1314. this.dealSpread.getActiveSheet().setSelection(0, 0, 1, 1);
  1315. }
  1316. // 获取界面数据
  1317. getBatchData () {
  1318. const result = [];
  1319. const qdSheet = this.qdSpread.getActiveSheet(), posSheet = this.posSpread.getActiveSheet();
  1320. for (let iRow = 0; iRow < qdSheet.getRowCount(); iRow++) {
  1321. if (qdSheet.getText(iRow, 0) === '') { continue; }
  1322. const qd = {
  1323. b_code: qdSheet.getText(iRow, 0),
  1324. name: qdSheet.getText(iRow, 1),
  1325. unit: qdSheet.getText(iRow, 2),
  1326. price: _.toNumber(qdSheet.getText(iRow, 3)),
  1327. pos: [],
  1328. };
  1329. result.push(qd);
  1330. for (let iPosRow = 0; iPosRow < posSheet.getRowCount(); iPosRow++) {
  1331. const value = _.toNumber(posSheet.getText(iPosRow, iRow + 2));
  1332. if (value !== 0 && !isNaN(value)) {
  1333. qd.pos.push({
  1334. name: posSheet.getText(iPosRow, 0),
  1335. drawing_code: posSheet.getText(iPosRow, 1),
  1336. quantity: value,
  1337. });
  1338. }
  1339. }
  1340. }
  1341. return result;
  1342. }
  1343. }
  1344. const dealBills = new DealBills('#deal-bills-spread', {
  1345. cols: [
  1346. {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
  1347. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1348. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
  1349. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  1350. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  1351. {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
  1352. ],
  1353. emptyRows: 0,
  1354. headRows: 1,
  1355. headRowHeight: [32],
  1356. defaultRowHeight: 21,
  1357. headerFont: '12px 微软雅黑',
  1358. font: '12px 微软雅黑',
  1359. });
  1360. $.divResizer({
  1361. select: '#revise-right-spr',
  1362. callback: function () {
  1363. billsSpread.refresh();
  1364. if (posSpread) {
  1365. posSpread.refresh();
  1366. }
  1367. if (stdXmj) {
  1368. stdXmj.spread.refresh();
  1369. }
  1370. if (stdGcl) {
  1371. stdGcl.spread.refresh();
  1372. }
  1373. if (dealBills) {
  1374. dealBills.spread.refresh();
  1375. }
  1376. if (searchLedger) {
  1377. searchLedger.spread.refresh();
  1378. }
  1379. }
  1380. });
  1381. $.subMenu({
  1382. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  1383. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  1384. key: 'menu.1.0.0',
  1385. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  1386. callback: function (info) {
  1387. if (info.mini) {
  1388. $('.panel-title').addClass('fluid');
  1389. $('#sub-menu').removeClass('panel-sidebar');
  1390. } else {
  1391. $('.panel-title').removeClass('fluid');
  1392. $('#sub-menu').addClass('panel-sidebar');
  1393. }
  1394. autoFlashHeight();
  1395. billsSpread.refresh();
  1396. if (posSpread) {
  1397. posSpread.refresh();
  1398. }
  1399. if (stdXmj) {
  1400. stdXmj.spread.refresh();
  1401. }
  1402. if (stdGcl) {
  1403. stdGcl.spread.refresh();
  1404. }
  1405. if (dealBills) {
  1406. dealBills.spread.refresh();
  1407. }
  1408. if (searchLedger) {
  1409. searchLedger.spread.refresh();
  1410. }
  1411. }
  1412. });
  1413. const showSideTools = function (show) {
  1414. const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
  1415. if (show) {
  1416. right.show();
  1417. autoFlashHeight();
  1418. /**
  1419. * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
  1420. * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
  1421. * 故需要通过最终的parent.width再计算一次left.width
  1422. *
  1423. * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
  1424. * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
  1425. *
  1426. */
  1427. //left.css('width', parent.width() - right.outerWidth());
  1428. //left.css('width', parent.width() - right.outerWidth());
  1429. const percent = 100 - right.outerWidth() /parent.width() * 100;
  1430. left.css('width', percent + '%');
  1431. } else {
  1432. left.width(parent.width());
  1433. right.hide();
  1434. }
  1435. };
  1436. $('#content-tab').addClass('active');
  1437. $('#xd-content').addClass('active');
  1438. showSideTools(true);
  1439. billsSpread.refresh();
  1440. if (posSpread) {
  1441. posSpread.refresh();
  1442. }
  1443. // 展开收起标准节点
  1444. $('a', '#side-menu').bind('click', function (e) {
  1445. e.preventDefault();
  1446. const tab = $(this), tabPanel = $(tab.attr('content'));
  1447. // 展开工具栏、切换标签
  1448. if (!tab.hasClass('active')) {
  1449. const close = $('.active', '#side-menu').length === 0;
  1450. $('a', '#side-menu').removeClass('active');
  1451. tab.addClass('active');
  1452. $('.tab-content .tab-pane').removeClass('active');
  1453. tabPanel.addClass('active');
  1454. showSideTools(tab.hasClass('active'));
  1455. if (tab.attr('content') === '#std-xmj') {
  1456. if (!stdXmj) {
  1457. stdXmj = new stdLib('#std-xmj', 'xmj', {
  1458. id: 'chapter_id',
  1459. pid: 'pid',
  1460. order: 'order',
  1461. level: 'level',
  1462. rootId: -1,
  1463. keys: ['id', 'list_id', 'chapter_id'],
  1464. }, {
  1465. cols: [
  1466. {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  1467. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1468. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  1469. ],
  1470. treeCol: 0,
  1471. emptyRows: 0,
  1472. headRows: 1,
  1473. headRowHeight: [32],
  1474. defaultRowHeight: 21,
  1475. headerFont: '12px 微软雅黑',
  1476. font: '12px 微软雅黑',
  1477. headColWidth: [0],
  1478. });
  1479. stdXmj.loadLib($('select', '#std-xmj').val());
  1480. }
  1481. stdXmj.spread.refresh();
  1482. } else if (tab.attr('content') === '#std-gcl') {
  1483. if (!stdGcl) {
  1484. stdGcl = new stdLib('#std-gcl', 'gcl', {
  1485. id: 'bill_id',
  1486. pid: 'pid',
  1487. order: 'order',
  1488. level: 'level',
  1489. rootId: -1,
  1490. keys: ['id', 'list_id', 'bill_id']
  1491. }, {
  1492. cols: [
  1493. {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  1494. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1495. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  1496. ],
  1497. treeCol: 0,
  1498. emptyRows: 0,
  1499. headRows: 1,
  1500. headRowHeight: [32],
  1501. defaultRowHeight: 21,
  1502. headerFont: '12px 微软雅黑',
  1503. font: '12px 微软雅黑',
  1504. headColWidth: [0],
  1505. });
  1506. stdGcl.loadLib($('select', '#std-gcl').val());
  1507. }
  1508. stdGcl.spread.refresh();
  1509. } else if (tab.attr('content') === '#deal-bills') {
  1510. dealBills.loadData();
  1511. dealBills.spread.refresh();
  1512. } else if (tab.attr('content') === '#search' && !searchLedger) {
  1513. if (!searchLedger) {
  1514. searchLedger = $.billsSearch({
  1515. selector: '#search',
  1516. searchSpread: billsSpread,
  1517. resultSpreadSetting: {
  1518. cols: [
  1519. {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  1520. {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  1521. {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
  1522. {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
  1523. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  1524. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  1525. ],
  1526. emptyRows: 0,
  1527. headRows: 1,
  1528. headRowHeight: [32],
  1529. defaultRowHeight: 21,
  1530. headerFont: '12px 微软雅黑',
  1531. font: '12px 微软雅黑',
  1532. },
  1533. afterLocated: function () {
  1534. posSpreadObj.loadCurPosData();
  1535. }
  1536. });
  1537. }
  1538. searchLedger.spread.refresh();
  1539. }
  1540. }
  1541. else {// 收起工具栏
  1542. tab.removeClass('active');
  1543. tabPanel.removeClass('active');
  1544. showSideTools(tab.hasClass('active'));
  1545. }
  1546. billsSpread.refresh();
  1547. if (posSpread) {
  1548. posSpread.refresh();
  1549. }
  1550. });
  1551. if (!readOnly) {
  1552. // 修订详情 保存
  1553. $('#save').click(function () {
  1554. const content = $('#content').val();
  1555. postData('save', { content: content }, function () {
  1556. $('#content').attr('org-value', content);
  1557. });
  1558. });
  1559. }
  1560. // 显示层次
  1561. (function (select, sheet) {
  1562. $(select).click(function () {
  1563. if (!sheet.zh_tree) return;
  1564. const tag = $(this).attr('tag');
  1565. const tree = sheet.zh_tree;
  1566. switch (tag) {
  1567. case "1":
  1568. case "2":
  1569. case "3":
  1570. case "4":
  1571. case "5":
  1572. tree.expandByLevel(parseInt(tag));
  1573. SpreadJsObj.refreshTreeRowVisible(sheet);
  1574. break;
  1575. case "last":
  1576. tree.expandByCustom(() => { return true; });
  1577. SpreadJsObj.refreshTreeRowVisible(sheet);
  1578. break;
  1579. case "leafXmj":
  1580. tree.expandToLeafXmj();
  1581. SpreadJsObj.refreshTreeRowVisible(sheet);
  1582. break;
  1583. }
  1584. });
  1585. })('a[name=showLevel]', billsSheet);
  1586. });