revise.js 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  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());
  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(info.sheet, 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 field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
  974. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  975. const data = {id: select.id};
  976. const num = _.toNumber(newValue);
  977. if (num) {
  978. data[field] = num;
  979. } else {
  980. try {
  981. data[field] = math.evaluate(transExpr(newValue));
  982. } catch (err) {
  983. toastr.error('输入的表达式非法');
  984. return;
  985. }
  986. }
  987. // 更新至服务器
  988. postData(window.location.pathname + '/update', {posPostType: 'update', posData: data}, function (result) {
  989. const updateRst = pos.updateDatas(result.pos);
  990. expr.val(select[field]);
  991. // 刷新当前行, 不适用于新增(在非下一空白行新增)
  992. SpreadJsObj.reLoadRowData(info.sheet, _.toNumber(row));
  993. const loadResult = billsTree.loadPostData(result.ledger);
  994. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  995. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  996. });
  997. });
  998. posSpread.bind(spreadNS.Events.EditStarting, posSpreadObj.editStarting);
  999. posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
  1000. posSpread.bind(spreadNS.Events.ClipboardPasting, posSpreadObj.clipboardPasting);
  1001. posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
  1002. SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
  1003. $.contextMenu({
  1004. selector: '#pos-spread',
  1005. build: function ($trigger, e) {
  1006. const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
  1007. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  1008. },
  1009. items: {
  1010. 'delete': {
  1011. name: '删除',
  1012. icon: 'fa-remove',
  1013. disabled: function (key, opt) {
  1014. if (posSheet.zh_data) {
  1015. const selection = posSheet.getSelections();
  1016. return posSheet.zh_data.length < selection[0].row + selection[0].rowCount;
  1017. } else {
  1018. return true;
  1019. }
  1020. },
  1021. callback: function (key, opt) {
  1022. posSpreadObj.deletePos(posSheet);
  1023. }
  1024. }
  1025. }
  1026. });
  1027. }
  1028. $.divResizer({
  1029. select: '#revise-resize',
  1030. callback: function () {
  1031. billsSpread.refresh();
  1032. let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
  1033. $(".sp-wrap").height(bcontent-40);
  1034. posSpread.refresh();
  1035. }
  1036. });
  1037. class stdLib {
  1038. constructor(selector, stdType, treeSetting, spreadSetting) {
  1039. const self = this;
  1040. this.obj = $(selector + '-spread')[0];
  1041. this.stdType = stdType;
  1042. this.treeSetting = treeSetting;
  1043. treeSetting.preUrl = this.url;
  1044. this.spreadSetting = spreadSetting;
  1045. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1046. SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
  1047. if (!readOnly) {
  1048. this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
  1049. const stdSheet = info.sheet;
  1050. const mainSheet = billsSheet;
  1051. if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
  1052. const stdTree = stdSheet.zh_tree;
  1053. const stdNode = stdTree.nodes[info.row];
  1054. const mainTree = mainSheet.zh_tree;
  1055. const sel = mainSheet.getSelections()[0];
  1056. const mainNode = mainTree.nodes[sel.row];
  1057. if (!stdNode) return;
  1058. if (stdType === 'gcl') {
  1059. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1060. toastr.warning('非最底层项目下,不应添加节点');
  1061. return;
  1062. }
  1063. }
  1064. postData(window.location.pathname + '/update', {
  1065. postType: 'add-std',
  1066. postData: {
  1067. id: mainTree.getNodeKey(mainNode),
  1068. tender_id: mainNode.tender_id,
  1069. stdType: stdType,
  1070. stdLibId: stdNode.list_id,
  1071. stdNode: stdTree.getNodeKey(stdNode)
  1072. }
  1073. }, function (result) {
  1074. const refreshNode = mainTree.loadPostData(result);
  1075. billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
  1076. if (sel) {
  1077. if (refreshNode.create && refreshNode.create.length > 0) {
  1078. mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
  1079. } else {
  1080. const node = _.find(mainTree.nodes, {code: stdNode.code, name: stdNode.name});
  1081. if (node) {
  1082. mainSheet.setSelection(mainTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
  1083. }
  1084. }
  1085. }
  1086. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1087. billsSpread.focus();
  1088. posSpreadObj.loadCurPosData();
  1089. });
  1090. });
  1091. }
  1092. this.pathTree = createNewPathTree('base', this.treeSetting);
  1093. this.cacheLib = [];
  1094. $('select', selector).change(function () {
  1095. self.loadLib(parseInt(this.value));
  1096. });
  1097. }
  1098. loadLib (listId) {
  1099. const cacheData = this.cacheLib.find(function (lib) {
  1100. return lib.id === listId;
  1101. });
  1102. if (cacheData) {
  1103. this.pathTree.loadDatas(cacheData.data);
  1104. SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'tree', this.pathTree);
  1105. } else {
  1106. const self = this;
  1107. postData('/std-lib/get-data', {stdType: this.stdType, list_id: listId}, function (data) {
  1108. self.cacheLib.push({id: listId, data: data});
  1109. self.pathTree.loadDatas(data);
  1110. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
  1111. });
  1112. }
  1113. }
  1114. }
  1115. class DealBills {
  1116. constructor (selector, spreadSetting) {
  1117. const self = this;
  1118. this.loaded = false;
  1119. this.obj = $(selector)[0];
  1120. this.url = '/tender/' + window.location.pathname.split('/')[2] + '/deal';
  1121. this.spreadSetting = spreadSetting;
  1122. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1123. SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
  1124. if (!readOnly) {
  1125. this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
  1126. const dealSheet = info.sheet;
  1127. const mainSheet = billsSheet;
  1128. const dealBills = SpreadJsObj.getSelectObject(dealSheet);
  1129. if (!dealBills) { return; }
  1130. const mainTree = mainSheet.zh_tree;
  1131. const mainNode = SpreadJsObj.getSelectObject(mainSheet);
  1132. if (!mainNode || !mainTree) { return; }
  1133. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1134. toastr.warning('非最底层项目下,不应添加节点');
  1135. return;
  1136. }
  1137. postData(window.location.pathname + '/update', {
  1138. postType: 'add-deal',
  1139. postData: {
  1140. id: mainNode.ledger_id,
  1141. type: mainNode.code ? 'child' : 'next',
  1142. dealBills: {
  1143. b_code: dealBills.code, name: dealBills.name, unit: dealBills.unit,
  1144. unit_price: dealBills.unit_price,
  1145. }
  1146. },
  1147. }, function (result) {
  1148. const refreshData = mainTree.loadPostData(result);
  1149. billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
  1150. const sel = mainSheet.getSelections()[0];
  1151. if (sel && refreshData.create[0]) {
  1152. mainSheet.setSelection(mainTree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  1153. }
  1154. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1155. billsSpread.focus();
  1156. posSpreadObj.loadCurPosData();
  1157. });
  1158. });
  1159. }
  1160. SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
  1161. }
  1162. loadData () {
  1163. if (this.loaded) return;
  1164. const self = this;
  1165. postData(this.url+'/get-data', {}, function (data) {
  1166. self.data = data;
  1167. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
  1168. self.loaded = true;
  1169. });
  1170. }
  1171. calculateData () {
  1172. if (this.data) {
  1173. for (const d of this.data) {
  1174. d.total_price = _.multiply(d.quantity, d.unit_price);
  1175. }
  1176. }
  1177. }
  1178. }
  1179. class BatchInsertBillsPosObj {
  1180. constructor (obj) {
  1181. const self = this;
  1182. this.obj = obj;
  1183. this.billsCount = 6;
  1184. this.posCount = 1000;
  1185. // 初始化 清单编号窗口 参数
  1186. this.qdSpreadSetting = {
  1187. cols: [
  1188. {title: '编号', field: 'code', hAlign: 0, width: 80, formatter: '@'},
  1189. {title: '名称', field: 'name', hAlign: 0, width: 120, formatter: '@'},
  1190. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@'},
  1191. {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
  1192. {title: '图册号', field: 'name', hAlign: 0, width: 60, formatter: '@'},
  1193. ],
  1194. emptyRows: this.billsCount,
  1195. headRows: 1,
  1196. headRowHeight: [32],
  1197. headerFont: '12px 微软雅黑',
  1198. font: '12px 微软雅黑',
  1199. };
  1200. this.qdSpread = SpreadJsObj.createNewSpread($('.batch-l-t', this.obj)[0]);
  1201. // 初始化 部位数量复核表 参数
  1202. this.posSpreadSetting = {
  1203. cols: [
  1204. {title: '部位', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
  1205. {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
  1206. ],
  1207. emptyRows: this.posCount,
  1208. headRows: 1,
  1209. headRowHeight: [32],
  1210. headerFont: '12px 微软雅黑',
  1211. font: '12px 微软雅黑',
  1212. };
  1213. for (let iNum = 1; iNum <= this.billsCount; iNum++) {
  1214. this.posSpreadSetting.cols.push(
  1215. {title: '节点' + iNum, field: 'bills' + iNum, hAlign: 2, width: 50}
  1216. )
  1217. }
  1218. this.posSpread = SpreadJsObj.createNewSpread($('.batch-l-b', this.obj)[0]);
  1219. // 初始化 签约节点 参数
  1220. this.dealSpreadSetting = {
  1221. cols: [
  1222. {title: '清单编号', field: 'code', width: 80, formatter: '@', readOnly: true},
  1223. {title: '名称', field: 'name', width: 120, formatter: '@', readOnly: true},
  1224. {title: '单位', field: 'unit', width: 50, formatter: '@', readOnly: true},
  1225. {title: '单价', field: 'unit_price', width: 50, readOnly: true},
  1226. ],
  1227. emptyRows: 0,
  1228. headRows: 1,
  1229. headRowHeight: [32],
  1230. headerFont: '12px 微软雅黑',
  1231. font: '12px 微软雅黑',
  1232. };
  1233. this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r', this.obj)[0]);
  1234. // 初始化 清单编号、部位数量复核表 表格
  1235. this.initView();
  1236. SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);
  1237. SpreadJsObj.refreshColumnAlign(this.dealSpread.getActiveSheet());
  1238. // 拉取签约节点数据
  1239. dealBills.loadData();
  1240. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  1241. // 双击签约节点,自动添加到清单编号窗口
  1242. this.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
  1243. const deal = info.sheet.zh_data[info.row];
  1244. const qdSheet = self.qdSpread.getActiveSheet(), posSheet = self.posSpread.getActiveSheet();
  1245. const sel = qdSheet.getSelections()[0];
  1246. qdSheet.getCell(sel.row, 0).value(deal.code);
  1247. qdSheet.getCell(sel.row, 1).value(deal.name);
  1248. qdSheet.getCell(sel.row, 2).value(deal.unit);
  1249. qdSheet.getCell(sel.row, 3).value(deal.unit_price);
  1250. if (sel.row + 1 === qdSheet.getRowCount()) {
  1251. const count = sel.row + 2;
  1252. qdSheet.setRowCount(count);
  1253. qdSheet.getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('节点' + count);
  1254. const colCount = posSheet.getColumnCount() + 1;
  1255. posSheet.setColumnCount(colCount);
  1256. posSheet.getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('数量' + count);
  1257. }
  1258. qdSheet.setSelection(sel.row + 1, sel.col, 1, 1);
  1259. qdSheet.getParent().focus();
  1260. });
  1261. this.obj.bind('shown.bs.modal', function () {
  1262. self.qdSpread.refresh();
  1263. self.posSpread.refresh();
  1264. self.dealSpread.refresh();
  1265. });
  1266. $('#batch-ok').click(function () {
  1267. const selection = billsSheet.getSelections();
  1268. const row = selection[0].row;
  1269. const select = billsTree.nodes[row];
  1270. if (select) {
  1271. const insertData = {};
  1272. insertData.batchType = (select.code && select.code !== '') ? 'child' : 'next';
  1273. insertData.id = select[billsTree.setting.id];
  1274. insertData.batchData = self.getBatchData();
  1275. postData(window.location.pathname + '/update', {postType: 'batch-insert', postData: insertData}, function (data) {
  1276. pos.updateDatas(data.pos);
  1277. const result = billsTree.loadPostData(data.ledger);
  1278. billsTreeSpreadObj.refreshTree(sheet, result);
  1279. billsTreeSpreadObj.refreshOperationValid(sheet, selection);
  1280. self.obj.modal('hide');
  1281. }, null, true);
  1282. }
  1283. });
  1284. }
  1285. // 初始化左侧表格
  1286. initView () {
  1287. // 初始化 清单编号
  1288. const qdSheet = this.qdSpread.getActiveSheet();
  1289. SpreadJsObj.initSheet(qdSheet, this.qdSpreadSetting);
  1290. SpreadJsObj.refreshColumnAlign(qdSheet);
  1291. // 清理原有数据
  1292. SpreadJsObj.beginMassOperation(qdSheet);
  1293. qdSheet.clear(0, 0, qdSheet.getRowCount(), qdSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  1294. for (let iRow = 1; iRow <= this.billsCount; iRow++) {
  1295. qdSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('节点' + iRow);
  1296. }
  1297. qdSheet.setSelection(0, 0, 1 ,1);
  1298. SpreadJsObj.endMassOperation(qdSheet);
  1299. // 初始化 部位数量复核表
  1300. const posSheet = this.posSpread.getActiveSheet();
  1301. SpreadJsObj.initSheet(posSheet, this.posSpreadSetting);
  1302. SpreadJsObj.refreshColumnAlign(posSheet);
  1303. // 清理原有数据
  1304. SpreadJsObj.beginMassOperation(posSheet);
  1305. posSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
  1306. posSheet.clear(0, 0, posSheet.getRowCount(), posSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  1307. posSheet.setSelection(0, 0, 1 ,1);
  1308. SpreadJsObj.endMassOperation(posSheet);
  1309. // 检查签约节点数据,以工具栏数据为准
  1310. if (dealBills) {
  1311. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  1312. }
  1313. this.dealSpread.getActiveSheet().setSelection(0, 0, 1, 1);
  1314. }
  1315. // 获取界面数据
  1316. getBatchData () {
  1317. const result = [];
  1318. const qdSheet = this.qdSpread.getActiveSheet(), posSheet = this.posSpread.getActiveSheet();
  1319. for (let iRow = 0; iRow < qdSheet.getRowCount(); iRow++) {
  1320. if (qdSheet.getText(iRow, 0) === '') { continue; }
  1321. const qd = {
  1322. b_code: qdSheet.getText(iRow, 0),
  1323. name: qdSheet.getText(iRow, 1),
  1324. unit: qdSheet.getText(iRow, 2),
  1325. price: _.toNumber(qdSheet.getText(iRow, 3)),
  1326. pos: [],
  1327. };
  1328. result.push(qd);
  1329. for (let iPosRow = 0; iPosRow < posSheet.getRowCount(); iPosRow++) {
  1330. const value = _.toNumber(posSheet.getText(iPosRow, iRow + 2));
  1331. if (value !== 0 && !isNaN(value)) {
  1332. qd.pos.push({
  1333. name: posSheet.getText(iPosRow, 0),
  1334. drawing_code: posSheet.getText(iPosRow, 1),
  1335. quantity: value,
  1336. });
  1337. }
  1338. }
  1339. }
  1340. return result;
  1341. }
  1342. }
  1343. const dealBills = new DealBills('#deal-bills-spread', {
  1344. cols: [
  1345. {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
  1346. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1347. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
  1348. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  1349. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  1350. {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
  1351. ],
  1352. emptyRows: 0,
  1353. headRows: 1,
  1354. headRowHeight: [32],
  1355. defaultRowHeight: 21,
  1356. headerFont: '12px 微软雅黑',
  1357. font: '12px 微软雅黑',
  1358. });
  1359. $.divResizer({
  1360. select: '#revise-right-spr',
  1361. callback: function () {
  1362. billsSpread.refresh();
  1363. if (posSpread) {
  1364. posSpread.refresh();
  1365. }
  1366. if (stdXmj) {
  1367. stdXmj.spread.refresh();
  1368. }
  1369. if (stdGcl) {
  1370. stdGcl.spread.refresh();
  1371. }
  1372. if (dealBills) {
  1373. dealBills.spread.refresh();
  1374. }
  1375. if (searchLedger) {
  1376. searchLedger.spread.refresh();
  1377. }
  1378. }
  1379. });
  1380. $.subMenu({
  1381. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  1382. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  1383. key: 'menu.1.0.0',
  1384. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  1385. callback: function (info) {
  1386. if (info.mini) {
  1387. $('.panel-title').addClass('fluid');
  1388. $('#sub-menu').removeClass('panel-sidebar');
  1389. } else {
  1390. $('.panel-title').removeClass('fluid');
  1391. $('#sub-menu').addClass('panel-sidebar');
  1392. }
  1393. autoFlashHeight();
  1394. billsSpread.refresh();
  1395. if (posSpread) {
  1396. posSpread.refresh();
  1397. }
  1398. if (stdXmj) {
  1399. stdXmj.spread.refresh();
  1400. }
  1401. if (stdGcl) {
  1402. stdGcl.spread.refresh();
  1403. }
  1404. if (dealBills) {
  1405. dealBills.spread.refresh();
  1406. }
  1407. if (searchLedger) {
  1408. searchLedger.spread.refresh();
  1409. }
  1410. }
  1411. });
  1412. const showSideTools = function (show) {
  1413. const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
  1414. if (show) {
  1415. right.show();
  1416. autoFlashHeight();
  1417. /**
  1418. * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
  1419. * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
  1420. * 故需要通过最终的parent.width再计算一次left.width
  1421. *
  1422. * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
  1423. * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
  1424. *
  1425. */
  1426. //left.css('width', parent.width() - right.outerWidth());
  1427. //left.css('width', parent.width() - right.outerWidth());
  1428. const percent = 100 - right.outerWidth() /parent.width() * 100;
  1429. left.css('width', percent + '%');
  1430. } else {
  1431. left.width(parent.width());
  1432. right.hide();
  1433. }
  1434. };
  1435. $('#content-tab').addClass('active');
  1436. $('#xd-content').addClass('active');
  1437. showSideTools(true);
  1438. billsSpread.refresh();
  1439. if (posSpread) {
  1440. posSpread.refresh();
  1441. }
  1442. // 展开收起标准节点
  1443. $('a', '#side-menu').bind('click', function (e) {
  1444. e.preventDefault();
  1445. const tab = $(this), tabPanel = $(tab.attr('content'));
  1446. // 展开工具栏、切换标签
  1447. if (!tab.hasClass('active')) {
  1448. const close = $('.active', '#side-menu').length === 0;
  1449. $('a', '#side-menu').removeClass('active');
  1450. tab.addClass('active');
  1451. $('.tab-content .tab-pane').removeClass('active');
  1452. tabPanel.addClass('active');
  1453. showSideTools(tab.hasClass('active'));
  1454. if (tab.attr('content') === '#std-xmj') {
  1455. if (!stdXmj) {
  1456. stdXmj = new stdLib('#std-xmj', 'xmj', {
  1457. id: 'chapter_id',
  1458. pid: 'pid',
  1459. order: 'order',
  1460. level: 'level',
  1461. rootId: -1,
  1462. keys: ['id', 'list_id', 'chapter_id'],
  1463. }, {
  1464. cols: [
  1465. {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  1466. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1467. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  1468. ],
  1469. treeCol: 0,
  1470. emptyRows: 0,
  1471. headRows: 1,
  1472. headRowHeight: [32],
  1473. defaultRowHeight: 21,
  1474. headerFont: '12px 微软雅黑',
  1475. font: '12px 微软雅黑',
  1476. headColWidth: [0],
  1477. });
  1478. stdXmj.loadLib($('select', '#std-xmj').val());
  1479. }
  1480. stdXmj.spread.refresh();
  1481. } else if (tab.attr('content') === '#std-gcl') {
  1482. if (!stdGcl) {
  1483. stdGcl = new stdLib('#std-gcl', 'gcl', {
  1484. id: 'bill_id',
  1485. pid: 'pid',
  1486. order: 'order',
  1487. level: 'level',
  1488. rootId: -1,
  1489. keys: ['id', 'list_id', 'bill_id']
  1490. }, {
  1491. cols: [
  1492. {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  1493. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  1494. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  1495. ],
  1496. treeCol: 0,
  1497. emptyRows: 0,
  1498. headRows: 1,
  1499. headRowHeight: [32],
  1500. defaultRowHeight: 21,
  1501. headerFont: '12px 微软雅黑',
  1502. font: '12px 微软雅黑',
  1503. headColWidth: [0],
  1504. });
  1505. stdGcl.loadLib($('select', '#std-gcl').val());
  1506. }
  1507. stdGcl.spread.refresh();
  1508. } else if (tab.attr('content') === '#deal-bills') {
  1509. dealBills.loadData();
  1510. dealBills.spread.refresh();
  1511. } else if (tab.attr('content') === '#search' && !searchLedger) {
  1512. if (!searchLedger) {
  1513. searchLedger = $.billsSearch({
  1514. selector: '#search',
  1515. searchSpread: billsSpread,
  1516. resultSpreadSetting: {
  1517. cols: [
  1518. {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  1519. {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  1520. {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
  1521. {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
  1522. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  1523. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  1524. ],
  1525. emptyRows: 0,
  1526. headRows: 1,
  1527. headRowHeight: [32],
  1528. defaultRowHeight: 21,
  1529. headerFont: '12px 微软雅黑',
  1530. font: '12px 微软雅黑',
  1531. },
  1532. afterLocated: function () {
  1533. posSpreadObj.loadCurPosData();
  1534. }
  1535. });
  1536. }
  1537. searchLedger.spread.refresh();
  1538. }
  1539. }
  1540. else {// 收起工具栏
  1541. tab.removeClass('active');
  1542. tabPanel.removeClass('active');
  1543. showSideTools(tab.hasClass('active'));
  1544. }
  1545. billsSpread.refresh();
  1546. if (posSpread) {
  1547. posSpread.refresh();
  1548. }
  1549. });
  1550. if (!readOnly) {
  1551. // 修订详情 保存
  1552. $('#save').click(function () {
  1553. const content = $('#content').val();
  1554. postData('save', { content: content }, function () {
  1555. $('#content').attr('org-value', content);
  1556. });
  1557. });
  1558. }
  1559. // 显示层次
  1560. (function (select, sheet) {
  1561. $(select).click(function () {
  1562. if (!sheet.zh_tree) return;
  1563. const tag = $(this).attr('tag');
  1564. const tree = sheet.zh_tree;
  1565. switch (tag) {
  1566. case "1":
  1567. case "2":
  1568. case "3":
  1569. case "4":
  1570. case "5":
  1571. tree.expandByLevel(parseInt(tag));
  1572. SpreadJsObj.refreshTreeRowVisible(sheet);
  1573. break;
  1574. case "last":
  1575. tree.expandByCustom(() => { return true; });
  1576. SpreadJsObj.refreshTreeRowVisible(sheet);
  1577. break;
  1578. case "leafXmj":
  1579. tree.expandToLeafXmj();
  1580. SpreadJsObj.refreshTreeRowVisible(sheet);
  1581. break;
  1582. }
  1583. });
  1584. })('a[name=showLevel]', billsSheet);
  1585. });