revise.js 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629
  1. 'use strict';
  2. /**
  3. * 台账修订页面js
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const ckBillsSpread = window.location.pathname + '-billsSelect';
  10. const invalidFields = {
  11. parent: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'deal_qty', 'deal_tp', 'unit_price'],
  12. gcl: ['dgn_qty1', 'dgn_qty2'],
  13. posCode: ['b_code'],
  14. posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
  15. posXmj: ['code'],
  16. };
  17. function getExprInfo (field) {
  18. const exprField = [
  19. {qty: 'sgfh_qty', expr: 'sgfh_expr'},
  20. {qty: 'sjcl_qty', expr: 'sjcl_expr'},
  21. {qty: 'qtcl_qty', expr: 'qtcl_expr'},
  22. ];
  23. return _.find(exprField, {qty: field});
  24. }
  25. function transExpr(expr) {
  26. return $.trim(expr).replace('\t', '').replace('=', '').replace('%', '/100');
  27. }
  28. const copyBlockTag = 'zh.calc.copyBlock';
  29. const checkOption = {
  30. sibling: { enable: 1 },
  31. empty_code: { enable: 1 },
  32. calc: {
  33. enable: 1,
  34. fields: ['sgfh_qty', 'qtcl_qty', 'sjcl_qty', 'quantity'],
  35. },
  36. zero: { enable: 1 },
  37. tp: {
  38. enable: 1,
  39. fields: [
  40. {qty: 'sgfh_qty', tp: 'sgfh_tp'},
  41. {qty: 'sjcl_qty', tp: 'sjcl_tp'},
  42. {qty: 'qtcl_qty', tp: 'qtcl_tp'},
  43. {qty: 'quantity', tp: 'total_price'},
  44. {qty: 'deal_qty', tp: 'deal_tp'},
  45. ],
  46. },
  47. };
  48. $(document).ready(() => {
  49. let stdXmj, stdGcl, searchLedger;
  50. autoFlashHeight();
  51. // 初始化spread
  52. const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]);
  53. const billsSheet = billsSpread.getActiveSheet();
  54. sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
  55. if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting);
  56. SpreadJsObj.initSheet(billsSheet, billsSpreadSetting);
  57. const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
  58. const posSheet = posSpread.getActiveSheet();
  59. sjsSettingObj.setGridSelectStyle(posSpreadSetting);
  60. if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting);
  61. SpreadJsObj.initSheet(posSheet, posSpreadSetting);
  62. const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
  63. const errorList = $.cs_errorList({
  64. tabSelector: '#error-list-tab',
  65. selector: '#error-list',
  66. relaSpread: billsSpread,
  67. storeKey: 'revise-error-' + window.location.pathname.split('/')[2] + '-' + window.location.pathname.split('/')[4],
  68. afterLocated: function () {
  69. posSpreadObj.loadCurPosData();
  70. },
  71. afterShow: function () {
  72. billsSpread.refresh();
  73. if (posSpread) posSpread.refresh();
  74. },
  75. });
  76. const checkList = $.ledger_checkList({
  77. id: 'check-list',
  78. tabSelector: '#check-list-tab',
  79. selector: '#check-list',
  80. relaSpread: billsSpread,
  81. storeKey: 'revise-check-' + window.location.pathname.split('/')[2] + '-' + window.location.pathname.split('/')[4],
  82. checkType: getCheckType(checkOption),
  83. afterLocated: function () {
  84. posSpreadObj.loadCurPosData();
  85. },
  86. afterShow: function () {
  87. billsSpread.refresh();
  88. if (posSpread) posSpread.refresh();
  89. },
  90. });
  91. // 初始化 节点树结构
  92. const treeSetting = {
  93. id: 'ledger_id',
  94. pid: 'ledger_pid',
  95. order: 'order',
  96. level: 'level',
  97. rootId: -1,
  98. keys: ['id', 'tender_id', 'ledger_id'],
  99. calcFields: ['sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price'],
  100. autoExpand: 3,
  101. };
  102. if (!isTz) {
  103. treeSetting.calcFields.push('deal_tp');
  104. }
  105. treeSetting.calcFun = function (node) {
  106. node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
  107. };
  108. const billsTree = createNewPathTree('revise', treeSetting);
  109. // 初始化 计量单元
  110. const pos = new PosData({ id: 'id', ledgerId: 'lid' });
  111. // 清单 相关方法&绑定spreadjs事件
  112. const billsTreeSpreadObj = {
  113. loadExprToInput(sheet) {
  114. const sel = sheet.getSelections()[0];
  115. const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
  116. if (col && col.type === 'Number') {
  117. const data = SpreadJsObj.getSelectObject(sheet);
  118. if (data) {
  119. const exprInfo = getExprInfo(col.field);
  120. if (exprInfo) {
  121. $('#bills-expr').val(data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
  122. .attr('field', col.field).attr('org', data[col.field]);
  123. } else {
  124. $('#bills-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field]);
  125. }
  126. if (col.field.indexOf('dgn') >= 0) {
  127. $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (_.isString(data.b_code) && data.b_code !== ''));
  128. } else if (col.field === 'unit_price') {
  129. $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0) || (_.isBoolean(data.used) && data.used === true));
  130. } else {
  131. const nodePos = pos.getLedgerPos(data.id);
  132. if (nodePos && nodePos.length > 0) {
  133. $('#bills-expr').val('').attr('readOnly', true);
  134. $('#bills-expr').removeAttr('data-row');
  135. } else {
  136. $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
  137. }
  138. }
  139. $('#bills-expr').attr('data-row', sel.row);
  140. } else {
  141. $('#bills-expr').val('').attr('readOnly', true);
  142. $('#bills-expr').removeAttr('data-row');
  143. }
  144. } else {
  145. $('#bills-expr').val('').attr('readOnly', true);
  146. $('#bills-expr').removeAttr('data-row');
  147. }
  148. },
  149. getDefaultSelectInfo: function (sheet) {
  150. const tree = sheet.zh_tree;
  151. if (!tree) return;
  152. const sel = sheet.getSelections()[0];
  153. const node = sheet.zh_tree.nodes[sel.row];
  154. if (!node) return;
  155. let count = 1;
  156. if (sel.rowCount > 1) {
  157. for (let r = 1; r < sel.rowCount; r++) {
  158. const rNode = sheet.zh_tree.nodes[sel.row + r];
  159. if (rNode.level > node.level) continue;
  160. if ((rNode.level < node.level) || (rNode.level === node.level && rNode.pid !== node.pid)) {
  161. toastr.warning('请选择同一节点下的节点,进行该操作');
  162. return;
  163. }
  164. count += 1;
  165. }
  166. }
  167. return [tree, node, count];
  168. },
  169. /**
  170. * 刷新顶部按钮是否可用
  171. * @param sheet
  172. * @param selections
  173. */
  174. refreshOperationValid: function (sheet, selection) {
  175. const setObjEnable = function (obj, enable) {
  176. if (enable) {
  177. obj.removeClass('disabled');
  178. } else {
  179. obj.addClass('disabled');
  180. }
  181. };
  182. const invalidAll = function () {
  183. setObjEnable($('a[name=base-opr][type=add]'), false);
  184. setObjEnable($('a[name=base-opr][type=delete]'), false);
  185. setObjEnable($('a[name=base-opr][type=up-move]'), false);
  186. setObjEnable($('a[name=base-opr][type=down-move]'), false);
  187. setObjEnable($('a[name=base-opr][type=up-level]'), false);
  188. setObjEnable($('a[name=base-opr][type=down-level]'), false);
  189. };
  190. const sel = selection ? selection[0] : sheet.getSelections()[0];
  191. const row = sel ? sel.row : -1;
  192. const tree = sheet.zh_tree;
  193. if (!tree) {
  194. invalidAll();
  195. return;
  196. }
  197. const first = sheet.zh_tree.nodes[row];
  198. if (!first) {
  199. invalidAll();
  200. return;
  201. }
  202. let last = first, sameParent = true, nodeUsed = first.used;
  203. if (sel.rowCount > 1 && first) {
  204. for (let r = 1; r < sel.rowCount; r++) {
  205. const rNode = tree.nodes[sel.row + r];
  206. if (!rNode) {
  207. sameParent = false;
  208. break;
  209. }
  210. nodeUsed = nodeUsed || rNode.used;
  211. if (rNode.level > first.level) continue;
  212. if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
  213. sameParent = false;
  214. break;
  215. }
  216. last = rNode;
  217. }
  218. }
  219. const preNode = tree.getPreSiblingNode(first);
  220. const valid = !sheet.zh_setting.readOnly;
  221. setObjEnable($('a[name=base-opr][type=add]'), valid && first && first.level > 1);
  222. setObjEnable($('a[name=base-opr][type=delete]'), valid && first && sameParent && first.level > 1 && !nodeUsed);
  223. setObjEnable($('a[name=base-opr][type=up-move]'), valid && first && sameParent && first.level > 1 && preNode);
  224. setObjEnable($('a[name=base-opr][type=down-move]'), valid && first && sameParent && first.level > 1 && !tree.isLastSibling(last));
  225. const posRange = last ? pos.getLedgerPos(last.id) : [];
  226. setObjEnable($('a[name=base-opr][type=up-level]'), valid && first && sameParent && tree.getParent(first) && !nodeUsed
  227. && first.level > 2 && ((!posRange || posRange.length === 0) || tree.isLastSibling(last)));
  228. const preNodePosRange = preNode ? pos.getLedgerPos(preNode.id) : [];
  229. setObjEnable($('a[name=base-opr][type=down-level]'), valid && first && sameParent
  230. && first.level > 1 && preNode && (!preNodePosRange || preNodePosRange.length === 0) && !preNode.used);
  231. setObjEnable($('#cut'), valid);
  232. setObjEnable($('#paste'), valid);
  233. },
  234. /**
  235. *
  236. * @param sheet
  237. * @param data
  238. */
  239. refreshTree: function (sheet, data) {
  240. SpreadJsObj.massOperationSheet(sheet, function () {
  241. const tree = sheet.zh_tree;
  242. // 处理删除
  243. if (data.delete) {
  244. data.delete.sort(function (a, b) {
  245. return b.deleteIndex - a.deleteIndex;
  246. });
  247. for (const d of data.delete) {
  248. sheet.deleteRows(d.deleteIndex, 1);
  249. }
  250. }
  251. // 处理新增
  252. if (data.create) {
  253. const newNodes = data.create;
  254. if (newNodes) {
  255. newNodes.sort(function (a, b) {
  256. return a.index - b.index;
  257. });
  258. for (const node of newNodes) {
  259. sheet.addRows(node.index, 1);
  260. SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
  261. }
  262. }
  263. }
  264. // 处理更新
  265. if (data.update) {
  266. const rows = [];
  267. for (const u of data.update) {
  268. rows.push(tree.nodes.indexOf(u));
  269. }
  270. SpreadJsObj.reLoadRowsData(sheet, rows);
  271. }
  272. // 处理展开
  273. if (data.expand) {
  274. const expanded = [];
  275. for (const e of data.expand) {
  276. if (expanded.indexOf(e) === -1) {
  277. const posterity = tree.getPosterity(e);
  278. for (const p of posterity) {
  279. sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
  280. expanded.push(p);
  281. }
  282. }
  283. }
  284. }
  285. });
  286. },
  287. selectionChanged: function (e, info) {
  288. if (info.newSelections) {
  289. if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row) {
  290. billsTreeSpreadObj.refreshOperationValid(info.sheet);
  291. SpreadJsObj.resetTopAndSelect(posSheet);
  292. posSpreadObj.loadCurPosData();
  293. SpreadJsObj.saveTopAndSelect(billsSheet, ckBillsSpread);
  294. posSearch.search($('#pos-keyword').val());
  295. }
  296. }
  297. billsTreeSpreadObj.loadExprToInput(info.sheet);
  298. },
  299. /**
  300. * 新增节点
  301. * @param spread
  302. */
  303. baseOpr: function (sheet, type, addCount = 1) {
  304. const self = this;
  305. const [tree, node, count] = this.getDefaultSelectInfo(sheet);
  306. if (!tree || !node || !count) return;
  307. if (type === 'delete') {
  308. const parent = tree.getParent(node);
  309. const children = parent ? parent.children : tree.children;
  310. const index = children.indexOf(node);
  311. for (let i = 0; i < count; i++) {
  312. const child = children[i+index];
  313. if (tree.checkNodeUsed(child, pos)) {
  314. toastr.warning('选中的节点已计量,不可删除');
  315. return;
  316. }
  317. }
  318. } else if (type === 'up-level') {
  319. const parent = tree.getParent(node);
  320. const children = parent ? parent.children : tree.children;
  321. const index = children.indexOf(node);
  322. for (let i = index; i < children.length; i++) {
  323. const child = children[index];
  324. if (tree.checkNodeUsed(child, pos)) {
  325. if (i >= index + count) {
  326. toastr.warning('其后节点已计量,选中的节点不可升级');
  327. } else {
  328. toastr.warning('选中的节点已计量,不可升级');
  329. }
  330. return;
  331. }
  332. }
  333. } else if (type === 'down-level') {
  334. const parent = tree.getParent(node);
  335. const children = parent ? parent.children : tree.children;
  336. const index = children.indexOf(node);
  337. for (let i = 0; i < count; i++) {
  338. const child = children[i+index];
  339. if (tree.checkNodeUsed(child, pos)) {
  340. toastr.warning('选中的节点已计量,不可降级');
  341. return;
  342. }
  343. }
  344. }
  345. if (type === 'delete') {
  346. deleteAfterHint(function () {
  347. postData(window.location.pathname + '/update', {
  348. postType: type,
  349. postData: {
  350. id: node.ledger_id,
  351. count: type === 'add' ? addCount : count,
  352. }
  353. }, function (result) {
  354. const refreshData = tree.loadPostData(result);
  355. self.refreshTree(sheet, refreshData);
  356. const sel = sheet.getSelections()[0];
  357. if (sel) {
  358. sheet.setSelection(sel.row, sel.col, 1, sel.colCount);
  359. }
  360. self.refreshOperationValid(sheet);
  361. });
  362. });
  363. } else {
  364. postData(window.location.pathname + '/update', {
  365. postType: type,
  366. postData: {
  367. id: node.ledger_id,
  368. count: type === 'add' ? addCount : count,
  369. }
  370. }, function (result) {
  371. const refreshData = tree.loadPostData(result);
  372. self.refreshTree(sheet, refreshData);
  373. if (['up-move', 'down-move'].indexOf(type) > -1) {
  374. const sel = sheet.getSelections()[0];
  375. if (sel) {
  376. sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
  377. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(node)]);
  378. }
  379. } else if (type === 'add') {
  380. const sel = sheet.getSelections()[0];
  381. if (sel) {
  382. sheet.setSelection(tree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  383. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(refreshData.create[0])]);
  384. }
  385. }
  386. self.refreshOperationValid(sheet);
  387. });
  388. }
  389. },
  390. /**
  391. * 编辑单元格响应事件
  392. * @param {Object} e
  393. * @param {Object} info
  394. */
  395. editEnded: function (e, info) {
  396. if (info.sheet.zh_setting) {
  397. const col = info.sheet.zh_setting.cols[info.col];
  398. const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
  399. const node = sortData[info.row];
  400. const data = {
  401. id: node.id,
  402. tender_id: node.tender_id,
  403. ledger_id: node.ledger_id
  404. };
  405. // 未改变值则不提交
  406. const orgValue = node[col.field];
  407. const newValue = trimInvalidChar(info.editingText);
  408. if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
  409. return;
  410. }
  411. // 台账模式,检查计量单元相关
  412. if (isTz) {
  413. if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
  414. col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
  415. col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
  416. if (!node.children || node.children.length ===0) {
  417. const lPos = pos.getLedgerPos(node.id);
  418. if (lPos && lPos.length > 0) {
  419. toastr.error('清单含有计量单元,不可修改施工图复核数量');
  420. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  421. return;
  422. }
  423. }
  424. }
  425. if (col.field === 'b_code' && (newValue === '' || !newValue)) {
  426. const lPos = pos.getLedgerPos(node.id);
  427. if (lPos && lPos.length > 0) {
  428. toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
  429. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  430. return;
  431. }
  432. }
  433. }
  434. // 获取更新数据
  435. const exprInfo = getExprInfo(col.field);
  436. if (info.editingText) {
  437. const text = newValue;
  438. if (node.used && (col.field === 'code' || col.field ==='b_code') && orgValue !== '' && text === '') {
  439. toastr.error('节点已计量,请勿删除编号');
  440. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  441. return;
  442. }
  443. if (col.type === 'Number') {
  444. const num = _.toNumber(text);
  445. if (_.isFinite(num)) {
  446. data[col.field] = num;
  447. if (exprInfo) {
  448. data[exprInfo.expr] = '';
  449. }
  450. } else {
  451. try {
  452. data[col.field] = math.evaluate(transExpr(text));
  453. if (exprInfo) {
  454. data[exprInfo.expr] = newValue;
  455. }
  456. } catch(err) {
  457. toastr.error('输入的表达式非法');
  458. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  459. return;
  460. }
  461. }
  462. } else {
  463. data[col.field] = text;
  464. }
  465. } else {
  466. if (node.used && (col.field === 'code' || col.field ==='b_code') && orgValue !== '') {
  467. toastr.error('节点已计量,请勿删除编号');
  468. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  469. return;
  470. }
  471. data[col.field] = null;
  472. if (exprInfo) {
  473. data[exprInfo.expr] = '';
  474. }
  475. }
  476. // 更新至服务器
  477. postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
  478. const refreshNode = billsTree.loadPostData(result);
  479. billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
  480. });
  481. }
  482. },
  483. clipboardPasting: function (e, info) {
  484. const tree = info.sheet.zh_tree, setting = info.sheet.zh_setting;
  485. info.cancel = true;
  486. if (!setting || !tree) return;
  487. // const range = info.cellRange;
  488. // for (let iRow = range.row; iRow < range.row + range.rowCount; iRow++) {
  489. // const node = tree.nodes[iRow];
  490. // if (tree.checkNodeUsed(node, pos)) {
  491. // toastr.warning('"' + node.code + node.b_code + ' ' + node.name +'"已计量,请勿修改');
  492. // return;
  493. // }
  494. // }
  495. const pasteData = info.pasteData.html
  496. ? SpreadJsObj.analysisPasteHtml(info.pasteData.html)
  497. : (info.pasteData.text === ''
  498. ? SpreadJsObj.Clipboard.getAnalysisPasteText()
  499. : SpreadJsObj.analysisPasteText(info.pasteData.text));
  500. const hint = {
  501. usedUp: {type: 'warning', msg: '节点已计量,不可修改单价'},
  502. usedCode: {type: 'warning', msg: '节点已计量,编号不可修改为空值'},
  503. invalidExpr: {type: 'warning', msg: '粘贴的表达式非法'},
  504. posCode: {type: 'warning', msg: '清单含有计量单元,不可粘贴清单编号为空'},
  505. posQty: {type: 'warning', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可粘贴'},
  506. parent: {type: 'warning', msg: '含有子项的清单,不可粘贴数量、单价、金额'},
  507. gcl: {type: 'warning', msg: '工程量清单,不可粘贴项目节数量'},
  508. posXmj: {type: 'warning', msg: '清单含有计量单元,不可粘贴项目节编号'},
  509. sameParent: {type: 'warning', msg: '仅可粘贴同层节点'},
  510. };
  511. const datas = [], filterNodes = [];
  512. let pid, level, filterRow = 0;
  513. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
  514. const curRow = info.cellRange.row + iRow;
  515. const node = tree.nodes[curRow];
  516. if (!node) continue;
  517. if (!pid) pid = node.ledger_pid;
  518. if (!level) level = node.level;
  519. if (node.ledger_pid !== pid) {
  520. toastMessageUniq(hint.sameParent);
  521. filterRow+=1;
  522. continue;
  523. }
  524. if (node.level < level) break;
  525. let bPaste = false;
  526. const data = info.sheet.zh_tree.getNodeKeyData(node);
  527. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  528. const curCol = info.cellRange.col + iCol;
  529. const colSetting = info.sheet.zh_setting.cols[curCol];
  530. const value = trimInvalidChar(pasteData[iRow-filterRow][iCol]);
  531. if (node.children && node.children.length > 0 && invalidFields.parent.indexOf(colSetting.field) >= 0) {
  532. toastMessageUniq(hint.parent);
  533. continue;
  534. }
  535. if (!_.isEmpty(node.b_code) && invalidFields.gcl.indexOf(colSetting.field) >= 0) {
  536. toastMessageUniq(hint.gcl);
  537. continue;
  538. }
  539. const lPos = pos.getLedgerPos(node.id);
  540. if (lPos && lPos.length > 0) {
  541. if (value === '' && colSetting.field === 'b_code') {
  542. toastMessageUniq(hint.posCode);
  543. continue;
  544. }
  545. if (colSetting.field === 'sgfh_qty' || colSetting.field === 'sgfh_tp' ||
  546. colSetting.field === 'sjcl_qty' || colSetting.field === 'sjcl_tp' ||
  547. colSetting.field === 'qtcl_qty' || colSetting.field === 'qtcl_tp') {
  548. toastMessageUniq(hint.posQty);
  549. continue;
  550. }
  551. if (value !== '' && invalidFields.posXmj.indexOf(colSetting.field) >= 0) {
  552. toastMessageUniq(hint.posXmj);
  553. continue;
  554. }
  555. }
  556. if (tree.checkNodeUsed(node, pos) && col.field === 'unit_price') {
  557. toastMessageUniq (hint.usedUp);
  558. continue;
  559. }
  560. if (colSetting.type === 'Number') {
  561. const num = _.toNumber(value);
  562. if (num) {
  563. data[colSetting.field] = num;
  564. } else {
  565. try {
  566. data[colSetting.field] = math.evaluate(transExpr(value));
  567. const exprInfo = getExprInfo(colSetting.field);
  568. if (exprInfo) {
  569. data[exprInfo.expr] = value;
  570. }
  571. bPaste = true;
  572. } catch (err) {
  573. toastMessageUniq(hint.invalidExpr);
  574. continue;
  575. }
  576. }
  577. } else {
  578. if (node.used && (col.field === 'code' || col.field ==='b_code')
  579. && data[colSetting.field] !== '' && value === '') {
  580. toastMessageUniq(hint.usedCode);
  581. continue;
  582. }
  583. data[colSetting.field] = value;
  584. }
  585. bPaste = true;
  586. }
  587. if (bPaste) {
  588. datas.push(data);
  589. } else {
  590. filterNodes.push(node);
  591. }
  592. }
  593. if (datas.length > 0) {
  594. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  595. const refreshNode = tree.loadPostData(result);
  596. if (refreshNode.update) {
  597. refreshNode.update = refreshNode.update.concat(filterNodes);
  598. }
  599. billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
  600. }, function () {
  601. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  602. });
  603. } else {
  604. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  605. }
  606. },
  607. clipboardPasted: function (e, info) {
  608. const hint = {
  609. usedUp: {type: 'error', msg: '节点已计量,不可修改单价'},
  610. usedCode: {type: 'error', msg: '节点已计量,编号不可修改为空值'},
  611. invalidExpr: {type: 'error', msg: '粘贴的表达式非法'},
  612. posCode: {type: 'error', msg: '清单含有计量单元,请先删除计量单元,再修改清单编号为空'},
  613. posQty: {type: 'error', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可修改'},
  614. };
  615. const tree = info.sheet.zh_tree;
  616. if (!tree) { return; }
  617. const sortData = info.sheet.zh_tree.nodes;
  618. const datas = [], filterNodes = [];
  619. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
  620. let bPaste = false;
  621. const curRow = info.cellRange.row + iRow;
  622. const node = sortData[curRow];
  623. if (node) {
  624. const data = info.sheet.zh_tree.getNodeKeyData(node);
  625. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  626. const curCol = info.cellRange.col + iCol;
  627. const colSetting = info.sheet.zh_setting.cols[curCol];
  628. const value = trimInvalidChar(info.sheet.getText(curRow, curCol));
  629. const lPos = pos.getLedgerPos(node.id);
  630. if (lPos && lPos.length > 0) {
  631. if (value === '' && colSetting.field === 'b_code') {
  632. toastMessageUniq(hint.posCode);
  633. continue;
  634. }
  635. if (colSetting.field === 'sgfh_qty' || colSetting.field === 'sgfh_tp' ||
  636. colSetting.field === 'sjcl_qty' || colSetting.field === 'sjcl_tp' ||
  637. colSetting.field === 'qtcl_qty' || colSetting.field === 'qtcl_tp') {
  638. toastMessageUniq(hint.posQty);
  639. continue;
  640. }
  641. }
  642. if (node.used && col.field === 'unit_price') {
  643. toastMessageUniq (hint.usedUp);
  644. continue;
  645. }
  646. if (colSetting.type === 'Number') {
  647. const num = _.toNumber(value);
  648. if (num) {
  649. data[colSetting.field] = num;
  650. } else {
  651. try {
  652. data[colSetting.field] = math.evaluate(transExpr(value));
  653. } catch (err) {
  654. toastMessageUniq(hint.invalidExpr);
  655. continue;
  656. }
  657. }
  658. } else {
  659. if (node.used && (col.field === 'code' || col.field ==='b_code')
  660. && data[colSetting.field] !== '' && value === '') {
  661. toastMessageUniq(hint.usedCode);
  662. continue;
  663. }
  664. data[colSetting.field] = value;
  665. }
  666. bPaste = true;
  667. }
  668. if (bPaste) {
  669. datas.push(data);
  670. } else {
  671. filterNodes.push(node);
  672. }
  673. }
  674. }
  675. if (datas.length > 0) {
  676. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  677. const refreshNode = tree.loadPostData(result);
  678. if (refreshNode.update) {
  679. refreshNode.update = refreshNode.update.concat(filterNodes);
  680. }
  681. billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
  682. }, function () {
  683. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  684. });
  685. } else {
  686. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  687. }
  688. },
  689. deletePress: function (sheet) {
  690. if (!sheet.zh_setting) return;
  691. const sel = sheet.getSelections()[0], datas = [];
  692. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  693. let bDel = false;
  694. const node = sheet.zh_tree.nodes[iRow];
  695. const data = sheet.zh_tree.getNodeKeyData(node);
  696. for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
  697. const col = sheet.zh_setting.cols[iCol];
  698. const style = sheet.getStyle(iRow, iCol);
  699. if (style.locked || (['dgn_qty1', 'dgn_qty2'].indexOf(col.field) >= 0 && node.b_code)) continue;
  700. if (['dgn_qty1', 'dgn_qty2'].indexOf(col.field) < 0 && sheet.zh_tree.checkNodeUsed(node, pos)) {
  701. toastr.warning('"' + (node.code || '') + (node.b_code || '') + ' ' + node.name +'"已计量,请勿修改');
  702. return;
  703. }
  704. data[col.field] = null;
  705. const exprInfo = getExprInfo(col.field);
  706. if (exprInfo) {
  707. data[exprInfo.expr] = '';
  708. }
  709. bDel = true;
  710. }
  711. if (bDel) datas.push(data);
  712. }
  713. if (datas.length > 0) {
  714. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  715. const refreshNode = sheet.zh_tree.loadPostData(result);
  716. billsTreeSpreadObj.refreshTree(sheet, refreshNode);
  717. billsTreeSpreadObj.loadExprToInput(sheet);
  718. });
  719. }
  720. },
  721. pasteBlock: function (spread, copyInfo) {
  722. const self = this;
  723. const sheet = spread.getActiveSheet();
  724. const [tree, node] = this.getDefaultSelectInfo(spread.getActiveSheet());
  725. postData(window.location.pathname + '/update', {
  726. postType: 'paste-block',
  727. postData: {
  728. id: tree.getNodeKey(node),
  729. tid: copyInfo.tid,
  730. block: copyInfo.block,
  731. }
  732. }, function (data) {
  733. pos.updateDatas(data.pos);
  734. const result = tree.loadPostData(data.ledger);
  735. self.refreshTree(sheet, result);
  736. const sel = sheet.getSelections()[0];
  737. if (sel) {
  738. sheet.setSelection(tree.nodes.indexOf(result.create[0]), sel.col, sel.rowCount, sel.colCount);
  739. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(result.create[0])]);
  740. }
  741. self.refreshOperationValid(sheet);
  742. removeLocalCache(copyBlockTag);
  743. }, null, true);
  744. },
  745. topRowChanged: function (e, info) {
  746. SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
  747. },
  748. editStarting(e, info) {
  749. if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
  750. const col = info.sheet.zh_setting.cols[info.col];
  751. const node = info.sheet.zh_tree.nodes[info.row];
  752. if (!node) {
  753. info.cancel = true;
  754. return;
  755. }
  756. const exprInfo = getExprInfo(col.field);
  757. if (exprInfo) {
  758. if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
  759. info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
  760. }
  761. }
  762. switch (col.field) {
  763. case 'code':
  764. const posRange = pos.getLedgerPos(node.id);
  765. info.cancel = posRange && posRange.length > 0;
  766. break;
  767. case 'unit_price':
  768. info.cancel = (node.children && node.children.length > 0) || node.used;
  769. break;
  770. case 'sgfh_qty':
  771. case 'sgfh_tp':
  772. case 'sjcl_qty':
  773. case 'sjcl_tp':
  774. case 'qtcl_qty':
  775. case 'qtcl_tp':
  776. case 'deal_qty':
  777. case 'deal_tp':
  778. info.cancel = (node.children && node.children.length > 0);
  779. break;
  780. case 'dgn_qty1':
  781. case 'dgn_qty2':
  782. info.cancel = !_.isEmpty(node.b_code);
  783. break;
  784. }
  785. },
  786. cut: function (sheet, sel, callback) {
  787. if (!sheet || !sel) return;
  788. if (sel.colCount >= sheet.zh_setting.cols.length) {
  789. toastr.warning('请勿选中整行剪切');
  790. return;
  791. }
  792. const sortData = SpreadJsObj.getSortData(sheet), datas = [];
  793. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  794. const node = sortData[iRow];
  795. if (node) {
  796. const data = sheet.zh_tree.getNodeKeyData(node);
  797. for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
  798. const col = sheet.zh_setting.cols[iCol];
  799. if (col.field === 'b_code' || col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
  800. col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
  801. col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
  802. const lPos = pos.getLedgerPos(node.id);
  803. if (lPos && lPos.length > 0) {
  804. toastr.error('不可剪切');
  805. return;
  806. }
  807. }
  808. const style = sheet.getStyle(iRow, iCol);
  809. if (style.locked) {
  810. toastr.error('不可剪切');
  811. return;
  812. }
  813. const colSetting = sheet.zh_setting.cols[iCol];
  814. data[colSetting.field] = null;
  815. const exprInfo = getExprInfo(colSetting.field);
  816. if (exprInfo) {
  817. data[exprInfo.expr] = '';
  818. }
  819. }
  820. datas.push(data);
  821. }
  822. }
  823. if (datas.length > 0) {
  824. callback();
  825. postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
  826. const refreshNode = sheet.zh_tree.loadPostData(result);
  827. billsTreeSpreadObj.refreshTree(sheet, refreshNode);
  828. });
  829. }
  830. },
  831. sortCode: function (sheet) {
  832. const tree = sheet.zh_tree;
  833. if (!tree) return;
  834. const select = SpreadJsObj.getSelectObject(sheet);
  835. if (!select || !select.code || select.code === '') return;
  836. const recursiveSortCode = function (data, parentCode, children) {
  837. if (!children || children.length === 0) return;
  838. for (const [i, child] of children.entries()) {
  839. if (!child.b_code || child.b_code === '') {
  840. const code = parentCode + '-' + (i + 1);
  841. const cData = tree.getNodeKeyData(child);
  842. cData.code = code;
  843. data.push(cData);
  844. if (!tree.isLeafXmj(child)) {
  845. recursiveSortCode(data, code, child.children);
  846. }
  847. }
  848. }
  849. };
  850. const data = [];
  851. recursiveSortCode(data, select.code, select.children);
  852. if (data.length > 0) {
  853. postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
  854. const refreshNode = tree.loadPostData(result);
  855. billsTreeSpreadObj.refreshTree(sheet, refreshNode);
  856. })
  857. }
  858. }
  859. };
  860. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  861. billsTreeSpreadObj.loadExprToInput(billsSheet);
  862. billsSpread.bind(spreadNS.Events.SelectionChanged, billsTreeSpreadObj.selectionChanged);
  863. billsSpread.bind(spreadNS.Events.topRowChanged, billsTreeSpreadObj.topRowChanged);
  864. if (!readOnly) {
  865. // 增删上下移升降级
  866. $('a[name="base-opr"]').click(function () {
  867. billsTreeSpreadObj.baseOpr(billsSheet, this.getAttribute('type'));
  868. });
  869. $('a[name=cpc]').click(function () {
  870. billsSpread.commandManager().execute({
  871. cmd: this.getAttribute('type'),
  872. sheetName: billsSheet.name()
  873. });
  874. });
  875. $('#bills-expr').bind('change onblur', function () {
  876. if (this.readOnly) return;
  877. const expr = $(this);
  878. const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
  879. const select = billsTree.getItemsByIndex(row);
  880. if (!select) return;
  881. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
  882. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  883. const data = {
  884. id: select.id,
  885. tender_id: select.tender_id,
  886. ledger_id: select.ledger_id
  887. };
  888. const exprInfo = getExprInfo(field);
  889. if (newValue !== '') {
  890. const num = _.toNumber(newValue);
  891. if (num) {
  892. data[field] = num;
  893. if (exprInfo) {
  894. data[exprInfo.expr] = '';
  895. }
  896. } else {
  897. try {
  898. data[field] = math.evaluate(transExpr(newValue));
  899. if (exprInfo) {
  900. data[exprInfo.expr] = newValue;
  901. }
  902. } catch (err) {
  903. toastr.error('输入的表达式非法');
  904. return;
  905. }
  906. }
  907. } else {
  908. data[field] = null;
  909. if (exprInfo) {
  910. data[exprInfo.expr] = '';
  911. }
  912. }
  913. // 更新至服务器
  914. postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
  915. const refreshNode = billsTree.loadPostData(result);
  916. billsTreeSpreadObj.refreshTree(billsSheet, refreshNode);
  917. });
  918. });
  919. billsSpread.bind(spreadNS.Events.EditStarting, billsTreeSpreadObj.editStarting);
  920. billsSpread.bind(spreadNS.Events.EditEnded, billsTreeSpreadObj.editEnded);
  921. billsSpread.bind(spreadNS.Events.ClipboardPasting, billsTreeSpreadObj.clipboardPasting);
  922. billsSpread.bind(spreadNS.Events.ClipboardChanging, function (e, info) {
  923. const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
  924. SpreadJsObj.Clipboard.setCopyData(copyText);
  925. });
  926. SpreadJsObj.addDeleteBind(billsSpread, billsTreeSpreadObj.deletePress);
  927. SpreadJsObj.addCutEvents(billsSpread, billsTreeSpreadObj.cut);
  928. }
  929. // 右键菜单
  930. let batchInsertObj;
  931. $.contextMenu.types.batchInsert = function (item, opt, root) {
  932. const self = this;
  933. if ($.isFunction(item.icon)) {
  934. item._icon = item.icon.call(this, this, $t, key, item);
  935. } else {
  936. if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
  937. // to enable font awesome
  938. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
  939. } else {
  940. item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
  941. }
  942. }
  943. this.addClass(item._icon);
  944. const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="20" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
  945. .appendTo(this);
  946. const $input = $obj.find('input');
  947. const event = () => {
  948. if (self.hasClass('context-menu-disabled')) return;
  949. item.batchInsert($input[0], root);
  950. };
  951. $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
  952. $input.click((e) => {e.stopPropagation();})
  953. .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
  954. .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
  955. };
  956. const billsContextMenuOptions = {
  957. selector: '#bills-spread',
  958. build: function ($trigger, e) {
  959. const target = SpreadJsObj.safeRightClickSelection($trigger, e, billsSpread);
  960. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  961. },
  962. items: {}
  963. };
  964. if (!readOnly) {
  965. billsContextMenuOptions.items.create = {
  966. name: '新增',
  967. icon: 'fa-sign-in',
  968. callback: function (key, opt) {
  969. billsTreeSpreadObj.baseOpr(billsSheet, 'add');
  970. },
  971. disabled: function (key, opt) {
  972. const sheet = billsSheet;
  973. const selection = sheet.getSelections();
  974. const sel = selection ? selection[0] : sheet.getSelections()[0];
  975. const row = sel ? sel.row : -1;
  976. const tree = sheet.zh_tree;
  977. if (!tree) return true;
  978. const first = sheet.zh_tree.nodes[row];
  979. const valid = !sheet.zh_setting.readOnly;
  980. return !(valid && first && first.level > 1);
  981. }
  982. };
  983. billsContextMenuOptions.items.delete = {
  984. name: '删除',
  985. icon: 'fa-remove',
  986. callback: function (key, opt) {
  987. billsTreeSpreadObj.baseOpr(billsSheet, 'delete');
  988. },
  989. disabled: function (key, opt) {
  990. const sheet = billsSheet;
  991. const selection = sheet.getSelections();
  992. const sel = selection ? selection[0] : sheet.getSelections()[0];
  993. const row = sel ? sel.row : -1;
  994. const tree = sheet.zh_tree;
  995. if (!tree) return true;
  996. const first = sheet.zh_tree.nodes[row];
  997. let last = first, sameParent = true, nodeUsed = first.used;
  998. if (sel.rowCount > 1 && first) {
  999. for (let r = 1; r < sel.rowCount; r++) {
  1000. const rNode = tree.nodes[sel.row + r];
  1001. if (!rNode) {
  1002. sameParent = false;
  1003. break;
  1004. }
  1005. nodeUsed = nodeUsed || rNode.used;
  1006. if (rNode.level > first.level) continue;
  1007. if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
  1008. sameParent = false;
  1009. break;
  1010. }
  1011. last = rNode;
  1012. }
  1013. }
  1014. const valid = !sheet.zh_setting.readOnly;
  1015. return !(valid && first && sameParent && !(first.level === 1 && first.node_type) && !nodeUsed);
  1016. }
  1017. };
  1018. billsContextMenuOptions.items.sprBase = '----';
  1019. }
  1020. billsContextMenuOptions.items.copyBlock = {
  1021. name: '复制整块',
  1022. icon: 'fa-files-o',
  1023. callback: function (key, opt) {
  1024. const copyBlockList = [];
  1025. const sheet = billsSheet;
  1026. const sel = sheet.getSelections()[0];
  1027. let iRow = sel.row;
  1028. const pid = sheet.zh_tree.nodes[iRow].ledger_pid;
  1029. while (iRow < sel.row + sel.rowCount) {
  1030. const node = sheet.zh_tree.nodes[iRow];
  1031. if (node.ledger_pid !== pid) {
  1032. toastr.error('仅可同时选中同层节点');
  1033. return;
  1034. }
  1035. const posterity = sheet.zh_tree.getPosterity(node);
  1036. iRow += posterity.length + 1;
  1037. posterity.unshift(node);
  1038. copyBlockList.push(sheet.zh_tree.getDefaultData(posterity));
  1039. }
  1040. for (const cbl of copyBlockList) {
  1041. for (const b of cbl) {
  1042. const posRange = pos.getLedgerPos(b.id);
  1043. if (posRange && posRange.length > 0) b.pos = posRange;
  1044. }
  1045. }
  1046. setLocalCache(copyBlockTag, JSON.stringify({ block: copyBlockList }));
  1047. },
  1048. visible: function (key, opt) {
  1049. const sheet = billsSheet;
  1050. const selection = sheet.getSelections();
  1051. const row = selection[0].row;
  1052. const select = billsTree.nodes[row];
  1053. return select;
  1054. },
  1055. disabled: function (key, opt) {
  1056. const sheet = billsSheet;
  1057. const selection = sheet.getSelections();
  1058. const row = selection[0].row;
  1059. const select = billsTree.nodes[row];
  1060. return select && select.level <= 1;
  1061. }
  1062. };
  1063. billsContextMenuOptions.items.copyBlockXmj = {
  1064. name: '复制整块(只复制项目节)',
  1065. icon: 'fa-files-o',
  1066. callback: function (key, opt) {
  1067. const copyBlockList = [];
  1068. const sheet = billsSheet;
  1069. const sel = sheet.getSelections()[0];
  1070. let iRow = sel.row;
  1071. const pid = sheet.zh_tree.nodes[iRow].ledger_pid;
  1072. while (iRow < sel.row + sel.rowCount) {
  1073. const node = sheet.zh_tree.nodes[iRow];
  1074. if (node.ledger_pid !== pid) {
  1075. toastr.error('仅可同时选中同层节点');
  1076. return;
  1077. }
  1078. const posterity = sheet.zh_tree.getPosterity(node);
  1079. iRow += posterity.length + 1;
  1080. const copyPosterity = posterity.filter(x => { return !x.b_code; });
  1081. copyPosterity.unshift(node);
  1082. const copyData = sheet.zh_tree.getDefaultData(copyPosterity);
  1083. for (const p of copyData) {
  1084. const children = copyData.filter(y => {return y.ledger_pid === p.ledger_id}) || [];
  1085. p.is_leaf = children.length === 0;
  1086. }
  1087. copyBlockList.push(copyData);
  1088. }
  1089. setLocalCache(copyBlockTag, JSON.stringify({ block: copyBlockList }));
  1090. },
  1091. visible: function (key, opt) {
  1092. const sheet = billsSheet;
  1093. const selection = sheet.getSelections();
  1094. const row = selection[0].row;
  1095. const select = billsTree.nodes[row];
  1096. return select;
  1097. },
  1098. disabled: function (key, opt) {
  1099. const sheet = billsSheet;
  1100. const selection = sheet.getSelections();
  1101. const row = selection[0].row;
  1102. const select = billsTree.nodes[row];
  1103. return select && select.level <= 1;
  1104. }
  1105. };
  1106. if (!readOnly) {
  1107. billsContextMenuOptions.items.pasteBlock = {
  1108. name: '粘贴整块',
  1109. icon: 'fa-clipboard',
  1110. disabled: function (key, opt) {
  1111. //const block = treeOperationObj.block || [];
  1112. const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
  1113. return !(copyInfo && copyInfo.block && copyInfo.block.length > 0);
  1114. },
  1115. callback: function (key, opt) {
  1116. //const block = treeOperationObj.block || [];
  1117. const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
  1118. if (copyInfo.block.length > 0) {
  1119. billsTreeSpreadObj.pasteBlock(billsSpread, copyInfo);
  1120. } else {
  1121. document.execCommand('paste');
  1122. }
  1123. },
  1124. visible: function (key, opt) {
  1125. return !readOnly;
  1126. }
  1127. };
  1128. billsContextMenuOptions.items.sprBlock = '----';
  1129. }
  1130. if (!readOnly) {
  1131. billsContextMenuOptions.items.batchInsert = {
  1132. name: '批量插入',
  1133. type: 'batchInsert',
  1134. value: '2',
  1135. icon: 'fa-sign-in',
  1136. batchInsert: function (obj, root) {
  1137. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  1138. obj.value = obj.max;
  1139. toastr.warning('批量插入不可多于' + obj.max);
  1140. } else if (_.toNumber(obj.value) < _.toNumber(obj.min)) {
  1141. obj.value = obj.min;
  1142. toastr.warning('批量插入不可少于' + obj.min);
  1143. } else {
  1144. billsTreeSpreadObj.baseOpr(billsSheet, 'add', parseInt(obj.value));
  1145. root.$menu.trigger('contextmenu:hide');
  1146. }
  1147. },
  1148. disabled: function (key, opt) {
  1149. const sheet = billsSheet;
  1150. const selection = sheet.getSelections();
  1151. const sel = selection ? selection[0] : sheet.getSelections()[0];
  1152. const row = sel ? sel.row : -1;
  1153. const tree = sheet.zh_tree;
  1154. if (!tree) return true;
  1155. const first = sheet.zh_tree.nodes[row];
  1156. const valid = !sheet.zh_setting.readOnly;
  1157. return !(valid && first && first.level > 1);
  1158. }
  1159. };
  1160. billsContextMenuOptions.items.batchInsertBillsPos = {
  1161. name: '批量插入清单-计量单元',
  1162. icon: 'fa-sign-in',
  1163. disabled: function (key, opt) {
  1164. if (!isTz) return true;
  1165. const select = SpreadJsObj.getSelectObject(billsSheet);
  1166. if (select) {
  1167. if (select.code && select.code !== '') {
  1168. return !billsTree.isLeafXmj(select);
  1169. } else {
  1170. const parent = billsTree.getParent(select);
  1171. return !(parent && billsTree.isLeafXmj(parent));
  1172. }
  1173. } else {
  1174. return false;
  1175. }
  1176. },
  1177. callback: function (key, opt) {
  1178. if (!batchInsertObj) {
  1179. batchInsertObj = new BatchInsertBillsPosObj($('#batch'));
  1180. } else {
  1181. batchInsertObj.initView();
  1182. }
  1183. $('#batch').modal('show');
  1184. }
  1185. };
  1186. billsContextMenuOptions.items.sprBatch = '----';
  1187. billsContextMenuOptions.items.importGclBills2Xmj = {
  1188. name: '导入工程量清单至项目节',
  1189. icon: 'fa-file-excel-o',
  1190. disabled: function (key, opt) {
  1191. const node = SpreadJsObj.getSelectObject(billsSheet);
  1192. return readOnly
  1193. || (node.children && node.children.length > 0)
  1194. || (!_.isNil(node.b_code) && node.b_code !== '')
  1195. || billsTree.checkNodeUsed(node, pos);
  1196. },
  1197. callback: function (key, opt) {
  1198. const node = SpreadJsObj.getSelectObject(billsSheet);
  1199. importExcel.doImport({
  1200. template: {
  1201. hint: '工程量清单',
  1202. url: '/template/导入工程量清单EXCEL格式.xls',
  1203. },
  1204. callback: function (sheet) {
  1205. postDataCompress(window.location.pathname + '/upload-excel/gcl2xmj', {id: node.id, sheet: sheet}, function (result) {
  1206. const sel = billsSheet.getSelections();
  1207. const refreshNode = billsTree.loadPostData(result);
  1208. billsTreeSpreadObj.refreshTree(billsSheet, refreshNode);
  1209. if (refreshNode.create[0]) {
  1210. if (sel && sel[0]) {
  1211. billsSheet.setSelection(refreshNode.create[0].index, sel[0].col, sel[0].rowCount, sel[0].colCount);
  1212. SpreadJsObj.reloadRowsBackColor(billsSheet, [sel[0].row, refreshNode.create[0].index]);
  1213. } else {
  1214. billsSheet.setSelection(refreshNode.create[0].index, 0, 1, 1);
  1215. SpreadJsObj.reloadRowsBackColor(billsSheet, [refreshNode.create[0].index]);
  1216. }
  1217. }
  1218. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1219. }, null);
  1220. }
  1221. });
  1222. }
  1223. };
  1224. }
  1225. billsContextMenuOptions.items.sprTag = '----';
  1226. billsContextMenuOptions.items.showLast = {
  1227. name: '显示至最底层',
  1228. callback: function (key, opt, menu, e) {
  1229. const node = SpreadJsObj.getSelectObject(billsSheet);
  1230. setTimeout(() => {
  1231. showWaitingView();
  1232. billsTree.expandByCustom(x => {
  1233. return (x.id === node.id) || (x.full_path.indexOf(node.ledger_id + '-') >= 0);
  1234. });
  1235. SpreadJsObj.refreshTreeRowVisible(billsSheet);
  1236. closeWaitingView();
  1237. }, 100);
  1238. },
  1239. };
  1240. $.contextMenu(billsContextMenuOptions);
  1241. // 计量单元 相关方法&绑定spreadjs事件
  1242. const posSpreadObj = {
  1243. refreshOperationValid: function (sheet, selection) {
  1244. const setObjEnable = function (obj, enable) {
  1245. if (enable) {
  1246. obj.removeClass('disabled');
  1247. } else {
  1248. obj.addClass('disabled');
  1249. }
  1250. };
  1251. const invalidAll = function () {
  1252. setObjEnable($('a[name=pos-opr][type=up-move]'), false);
  1253. setObjEnable($('a[name=pos-opr][type=down-move]'), false);
  1254. };
  1255. const sel = selection ? selection[0] : sheet.getSelections()[0];
  1256. const row = sel ? sel.row : -1;
  1257. const first = sheet.zh_data[row];
  1258. if (!first) {
  1259. invalidAll();
  1260. return;
  1261. }
  1262. let last = first;
  1263. if (sel.rowCount > 1 && first) {
  1264. for (let r = 1; r < sel.rowCount; r++) {
  1265. const rNode = sheet.zh_data[sel.row + r];
  1266. if (!rNode) break;
  1267. last = rNode;
  1268. }
  1269. }
  1270. const preNode = sheet.zh_data[row - 1];
  1271. const valid = !sheet.zh_setting.readOnly;
  1272. setObjEnable($('a[name=pos-opr][type=up-move]'), valid && first && preNode);
  1273. setObjEnable($('a[name=pos-opr][type=down-move]'), valid && first && (sheet.zh_data.indexOf(last) < sheet.zh_data.length - 1));
  1274. },
  1275. loadExprToInput: function () {
  1276. const sel = posSheet.getSelections()[0];
  1277. if (!sel) return;
  1278. const col = posSheet.zh_setting.cols[sel.col];
  1279. const cell = posSheet.getCell(sel.col, sel.col);
  1280. if (col && col.type === 'Number') {
  1281. const data = SpreadJsObj.getSelectObject(posSheet);
  1282. if (data) {
  1283. const exprInfo = getExprInfo(col.field);
  1284. const value = exprInfo
  1285. ? (data[exprInfo.expr] ? data[exprInfo.expr] : data[col.field])
  1286. : data[col.field];
  1287. $('#pos-expr').val(value).attr('field', col.field).attr('org', data[col.field])
  1288. .attr('readOnly', readOnly || cell.locked()).attr('data-row', sel.row);
  1289. } else {
  1290. $('#pos-expr').val('').attr('readOnly', true);
  1291. $('#pos-expr').removeAttr('data-row');
  1292. }
  1293. } else {
  1294. $('#pos-expr').val('').attr('readOnly', true);
  1295. $('#pos-expr').removeAttr('data-row');
  1296. }
  1297. },
  1298. /**
  1299. * 加载计量单元 根据当前台账选择节点
  1300. */
  1301. loadCurPosData: function () {
  1302. const node = SpreadJsObj.getSelectObject(billsSheet);
  1303. if (node) {
  1304. const posData = pos.getLedgerPos(node.id) || [];
  1305. SpreadJsObj.loadSheetData(posSheet, 'data', posData);
  1306. posSheet.zh_setting.readOnly = readOnly || (node.used && posData.length === 0);
  1307. } else {
  1308. SpreadJsObj.loadSheetData(posSheet, 'data', []);
  1309. posSheet.zh_setting.readOnly = true;
  1310. }
  1311. SpreadJsObj.refreshSheetReadOnly(posSheet);
  1312. posSpreadObj.loadExprToInput();
  1313. posSpreadObj.refreshOperationValid(posSheet);
  1314. },
  1315. baseOpr: function (sheet, type) {
  1316. const data = {
  1317. postType: 'pos',
  1318. posPostType: type === 'delete' ? type : 'update',
  1319. postData: [],
  1320. };
  1321. const selection = sheet.getSelections();
  1322. const row = selection[0].row, count = selection[0].rowCount;
  1323. const first = sheet.zh_data[row];
  1324. if (type === 'delete') {
  1325. for (let iRow = 0; iRow < count; iRow++) {
  1326. const posData = sheet.zh_data[iRow + row];
  1327. if (posData) {
  1328. if (posData.used) {
  1329. toastr.error('"' + posData.name + '"已计量,请勿删除');
  1330. return;
  1331. }
  1332. data.postData.push(sheet.zh_data[iRow + row].id);
  1333. }
  1334. }
  1335. } else if (type === 'up-move') {
  1336. const pre = sheet.zh_data[row - 1], preUpdate = {id: pre.id};
  1337. for (let iRow = 0; iRow < count; iRow++) {
  1338. const posData = sheet.zh_data[iRow + row];
  1339. if (posData) {
  1340. data.postData.push({id: posData.id, lid: posData.lid, porder: sheet.zh_data[iRow + row - 1].porder});
  1341. preUpdate.porder = posData.porder;
  1342. }
  1343. }
  1344. data.postData.push(preUpdate);
  1345. } else if (type === 'down-move') {
  1346. const next = sheet.zh_data[row + count], nextUpdate = {id: next.id};
  1347. for (let iRow = count - 1; iRow >= 0; iRow--) {
  1348. const posData = sheet.zh_data[iRow + row];
  1349. if (posData) {
  1350. data.postData.push({id: posData.id, lid: posData.lid, porder: sheet.zh_data[iRow + row + 1].porder});
  1351. nextUpdate.porder = posData.porder;
  1352. }
  1353. }
  1354. data.postData.push(nextUpdate);
  1355. }
  1356. if (data.postData.length > 0) {
  1357. postData(window.location.pathname + '/update', data, function (result) {
  1358. if (type === 'delete') {
  1359. pos.removeDatas(result.pos);
  1360. sheet.deleteRows(row, count);
  1361. const loadResult = billsTree.loadPostData(result.ledger);
  1362. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1363. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1364. posSpreadObj.refreshOperationValid(posSheet);
  1365. } else {
  1366. pos.updateDatas(result.pos);
  1367. const sel = selection[0];
  1368. if (sel) {
  1369. sheet.setSelection(sheet.zh_data.indexOf(first), sel.col, sel.rowCount, sel.colCount);
  1370. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, sheet.zh_data.indexOf(first)]);
  1371. }
  1372. posSpreadObj.loadCurPosData();
  1373. }
  1374. });
  1375. }
  1376. },
  1377. editStarting: function (e, info) {
  1378. posSpreadObj.billsNode = SpreadJsObj.getSelectObject(billsSheet);
  1379. const sel = info.sheet.getSelections();
  1380. if (!sel || !sel[0]) return;
  1381. const col = info.sheet.zh_setting.cols[sel[0].col];
  1382. const node = SpreadJsObj.getSelectObject(info.sheet);
  1383. const exprInfo = getExprInfo(col.field);
  1384. if (exprInfo) {
  1385. if (node[exprInfo.expr] && node[exprInfo.expr] !== '') {
  1386. info.sheet.getCell(info.row, info.col).text(node[exprInfo.expr]);
  1387. }
  1388. }
  1389. },
  1390. /**
  1391. * 编辑单元格响应事件
  1392. * @param {Object} e
  1393. * @param {Object} info
  1394. */
  1395. editEnded: function (e, info) {
  1396. if (!info.sheet.zh_setting) {
  1397. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1398. return;
  1399. }
  1400. const posData = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
  1401. const col = info.sheet.zh_setting.cols[info.col];
  1402. const orgText = posData ? posData[col.field] : null;
  1403. const newText = trimInvalidChar(info.editingText);
  1404. if (orgText === newText || ((!orgText || orgText === '') && (newText === ''))) return;
  1405. const node = posSpreadObj.billsNode;
  1406. if (!node) {
  1407. toastr.error('数据错误,请选择台账节点后再试');
  1408. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1409. return;
  1410. } else if (newText && newText !== '' && node.children && node.children.length > 0) {
  1411. toastr.error('父节点不可插入计量单元');
  1412. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1413. return;
  1414. } else if (newText && newText !== '' && (!node.b_code || node.b_code === '')) {
  1415. toastr.error('项目节不可插入计量单元');
  1416. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1417. return;
  1418. }
  1419. const data = {postType: 'pos'};
  1420. if (col.field === 'name') {
  1421. if (newText === '' && posData) {
  1422. toastr.error('部位名称不可为空', 'error');
  1423. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1424. return;
  1425. } else if (!posData) {
  1426. if (newText && newText !== '') {
  1427. data.posPostType = 'add';
  1428. const sortData = info.sheet.zh_data;
  1429. const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
  1430. data.postData = { name: newText, lid: node.id, porder: order};
  1431. } else {
  1432. return;
  1433. }
  1434. } else {
  1435. data.posPostType = 'update';
  1436. data.postData = {id: posData.id, name: newText};
  1437. }
  1438. } else if (!posData) {
  1439. toastr.warning('新增计量单元请先输入名称');
  1440. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1441. return;
  1442. } else {
  1443. data.posPostType = 'update';
  1444. data.postData = {id: posData.id};
  1445. if (col.type === 'Number') {
  1446. const exprInfo = getExprInfo(col.field);
  1447. const num = _.toNumber(newText);
  1448. if (_.isFinite(num)) {
  1449. data.postData[col.field] = num;
  1450. if (exprInfo) {
  1451. data.postData[exprInfo.expr] = '';
  1452. }
  1453. } else {
  1454. try {
  1455. data.postData[col.field] = math.evaluate(transExpr(newText));
  1456. if (exprInfo) {
  1457. data.postData[exprInfo.expr] = newText;
  1458. }
  1459. } catch(err) {
  1460. toastr.error('输入的表达式非法');
  1461. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1462. return;
  1463. }
  1464. }
  1465. } else {
  1466. data.postData[col.field] = newText;
  1467. }
  1468. }
  1469. postData(window.location.pathname + '/update', data, function (result) {
  1470. const updateRst = pos.updateDatas(result.pos);
  1471. // 刷新当前行, 不适用于新增(在非下一空白行新增)
  1472. if (updateRst.create.length > 0) {
  1473. posSpreadObj.loadCurPosData();
  1474. } else {
  1475. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1476. }
  1477. const loadResult = billsTree.loadPostData(result.ledger);
  1478. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1479. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1480. }, function () {
  1481. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  1482. });
  1483. },
  1484. /**
  1485. * 删除按钮响应事件
  1486. * @param sheet
  1487. */
  1488. deletePress: function (sheet) {
  1489. if (!sheet.zh_setting) return;
  1490. const sortData = sheet.zh_data;
  1491. const datas = [], posSelects = [];
  1492. const sel = sheet.getSelections()[0];
  1493. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
  1494. let bDel = false;
  1495. const node = sortData[iRow];
  1496. if (node) {
  1497. const data = {id: node.id};
  1498. for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
  1499. const colSetting = sheet.zh_setting.cols[iCol];
  1500. if (colSetting.field === 'name') {
  1501. toastr.error('部位名称不能为空');
  1502. return;
  1503. }
  1504. const style = sheet.getStyle(iRow, iCol);
  1505. if (!style.locked) {
  1506. const colSetting = sheet.zh_setting.cols[iCol];
  1507. data[colSetting.field] = null;
  1508. const exprInfo = getExprInfo(colSetting.field);
  1509. if (exprInfo) {
  1510. data[exprInfo.expr] = '';
  1511. }
  1512. bDel = true;
  1513. }
  1514. }
  1515. if (bDel) {
  1516. datas.push(data);
  1517. posSelects.push(node);
  1518. }
  1519. }
  1520. }
  1521. if (datas.length > 0) {
  1522. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: datas}, function (result) {
  1523. pos.updateDatas(result.pos);
  1524. posSpreadObj.loadCurPosData();
  1525. const loadResult = billsTree.loadPostData(result.ledger);
  1526. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1527. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1528. }, function () {
  1529. posSpreadObj.loadCurPosData();
  1530. });
  1531. }
  1532. },
  1533. /**
  1534. * 删除 计量单元
  1535. * @param sheet
  1536. */
  1537. deletePos: function (sheet) {
  1538. const selection = sheet.getSelections();
  1539. const data = {
  1540. postType: 'pos',
  1541. posPostType: 'delete',
  1542. postData: [],
  1543. };
  1544. const row = selection[0].row, count = selection[0].rowCount;
  1545. const sortData = sheet.zh_data;
  1546. for (let iRow = 0; iRow < count; iRow++) {
  1547. const posData = sortData[iRow + row];
  1548. if (posData) {
  1549. if (posData.used) {
  1550. toastr.error('"' + posData.name + '"已计量,请勿删除');
  1551. return;
  1552. }
  1553. data.postData.push(sortData[iRow + row].id);
  1554. }
  1555. }
  1556. if (data.postData.length > 0) {
  1557. postData(window.location.pathname + '/update', data, function (result) {
  1558. pos.removeDatas(result.pos);
  1559. sheet.deleteRows(row, count);
  1560. const loadResult = billsTree.loadPostData(result.ledger);
  1561. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1562. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1563. });
  1564. }
  1565. },
  1566. /**
  1567. * 粘贴单元格响应事件
  1568. * @param e
  1569. * @param info
  1570. */
  1571. clipboardPasted: function (e, info) {
  1572. if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
  1573. info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
  1574. }
  1575. const node = SpreadJsObj.getSelectObject(billsSheet);
  1576. if (node.code && (node.code !== '')) {
  1577. toastr.error('项目节不可含有节点明细');
  1578. posSpreadObj.loadCurPosData();
  1579. return;
  1580. }
  1581. if (node.children && (node.children.length > 0)) {
  1582. toastr.error('仅节点子项可以含有计量单元');
  1583. posSpreadObj.loadCurPosData();
  1584. return;
  1585. }
  1586. if (!info.sheet.zh_setting) {
  1587. posSpreadObj.loadCurPosData();
  1588. return;
  1589. }
  1590. const data = [];
  1591. const sortData = info.sheet.zh_data || [];
  1592. if (sortData.length === 0 || info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  1593. if (info.cellRange.col !== 0) {
  1594. toastr.warning('新增计量单元请先输入名称');
  1595. posSpreadObj.loadCurPosData();
  1596. return;
  1597. }
  1598. }
  1599. let bHint = false;
  1600. const lastOrder = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
  1601. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  1602. let bPaste = true;
  1603. const curRow = info.cellRange.row + iRow;
  1604. const posData = curRow >= sortData.length ? {lid: node.id, porder: lastOrder + curRow - sortData.length} : {id: sortData[curRow].id, lid: node.id};
  1605. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  1606. const curCol = info.cellRange.col + iCol;
  1607. const colSetting = info.sheet.zh_setting.cols[curCol];
  1608. if (!colSetting) continue;
  1609. posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
  1610. if (colSetting.type === 'Number') {
  1611. const num = _.toNumber(posData[colSetting.field]);
  1612. if (num) {
  1613. posData[colSetting.field] = num;
  1614. } else {
  1615. try {
  1616. posData[colSetting.field] = math.evaluate(transExpr(posData[colSetting.field]));
  1617. const exprInfo = getExprInfo(colSetting.field);
  1618. if (exprInfo) {
  1619. posData[exprInfo.expr] = trimInvalidChar(info.sheet.getText(curRow, curCol));
  1620. }
  1621. } catch (err) {
  1622. if (!bHint) {
  1623. toastr.warning('粘贴了非法表达式,已过滤');
  1624. bHint = true;
  1625. }
  1626. bPaste = false;
  1627. }
  1628. }
  1629. }
  1630. }
  1631. if (bPaste) {
  1632. data.push(posData);
  1633. }
  1634. }
  1635. if (data.length === 0) {
  1636. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  1637. return;
  1638. }
  1639. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: data}, function (result) {
  1640. pos.updateDatas(result.pos);
  1641. posSpreadObj.loadCurPosData();
  1642. const loadResult = billsTree.loadPostData(result.ledger);
  1643. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1644. posSpreadObj.loadCurPosData();
  1645. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1646. }, function () {
  1647. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  1648. });
  1649. },
  1650. selectionChanged: function (e, info) {
  1651. posSpreadObj.loadExprToInput();
  1652. posSpreadObj.refreshOperationValid(posSheet);
  1653. },
  1654. addPegs: function (pegs) {
  1655. if (!pegs || pegs.length <= 0) return;
  1656. const node = SpreadJsObj.getSelectObject(billsSheet);
  1657. if (!node) return;
  1658. const sheet = posSpread.getActiveSheet();
  1659. const sortData = sheet.zh_data || [];
  1660. let order = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
  1661. pegs.forEach(function (p) {p.porder = ++order; p.lid = node.id});
  1662. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: pegs}, function (result) {
  1663. pos.updateDatas(result.pos);
  1664. posSpreadObj.loadCurPosData();
  1665. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1666. });
  1667. }
  1668. };
  1669. posSpread.bind(spreadNS.Events.SelectionChanged, posSpreadObj.selectionChanged);
  1670. if (!readOnly && isTz) {
  1671. $('a[name="pos-opr"]').click(function () {
  1672. posSpreadObj.baseOpr(posSheet, this.getAttribute('type'));
  1673. });
  1674. $('#pos-expr').bind('change onblur', function () {
  1675. if (this.readOnly) return;
  1676. const expr = $(this);
  1677. const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
  1678. const select = posSheet.zh_data ? posSheet.zh_data[row] : null;
  1679. if (!select) return;
  1680. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
  1681. if (orgValue === newValue || (!orgValue && newValue == '')) return;
  1682. const data = {id: select.id};
  1683. const exprInfo = getExprInfo(field);
  1684. if (newValue !== '') {
  1685. const num = _.toNumber(newValue);
  1686. if (num) {
  1687. data[field] = num;
  1688. if (exprInfo) data[exprInfo.expr] = '';
  1689. } else {
  1690. try {
  1691. data[field] = math.evaluate(transExpr(newValue));
  1692. if (exprInfo) data[exprInfo.expr] = newValue;
  1693. } catch (err) {
  1694. toastr.error('输入的表达式非法');
  1695. return;
  1696. }
  1697. }
  1698. } else {
  1699. data[field] = null;
  1700. if (exprInfo) data[exprInfo.expr] = '';
  1701. }
  1702. // 更新至服务器
  1703. postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: data}, function (result) {
  1704. const updateRst = pos.updateDatas(result.pos);
  1705. // 刷新当前行, 不适用于新增(在非下一空白行新增)
  1706. SpreadJsObj.reLoadRowData(posSheet, row);
  1707. const loadResult = billsTree.loadPostData(result.ledger);
  1708. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  1709. billsTreeSpreadObj.refreshOperationValid(billsSheet);
  1710. });
  1711. });
  1712. posSpread.bind(spreadNS.Events.EditStarting, posSpreadObj.editStarting);
  1713. posSpread.bind(spreadNS.Events.EditEnded, posSpreadObj.editEnded);
  1714. posSpread.bind(spreadNS.Events.ClipboardPasted, posSpreadObj.clipboardPasted);
  1715. SpreadJsObj.addDeleteBind(posSpread, posSpreadObj.deletePress);
  1716. const mergePeg = NewMergePeg({ callback: posSpreadObj.addPegs });
  1717. $.contextMenu({
  1718. selector: '#pos-spread',
  1719. build: function ($trigger, e) {
  1720. const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
  1721. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  1722. },
  1723. items: {
  1724. 'delete': {
  1725. name: '删除',
  1726. icon: 'fa-remove',
  1727. disabled: function (key, opt) {
  1728. if (posSheet.zh_data) {
  1729. const selection = posSheet.getSelections();
  1730. return posSheet.zh_data.length < selection[0].row + selection[0].rowCount;
  1731. } else {
  1732. return true;
  1733. }
  1734. },
  1735. callback: function (key, opt) {
  1736. posSpreadObj.deletePos(posSheet);
  1737. }
  1738. },
  1739. 'merge-peg': {
  1740. name: '合并起讫桩号',
  1741. disabled: function (key, opt) {
  1742. const node = SpreadJsObj.getSelectObject(billsSheet);
  1743. return _.isNil(node) || _.isNil(node.b_code) || node.b_code === '';
  1744. },
  1745. callback: function (key, opt) {
  1746. mergePeg.show();
  1747. },
  1748. visible: function (key, opt) {
  1749. return isTz;
  1750. }
  1751. }
  1752. }
  1753. });
  1754. }
  1755. // 加载清单&计量单元数据
  1756. postData(window.location.pathname + '/load', {}, function (result) {
  1757. billsTree.loadDatas(result.bills);
  1758. treeCalc.calculateAll(billsTree);
  1759. SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, billsTree);
  1760. SpreadJsObj.loadTopAndSelect(billsSheet, ckBillsSpread);
  1761. checkShowLast(data.bills.length);
  1762. pos.loadDatas(result.pos);
  1763. posSpreadObj.loadCurPosData();
  1764. SpreadJsObj.resetTopAndSelect(posSheet);
  1765. checkList.loadHisCheckData();
  1766. }, null);
  1767. $.divResizer({
  1768. select: '#revise-resize',
  1769. callback: function () {
  1770. billsSpread.refresh();
  1771. let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
  1772. $(".sp-wrap").height(bcontent-30);
  1773. posSpread.refresh();
  1774. }
  1775. });
  1776. class DealBills {
  1777. constructor (selector, spreadSetting) {
  1778. const self = this;
  1779. this.loaded = false;
  1780. this.obj = $(selector)[0];
  1781. this.url = '/tender/' + window.location.pathname.split('/')[2] + '/deal';
  1782. this.spreadSetting = spreadSetting;
  1783. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1784. SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
  1785. if (!readOnly) {
  1786. this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
  1787. const dealSheet = info.sheet;
  1788. const mainSheet = billsSheet;
  1789. const dealBills = SpreadJsObj.getSelectObject(dealSheet);
  1790. if (!dealBills) { return; }
  1791. const mainTree = mainSheet.zh_tree;
  1792. const mainNode = SpreadJsObj.getSelectObject(mainSheet);
  1793. if (!mainNode || !mainTree) { return; }
  1794. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1795. toastr.warning('非最底层项目下,不应添加节点');
  1796. return;
  1797. }
  1798. postData(window.location.pathname + '/update', {
  1799. postType: 'add-deal',
  1800. postData: {
  1801. id: mainNode.ledger_id,
  1802. type: mainNode.code ? 'child' : 'next',
  1803. dealBills: {
  1804. b_code: dealBills.code, name: dealBills.name, unit: dealBills.unit,
  1805. unit_price: dealBills.unit_price,
  1806. }
  1807. },
  1808. }, function (result) {
  1809. const refreshData = mainTree.loadPostData(result);
  1810. billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
  1811. const sel = mainSheet.getSelections()[0];
  1812. if (sel && refreshData.create[0]) {
  1813. mainSheet.setSelection(mainTree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  1814. SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, mainTree.nodes.indexOf(refreshData.create[0])]);
  1815. }
  1816. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1817. billsSpread.focus();
  1818. posSpreadObj.loadCurPosData();
  1819. });
  1820. });
  1821. }
  1822. SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
  1823. }
  1824. loadData (callback) {
  1825. if (this.loaded) {
  1826. if (callback) callback();
  1827. return;
  1828. }
  1829. const self = this;
  1830. postData(this.url+'/get-data', {}, function (data) {
  1831. self.data = data;
  1832. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
  1833. self.loaded = true;
  1834. if (callback) callback();
  1835. });
  1836. }
  1837. calculateData () {
  1838. if (this.data) {
  1839. for (const d of this.data) {
  1840. d.total_price = _.multiply(d.quantity, d.unit_price);
  1841. }
  1842. }
  1843. }
  1844. }
  1845. class BgBills {
  1846. constructor (selector, spreadSetting) {
  1847. this.loaded = false;
  1848. this.obj = $(selector)[0];
  1849. this.spreadSetting = spreadSetting;
  1850. this.spread = SpreadJsObj.createNewSpread(this.obj);
  1851. this.sheet = this.spread.getActiveSheet();
  1852. SpreadJsObj.initSheet(this.sheet, this.spreadSetting);
  1853. if (!readOnly) {
  1854. this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
  1855. const dealSheet = info.sheet;
  1856. const mainSheet = billsSheet;
  1857. const bgBills = SpreadJsObj.getSelectObject(dealSheet);
  1858. if (!bgBills) { return; }
  1859. const mainTree = mainSheet.zh_tree;
  1860. const mainNode = SpreadJsObj.getSelectObject(mainSheet);
  1861. if (!mainNode || !mainTree) { return; }
  1862. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  1863. toastr.warning('非最底层项目下,不应添加变更清单');
  1864. return;
  1865. }
  1866. postData(window.location.pathname + '/update', {
  1867. postType: 'add-bg',
  1868. postData: {
  1869. id: mainNode.ledger_id,
  1870. type: mainNode.code ? 'child' : 'next',
  1871. dealBills: {
  1872. b_code: bgBills.code, name: bgBills.name, unit: bgBills.unit,
  1873. unit_price: bgBills.unit_price,
  1874. }
  1875. },
  1876. }, function (result) {
  1877. const refreshData = mainTree.loadPostData(result);
  1878. billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
  1879. const sel = mainSheet.getSelections()[0];
  1880. if (sel && refreshData.create[0]) {
  1881. mainSheet.setSelection(mainTree.nodes.indexOf(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  1882. SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, mainTree.nodes.indexOf(refreshData.create[0])]);
  1883. }
  1884. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  1885. billsSpread.focus();
  1886. posSpreadObj.loadCurPosData();
  1887. });
  1888. });
  1889. }
  1890. SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
  1891. }
  1892. loadData () {
  1893. if (this.loaded) return;
  1894. const self = this;
  1895. postData('/tender/' + window.location.pathname.split('/')[2] +'/change/bills', {type: 'gather'}, function (data) {
  1896. self.data = data;
  1897. SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
  1898. self.loaded = true;
  1899. });
  1900. }
  1901. }
  1902. class BatchInsertBillsPosObj {
  1903. constructor (obj) {
  1904. const self = this;
  1905. this.obj = obj;
  1906. this.billsCount = 6;
  1907. this.posCount = 1000;
  1908. this.filter = getLocalCache('zh-calc-batch-filter');
  1909. if (!this.filter) {
  1910. this.filter = '1';
  1911. }
  1912. $('input[name=batch-filter]')[0].checked = this.filter && this.filter != '0';
  1913. // 初始化 清单编号窗口 参数
  1914. this.qdSpreadSetting = {
  1915. cols: [
  1916. {title: '编号', field: 'code', hAlign: 0, width: 80, formatter: '@'},
  1917. {title: '名称', field: 'name', hAlign: 0, width: 120, formatter: '@'},
  1918. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@'},
  1919. {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
  1920. {title: '图册号', field: 'name', hAlign: 0, width: 60, formatter: '@'},
  1921. ],
  1922. emptyRows: this.billsCount,
  1923. headRows: 1,
  1924. headRowHeight: [32],
  1925. headerFont: '12px 微软雅黑',
  1926. font: '12px 微软雅黑',
  1927. };
  1928. this.qdSpread = SpreadJsObj.createNewSpread($('.batch-l-t', this.obj)[0]);
  1929. // 初始化 部位数量复核表 参数
  1930. this.posSpreadSetting = {
  1931. cols: [
  1932. {title: '名称', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
  1933. {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
  1934. ],
  1935. emptyRows: this.posCount,
  1936. headRows: 1,
  1937. headRowHeight: [32],
  1938. headerFont: '12px 微软雅黑',
  1939. font: '12px 微软雅黑',
  1940. };
  1941. for (let iNum = 1; iNum <= this.billsCount; iNum++) {
  1942. this.posSpreadSetting.cols.push(
  1943. {title: '清单' + iNum, field: 'bills' + iNum, hAlign: 2, width: 50}
  1944. )
  1945. }
  1946. this.posSpread = SpreadJsObj.createNewSpread($('.batch-l-b', this.obj)[0]);
  1947. // 初始化 签约节点 参数
  1948. this.dealSpreadSetting = {
  1949. cols: [
  1950. {title: '清单编号', field: 'code', width: 80, hAlign: 0, formatter: '@', readOnly: true},
  1951. {title: '名称', field: 'name', width: 230, hAlign: 0, formatter: '@', readOnly: true},
  1952. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
  1953. {title: '单价', field: 'unit_price', hAlign: 2, width: 60, readOnly: true},
  1954. ],
  1955. emptyRows: 0,
  1956. headRows: 1,
  1957. headRowHeight: [32],
  1958. headerFont: '12px 微软雅黑',
  1959. font: '12px 微软雅黑',
  1960. };
  1961. this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r', this.obj)[0]);
  1962. // 初始化 清单编号、部位数量复核表 表格
  1963. this.initView();
  1964. SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);
  1965. SpreadJsObj.refreshColumnAlign(this.dealSpread.getActiveSheet());
  1966. // 拉取签约节点数据
  1967. dealBills.loadData(() => {
  1968. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  1969. });
  1970. // 双击签约节点,自动添加到清单编号窗口
  1971. this.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
  1972. const deal = info.sheet.zh_data[info.row];
  1973. const qdSheet = self.qdSpread.getActiveSheet(), posSheet = self.posSpread.getActiveSheet();
  1974. const sel = qdSheet.getSelections()[0];
  1975. qdSheet.getCell(sel.row, 0).value(deal.code);
  1976. qdSheet.getCell(sel.row, 1).value(deal.name);
  1977. qdSheet.getCell(sel.row, 2).value(deal.unit);
  1978. qdSheet.getCell(sel.row, 3).value(deal.unit_price);
  1979. if (sel.row + 1 === qdSheet.getRowCount()) {
  1980. const count = sel.row + 2;
  1981. qdSheet.setRowCount(count);
  1982. qdSheet.getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + count);
  1983. const colCount = posSheet.getColumnCount() + 1;
  1984. posSheet.setColumnCount(colCount);
  1985. posSheet.getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('清单' + count);
  1986. }
  1987. qdSheet.setSelection(sel.row + 1, sel.col, 1, 1);
  1988. qdSheet.getParent().focus();
  1989. });
  1990. this.qdSpread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  1991. const billsCount = info.sheet.getRowCount(), posSheet = self.posSpread.getActiveSheet();
  1992. const count = posSheet.getColumnCount() - 2;
  1993. if (billsCount > count) {
  1994. posSheet.setColumnCount(billsCount + 2);
  1995. for (let i = count + 1; i <= billsCount; i++) {
  1996. info.sheet.getCell(i - 1, 0, spreadNS.SheetArea.rowHeader).text('清单' + i);
  1997. posSheet.getCell(0, i + 2 - 1, spreadNS.SheetArea.colHeader).text('清单' + i);
  1998. }
  1999. }
  2000. if (info.cellRange.col === 0 && info.cellRange.colCount === 1) {
  2001. const dealBills = self.dealSpread.getActiveSheet().zh_data;
  2002. if (dealBills && dealBills.length > 0) {
  2003. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  2004. const curRow = iRow + info.cellRange.row;
  2005. const bills = _.find(dealBills, {code: info.sheet.getText(curRow, 0)});
  2006. if (bills) {
  2007. info.sheet.getCell(curRow, 1).value(bills.name);
  2008. info.sheet.getCell(curRow, 2).value(bills.unit);
  2009. info.sheet.getCell(curRow, 3).value(bills.unit_price);
  2010. }
  2011. }
  2012. }
  2013. }
  2014. });
  2015. this.posSpread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  2016. const billsCount = info.sheet.getColumnCount() - 2, qdSheet = self.qdSpread.getActiveSheet();
  2017. const count = qdSheet.getRowCount();
  2018. if (billsCount > count) {
  2019. qdSheet.setRowCount(billsCount);
  2020. for (let i = count + 1; i <= billsCount; i++) {
  2021. qdSheet.getCell(i - 1, 0, spreadNS.SheetArea.rowHeader).text('清单' + i);
  2022. info.sheet.getCell(0, i + 2 - 1, spreadNS.SheetArea.colHeader).text('清单' + i);
  2023. }
  2024. }
  2025. });
  2026. this.qdSpread.bind(spreadNS.Events.EditEnded, function (e, info) {
  2027. if (info.col === 0) {
  2028. const dealBills = self.dealSpread.getActiveSheet().zh_data;
  2029. if (dealBills && dealBills.length > 0) {
  2030. const bills = _.find(dealBills, {code: info.editingText});
  2031. if (bills) {
  2032. info.sheet.getCell(info.row, 1).value(bills.name);
  2033. info.sheet.getCell(info.row, 2).value(bills.unit);
  2034. info.sheet.getCell(info.row, 3).value(bills.unit_price);
  2035. }
  2036. }
  2037. }
  2038. });
  2039. this.obj.bind('shown.bs.modal', function () {
  2040. self.qdSpread.refresh();
  2041. self.posSpread.refresh();
  2042. self.dealSpread.refresh();
  2043. });
  2044. $('#batch-ok').click(function () {
  2045. const selection = billsSheet.getSelections();
  2046. const sel = selection[0];
  2047. const row = selection[0].row;
  2048. const select = billsTree.nodes[row];
  2049. if (select) {
  2050. const insertData = {};
  2051. insertData.batchType = (select.code && select.code !== '') ? 'child' : 'next';
  2052. insertData.id = select[billsTree.setting.id];
  2053. insertData.batchData = self.getBatchData();
  2054. if (insertData.batchData.length > 0) {
  2055. postData(window.location.pathname + '/update', {
  2056. postType: 'batch-insert',
  2057. postData: insertData
  2058. }, function (data) {
  2059. pos.updateDatas(data.pos);
  2060. const result = billsTree.loadPostData(data.ledger);
  2061. billsTreeSpreadObj.refreshTree(billsSheet, result);
  2062. billsSheet.setSelection(result.create[0].index, sel.col, sel.rowCount, sel.colCount);
  2063. SpreadJsObj.reloadRowsBackColor(billsSheet, [sel.row, result.create[0].index]);
  2064. billsTreeSpreadObj.refreshOperationValid(billsSheet, selection);
  2065. posSpreadObj.loadCurPosData();
  2066. self.obj.modal('hide');
  2067. }, null, true);
  2068. } else {
  2069. self.obj.modal('hide');
  2070. }
  2071. }
  2072. });
  2073. $('input[name=batch-filter]').change(function () {
  2074. setLocalCache('zh-calc-batch-filter', this.checked ? 1 : 0);
  2075. });
  2076. $.contextMenu({
  2077. selector: '.batch-l-t',
  2078. build: function ($trigger, e) {
  2079. const target = SpreadJsObj.safeRightClickSelection($trigger, e, self.qdSpread);
  2080. return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
  2081. },
  2082. items: {
  2083. 'create': {
  2084. name: '新增行',
  2085. icon: 'fa-sign-in',
  2086. callback: function (key, opt) {
  2087. const qdSheet = self.qdSpread.getActiveSheet();
  2088. const posSheet = self.posSpread.getActiveSheet();
  2089. qdSheet.addRows(qdSheet.getRowCount(), 1);
  2090. const index = qdSheet.getRowCount();
  2091. qdSheet.getCell(qdSheet.getRowCount() - 1, 0, spreadNS.SheetArea.rowHeader).text('清单' + index);
  2092. posSheet.addColumns(posSheet.getColumnCount(), 1);
  2093. posSheet.getCell(0, index + 2 - 1, spreadNS.SheetArea.colHeader).text('清单' + index);
  2094. },
  2095. },
  2096. 'delete': {
  2097. name: '删除行',
  2098. icon: 'fa-remove',
  2099. callback: function (key, opt) {
  2100. const qdSheet = self.qdSpread.getActiveSheet();
  2101. const posSheet = self.posSpread.getActiveSheet();
  2102. const sel = qdSheet.getSelections()[0];
  2103. qdSheet.deleteRows(sel.row, sel.rowCount);
  2104. posSheet.deleteColumns(sel.row + 2, sel.rowCount);
  2105. for (let iRow = 0, iLen = qdSheet.getRowCount(); iRow < iLen; iRow++) {
  2106. qdSheet.getCell(iRow, 0, spreadNS.SheetArea.rowHeader).text('清单' + (iRow+1));
  2107. }
  2108. for (let iCol = 0, iLen = posSheet.getColumnCount() - 2; iCol < iLen; iCol++) {
  2109. posSheet.getCell(0, iCol + 2, spreadNS.SheetArea.colHeader).text('清单' + (iCol+1));
  2110. }
  2111. qdSheet.setSelection(sel.row, sel.col, 1, 1);
  2112. },
  2113. },
  2114. }
  2115. });
  2116. }
  2117. // 初始化左侧表格
  2118. initView () {
  2119. // 初始化 清单编号
  2120. const qdSheet = this.qdSpread.getActiveSheet();
  2121. SpreadJsObj.initSheet(qdSheet, this.qdSpreadSetting);
  2122. SpreadJsObj.refreshColumnAlign(qdSheet);
  2123. // 清理原有数据
  2124. SpreadJsObj.beginMassOperation(qdSheet);
  2125. qdSheet.clear(0, 0, qdSheet.getRowCount(), qdSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  2126. for (let iRow = 1; iRow <= this.billsCount; iRow++) {
  2127. qdSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + iRow);
  2128. }
  2129. qdSheet.setSelection(0, 0, 1 ,1);
  2130. SpreadJsObj.endMassOperation(qdSheet);
  2131. // 初始化 部位数量复核表
  2132. const posSheet = this.posSpread.getActiveSheet();
  2133. SpreadJsObj.initSheet(posSheet, this.posSpreadSetting);
  2134. SpreadJsObj.refreshColumnAlign(posSheet);
  2135. // 清理原有数据
  2136. SpreadJsObj.beginMassOperation(posSheet);
  2137. posSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
  2138. posSheet.clear(0, 0, posSheet.getRowCount(), posSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
  2139. posSheet.setSelection(0, 0, 1 ,1);
  2140. SpreadJsObj.endMassOperation(posSheet);
  2141. // 检查签约节点数据,以工具栏数据为准
  2142. if (dealBills) {
  2143. SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
  2144. }
  2145. this.dealSpread.getActiveSheet().setSelection(0, 0, 1, 1);
  2146. }
  2147. // 获取界面数据
  2148. getBatchData () {
  2149. const result = [];
  2150. const qdSheet = this.qdSpread.getActiveSheet(), posSheet = this.posSpread.getActiveSheet();
  2151. for (let iRow = 0; iRow < qdSheet.getRowCount(); iRow++) {
  2152. if (qdSheet.getText(iRow, 0) === '') { continue; }
  2153. const qd = {
  2154. b_code: qdSheet.getText(iRow, 0),
  2155. name: qdSheet.getText(iRow, 1),
  2156. unit: qdSheet.getText(iRow, 2),
  2157. price: _.toNumber(qdSheet.getText(iRow, 3)),
  2158. pos: [],
  2159. };
  2160. for (let iPosRow = 0; iPosRow < posSheet.getRowCount(); iPosRow++) {
  2161. const value = _.toNumber(posSheet.getText(iPosRow, iRow + 2));
  2162. if (value !== 0 && !isNaN(value)) {
  2163. qd.pos.push({
  2164. name: posSheet.getText(iPosRow, 0),
  2165. drawing_code: posSheet.getText(iPosRow, 1),
  2166. quantity: value, porder: qd.pos.length + 1,
  2167. });
  2168. }
  2169. }
  2170. if (!$('input[name=batch-filter]')[0].checked || qd.pos.length > 0) result.push(qd);
  2171. }
  2172. return result;
  2173. }
  2174. }
  2175. const dealBills = new DealBills('#deal-bills-spread', {
  2176. cols: [
  2177. {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
  2178. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  2179. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
  2180. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  2181. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  2182. {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
  2183. ],
  2184. emptyRows: 0,
  2185. headRows: 1,
  2186. headRowHeight: [32],
  2187. headColWidth: [30],
  2188. defaultRowHeight: 21,
  2189. headerFont: '12px 微软雅黑',
  2190. font: '12px 微软雅黑',
  2191. selectedBackColor: '#fffacd',
  2192. });
  2193. const bgBills = new BgBills('#bg-bills-spread', {
  2194. cols: [
  2195. {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
  2196. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  2197. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
  2198. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  2199. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  2200. {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
  2201. ],
  2202. emptyRows: 0,
  2203. headRows: 1,
  2204. headRowHeight: [32],
  2205. headColWidth: [30],
  2206. defaultRowHeight: 21,
  2207. headerFont: '12px 微软雅黑',
  2208. font: '12px 微软雅黑',
  2209. selectedBackColor: '#fffacd',
  2210. });
  2211. $.divResizer({
  2212. select: '#revise-right-spr',
  2213. callback: function () {
  2214. billsSpread.refresh();
  2215. if (posSpread) {
  2216. posSpread.refresh();
  2217. }
  2218. if (stdXmj) {
  2219. stdXmj.spread.refresh();
  2220. }
  2221. if (stdGcl) {
  2222. stdGcl.spread.refresh();
  2223. }
  2224. if (dealBills) {
  2225. dealBills.spread.refresh();
  2226. }
  2227. if (bgBills) {
  2228. bgBills.spread.refresh();
  2229. }
  2230. if (searchLedger) {
  2231. searchLedger.spread.refresh();
  2232. }
  2233. if (errorList) {
  2234. errorList.spread.refresh();
  2235. }
  2236. if (checkList) {
  2237. checkList.spread.refresh();
  2238. }
  2239. }
  2240. });
  2241. $.subMenu({
  2242. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  2243. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  2244. key: 'menu.1.0.0',
  2245. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  2246. callback: function (info) {
  2247. if (info.mini) {
  2248. $('.panel-title').addClass('fluid');
  2249. $('#sub-menu').removeClass('panel-sidebar');
  2250. } else {
  2251. $('.panel-title').removeClass('fluid');
  2252. $('#sub-menu').addClass('panel-sidebar');
  2253. }
  2254. autoFlashHeight();
  2255. billsSpread.refresh();
  2256. if (posSpread) {
  2257. posSpread.refresh();
  2258. }
  2259. if (stdXmj) {
  2260. stdXmj.spread.refresh();
  2261. }
  2262. if (stdGcl) {
  2263. stdGcl.spread.refresh();
  2264. }
  2265. if (dealBills) {
  2266. dealBills.spread.refresh();
  2267. }
  2268. if (bgBills) {
  2269. bgBills.spread.refresh();
  2270. }
  2271. if (searchLedger) {
  2272. searchLedger.spread.refresh();
  2273. }
  2274. if (errorList) {
  2275. errorList.spread.refresh();
  2276. }
  2277. if (checkList) {
  2278. checkList.spread.refresh();
  2279. }
  2280. }
  2281. });
  2282. $('#content-tab').addClass('active');
  2283. $('#xd-content').addClass('active');
  2284. showSideTools(true);
  2285. billsSpread.refresh();
  2286. if (posSpread) {
  2287. posSpread.refresh();
  2288. }
  2289. const stdLibCellDoubleClick = function (e, info) {
  2290. const stdSheet = info.sheet;
  2291. const mainSheet = billsSheet;
  2292. if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
  2293. const stdTree = stdSheet.zh_tree;
  2294. const stdNode = stdTree.nodes[info.row];
  2295. const mainTree = mainSheet.zh_tree;
  2296. const sel = mainSheet.getSelections()[0];
  2297. const mainNode = mainTree.nodes[sel.row];
  2298. if (!stdNode) return;
  2299. if (info.sheet.zh_setting.stdType === 'gcl') {
  2300. if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
  2301. toastr.warning('非最底层项目下,不应添加节点');
  2302. return;
  2303. }
  2304. }
  2305. postData(window.location.pathname + '/update', {
  2306. postType: 'add-std',
  2307. postData: {
  2308. id: mainTree.getNodeKey(mainNode),
  2309. tender_id: mainNode.tender_id,
  2310. stdType: info.sheet.zh_setting.stdType,
  2311. stdLibId: stdNode.list_id,
  2312. stdNode: stdTree.getNodeKey(stdNode)
  2313. }
  2314. }, function (result) {
  2315. const refreshNode = mainTree.loadPostData(result);
  2316. billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
  2317. if (sel) {
  2318. if (refreshNode.create && refreshNode.create.length > 0) {
  2319. mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
  2320. SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, refreshNode.create[refreshNode.create.length - 1].index]);
  2321. } else {
  2322. const node = _.find(mainTree.nodes, {code: stdNode.code, name: stdNode.name});
  2323. if (node) {
  2324. mainSheet.setSelection(mainTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
  2325. SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, mainTree.nodes.indexOf(node)]);
  2326. }
  2327. }
  2328. }
  2329. billsTreeSpreadObj.refreshOperationValid(mainSheet);
  2330. billsSpread.focus();
  2331. posSpreadObj.loadCurPosData();
  2332. });
  2333. };
  2334. const stdXmjSetting = {
  2335. selector: '#std-xmj',
  2336. stdType: 'xmj',
  2337. treeSetting: {
  2338. id: 'chapter_id',
  2339. pid: 'pid',
  2340. order: 'order',
  2341. level: 'level',
  2342. rootId: -1,
  2343. keys: ['id', 'list_id', 'chapter_id'],
  2344. },
  2345. spreadSetting: {
  2346. cols: [
  2347. {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  2348. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  2349. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  2350. ],
  2351. treeCol: 0,
  2352. emptyRows: 0,
  2353. headRows: 1,
  2354. headRowHeight: [32],
  2355. defaultRowHeight: 21,
  2356. headerFont: '12px 微软雅黑',
  2357. font: '12px 微软雅黑',
  2358. headColWidth: [30],
  2359. selectedBackColor: '#fffacd',
  2360. },
  2361. cellDoubleClick: stdLibCellDoubleClick,
  2362. page: 'revise',
  2363. tid: window.location.pathname.split('/')[2],
  2364. };
  2365. const stdGclSetting = {
  2366. selector: '#std-gcl',
  2367. stdType: 'gcl',
  2368. treeSetting: {
  2369. id: 'bill_id',
  2370. pid: 'pid',
  2371. order: 'order',
  2372. level: 'level',
  2373. rootId: -1,
  2374. keys: ['id', 'list_id', 'bill_id']
  2375. },
  2376. spreadSetting: {
  2377. cols: [
  2378. {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
  2379. {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
  2380. {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
  2381. ],
  2382. treeCol: 0,
  2383. emptyRows: 0,
  2384. headRows: 1,
  2385. headRowHeight: [32],
  2386. defaultRowHeight: 21,
  2387. headerFont: '12px 微软雅黑',
  2388. font: '12px 微软雅黑',
  2389. headColWidth: [30],
  2390. selectedBackColor: '#fffacd',
  2391. },
  2392. cellDoubleClick: stdLibCellDoubleClick,
  2393. page: 'revise',
  2394. tid: window.location.pathname.split('/')[2],
  2395. };
  2396. // 展开收起标准节点
  2397. $('a', '#side-menu').bind('click', function (e) {
  2398. e.preventDefault();
  2399. const tab = $(this), tabPanel = $(tab.attr('content'));
  2400. // 展开工具栏、切换标签
  2401. if (!tab.hasClass('active')) {
  2402. const close = $('.active', '#side-menu').length === 0;
  2403. $('a', '#side-menu').removeClass('active');
  2404. tab.addClass('active');
  2405. $('.tab-content .tab-pane').removeClass('active');
  2406. tabPanel.addClass('active');
  2407. showSideTools(tab.hasClass('active'));
  2408. if (tab.attr('content') === '#std-xmj') {
  2409. if (!stdXmj) {
  2410. stdXmj = new stdLib(stdXmjSetting);
  2411. }
  2412. stdXmj.spread.refresh();
  2413. } else if (tab.attr('content') === '#std-gcl') {
  2414. if (!stdGcl) {
  2415. stdGcl = new stdLib(stdGclSetting);
  2416. }
  2417. stdGcl.spread.refresh();
  2418. } else if (tab.attr('content') === '#deal-bills') {
  2419. dealBills.loadData();
  2420. dealBills.spread.refresh();
  2421. } else if (tab.attr('content') === '#bg-bills') {
  2422. bgBills.loadData();
  2423. bgBills.spread.refresh();
  2424. } else if (tab.attr('content') === '#search') {
  2425. if (!searchLedger) {
  2426. searchLedger = $.billsSearch({
  2427. selector: '#search',
  2428. searchSpread: billsSpread,
  2429. resultSpreadSetting: {
  2430. cols: [
  2431. {title: '项目节编号', field: 'code', hAlign: 0, width: 90, formatter: '@', readOnly: true},
  2432. {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
  2433. {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
  2434. {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
  2435. {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
  2436. {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
  2437. ],
  2438. emptyRows: 0,
  2439. headRows: 1,
  2440. headRowHeight: [32],
  2441. headColWidth: [30],
  2442. defaultRowHeight: 21,
  2443. headerFont: '12px 微软雅黑',
  2444. font: '12px 微软雅黑',
  2445. selectedBackColor: '#fffacd',
  2446. },
  2447. afterLocated: function () {
  2448. posSpreadObj.loadCurPosData();
  2449. }
  2450. });
  2451. }
  2452. searchLedger.spread.refresh();
  2453. } else if (tab.attr('content') === '#error-list') {
  2454. errorList.spread.refresh();
  2455. } else if (tab.attr('content') === '#check-list') {
  2456. checkList.spread.refresh();
  2457. }
  2458. }
  2459. else {// 收起工具栏
  2460. tab.removeClass('active');
  2461. tabPanel.removeClass('active');
  2462. showSideTools(tab.hasClass('active'));
  2463. }
  2464. billsSpread.refresh();
  2465. if (posSpread) {
  2466. posSpread.refresh();
  2467. }
  2468. });
  2469. if (!readOnly) {
  2470. // 修订详情 保存
  2471. $('#save').click(function () {
  2472. const content = $('#content').val();
  2473. postData('save', { content: content }, function () {
  2474. $('#content').attr('org-value', content);
  2475. });
  2476. });
  2477. }
  2478. // 显示层次
  2479. (function (select, sheet) {
  2480. $(select).click(function () {
  2481. if (!sheet.zh_tree) return;
  2482. const tag = $(this).attr('tag');
  2483. const tree = sheet.zh_tree;
  2484. setTimeout(() => {
  2485. showWaitingView();
  2486. switch (tag) {
  2487. case "1":
  2488. case "2":
  2489. case "3":
  2490. case "4":
  2491. case "5":
  2492. tree.expandByLevel(parseInt(tag));
  2493. SpreadJsObj.refreshTreeRowVisible(sheet);
  2494. break;
  2495. case "last":
  2496. tree.expandByCustom(() => { return true; });
  2497. SpreadJsObj.refreshTreeRowVisible(sheet);
  2498. break;
  2499. case "leafXmj":
  2500. tree.expandToLeafXmj();
  2501. SpreadJsObj.refreshTreeRowVisible(sheet);
  2502. break;
  2503. }
  2504. closeWaitingView();
  2505. }, 100);
  2506. });
  2507. })('a[name=showLevel]', billsSheet);
  2508. const dataChecker = DataChecker({
  2509. checkUrl: window.location.pathname + '/check',
  2510. completeData: function (data) {
  2511. pos.updateDatas({update: data.source.pos});
  2512. const loadResult = billsTree.loadPostData({update: data.source.bills});
  2513. billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
  2514. posSpreadObj.loadCurPosData();
  2515. for (const e of data.error) {
  2516. e.serialNo = billsTree.getNodeIndex(billsTree.getItems(e.ledger_id)) + 1;
  2517. }
  2518. },
  2519. errorList: errorList,
  2520. });
  2521. $('#ledger-check2').click(() => {
  2522. const result = ledgerCheck2({
  2523. ledgerTree: billsTree,
  2524. ledgerPos: pos,
  2525. checkList: checkList,
  2526. decimal: decimal,
  2527. checkOption: checkOption,
  2528. });
  2529. check2Viewing({
  2530. extra: ZhCalc.div(billsTree.datas.length + pos.datas.length, 10000, 0),
  2531. randomWait: true,
  2532. prefix: 'check2-',
  2533. checks: result,
  2534. checkList: checkList,
  2535. })
  2536. });
  2537. $('[name=revise-start]').submit(function (e) {
  2538. if (checkAuditorFrom()) {
  2539. $(this).parent().parent().parent().modal('hide');
  2540. dataChecker.checkAndPost(this.action, {});
  2541. $('#hide-all').hide();
  2542. }
  2543. return false;
  2544. });
  2545. });