| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614 | 
							- /**
 
-  * 台账相关js
 
-  *
 
-  * @author Mai
 
-  * @date 2018/02/05
 
-  * @version
 
-  */
 
- const ckBillsSpread = window.location.pathname + '-billsSelect';
 
- function checkTzMeasureType () {
 
-     return tender.measure_type === measureType.tz.value;
 
- }
 
- function getTenderId() {
 
-     return window.location.pathname.split('/')[2];
 
- }
 
- const copyBlockTag = 'zh.calc.copyBlock';
 
- const invalidFields = {
 
-     parent: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp', 'deal_qty', 'deal_tp', 'unit_price'],
 
-     gcl: ['dgn_qty1', 'dgn_qty2'],
 
-     posCode: ['b_code'],
 
-     posCalc: ['sgfh_qty', 'sgfh_tp', 'sjcl_qty', 'sjcl_tp', 'qtcl_qty', 'qtcl_tp'],
 
-     posXmj: ['code'],
 
- };
 
- function transExpr(expr) {
 
-     return expr.replace('=', '').replace('%', '/100');
 
- }
 
- $(document).ready(function() {
 
-     let stdXmj, stdGcl, dealBills, searchLedger;
 
-     autoFlashHeight();
 
-     // 初始化台账
 
-     const ledgerSpread = SpreadJsObj.createNewSpread($('#ledger-spread')[0]);
 
-     const treeSetting = {
 
-         id: 'ledger_id',
 
-         pid: 'ledger_pid',
 
-         order: 'order',
 
-         level: 'level',
 
-         rootId: -1,
 
-         keys: ['id', 'tender_id', 'ledger_id'],
 
-         preUrl: '/tender/' + getTenderId() + '/ledger',
 
-     };
 
-     if (checkTzMeasureType()) {
 
-         treeSetting.calcFields = ['sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price'];
 
-     } else {
 
-         treeSetting.calcFields = ['deal_tp', 'sgfh_tp', 'sjcl_tp', 'qtcl_tp', 'total_price'];
 
-     }
 
-     treeSetting.calcFun = function (node) {
 
-         node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
 
-     };
 
-     const ledgerTree = createNewPathTree('ledger', treeSetting);
 
-     // 初始化 计量单元
 
-     const pos = new PosData({
 
-         id: 'id', ledgerId: 'lid',
 
-     });
 
-     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
 
-     const errorList = $.cs_errorList({
 
-         tabSelector: '#error-list-tab',
 
-         selector: '#error-list',
 
-         relaSpread: ledgerSpread,
 
-         storeKey: 'ledger-error-' + getTenderId(),
 
-         afterLocated:  function () {
 
-             posOperationObj.loadCurPosData();
 
-         },
 
-         afterShow: function () {
 
-             ledgerSpread.refresh();
 
-             if (posSpread) posSpread.refresh();
 
-         },
 
-     });
 
-     $.subMenu({
 
-         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
 
-         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
 
-         key: 'menu.1.0.0',
 
-         miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
 
-         callback: function (info) {
 
-             if (info.mini) {
 
-                 $('.panel-title').addClass('fluid');
 
-                 $('#sub-menu').removeClass('panel-sidebar');
 
-             } else {
 
-                 $('.panel-title').removeClass('fluid');
 
-                 $('#sub-menu').addClass('panel-sidebar');
 
-             }
 
-             autoFlashHeight();
 
-             ledgerSpread.refresh();
 
-             if (posSpread) {
 
-                 posSpread.refresh();
 
-             }
 
-             if (stdXmj) {
 
-                 stdXmj.spread.refresh();
 
-             }
 
-             if (stdGcl) {
 
-                 stdGcl.spread.refresh();
 
-             }
 
-             if (dealBills) {
 
-                 dealBills.spread.refresh();
 
-             }
 
-             if (searchLedger) {
 
-                 searchLedger.spread.refresh();
 
-             }
 
-             if (errorList) {
 
-                 errorList.spread.refresh();
 
-             }
 
-         }
 
-     });
 
-     // 定义事件
 
-     const treeOperationObj = {
 
-         loadExprToInput(sheet) {
 
-             const sel = sheet.getSelections()[0];
 
-             const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
 
-             if (col && col.type === 'Number') {
 
-                 const data = SpreadJsObj.getSelectObject(sheet);
 
-                 if (data) {
 
-                     $('#bills-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field]);
 
-                     if (col.field.indexOf('dgn') >= 0) {
 
-                         $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (_.isString(data.b_code) && data.b_code !== ''));
 
-                     } else {
 
-                         $('#bills-expr').attr('readOnly', readOnly || cell.locked() || (data.children && data.children.length > 0));
 
-                     }
 
-                 } else {
 
-                     $('#bills-expr').val('').attr('readOnly', true);
 
-                 }
 
-             } else {
 
-                 $('#bills-expr').val('').attr('readOnly', true);
 
-             }
 
-         },
 
-         getSelectNode: function (sheet) {
 
-             if (!sheet || !sheet.zh_tree) {
 
-                 return null;
 
-             } else {
 
-                 const sel = sheet.getSelections()[0];
 
-                 return sheet.zh_tree.nodes[sel.row];
 
-             }
 
-         },
 
-         getDefaultSelectInfo: function (sheet) {
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) return;
 
-             const sel = sheet.getSelections()[0];
 
-             const node = sheet.zh_tree.nodes[sel.row];
 
-             if (!node) return;
 
-             let count = 1;
 
-             if (sel.rowCount > 1) {
 
-                 for (let r = 1; r < sel.rowCount; r++) {
 
-                     const rNode = sheet.zh_tree.nodes[sel.row + r];
 
-                     if (rNode.level > node.level) continue;
 
-                     if ((rNode.level < node.level) || (rNode.level === node.level && rNode.pid !== node.pid)) {
 
-                         toastr.error('请选择同一清单下的节点,进行该操作');
 
-                         return;
 
-                     }
 
-                     count += 1;
 
-                 }
 
-             }
 
-             return [tree, node, count];
 
-         },
 
-         /**
 
-          * 刷新顶部按钮是否可用
 
-          * @param sheet
 
-          * @param selections
 
-          */
 
-         refreshOperationValid: function (sheet, selection) {
 
-             const setObjEnable = function (obj, enable) {
 
-                 if (enable) {
 
-                     obj.removeClass('disabled');
 
-                 } else {
 
-                     obj.addClass('disabled');
 
-                 }
 
-             };
 
-             const invalidAll = function () {
 
-                 setObjEnable($('#insert'), false);
 
-                 setObjEnable($('#delete'), false);
 
-                 setObjEnable($('#up-move'), false);
 
-                 setObjEnable($('#down-move'), false);
 
-                 setObjEnable($('#up-level'), false);
 
-                 setObjEnable($('#down-level'), false);
 
-             };
 
-             const sel = selection ? selection[0] : sheet.getSelections()[0];
 
-             const row = sel ? sel.row : -1;
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) {
 
-                 invalidAll();
 
-                 return;
 
-             }
 
-             const first = sheet.zh_tree.nodes[row];
 
-             if (!first) {
 
-                 invalidAll();
 
-                 return;
 
-             }
 
-             let last = first, sameParent = true;
 
-             if (sel.rowCount > 1 && first) {
 
-                 for (let r = 1; r < sel.rowCount; r++) {
 
-                     const rNode = tree.nodes[row + r];
 
-                     if (!rNode) {
 
-                         sameParent = false;
 
-                         break;
 
-                     }
 
-                     if (rNode.level > first.level) continue;
 
-                     if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
 
-                         sameParent = false;
 
-                         break;
 
-                     }
 
-                     last = rNode;
 
-                 }
 
-             }
 
-             const preNode = tree.getPreSiblingNode(first);
 
-             const valid = !sheet.zh_setting.readOnly;
 
-             setObjEnable($('#insert'), valid && first && first.level > 1);
 
-             setObjEnable($('#delete'), valid && first && sameParent && !(first.level === 1 && first.node_type));
 
-             setObjEnable($('#up-move'), valid && first && sameParent && first.level > 1 && preNode);
 
-             setObjEnable($('#down-move'), valid && first && sameParent && first.level > 1 && !tree.isLastSibling(last));
 
-             if (checkTzMeasureType()) {
 
-                 const posRange = last ? pos.getLedgerPos(last.id) : [];
 
-                 setObjEnable($('#up-level'), valid && first && sameParent && tree.getParent(first) && first.level > 2 && ((!posRange || posRange.length === 0) || tree.isLastSibling(last)));
 
-                 const preNodePosRange = preNode ? pos.getLedgerPos(preNode.id) : [];
 
-                 setObjEnable($('#down-level'), valid && first && sameParent && first.level > 1 && preNode && (!preNodePosRange || preNodePosRange.length === 0));
 
-             } else {
 
-                 setObjEnable($('#up-level'), valid && first && sameParent && first.level > 2 && tree.getParent(first));
 
-                 setObjEnable($('#down-level'), valid && first && sameParent && first.level > 1 && preNode);
 
-             }
 
-             setObjEnable($('#cut'), valid);
 
-             setObjEnable($('#paste'), valid);
 
-         },
 
-         refreshTree: function (sheet, data) {
 
-             SpreadJsObj.massOperationSheet(sheet, function () {
 
-                 const tree = sheet.zh_tree;
 
-                 // 处理删除
 
-                 if (data.delete) {
 
-                     data.delete.sort(function (x, y) {
 
-                         return y.deleteIndex - x.deleteIndex;
 
-                     });
 
-                     for (const d of data.delete) {
 
-                         sheet.deleteRows(d.deleteIndex, 1);
 
-                     }
 
-                 }
 
-                 // 处理新增
 
-                 if (data.create) {
 
-                     const newNodes = data.create;
 
-                     if (newNodes) {
 
-                         newNodes.sort(function (a, b) {
 
-                             return a.index - b.index;
 
-                         });
 
-                         for (const node of newNodes) {
 
-                             sheet.addRows(node.index, 1);
 
-                             SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
 
-                         }
 
-                     }
 
-                 }
 
-                 // 处理更新
 
-                 if (data.update) {
 
-                     const rows = [];
 
-                     for (const u of data.update) {
 
-                         rows.push(tree.nodes.indexOf(u));
 
-                     }
 
-                     SpreadJsObj.reLoadRowsData(sheet, rows);
 
-                 }
 
-                 // 处理展开
 
-                 if (data.expand) {
 
-                     const expanded = [];
 
-                     for (const e of data.expand) {
 
-                         if (expanded.indexOf(e) === -1) {
 
-                             const posterity = tree.getPosterity(e);
 
-                             for (const p of posterity) {
 
-                                 sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
 
-                                 expanded.push(p);
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             });
 
-         },
 
-         /**
 
-          * 新增节点
 
-          * @param spread
 
-          */
 
-         addNode: function (sheet, count = 1) {
 
-             const self = this;
 
-             const sel = sheet.getSelections()[0];
 
-             const row = sheet.getSelections()[0].row;
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) { return; }
 
-             const node = sheet.zh_tree.nodes[row];
 
-             if (!node) { return; }
 
-             postData(window.location.pathname + '/update', {
 
-                 postType: 'add',
 
-                 postData: {
 
-                     id: tree.getNodeKey(node),
 
-                     count: count,
 
-                 }
 
-             }, function (result) {
 
-                 const refreshNode = tree.loadPostData(result);
 
-                 self.refreshTree(sheet, refreshNode);
 
-                 sheet.setSelection(refreshNode.create[0].index, sel.col, sel.rowCount, sel.colCount);
 
-                 SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, refreshNode.create[0].index]);
 
-                 self.refreshOperationValid(sheet);
 
-             });
 
-         },
 
-         /**
 
-          * 删除选中节点
 
-          * @param spread
 
-          */
 
-         deleteNode: function (sheet) {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 
-             if (tree && node && count) {
 
-                 const data = {
 
-                     postType: 'delete',
 
-                     postData: {
 
-                         id: tree.getNodeKey(node),
 
-                         count: count
 
-                     }
 
-                 };
 
-                 deleteAfterHint(function () {
 
-                     postData(window.location.pathname + '/update', data, function (result) {
 
-                         const refreshNode = tree.loadPostData(result);
 
-                         for (const d of refreshNode.delete) pos.removeDatasByMasterId(d.id);
 
-                         self.refreshTree(sheet, refreshNode);
 
-                         self.refreshOperationValid(sheet);
 
-                         posOperationObj.loadCurPosData();
 
-                     });
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 上移选中节点
 
-          * @param spread
 
-          */
 
-         upMove: function (sheet) {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 
-             if (tree && node && count) {
 
-                 const data = {
 
-                     postType: 'up-move',
 
-                     postData: {
 
-                         id: tree.getNodeKey(node),
 
-                         count: count
 
-                     }
 
-                 };
 
-                 postData(window.location.pathname + '/update', data, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     self.refreshTree(sheet, refreshNode);
 
-                     const sel = sheet.getSelections()[0];
 
-                     sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
 
-                     SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(node)]);
 
-                     self.refreshOperationValid(sheet);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 下移选中节点
 
-          * @param spread
 
-          */
 
-         downMove: function (sheet) {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 
-             if (tree && node && count) {
 
-                 const data = {
 
-                     postType: 'down-move',
 
-                     postData: {
 
-                         id: tree.getNodeKey(node),
 
-                         count: count
 
-                     }
 
-                 };
 
-                 postData(window.location.pathname + '/update', data, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     self.refreshTree(sheet, refreshNode);
 
-                     const sel = sheet.getSelections()[0];
 
-                     sheet.setSelection(tree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
 
-                     SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, tree.nodes.indexOf(node)]);
 
-                     self.refreshOperationValid(sheet);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 升级选中节点
 
-          * @param spread
 
-          */
 
-         upLevel: function (sheet) {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 
-             if (tree && node && count) {
 
-                 const data = {
 
-                     postType: 'up-level',
 
-                     postData: {
 
-                         id: tree.getNodeKey(node),
 
-                         count: count
 
-                     }
 
-                 };
 
-                 postData(window.location.pathname + '/update', data, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     self.refreshTree(sheet, refreshNode);
 
-                     self.refreshOperationValid(sheet);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 降级选中节点
 
-          * @param spread
 
-          */
 
-         downLevel: function (sheet) {
 
-             const self = this;
 
-             const [tree, node, count] = this.getDefaultSelectInfo(sheet);
 
-             if (tree && node && count) {
 
-                 const data = {
 
-                     postType: 'down-level',
 
-                     postData: {
 
-                         id: tree.getNodeKey(node),
 
-                         count: count
 
-                     }
 
-                 };
 
-                 postData(window.location.pathname + '/update', data, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     self.refreshTree(sheet, refreshNode);
 
-                     self.refreshOperationValid(sheet);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 编辑单元格响应事件
 
-          * @param {Object} e
 
-          * @param {Object} info
 
-          */
 
-         editEnded: function (e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 const sortData = info.sheet.zh_dataType === 'tree' ? info.sheet.zh_tree.nodes : info.sheet.zh_data;
 
-                 const node = sortData[info.row];
 
-                 const data = {
 
-                     id: node.id,
 
-                     tender_id: node.tender_id,
 
-                     ledger_id: node.ledger_id
 
-                 };
 
-                 // 未改变值则不提交
 
-                 const orgValue = node[col.field];
 
-                 const newValue = trimInvalidChar(info.editingText);
 
-                 if (orgValue == info.editingText || ((!orgValue || orgValue === '') && (newValue === ''))) {
 
-                     return;
 
-                 }
 
-                 // 台账模式,检查计量单元相关
 
-                 if (checkTzMeasureType()) {
 
-                     if (col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
 
-                         col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
 
-                         col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
 
-                         if (!node.children || node.children.length ===0) {
 
-                             const lPos = pos.getLedgerPos(node.id);
 
-                             if (lPos && lPos.length > 0) {
 
-                                 toastr.error('清单含有计量单元,请在计量单元输入数量');
 
-                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                                 return;
 
-                             }
 
-                         }
 
-                     }
 
-                     if (col.field === 'b_code' && (info.editingText === '' || !info.editingText)) {
 
-                         const lPos = pos.getLedgerPos(node.id);
 
-                         if (lPos && lPos.length > 0) {
 
-                             toastr.error('清单含有计量单元,请先删除计量单元,再删除清单编号');
 
-                             SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                             return;
 
-                         }
 
-                     }
 
-                 }
 
-                 // 获取更新数据
 
-                 if (col.type === 'Number') {
 
-                     if (newValue) {
 
-                         const num = _.toNumber(newValue);
 
-                         if (_.isFinite(num)) {
 
-                             data[col.field] = num;
 
-                         } else {
 
-                             try {
 
-                                 data[col.field] = math.evaluate(transExpr(newValue));
 
-                             } catch(err) {
 
-                                 toastr.error('输入的表达式非法');
 
-                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                                 return;
 
-                             }
 
-                         }
 
-                     } else {
 
-                         data[col.field] = null;
 
-                     }
 
-                 } else {
 
-                     data[col.field] = newValue;
 
-                 }
 
-                 // 更新至服务器
 
-                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
 
-                     const refreshNode = ledgerTree.loadPostData(result);
 
-                     treeOperationObj.refreshTree(info.sheet, refreshNode);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 粘贴单元格响应事件
 
-          * @param e
 
-          * @param info
 
-          */
 
-         clipboardPasted: function (e, info) {
 
-             if (info.sheet.zh_setting && info.sheet.zh_dataType === 'tree') {
 
-                 const tree = info.sheet.zh_tree;
 
-                 if (!tree) { return; }
 
-                 const sortData = info.sheet.zh_tree.nodes;
 
-                 const datas = [], filterNodes = [];
 
-                 let bHint = false, bPaste;
 
-                 for (let iRow = 0; iRow < info.cellRange.rowCount; iRow ++) {
 
-                     bPaste = false;
 
-                     const curRow = info.cellRange.row + iRow;
 
-                     const node = sortData[curRow];
 
-                     if (node) {
 
-                         const data = info.sheet.zh_tree.getNodeKeyData(node);
 
-                         for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 
-                             const curCol = info.cellRange.col + iCol;
 
-                             const colSetting = info.sheet.zh_setting.cols[curCol];
 
-                             const value = trimInvalidChar(info.sheet.getText(curRow, curCol));
 
-                             const lPos = pos.getLedgerPos(node.id);
 
-                             if (lPos && lPos.length > 0) {
 
-                                 if (value === '' && colSetting.field === 'b_code') {
 
-                                     if (!bHint) {
 
-                                         toastr.warning('清单含有计量单元,请先删除计量单元,再删除清单编号');
 
-                                         bHint = true;
 
-                                     }
 
-                                     continue;
 
-                                 }
 
-                                 if (colSetting.field === 'sgfh_qty' || colSetting.field === 'sgfh_tp' ||
 
-                                     colSetting.field === 'sjcl_qty' || colSetting.field === 'sjcl_tp' ||
 
-                                     colSetting.field === 'qtcl_qty' || colSetting.field === 'qtcl_tp') {
 
-                                     if (!bHint) {
 
-                                         toastr.warning('清单含有计量单元,数量金额根据计量单元汇总计算所得,不可编辑');
 
-                                         bHint = true;
 
-                                     }
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                             if (colSetting.type === 'Number') {
 
-                                 const num = _.toNumber(value);
 
-                                 if (num) {
 
-                                     data[colSetting.field] = num;
 
-                                     bPaste = true;
 
-                                 } else {
 
-                                     try {
 
-                                         data[colSetting.field] = math.evaluate(transExpr(value));
 
-                                         bPaste = true;
 
-                                     } catch(err) {
 
-                                         delete data[colSetting.field];
 
-                                         if (!bHint) {
 
-                                             toastr.warning('输入的表达式非法');
 
-                                             bHint = true;
 
-                                         }
 
-                                     }
 
-                                 }
 
-                             } else {
 
-                                 data[colSetting.field] = value;
 
-                                 bPaste = true;
 
-                             }
 
-                         }
 
-                         if (bPaste) {
 
-                             datas.push(data);
 
-                         } else {
 
-                             filterNodes.push(node);
 
-                         }
 
-                     }
 
-                 }
 
-                 if (datas.length > 0) {
 
-                     postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 
-                         const refreshNode = tree.loadPostData(result);
 
-                         if (refreshNode.update) {
 
-                             refreshNode.update = refreshNode.update.concat(filterNodes);
 
-                         }
 
-                         treeOperationObj.refreshTree(info.sheet, refreshNode);
 
-                     }, function () {
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                     });
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 }
 
-             }
 
-         },
 
-         clipboardPasting: function (e, info) {
 
-             const tree = info.sheet.zh_tree, setting = info.sheet.zh_setting;
 
-             info.cancel = true;
 
-             if (!setting || !tree) return;
 
-             const pasteData = info.pasteData.html
 
-                 ? SpreadJsObj.analysisPasteHtml(info.pasteData.html)
 
-                 : (info.pasteData.text === ''
 
-                     ? SpreadJsObj.Clipboard.getAnalysisPasteText()
 
-                     : SpreadJsObj.analysisPasteText(info.pasteData.text));
 
-             const hint = {
 
-                 invalidExpr: {type: 'warning', msg: '粘贴的表达式非法'},
 
-                 posCode: {type: 'warning', msg: '清单含有计量单元,不可粘贴清单编号为空'},
 
-                 posQty: {type: 'warning', msg: '清单含有计量单元,数量金额根据计量单元汇总计算所得,不可粘贴'},
 
-                 parent: {type: 'warning', msg: '含有子项的清单,不可粘贴数量、单价、金额'},
 
-                 gcl: {type: 'warning', msg: '工程量清单,不可粘贴项目节数量'},
 
-                 posXmj: {type: 'warning', msg: '清单含有计量单元,不可粘贴项目节编号'},
 
-             };
 
-             const datas = [], filterNodes = [];
 
-             for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
 
-                 const curRow = info.cellRange.row + iRow;
 
-                 const node = tree.nodes[curRow];
 
-                 if (!node) continue;
 
-                 let bPaste = false;
 
-                 const data = info.sheet.zh_tree.getNodeKeyData(node);
 
-                 for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 
-                     const curCol = info.cellRange.col + iCol;
 
-                     const colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     const value = trimInvalidChar(pasteData[iRow][iCol]);
 
-                     const lPos = pos.getLedgerPos(node.id);
 
-                     if (node.children && node.children.length > 0 && invalidFields.parent.indexOf(colSetting.field) >= 0) {
 
-                         toastMessageUniq(hint.parent);
 
-                         continue;
 
-                     }
 
-                     if (!_.isEmpty(node.b_code) && invalidFields.gcl.indexOf(colSetting.field) >= 0) {
 
-                         toastMessageUniq(hint.gcl);
 
-                         continue;
 
-                     }
 
-                     if (lPos && lPos.length > 0) {
 
-                         if (value === '' && invalidFields.posCode.indexOf(colSetting.field) >= 0) {
 
-                             toastMessageUniq(hint.posCode);
 
-                             continue;
 
-                         }
 
-                         if (invalidFields.posCalc.indexOf(colSetting.field) >= 0) {
 
-                             toastMessageUniq(hint.posQty);
 
-                             continue;
 
-                         }
 
-                         if (value !== '' && invalidFields.posXmj.indexOf(colSetting.field) >= 0) {
 
-                             toastMessageUniq(hint.posXmj);
 
-                             continue;
 
-                         }
 
-                     }
 
-                     if (colSetting.type === 'Number') {
 
-                         const num = _.toNumber(value);
 
-                         if (num) {
 
-                             data[colSetting.field] = num;
 
-                             bPaste = true;
 
-                         } else {
 
-                             try {
 
-                                 data[colSetting.field] = math.evaluate(transExpr(value));
 
-                             } catch(err) {
 
-                                 toastMessageUniq(hint.invalidExpr);
 
-                             }
 
-                         }
 
-                     } else {
 
-                         data[colSetting.field] = value;
 
-                         bPaste = true;
 
-                     }
 
-                 }
 
-                 if (bPaste) {
 
-                     datas.push(data);
 
-                 } else {
 
-                     filterNodes.push(node);
 
-                 }
 
-             }
 
-             if (datas.length > 0) {
 
-                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     if (refreshNode.update) {
 
-                         refreshNode.update = refreshNode.update.concat(filterNodes);
 
-                     }
 
-                     treeOperationObj.refreshTree(info.sheet, refreshNode);
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 });
 
-             } else {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-             }
 
-         },
 
-         /**
 
-          * 删除按钮响应事件
 
-          * @param sheet
 
-          */
 
-         deletePress: function (sheet) {
 
-             if (sheet.zh_setting && sheet.zh_dataType === 'tree') {
 
-                 const tree = sheet.zh_tree;
 
-                 if (!tree) { return; }
 
-                 const sortData = sheet.zh_tree.nodes;
 
-                 const datas = [], nodes = [];
 
-                 const sel = sheet.getSelections()[0];
 
-                 let bHint = false;
 
-                 for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                     const node = sortData[iRow];
 
-                     if (node) {
 
-                         let bDel = false;
 
-                         const data = sheet.zh_tree.getNodeKeyData(node);
 
-                         for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                             const col = sheet.zh_setting.cols[iCol];
 
-                             if (col.field === 'b_code' || col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
 
-                                 col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
 
-                                 col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
 
-                                 const lPos = pos.getLedgerPos(node.id);
 
-                                 if (lPos && lPos.length > 0) {
 
-                                     if (!bHint) {
 
-                                         if (col.field === 'code') {
 
-                                             toastr.warning('清单含有计量单元,请先删除计量单元,再删除清单编号');
 
-                                         } else {
 
-                                             toastr.warning('清单含有计量单元,数量金额根据计量单元汇总计算所得,不可删除');
 
-                                         }
 
-                                         bHint = true;
 
-                                     }
 
-                                     continue;
 
-                                 }
 
-                             }
 
-                             const style = sheet.getStyle(iRow, iCol);
 
-                             if (!style.locked) {
 
-                                 const colSetting = sheet.zh_setting.cols[iCol];
 
-                                 data[colSetting.field] = null;
 
-                                 bDel = true;
 
-                             }
 
-                         }
 
-                         if (bDel) {
 
-                             datas.push(data);
 
-                             nodes.push(node);
 
-                         }
 
-                     }
 
-                 }
 
-                 if (datas.length > 0) {
 
-                     postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 
-                         const refreshNode = tree.loadPostData(result);
 
-                         treeOperationObj.refreshTree(sheet, refreshNode);
 
-                     });
 
-                 }
 
-             }
 
-         },
 
-         /**
 
-          * 粘贴整块
 
-          * @param spread
 
-          * @param block
 
-          */
 
-         pasteBlock: function (spread, copyInfo) {
 
-             const self = this;
 
-             const sheet = spread.getActiveSheet();
 
-             const sel = sheet.getSelections()[0];
 
-             const row = sel.row;
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) { return; }
 
-             const node = tree.nodes[row];
 
-             if (!node) { return; }
 
-             postData(window.location.pathname + '/update', {
 
-                 postType: 'paste-block',
 
-                 postData: {
 
-                     id: tree.getNodeKey(node),
 
-                     tid: copyInfo.tid,
 
-                     block: copyInfo.block,
 
-                 }
 
-             }, function (data) {
 
-                 pos.updateDatas(data.pos);
 
-                 const result = tree.loadPostData(data.ledger);
 
-                 self.refreshTree(sheet, result);
 
-                 sheet.setSelection(result.create[0].index, sel.col, sel.rowCount, sel.colCount);
 
-                 SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, result.create[0].index]);
 
-                 self.refreshOperationValid(sheet);
 
-                 removeLocalCache(copyBlockTag);
 
-             }, null, true);
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             if (!info.oldSelections || !info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
 
-                 posOperationObj.loadCurPosData();
 
-                 SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
 
-                 posSearch.search($('#pos-keyword').val());
 
-             }
 
-             SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
 
-             treeOperationObj.loadExprToInput(info.sheet);
 
-         },
 
-         topRowChanged(e, info) {
 
-             SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
 
-         },
 
-         cut: function (sheet, sel, callback) {
 
-             if (!sheet || !sel) return;
 
-             if (sel.colCount >= sheet.zh_setting.cols.length) {
 
-                 toastr.warning('请勿选中整行剪切');
 
-                 return;
 
-             }
 
-             const sortData = SpreadJsObj.getSortData(sheet), datas = [];
 
-             for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                 const node = sortData[iRow];
 
-                 if (node) {
 
-                     const data = sheet.zh_tree.getNodeKeyData(node);
 
-                     for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                         const col = sheet.zh_setting.cols[iCol];
 
-                         if (col.field === 'b_code' || col.field === 'sgfh_qty' || col.field === 'sgfh_tp' ||
 
-                             col.field === 'sjcl_qty' || col.field === 'sjcl_tp' ||
 
-                             col.field === 'qtcl_qty' || col.field === 'qtcl_tp') {
 
-                             const lPos = pos.getLedgerPos(node.id);
 
-                             if (lPos && lPos.length > 0) {
 
-                                 toastr.error('不可剪切');
 
-                                 return;
 
-                             }
 
-                         }
 
-                         const style = sheet.getStyle(iRow, iCol);
 
-                         if (style.locked) {
 
-                             toastr.error('不可剪切');
 
-                             return;
 
-                         }
 
-                         const colSetting = sheet.zh_setting.cols[iCol];
 
-                         data[colSetting.field] = null;
 
-                     }
 
-                     datas.push(data);
 
-                 }
 
-             }
 
-             if (datas.length > 0) {
 
-                 callback();
 
-                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 
-                     const refreshNode = sheet.zh_tree.loadPostData(result);
 
-                     treeOperationObj.refreshTree(sheet, refreshNode);
 
-                 });
 
-             }
 
-         },
 
-         editStarting(e, info) {
 
-             if (!info.sheet.zh_setting || !info.sheet.zh_tree) return;
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             const node = info.sheet.zh_tree.nodes[info.row];
 
-             if (!node) {
 
-                 info.cancel = true;
 
-                 return;
 
-             }
 
-             switch (col.field) {
 
-                 case 'code':
 
-                     const posRange = pos.getLedgerPos(node.id);
 
-                     info.cancel = posRange && posRange.length > 0;
 
-                     break;
 
-                 case 'unit_price':
 
-                 case 'sgfh_qty':
 
-                 case 'sgfh_tp':
 
-                 case 'sjcl_qty':
 
-                 case 'sjcl_tp':
 
-                 case 'qtcl_qty':
 
-                 case 'qtcl_tp':
 
-                 case 'deal_qty':
 
-                 case 'deal_tp':
 
-                     info.cancel = node.children && node.children.length > 0;
 
-                     break;
 
-                 case 'dgn_qty1':
 
-                 case 'dgn_qty2':
 
-                     info.cancel = !_.isEmpty(node.b_code);
 
-                     break;
 
-             }
 
-         },
 
-         sortCode: function (sheet) {
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) return;
 
-             const select = SpreadJsObj.getSelectObject(sheet);
 
-             if (!select || !select.code) return;
 
-             const recursiveSortCode = function (data, parentCode, children) {
 
-                 if (!children || children.length === 0) return;
 
-                 for (const [i, child] of children.entries()) {
 
-                     if (!child.b_code || child.b_code === '') {
 
-                         const code = parentCode + '-' + (i + 1);
 
-                         const cData = tree.getNodeKeyData(child);
 
-                         cData.code = code;
 
-                         data.push(cData);
 
-                         if (!tree.isLeafXmj(child)) {
 
-                             recursiveSortCode(data, code, child.children);
 
-                         }
 
-                     }
 
-                 }
 
-             };
 
-             const data = [];
 
-             recursiveSortCode(data, select.code, select.children);
 
-             if (data.length > 0) {
 
-                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
 
-                     const refreshNode = tree.loadPostData(result);
 
-                     treeOperationObj.refreshTree(sheet, refreshNode);
 
-                 })
 
-             }
 
-         },
 
-     };
 
-     sjsSettingObj.setFxTreeStyle(ledgerSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
 
-     ledgerTreeCol.initSpreadSetting(ledgerSpreadSetting);
 
-     SpreadJsObj.initSheet(ledgerSpread.getActiveSheet(), ledgerSpreadSetting);
 
-     SpreadJsObj.selChangedRefreshBackColor(ledgerSpread.getActiveSheet());
 
-     // 绑定事件
 
-     ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, treeOperationObj.selectionChanged);
 
-     ledgerSpread.bind(spreadNS.Events.TopRowChanged, treeOperationObj.topRowChanged);
 
-     if (!ledgerSpreadSetting.readOnly) {
 
-         ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
 
-             treeOperationObj.refreshOperationValid(info.sheet, info.newSelections);
 
-         });
 
-         ledgerSpread.bind(GC.Spread.Sheets.Events.EditEnded, treeOperationObj.editEnded);
 
-         //ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasted, treeOperationObj.clipboardPasted);
 
-         SpreadJsObj.addDeleteBind(ledgerSpread, treeOperationObj.deletePress);
 
-         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardChanging, function (e, info) {
 
-             const copyText = SpreadJsObj.getFilterCopyText(info.sheet);
 
-             //console.log(info.copyData);
 
-             SpreadJsObj.Clipboard.setCopyData(copyText);
 
-             //copyToClipboard(copyText);
 
-         });
 
-         ledgerSpread.bind(GC.Spread.Sheets.Events.ClipboardPasting, treeOperationObj.clipboardPasting);
 
-         ledgerSpread.bind(spreadNS.Events.EditStarting, treeOperationObj.editStarting);
 
-         SpreadJsObj.addCutEvents(ledgerSpread, treeOperationObj.cut);
 
-         // 绑定 删除等 顶部按钮
 
-         $('#insert').click(() => {
 
-             treeOperationObj.addNode(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#delete').click(function () {
 
-             treeOperationObj.deleteNode(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#up-move').click(function () {
 
-             treeOperationObj.upMove(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#down-move').click(function () {
 
-             treeOperationObj.downMove(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#up-level').click(function () {
 
-             treeOperationObj.upLevel(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#down-level').click(function () {
 
-             treeOperationObj.downLevel(ledgerSpread.getActiveSheet());
 
-         });
 
-         $('#copy').click(function () {
 
-             ledgerSpread.commandManager().execute({
 
-                 cmd: 'copy',
 
-                 sheetName: ledgerSpread.getActiveSheet().name()
 
-             });
 
-         });
 
-         $('#paste').click(function () {
 
-             ledgerSpread.commandManager().execute({
 
-                 cmd: 'paste',
 
-                 sheetName: ledgerSpread.getActiveSheet().name()
 
-             });
 
-         });
 
-         $('#cut').click(function () {
 
-             ledgerSpread.commandManager().execute({
 
-                 cmd: 'cut',
 
-                 sheetName: ledgerSpread.getActiveSheet().name()
 
-             });
 
-         });
 
-         $('#bills-expr').bind('change mouseleave', function () {
 
-             if (document.activeElement.id !== "bills-expr") return;
 
-             const expr = $(this);
 
-             const sheet = ledgerSpread.getActiveSheet();
 
-             const select = SpreadJsObj.getSelectObject(sheet);
 
-             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = trimInvalidChar(expr.val());
 
-             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
-             const data = {
 
-                 id: select.id,
 
-                 tender_id: select.tender_id,
 
-                 ledger_id: select.ledger_id
 
-             };
 
-             if (newValue !== '') {
 
-                 const num = _.toNumber(newValue);
 
-                 if (num) {
 
-                     data[field] = num;
 
-                 } else {
 
-                     try {
 
-                         data[field] = math.evaluate(transExpr(newValue));
 
-                     } catch (err) {
 
-                         toastr.error('输入的表达式非法');
 
-                         return;
 
-                     }
 
-                 }
 
-             } else {
 
-                 data[field] = null;
 
-             }
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
 
-                 const refreshNode = ledgerTree.loadPostData(result);
 
-                 expr.val(select[field]);
 
-                 treeOperationObj.refreshTree(sheet, refreshNode);
 
-             });
 
-         });
 
-     }
 
-     let batchInsertObj;
 
-     $.contextMenu.types.batchInsert = function (item, opt, root) {
 
-         const self = this;
 
-         if ($.isFunction(item.icon)) {
 
-             item._icon = item.icon.call(this, this, $t, key, item);
 
-         } else {
 
-             if (typeof(item.icon) === 'string' && item.icon.substring(0, 3) === 'fa-') {
 
-                 // to enable font awesome
 
-                 item._icon = root.classNames.icon + ' ' + root.classNames.icon + '--fa fa ' + item.icon;
 
-             } else {
 
-                 item._icon = root.classNames.icon + ' ' + root.classNames.icon + '-' + item.icon;
 
-             }
 
-         }
 
-         this.addClass(item._icon);
 
-         const $obj = $('<div>' + item.name + '<input class="text-right ml-1 mr-1" type="tel" max="100" min="1" value="' + item.value + '" style="width: 30px; height: 18px; padding-right: 4px;">行</div>')
 
-             .appendTo(this);
 
-         const $input = $obj.find('input');
 
-         const event = () => {
 
-             if (self.hasClass('context-menu-disabled')) return;
 
-             item.batchInsert($input[0], root);
 
-         };
 
-         $obj.on('click', event).keypress(function (e) {if (e.keyCode === 13) { event(); }});
 
-         $input.click((e) => {e.stopPropagation();})
 
-             .keyup((e) => {if (e.keyCode === 13) item.batchInsert($input[0], root);})
 
-             .on('input', function () {this.value = this.value.replace(/[^\d]/g, '');});
 
-     };
 
-     // 右键菜单
 
-     const billsContextMenuOptions = {
 
-         selector: '#ledger-spread',
 
-         build: function ($trigger, e) {
 
-             const target = SpreadJsObj.safeRightClickSelection($trigger, e, ledgerSpread);
 
-             return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
 
-         },
 
-         items: {},
 
-     };
 
-     if (!readOnly) {
 
-         billsContextMenuOptions.items.create = {
 
-             name: '新增',
 
-             icon: 'fa-sign-in',
 
-             callback: function (key, opt) {
 
-                 treeOperationObj.addNode(ledgerSpread.getActiveSheet());
 
-             },
 
-             disabled: function (key, opt) {
 
-                 const sheet = ledgerSpread.getActiveSheet();
 
-                 const selection = sheet.getSelections();
 
-                 const sel = selection ? selection[0] : sheet.getSelections()[0];
 
-                 const row = sel ? sel.row : -1;
 
-                 const tree = sheet.zh_tree;
 
-                 if (!tree) return true;
 
-                 const first = sheet.zh_tree.nodes[row];
 
-                 let last = first, sameParent = true;
 
-                 if (sel.rowCount > 1) {
 
-                     for (let r = 1; r < sel.rowCount; r++) {
 
-                         const rNode = tree.nodes[sel.row + r];
 
-                         if (rNode.level > first.level) continue;
 
-                         if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
 
-                             sameParent = false;
 
-                             break;
 
-                         }
 
-                         last = rNode;
 
-                     }
 
-                 }
 
-                 const valid = !sheet.zh_setting.readOnly;
 
-                 return !(valid && first && first.level > 1);
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.delete = {
 
-             name: '删除',
 
-             icon: 'fa-remove',
 
-             callback: function (key, opt) {
 
-                 treeOperationObj.deleteNode(ledgerSpread.getActiveSheet());
 
-             },
 
-             disabled: function (key, opt) {
 
-                 const sheet = ledgerSpread.getActiveSheet();
 
-                 const selection = sheet.getSelections();
 
-                 const sel = selection ? selection[0] : sheet.getSelections()[0];
 
-                 const row = sel ? sel.row : -1;
 
-                 const tree = sheet.zh_tree;
 
-                 if (!tree) return true;
 
-                 const first = sheet.zh_tree.nodes[row];
 
-                 let last = first, sameParent = true;
 
-                 if (sel.rowCount > 1) {
 
-                     for (let r = 1; r < sel.rowCount; r++) {
 
-                         const rNode = tree.nodes[sel.row + r];
 
-                         if (rNode.level > first.level) continue;
 
-                         if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
 
-                             sameParent = false;
 
-                             break;
 
-                         }
 
-                         last = rNode;
 
-                     }
 
-                 }
 
-                 const valid = !sheet.zh_setting.readOnly;
 
-                 return !(valid && first && sameParent && !(first.level === 1 && first.node_type));
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.sprBase = '-----------';
 
-     }
 
-     billsContextMenuOptions.items.copyBlock = {
 
-         name: '复制整块',
 
-         icon: 'fa-files-o',
 
-         callback: function (key, opt) {
 
-             /*ledgerSpread.commandManager().execute({
 
-                 cmd:"copy",
 
-                 sheetName:ledgerSpread.getActiveSheet().name()
 
-             });*/
 
-             treeOperationObj.block = [];
 
-             const copyBlockList = [];
 
-             const sheet = ledgerSpread.getActiveSheet();
 
-             const sel = sheet.getSelections()[0];
 
-             let iRow = sel.row;
 
-             const pid = sheet.zh_tree.nodes[iRow].ledger_pid;
 
-             while (iRow < sel.row + sel.rowCount) {
 
-                 const node = sheet.zh_tree.nodes[iRow];
 
-                 if (node.ledger_pid !== pid) {
 
-                     toastr.error('仅可同时选中同层节点');
 
-                     return;
 
-                 }
 
-                 copyBlockList.push(node.ledger_id);
 
-                 iRow += sheet.zh_tree.getPosterity(node).length + 1;
 
-             }
 
-             const tenderId = _.toInteger(getTenderId());
 
-             setLocalCache(copyBlockTag, JSON.stringify({tid: tenderId, block: copyBlockList}));
 
-             //treeOperationObj.block = copyBlockList;
 
-         },
 
-         visible: function (key, opt) {
 
-             const sheet = ledgerSpread.getActiveSheet();
 
-             const selection = sheet.getSelections();
 
-             const row = selection[0].row;
 
-             const select = ledgerTree.nodes[row];
 
-             return select;
 
-         },
 
-         disabled: function (key, opt) {
 
-             const sheet = ledgerSpread.getActiveSheet();
 
-             const selection = sheet.getSelections();
 
-             const row = selection[0].row;
 
-             const select = ledgerTree.nodes[row];
 
-             return select && select.level <= 1;
 
-         }
 
-     };
 
-     if (!readOnly) {
 
-         billsContextMenuOptions.items.pasteBlock = {
 
-             name: '粘贴整块',
 
-             icon: 'fa-clipboard',
 
-             disabled: function (key, opt) {
 
-                 //const block = treeOperationObj.block || [];
 
-                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
 
-                 return !(copyInfo && copyInfo.tid && copyInfo.tid > 0 && copyInfo.block && copyInfo.block.length > 0);
 
-             },
 
-             callback: function (key, opt) {
 
-                 //const block = treeOperationObj.block || [];
 
-                 const copyInfo = JSON.parse(getLocalCache(copyBlockTag));
 
-                 if (copyInfo.block.length > 0) {
 
-                     treeOperationObj.pasteBlock(ledgerSpread, copyInfo);
 
-                 } else {
 
-                     document.execCommand('paste');
 
-                 }
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.sprBlock = '-----------';
 
-     }
 
-     if (!readOnly) {
 
-         billsContextMenuOptions.items.sortChildren = {
 
-             name: '顺序重排子项编号',
 
-             icon: 'fa-sort-numeric-asc',
 
-             disabled: function (key, opt) {
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-                 return !node || !node.code || !node.children || node.children === 0;
 
-             },
 
-             callback: function (key, opt) {
 
-                 treeOperationObj.sortCode(ledgerSpread.getActiveSheet());
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         if (!checkTzMeasureType()) {
 
-             billsContextMenuOptions.items.applyDeal2Sgfh = {
 
-                 name: '填设计量',
 
-                 icon: 'fa-pencil',
 
-                 callback: function (key, opt) {
 
-                     postData(window.location.pathname + '/deal2sgfh', null, function (result) {
 
-                         ledgerTree.loadDatas(result.bills);
 
-                         treeCalc.calculateAll(ledgerTree);
 
-                         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
 
-                     });
 
-                 }
 
-             };
 
-         }
 
-         billsContextMenuOptions.items.sprSort = '-----------';
 
-     }
 
-     if (!readOnly) {
 
-         billsContextMenuOptions.items.batchInsert = {
 
-             name: '批量插入',
 
-             type: 'batchInsert',
 
-             value: '2',
 
-             icon: 'fa-sign-in',
 
-             batchInsert: function (obj, root) {
 
-                 if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
 
-                     obj.value = obj.max;
 
-                     toastr.warning('批量插入不可多于' + obj.max);
 
-                 } else if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
 
-                     obj.value = obj.min;
 
-                     toastr.warning('批量插入不可少于' + obj.min);
 
-                 } else {
 
-                     treeOperationObj.addNode(ledgerSpread.getActiveSheet(), parseInt(obj.value));
 
-                     root.$menu.trigger('contextmenu:hide');
 
-                 }
 
-             },
 
-             disabled: function (key, opt) {
 
-                 const sheet = ledgerSpread.getActiveSheet();
 
-                 const selection = sheet.getSelections();
 
-                 const sel = selection ? selection[0] : sheet.getSelections()[0];
 
-                 const row = sel ? sel.row : -1;
 
-                 const tree = sheet.zh_tree;
 
-                 if (!tree) return true;
 
-                 const first = sheet.zh_tree.nodes[row];
 
-                 let last = first, sameParent = true;
 
-                 if (sel.rowCount > 1) {
 
-                     for (let r = 1; r < sel.rowCount; r++) {
 
-                         const rNode = tree.nodes[sel.row + r];
 
-                         if (rNode.level > first.level) continue;
 
-                         if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
 
-                             sameParent = false;
 
-                             break;
 
-                         }
 
-                         last = rNode;
 
-                     }
 
-                 }
 
-                 const valid = !sheet.zh_setting.readOnly;
 
-                 return !(valid && first && first.level > 1);
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.batchInsertBillsPos = {
 
-             name: '批量插入清单-计量单元',
 
-             icon: 'fa-sign-in',
 
-             disabled: function (key, opt) {
 
-                 if (!checkTzMeasureType()) return true;
 
-                 const sheet = ledgerSpread.getActiveSheet();
 
-                 const selection = sheet.getSelections();
 
-                 const row = selection[0].row;
 
-                 const select = ledgerTree.nodes[row];
 
-                 if (select) {
 
-                     if (select.code && select.code !== '') {
 
-                         return !ledgerTree.isLeafXmj(select);
 
-                     } else {
 
-                         const parent = ledgerTree.getParent(select);
 
-                         return !(parent && ledgerTree.isLeafXmj(parent));
 
-                     }
 
-                 } else {
 
-                     return true;
 
-                 }
 
-             },
 
-             callback: function (key, opt) {
 
-                 if (!batchInsertObj) {
 
-                     batchInsertObj = new BatchInsertBillsPosObj($('#batch'));
 
-                 } else {
 
-                     batchInsertObj.initView();
 
-                 }
 
-                 $('#batch').modal('show');
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.sprBatch = '-----------';
 
-     }
 
-     if (!readOnly) {
 
-         billsContextMenuOptions.items.importExcel = {
 
-             name: '导入分项清单Excel',
 
-             icon: 'fa-file-excel-o',
 
-             disabled: function (key, opt) {
 
-                 return readOnly;
 
-             },
 
-             callback: function (key, opt) {
 
-                 importExcel.doImport({
 
-                     template: {
 
-                         hint: '0号台账',
 
-                         url: '/template/导入分项清单EXCEL格式.xls',
 
-                     },
 
-                     callback: function (sheet) {     
 
-                         postDataCompress(window.location.pathname + '/upload-excel/tz', sheet, function (result) {
 
-                             ledgerTree.loadDatas(result.bills);
 
-                             treeCalc.calculateAll(ledgerTree);
 
-                             SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
 
-                             pos.loadDatas(result.pos);
 
-                             posOperationObj.loadCurPosData();
 
-                         }, null);
 
-                     },
 
-                     // callback: function (file, select) {
 
-                     //     const formData = new FormData();
 
-                     //     formData.append('file', file.files[0]);     
 
-                     //     postDataWithFileProgress(window.location.pathname + '/upload-excel?ueType=tz&sheetName=' + select, formData, function (result) {
 
-                     //         ledgerTree.loadDatas(result.bills);
 
-                     //         treeCalc.calculateAll(ledgerTree);
 
-                     //         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
 
-                     //         pos.loadDatas(result.pos);
 
-                     //         posOperationObj.loadCurPosData();
 
-                     //     }, null);
 
-                     // }
 
-                     //u_type: importExcel.uploadType.file,
 
-                 });
 
-                 //$('#upload-ledger').modal('show');
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-         billsContextMenuOptions.items.importGclBills2Xmj = {
 
-             name: '导入工程量清单至项目节',
 
-             icon: 'fa-file-excel-o',
 
-             disabled: function (key, opt) {
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-                 return readOnly || !node
 
-                     || (node.children && node.children.length > 0)
 
-                     || (!_.isNil(node.b_code) && node.b_code !== '');
 
-             },
 
-             callback: function (key, opt) {
 
-                 const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-                 importExcel.doImport({
 
-                     template: {
 
-                         hint: '工程量清单',
 
-                         url: '/template/导入工程量清单EXCEL格式.xls',
 
-                     },
 
-                     callback: function (sheet) {
 
-                         postDataCompress(window.location.pathname + '/upload-excel/gcl2xmj', {id: node.id, sheet: sheet}, function (result) {
 
-                             const ledgerSheet = ledgerSpread.getActiveSheet();
 
-                             const sel = ledgerSheet.getSelections();
 
-                             const refreshNode = ledgerTree.loadPostData(result);
 
-                             treeOperationObj.refreshTree(ledgerSheet, refreshNode);
 
-                             if (refreshNode.create[0]) {
 
-                                 if (sel && sel[0]) {
 
-                                     ledgerSheet.setSelection(refreshNode.create[0].index, sel[0].col, sel[0].rowCount, sel[0].colCount);
 
-                                     SpreadJsObj.reloadRowsBackColor(ledgerSheet, [sel[0].row, refreshNode.create[0].index]);
 
-                                 } else {
 
-                                     ledgerSheet.setSelection(refreshNode.create[0].index, 0, 1, 1);
 
-                                     SpreadJsObj.reloadRowsBackColor(ledgerSheet, [refreshNode.create[0].index]);
 
-                                 }
 
-                             }
 
-                             treeOperationObj.refreshOperationValid(ledgerSheet);
 
-                         }, null);
 
-                     }
 
-                 });
 
-             },
 
-             visible: function (key, opt) {
 
-                 return !readOnly;
 
-             }
 
-         };
 
-     }
 
-     $.contextMenu(billsContextMenuOptions);
 
-     const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
 
-     // 台账模式加载计量单元数据
 
-     if (checkTzMeasureType()) {
 
-         $.divResizer({
 
-             select: '#main-resize',
 
-             callback: function () {
 
-                 ledgerSpread.refresh();
 
-                 let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
 
-                 $(".sp-wrap").height(bcontent-30);
 
-                 posSpread.refresh();
 
-             }
 
-         });
 
-         SpreadJsObj.initSheet(posSpread.getActiveSheet(), posSpreadSetting);
 
-     }
 
-     //绑定计量单元编辑事件
 
-     const posOperationObj = {
 
-         editStarting: function (e, info) {
 
-             posOperationObj.ledgerTreeNode = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-         },
 
-         loadExprToInput: function () {
 
-             const sheet = posSpread.getActiveSheet();
 
-             const sel = sheet.getSelections()[0];
 
-             if (!sel || !sheet.zh_setting) return;
 
-             const col = sheet.zh_setting.cols[sel.col], cell = sheet.getCell(sel.row, sel.col);
 
-             if (col && col.type === 'Number') {
 
-                 const data = SpreadJsObj.getSelectObject(sheet);
 
-                 if (data) {
 
-                     $('#pos-expr').val(data[col.field]).attr('field', col.field).attr('org', data[col.field])
 
-                         .attr('row', sel.row).attr('readOnly', readOnly || cell.locked());
 
-                 } else {
 
-                     $('#pos-expr').val('').attr('readOnly', true);
 
-                 }
 
-             } else {
 
-                 $('#pos-expr').val('').attr('readOnly', true);
 
-             }
 
-         },
 
-         /**
 
-          * 加载计量单元 根据当前台账选择节点
 
-          */
 
-         loadCurPosData: function () {
 
-             //spreadJsObj.reinitSheet(posSpread.getActiveSheet());
 
-             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
 
-             if (node) {
 
-                 const posData = pos.ledgerPos[itemsPre + node.id] || [];
 
-                 SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', posData);
 
-             } else {
 
-                 SpreadJsObj.loadSheetData(posSpread.getActiveSheet(), 'data', []);
 
-             }
 
-             posOperationObj.loadExprToInput();
 
-         },
 
-         /**
 
-          * 编辑单元格响应事件
 
-          * @param {Object} e
 
-          * @param {Object} info
 
-          */
 
-         editEnded: function (e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const posData = info.sheet.zh_data ? info.sheet.zh_data[info.row] : null;
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 const orgText = posData ? posData[col.field] : null;
 
-                 const newText = trimInvalidChar(info.editingText);
 
-                 if (orgText === newText || ((!orgText || orgText === '') && (newText === ''))) {
 
-                     return;
 
-                 }
 
-                 //const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
 
-                 const node = posOperationObj.ledgerTreeNode;
 
-                 if (!node) {
 
-                     toastr.error('数据错误,请选择台账节点后再试');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else if (newText && newText !== '' && node.children && node.children.length > 0) {
 
-                     toastr.error('父节点不可插入计量单元');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else if (newText && newText !== '' && (!node.b_code || node.b_code === '')) {
 
-                     toastr.error('项目节不可插入计量单元');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const data = {};
 
-                 if (col.field === 'name') {
 
-                     if (newText === '' && posData) {
 
-                         toastr.error('部位名称不可为空');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     } else if (!posData) {
 
-                         if (newText && newText !== '') {
 
-                             data.updateType = 'add';
 
-                             const sortData = info.sheet.zh_data;
 
-                             const order = (!sortData || sortData.length === 0) ? 1 : Math.max(sortData[sortData.length - 1].porder + 1, sortData.length + 1);
 
-                             data.updateData = { name: newText, lid: node.id, tid: tender.id, porder: order};
 
-                         } else {
 
-                             return;
 
-                         }
 
-                     } else {
 
-                         data.updateType = 'update';
 
-                         data.updateData = {id: posData.id, name: newText};
 
-                     }
 
-                 } else if (!posData) {
 
-                     toastr.warning('新增计量单元请先输入名称');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 } else {
 
-                     data.updateType = 'update';
 
-                     data.updateData = {id: posData.id};
 
-                     if (col.type === 'Number') {
 
-                         const num = _.toNumber(newText);
 
-                         if (_.isFinite(num)) {
 
-                             data.updateData[col.field] = num;
 
-                         } else {
 
-                             try {
 
-                                 data.updateData[col.field] = math.evaluate(transExpr(newText));
 
-                             } catch(err) {
 
-                                 toastr.error('输入的表达式非法');
 
-                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                                 return;
 
-                             }
 
-                         }
 
-                     } else {
 
-                         data.updateData[col.field] = newText;
 
-                     }
 
-                 }
 
-                 postData('/tender/' + getTenderId() + '/pos/update', data, function (result) {
 
-                     const updateRst = pos.updateDatas(result.pos);
 
-                     // 刷新当前行, 不适用于新增(在非下一空白行新增)
 
-                     if (updateRst.create.length > 0) {
 
-                         // info.sheet.addRows(info.row, 1);
 
-                         // if (info.sheet.zh_data.length === 0) {
 
-                         //     info.sheet.zh_data = pos.ledgerPos[itemsPre + node.id] || [];
 
-                         // }
 
-                         // SpreadJsObj.reLoadRowData(info.sheet, info.sheet.zh_data.length - 1);
 
-                         posOperationObj.loadCurPosData();
 
-                     } else {
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     }
 
-                     const loadResult = ledgerTree.loadPostData(result.ledger);
 
-                     treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-                     treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-                 }, function () {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 删除按钮响应事件
 
-          * @param sheet
 
-          */
 
-         deletePress: function (sheet) {
 
-             const self = this;
 
-             if (sheet.zh_setting) {
 
-                 const sortData = sheet.zh_data;
 
-                 const datas = [], posSelects = [];
 
-                 const sel = sheet.getSelections()[0];
 
-                 for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
 
-                     let bDel = false;
 
-                     const node = sortData[iRow];
 
-                     if (node) {
 
-                         const data = {id: node.id};
 
-                         for (let iCol = sel.col; iCol < sel.col + sel.colCount; iCol++) {
 
-                             const colSetting = sheet.zh_setting.cols[iCol];
 
-                             if (colSetting.field === 'name') {
 
-                                 toastr.error('部位名称不能为空');
 
-                                 return;
 
-                             }
 
-                             const style = sheet.getStyle(iRow, iCol);
 
-                             if (!style.locked) {
 
-                                 const colSetting = sheet.zh_setting.cols[iCol];
 
-                                 data[colSetting.field] = null;
 
-                                 bDel = true;
 
-                             }
 
-                         }
 
-                         if (bDel) {
 
-                             datas.push(data);
 
-                             posSelects.push(node);
 
-                         }
 
-                     }
 
-                 }
 
-                 if (datas.length > 0) {
 
-                     postData('/tender/' + getTenderId() + '/pos/update', {updateType: 'update', updateData: datas}, function (result) {
 
-                         pos.updateDatas(result.pos);
 
-                         posOperationObj.loadCurPosData();
 
-                         const loadResult = ledgerTree.loadPostData(result.ledger);
 
-                         treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-                         treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-                     }, function () {
 
-                         posOperationObj.loadCurPosData();
 
-                     });
 
-                 }
 
-             }
 
-         },
 
-         /**
 
-          * 删除 计量单元
 
-          * @param sheet
 
-          */
 
-         deletePos: function (sheet) {
 
-             const selection = sheet.getSelections();
 
-             const data = {
 
-                 updateType: 'delete',
 
-                 updateData: [],
 
-             };
 
-             const row = selection[0].row, count = selection[0].rowCount;
 
-             const sortData = sheet.zh_data;
 
-             for (let iRow = 0; iRow < count; iRow++) {
 
-                 if (sortData[iRow + row]) {
 
-                     data.updateData.push(sortData[iRow + row].id);
 
-                 }
 
-             }
 
-             if (data.updateData.length > 0) {
 
-                 postData('/tender/' + getTenderId() + '/pos/update', data, function (result) {
 
-                     pos.removeDatas(result.pos);
 
-                     sheet.deleteRows(row, count);
 
-                     const loadResult = ledgerTree.loadPostData(result.ledger);
 
-                     treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-                     treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-                 });
 
-             }
 
-         },
 
-         /**
 
-          * 粘贴单元格响应事件
 
-          * @param e
 
-          * @param info
 
-          */
 
-         clipboardPasted: function (e, info) {
 
-             if (info.sheet.getColumnCount() > info.sheet.zh_setting.cols.length) {
 
-                 info.sheet.setColumnCount(info.sheet.zh_setting.cols.length);
 
-             }
 
-             const node = treeOperationObj.getSelectNode(ledgerSpread.getActiveSheet());
 
-             if (node.code && (node.code !== '')) {
 
-                 toastr.error('项目节不可含有清单明细');
 
-                 posOperationObj.loadCurPosData();
 
-                 return;
 
-             }
 
-             if (node.children && (node.children.length > 0)) {
 
-                 toastr.error('仅清单子项可以含有计量单元');
 
-                 posOperationObj.loadCurPosData();
 
-                 return;
 
-             }
 
-             if (info.sheet.zh_setting) {
 
-                 const data = [];
 
-                 const sortData = info.sheet.zh_data || [];
 
-                 if (sortData.length === 0 || info.cellRange.row + info.cellRange.rowCount > sortData.length) {
 
-                     if (info.cellRange.col !== 0) {
 
-                         toastr.warning('新增计量单元请先输入名称');
 
-                         posOperationObj.loadCurPosData();
 
-                         return;
 
-                     }
 
-                 }
 
-                 const lastOrder = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
 
-                 for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
 
-                     let bPaste = false;
 
-                     const curRow = info.cellRange.row + iRow;
 
-                     const posData = curRow >= sortData.length ? {lid: node.id, porder: lastOrder + curRow - sortData.length} : {id: sortData[curRow].id, lid: node.id};
 
-                     for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
 
-                         const curCol = info.cellRange.col + iCol;
 
-                         const colSetting = info.sheet.zh_setting.cols[curCol];
 
-                         if (!colSetting) continue;
 
-                         posData[colSetting.field] = trimInvalidChar(info.sheet.getText(curRow, curCol));
 
-                         if (colSetting.type === 'Number') {
 
-                             const num = _.toNumber(posData[colSetting.field]);
 
-                             if (num) {
 
-                                 posData[colSetting.field] = num;
 
-                                 bPaste = true;
 
-                             } else {
 
-                                 try {
 
-                                     posData[colSetting.field] = math.evaluate(transExpr(posData[colSetting.field]));
 
-                                     bPaste = true;
 
-                                 } catch(err) {
 
-                                     delete posData[colSetting.field];
 
-                                     toastr.warning('粘贴了表达式非法,已过滤');
 
-                                 }
 
-                             }
 
-                         } else {
 
-                             bPaste = true;
 
-                         }
 
-                     }
 
-                     if (bPaste) {
 
-                         data.push(posData);
 
-                     }
 
-                 }
 
-                 if (data.length > 0) {
 
-                     postData('/tender/' + getTenderId() + '/pos/paste', data, function (result) {
 
-                         pos.updateDatas(result.pos);
 
-                         posOperationObj.loadCurPosData();
 
-                         const loadResult = ledgerTree.loadPostData(result.ledger);
 
-                         treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-                         posOperationObj.loadCurPosData();
 
-                         treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-                     }, function () {
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                     });
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 }
 
-             }
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             posOperationObj.loadExprToInput();
 
-         },
 
-         addPegs: function (pegs) {
 
-             if (!pegs || pegs.length <= 0) return;
 
-             const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-             if (!node) return;
 
-             const sheet = posSpread.getActiveSheet();
 
-             const sortData = sheet.zh_data || [];
 
-             let order = sortData.length > 0 ? sortData[sortData.length - 1].porder + 1 : 1;
 
-             pegs.forEach(function (p) {p.porder = ++order; p.lid = node.id});
 
-             postData('/tender/' + getTenderId() + '/pos/paste', pegs, function (result) {
 
-                 pos.updateDatas(result.pos);
 
-                 posOperationObj.loadCurPosData();
 
-                 treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-             });
 
-         }
 
-     };
 
-     posSpread.bind(spreadNS.Events.SelectionChanged, posOperationObj.selectionChanged);
 
-     if (!posSpreadSetting.readOnly) {
 
-         $('#pos-expr').bind('change mouseleave', function () {
 
-             if (document.activeElement.id !== "pos-expr") return;
 
-             const expr = $(this);
 
-             const posSheet = posSpread.getActiveSheet();
 
-             const select = SpreadJsObj.getSelectObject(posSheet);
 
-             if (!select) return;
 
-             const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val(), row = trimInvalidChar(expr.attr('row'));
 
-             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
-             const data = {id: select.id};
 
-             if (newValue !== '') {
 
-                 const num = _.toNumber(newValue);
 
-                 if (num) {
 
-                     data[field] = num;
 
-                 } else {
 
-                     try {
 
-                         data[field] = math.evaluate(transExpr(newValue));
 
-                     } catch (err) {
 
-                         toastr.error('输入的表达式非法');
 
-                         return;
 
-                     }
 
-                 }
 
-             } else {
 
-                 data[field] = null;
 
-             }
 
-             // 更新至服务器
 
-             postData('/tender/' + getTenderId() + '/pos/update', {updateType: 'update', updateData: data}, function (result) {
 
-                 const updateRst = pos.updateDatas(result.pos);
 
-                 expr.val(select[field]);
 
-                 SpreadJsObj.reLoadRowData(posSheet, _.toNumber(row));
 
-                 const loadResult = ledgerTree.loadPostData(result.ledger);
 
-                 treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-                 treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-             });
 
-         });
 
-         SpreadJsObj.addDeleteBind(posSpread, posOperationObj.deletePress);
 
-         posSpread.bind(spreadNS.Events.EditStarting, posOperationObj.editStarting);
 
-         posSpread.bind(spreadNS.Events.EditEnded, posOperationObj.editEnded);
 
-         posSpread.bind(spreadNS.Events.ClipboardPasted, posOperationObj.clipboardPasted);
 
-         const mergePeg = NewMergePeg({ callback: posOperationObj.addPegs });
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#pos-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, posSpread);
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'delete': {
 
-                     name: '删除',
 
-                     icon: 'fa-remove',
 
-                     disabled: function (key, opt) {
 
-                         const sheet = posSpread.getActiveSheet();
 
-                         if (sheet.zh_data) {
 
-                             const selection = sheet.getSelections();
 
-                             return sheet.zh_data.length < selection[0].row + selection[0].rowCount;
 
-                         } else {
 
-                             return true;
 
-                         }
 
-                     },
 
-                     callback: function (key, opt) {
 
-                         posOperationObj.deletePos(posSpread.getActiveSheet());
 
-                     }
 
-                 },
 
-                 'merge-peg': {
 
-                     name: '合并起讫桩号',
 
-                     disabled: function (key, opt) {
 
-                         const node = SpreadJsObj.getSelectObject(ledgerSpread.getActiveSheet());
 
-                         return _.isNil(node) || _.isNil(node.b_code) || node.b_code === '';
 
-                     },
 
-                     callback: function (key, opt) {
 
-                         mergePeg.show();
 
-                     }
 
-                 }
 
-             }
 
-         });
 
-     } else {
 
-         SpreadJsObj.forbiddenSpreadContextMenu('#pos-spread', posSpread);
 
-     }
 
-     postData(window.location.pathname + '/load', {}, function (data) {
 
-         ledgerTree.loadDatas(data.bills);
 
-         treeCalc.calculateAll(ledgerTree);
 
-         SpreadJsObj.loadSheetData(ledgerSpread.getActiveSheet(), 'tree', ledgerTree);
 
-         SpreadJsObj.loadTopAndSelect(ledgerSpread.getActiveSheet(), ckBillsSpread);
 
-         pos.loadDatas(data.pos);
 
-         posOperationObj.loadCurPosData();
 
-         SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
 
-         treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-         treeOperationObj.loadExprToInput(ledgerSpread.getActiveSheet());
 
-     }, null, true);
 
-     $.divResizer({
 
-         select: '#right-spr',
 
-         callback: function () {
 
-             ledgerSpread.refresh();
 
-             if (posSpread) {
 
-                 posSpread.refresh();
 
-             }
 
-             if (stdXmj) {
 
-                 stdXmj.spread.refresh();
 
-             }
 
-             if (stdGcl) {
 
-                 stdGcl.spread.refresh();
 
-             }
 
-             if (dealBills) {
 
-                 dealBills.spread.refresh();
 
-             }
 
-             if (searchLedger) {
 
-                 searchLedger.spread.refresh();
 
-             }
 
-         }
 
-     });
 
-     const stdLibCellDoubleClick = function (e, info) {
 
-         const stdSheet = info.sheet;
 
-         const mainSheet = ledgerSpread.getActiveSheet();
 
-         if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
 
-         const stdTree = stdSheet.zh_tree;
 
-         const stdNode = stdTree.nodes[info.row];
 
-         const mainTree = mainSheet.zh_tree;
 
-         const sel = mainSheet.getSelections()[0];
 
-         const mainNode = mainTree.nodes[sel.row];
 
-         if (!stdNode) { return; }
 
-         if (info.sheet.zh_setting.stdType === 'gcl') {
 
-             if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
 
-                 toastr.warning('非最底层项目下,不应添加清单');
 
-                 return;
 
-             }
 
-         }
 
-         postData(window.location.pathname + '/update', {
 
-             postType: 'add-std',
 
-             postData: {
 
-                 id: ledgerTree.getNodeKey(mainNode),
 
-                 tender_id: mainNode.tender_id,
 
-                 stdType: info.sheet.zh_setting.stdType,
 
-                 stdLibId: stdNode.list_id,
 
-                 stdNode: stdTree.getNodeKey(stdNode)
 
-             }
 
-         }, function (result) {
 
-             const refreshNode = mainTree.loadPostData(result);
 
-             treeOperationObj.refreshTree(mainSheet, refreshNode);
 
-             if (refreshNode.create && refreshNode.create.length > 0) {
 
-                 mainSheet.setSelection(refreshNode.create[refreshNode.create.length - 1].index, sel.col, sel.rowCount, sel.colCount);
 
-                 SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, refreshNode.create[refreshNode.create.length - 1].index]);
 
-             } else {
 
-                 const node = _.find(ledgerTree.nodes, {code: stdNode.code, name: stdNode.name});
 
-                 if (node) {
 
-                     mainSheet.setSelection(ledgerTree.nodes.indexOf(node), sel.col, sel.rowCount, sel.colCount);
 
-                     SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, ledgerTree.nodes.indexOf(node)]);
 
-                 }
 
-             }
 
-             treeOperationObj.refreshOperationValid(mainSheet);
 
-             ledgerSpread.focus();
 
-             posOperationObj.loadCurPosData();
 
-         });
 
-     };
 
-     const stdXmjSetting = {
 
-         selector: '#std-xmj',
 
-         stdType: 'xmj',
 
-         treeSetting: {
 
-             id: 'chapter_id',
 
-             pid: 'pid',
 
-             order: 'order',
 
-             level: 'level',
 
-             rootId: -1,
 
-             keys: ['id', 'list_id', 'chapter_id'],
 
-         },
 
-         spreadSetting: {
 
-             cols: [
 
-                 {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
 
-                 {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
 
-                 {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
 
-             ],
 
-             treeCol: 0,
 
-             emptyRows: 0,
 
-             headRows: 1,
 
-             headRowHeight: [32],
 
-             defaultRowHeight: 21,
 
-             headerFont: '12px 微软雅黑',
 
-             font: '12px 微软雅黑',
 
-             headColWidth: [0],
 
-             selectedBackColor: '#fffacd',
 
-         },
 
-         cellDoubleClick: stdLibCellDoubleClick,
 
-         page: 'ledger',
 
-         tid: getTenderId(),
 
-     };
 
-     const stdGclSetting = {
 
-         selector: '#std-gcl',
 
-         stdType: 'gcl',
 
-         treeSetting: {
 
-             id: 'bill_id',
 
-             pid: 'pid',
 
-             order: 'order',
 
-             level: 'level',
 
-             rootId: -1,
 
-             keys: ['id', 'list_id', 'bill_id']
 
-         },
 
-         spreadSetting: {
 
-             cols: [
 
-                 {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
 
-                 {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
 
-                 {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
 
-             ],
 
-             treeCol: 0,
 
-             emptyRows: 0,
 
-             headRows: 1,
 
-             headRowHeight: [32],
 
-             defaultRowHeight: 21,
 
-             headerFont: '12px 微软雅黑',
 
-             font: '12px 微软雅黑',
 
-             headColWidth: [0],
 
-             selectedBackColor: '#fffacd',
 
-         },
 
-         cellDoubleClick: stdLibCellDoubleClick,
 
-         page: 'ledger',
 
-         tid: getTenderId(),
 
-     };
 
-     // 展开收起标准清单
 
-     $('a', '#side-menu').bind('click', function (e) {
 
-         e.preventDefault();
 
-         const tab = $(this), tabPanel = $(tab.attr('content'));
 
-         // 展开工具栏、切换标签
 
-         if (!tab.hasClass('active')) {
 
-             const close = $('.active', '#side-menu').length === 0;
 
-             $('a', '#side-menu').removeClass('active');
 
-             tab.addClass('active');
 
-             $('.tab-content .tab-pane').removeClass('active');
 
-             tabPanel.addClass('active');
 
-             showSideTools(tab.hasClass('active'));
 
-             if (tab.attr('content') === '#std-xmj') {
 
-                 if (!stdXmj) {
 
-                     stdXmj = new stdLib(stdXmjSetting);
 
-                     //stdXmj.loadLib($('select', '#std-xmj').val());
 
-                 }
 
-                 stdXmj.spread.refresh();
 
-             } else if (tab.attr('content') === '#std-gcl') {
 
-                 if (!stdGcl) {
 
-                     stdGcl = new stdLib(stdGclSetting);
 
-                     //stdGcl.loadLib($('select', '#std-gcl').val());
 
-                 }
 
-                 stdGcl.spread.refresh();
 
-             } else if (tab.attr('content') === '#deal-bills') {
 
-                 if (!dealBills) {
 
-                     dealBills = new DealBills('#deal-bills-spread', {
 
-                         cols: [
 
-                             {title: '清单编号', field: 'code', hAlign: 0, width: 85, formatter: '@', readOnly: true},
 
-                             {title: '名称', field: 'name', hAlign: 0, width: 150, formatter: '@', readOnly: true},
 
-                             {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
 
-                             {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
 
-                             {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
 
-                             {title: '金额', field: 'total_price', hAlign: 2, width: 50, readOnly: true},
 
-                         ],
 
-                         emptyRows: 0,
 
-                         headRows: 1,
 
-                         headRowHeight: [32],
 
-                         defaultRowHeight: 21,
 
-                         headerFont: '12px 微软雅黑',
 
-                         font: '12px 微软雅黑',
 
-                         headColWidth: [0],
 
-                         selectedBackColor: '#fffacd',
 
-                     });
 
-                     dealBills.loadData();
 
-                 }
 
-                 dealBills.spread.refresh();
 
-             } else if (tab.attr('content') === '#search') {
 
-                 if (!searchLedger) {
 
-                     searchLedger = $.billsSearch({
 
-                         selector: '#search',
 
-                         searchSpread: ledgerSpread,
 
-                         resultSpreadSetting: {
 
-                             cols: [
 
-                                 {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 
-                                 {title: '清单编号', field: 'b_code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
 
-                                 {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
 
-                                 {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
 
-                                 {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
 
-                                 {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
 
-                             ],
 
-                             emptyRows: 0,
 
-                             headRows: 1,
 
-                             headRowHeight: [32],
 
-                             defaultRowHeight: 21,
 
-                             headerFont: '12px 微软雅黑',
 
-                             font: '12px 微软雅黑',
 
-                             selectedBackColor: '#fffacd',
 
-                         },
 
-                         afterLocated: function () {
 
-                             posOperationObj.loadCurPosData();
 
-                         }
 
-                     });
 
-                 }
 
-                 searchLedger.spread.refresh();
 
-             } else if (tab.attr('content') === '#error-list') {
 
-                 errorList.spread.refresh();
 
-             }
 
-         } else { // 收起工具栏
 
-             tab.removeClass('active');
 
-             tabPanel.removeClass('active');
 
-             showSideTools(tab.hasClass('active'));
 
-         }
 
-         ledgerSpread.refresh();
 
-         if (posSpread) {
 
-             posSpread.refresh();
 
-         }
 
-     });
 
-     class DealBills {
 
-         constructor (selector, spreadSetting) {
 
-             const self = this;
 
-             this.obj = $(selector)[0];
 
-             this.url = '/tender/' + getTenderId() + '/deal';
 
-             this.spreadSetting = spreadSetting;
 
-             this.spread = SpreadJsObj.createNewSpread(this.obj);
 
-             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
 
-             if (!readOnly) {
 
-                 this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
 
-                 const dealSheet = info.sheet;
 
-                 const mainSheet = ledgerSpread.getActiveSheet();
 
-                 const dealBills = SpreadJsObj.getSelectObject(dealSheet);
 
-                 if (!dealBills) { return; }
 
-                 const mainTree = mainSheet.zh_tree;
 
-                 const mainNode = SpreadJsObj.getSelectObject(mainSheet);
 
-                 if (!mainNode || !mainTree) { return; }
 
-                 if (mainNode.code && mainNode.code !== '' && !mainTree.isLeafXmj(mainNode)) {
 
-                     toastr.error('非最底层项目下,不应添加清单');
 
-                     return;
 
-                 }
 
-                 postData(window.location.pathname + '/update', {
 
-                     postType: 'add-deal',
 
-                     postData: {
 
-                         id: mainNode.ledger_id,
 
-                         type: mainNode.code ? 'child' : 'next',
 
-                         dealBills: {
 
-                             b_code: dealBills.code, name: dealBills.name, unit: dealBills.unit,
 
-                             unit_price: dealBills.unit_price,
 
-                         }
 
-                     },
 
-                 }, function (result) {
 
-                     const refreshData = mainTree.loadPostData(result);
 
-                     treeOperationObj.refreshTree(mainSheet, refreshData);
 
-                     const sel = mainSheet.getSelections()[0];
 
-                     mainSheet.setSelection(refreshData.create[0].index, sel.col, sel.rowCount, sel.colCount);
 
-                     SpreadJsObj.reloadRowsBackColor(mainSheet, [sel.row, refreshData.create[0].index]);
 
-                     treeOperationObj.refreshOperationValid(mainSheet);
 
-                     ledgerSpread.focus();
 
-                     posOperationObj.loadCurPosData();
 
-                 });
 
-             });
 
-             }
 
-             $('#upload-deal-bills').click(function () {
 
-                     const file = $('#deal-bills-file')[0];
 
-                     const formData = new FormData();
 
-                     formData.append('file', file.files[0]);
 
-                     postDataWithFileProgress(self.url+'/upload-excel', formData, function (data) {
 
-                         self.data = data;
 
-                         SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
 
-                         $('#upload-deal').modal('hide');
 
-                     }, function () {
 
-                         $('#upload-deal').modal('hide');
 
-                     });
 
-                 });
 
-             if (!readOnly) {
 
-                 $.contextMenu({
 
-                     selector: selector,
 
-                     build: function ($trigger, e) {
 
-                         const target = SpreadJsObj.safeRightClickSelection($trigger, e, self.spread);
 
-                         return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
 
-                     },
 
-                     items: {
 
-                         apply: {
 
-                             name: '应用全部清单单价至台账',
 
-                             icon: 'fa-magic',
 
-                             disabled: function (key, opt) {
 
-                                 const sheet = self.spread.getActiveSheet();
 
-                                 return sheet.getRowCount() === 0;
 
-                             },
 
-                             callback: function (key, opt) {
 
-                                 const datas = [], sourceData = self.spread.getActiveSheet().zh_data;
 
-                                 for (const db of sourceData) {
 
-                                     const targets = ledgerTree.nodes.filter(function (x) {
 
-                                         return x.b_code === db.code && x.name === db.name && x.unit === db.unit;
 
-                                     });
 
-                                     for (const t of targets) {
 
-                                         if (t.children && t.children.length > 0) continue;
 
-                                         const data = ledgerTree.getNodeKeyData(t);
 
-                                         data.unit_price = db.unit_price;
 
-                                         datas.push(data);
 
-                                     }
 
-                                 }
 
-                                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
 
-                                     const refreshNode = ledgerTree.loadPostData(result);
 
-                                     treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), refreshNode);
 
-                                 });
 
-                             }
 
-                         }
 
-                     }
 
-                 });
 
-             }
 
-         }
 
-         loadData () {
 
-             const self = this;
 
-             postData(this.url+'/get-data', {}, function (data) {
 
-                 self.data = data;
 
-                 SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
 
-                 if (data.length > 0) self.spread.getActiveSheet().setSelection(0, 0, 1, 1);
 
-             });
 
-         }
 
-         calculateData () {
 
-             if (this.data) {
 
-                 for (const d of this.data) {
 
-                     d.total_price = _.multiply(d.quantity, d.unit_price);
 
-                 }
 
-             }
 
-         }
 
-     }
 
-     class BatchInsertBillsPosObj {
 
-         constructor (obj) {
 
-             const self = this;
 
-             this.obj = obj;
 
-             this.billsCount = 6;
 
-             this.posCount = 1000;
 
-             this.filter = getLocalCache('zh-calc-batch-filter');
 
-             if (!this.filter) {
 
-                 this.filter = '1';
 
-             }
 
-             $('input[name=batch-filter]')[0].checked = this.filter && this.filter != '0';
 
-             // 初始化 清单编号窗口 参数
 
-             this.qdSpreadSetting = {
 
-                 cols: [
 
-                     {title: '编号', field: 'code', hAlign: 0, width: 80, formatter: '@'},
 
-                     {title: '名称', field: 'name', hAlign: 0, width: 120, formatter: '@'},
 
-                     {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@'},
 
-                     {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
 
-                     {title: '图册号', field: 'name', hAlign: 0, width: 60, formatter: '@'},
 
-                 ],
 
-                 emptyRows: this.billsCount,
 
-                 headRows: 1,
 
-                 headRowHeight: [32],
 
-                 headerFont: '12px 微软雅黑',
 
-                 font: '12px 微软雅黑',
 
-             };
 
-             this.qdSpread = SpreadJsObj.createNewSpread($('.batch-l-t', this.obj)[0]);
 
-             // 初始化 部位数量复核表 参数
 
-             this.posSpreadSetting = {
 
-                 cols: [
 
-                     {title: '计量单元', field: 'bw', hAlign: 0, width: 80, formatter: '@'},
 
-                     {title: '图册号', field: 'drawingCode', hAlign: 0, formatter: '@', width: 60},
 
-                 ],
 
-                 emptyRows: this.posCount,
 
-                 headRows: 1,
 
-                 headRowHeight: [32],
 
-                 headerFont: '12px 微软雅黑',
 
-                 font: '12px 微软雅黑',
 
-             };
 
-             for (let iNum = 1; iNum <= this.billsCount; iNum++) {
 
-                 this.posSpreadSetting.cols.push(
 
-                     {title: '清单' + iNum, field: 'bills' + iNum, hAlign: 2, width: 50}
 
-                 )
 
-             }
 
-             this.posSpread = SpreadJsObj.createNewSpread($('.batch-l-b', this.obj)[0]);
 
-             // 初始化 签约清单 参数
 
-             this.dealSpreadSetting = {
 
-                 cols: [
 
-                     {title: '清单编号', field: 'code', width: 80, hAlign: 0, formatter: '@', readOnly: true},
 
-                     {title: '名称', field: 'name', width: 230, hAlign: 0, formatter: '@', readOnly: true},
 
-                     {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true},
 
-                     {title: '单价', field: 'unit_price', hAlign: 2, width: 60, readOnly: true},
 
-                 ],
 
-                 emptyRows: 0,
 
-                 headRows: 1,
 
-                 headRowHeight: [32],
 
-                 headerFont: '12px 微软雅黑',
 
-                 font: '12px 微软雅黑',
 
-             };
 
-             this.dealSpread = SpreadJsObj.createNewSpread($('.batch-r', this.obj)[0]);
 
-             // 初始化 清单编号、部位数量复核表 表格
 
-             this.initView();
 
-             SpreadJsObj.initSheet(this.dealSpread.getActiveSheet(), this.dealSpreadSetting);
 
-             SpreadJsObj.refreshColumnAlign(this.dealSpread.getActiveSheet());
 
-             $.contextMenu({
 
-                 selector: '.batch-l-t',
 
-                 build: function ($trigger, e) {
 
-                     const target = SpreadJsObj.safeRightClickSelection($trigger, e, self.qdSpread);
 
-                     return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
 
-                 },
 
-                 items: {
 
-                     'create': {
 
-                         name: '新增行',
 
-                         icon: 'fa-sign-in',
 
-                         callback: function (key, opt) {
 
-                             const qdSheet = self.qdSpread.getActiveSheet();
 
-                             const posSheet = self.posSpread.getActiveSheet();
 
-                             qdSheet.addRows(qdSheet.getRowCount(), 1);
 
-                             const index = qdSheet.getRowCount();
 
-                             qdSheet.getCell(qdSheet.getRowCount() - 1, 0, spreadNS.SheetArea.rowHeader).text('清单' + index);
 
-                             posSheet.addColumns(posSheet.getColumnCount(), 1);
 
-                             posSheet.getCell(0, index + 2 - 1, spreadNS.SheetArea.colHeader).text('清单' + index);
 
-                         },
 
-                     },
 
-                     'delete': {
 
-                         name: '删除行',
 
-                         icon: 'fa-remove',
 
-                         callback: function (key, opt) {
 
-                             const qdSheet = self.qdSpread.getActiveSheet();
 
-                             const posSheet = self.posSpread.getActiveSheet();
 
-                             const sel = qdSheet.getSelections()[0];
 
-                             qdSheet.deleteRows(sel.row, sel.rowCount);
 
-                             posSheet.deleteColumns(sel.row + 2, sel.rowCount);
 
-                             for (let iRow = 0, iLen = qdSheet.getRowCount(); iRow < iLen; iRow++) {
 
-                                 qdSheet.getCell(iRow, 0, spreadNS.SheetArea.rowHeader).text('清单' + (iRow+1));
 
-                             }
 
-                             for (let iCol = 0, iLen = posSheet.getColumnCount() - 2; iCol < iLen; iCol++) {
 
-                                 posSheet.getCell(0, iCol + 2, spreadNS.SheetArea.colHeader).text('清单' + (iCol+1));
 
-                             }
 
-                             qdSheet.setSelection(sel.row, sel.col, 1, 1);
 
-                         },
 
-                     },
 
-                 }
 
-             });
 
-             // 拉取签约清单数据
 
-             if (dealBills) {
 
-                 SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
 
-             } else {
 
-                 postData('/tender/' + getTenderId() + '/deal/get-data', {}, function (data) {
 
-                     SpreadJsObj.loadSheetData(self.dealSpread.getActiveSheet(), 'data', data);
 
-                 });
 
-             }
 
-             // 双击签约清单,自动添加到清单编号窗口
 
-             this.dealSpread.bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
 
-                 const deal = info.sheet.zh_data[info.row];
 
-                 const qdSheet = self.qdSpread.getActiveSheet(), posSheet = self.posSpread.getActiveSheet();
 
-                 const sel = qdSheet.getSelections()[0];
 
-                 qdSheet.getCell(sel.row, 0).value(deal.code);
 
-                 qdSheet.getCell(sel.row, 1).value(deal.name);
 
-                 qdSheet.getCell(sel.row, 2).value(deal.unit);
 
-                 qdSheet.getCell(sel.row, 3).value(deal.unit_price);
 
-                 if (sel.row + 1 === qdSheet.getRowCount()) {
 
-                     const count = sel.row + 2;
 
-                     qdSheet.setRowCount(count);
 
-                     qdSheet.getCell(sel.row + 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + count);
 
-                     const colCount = posSheet.getColumnCount() + 1
 
-                     posSheet.setColumnCount(colCount);
 
-                     posSheet.getCell(0, colCount - 1, GC.Spread.Sheets.SheetArea.colHeader).text('清单' + count);
 
-                 }
 
-                 qdSheet.setSelection(sel.row + 1, sel.col, 1, 1);
 
-             });
 
-             this.qdSpread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
 
-                 const billsCount = info.sheet.getRowCount(), posSheet = self.posSpread.getActiveSheet();
 
-                 const count = posSheet.getColumnCount() - 2;
 
-                 if (billsCount > count) {
 
-                     posSheet.setColumnCount(billsCount + 2);
 
-                     for (let i = count + 1; i <= billsCount; i++) {
 
-                         info.sheet.getCell(i - 1, 0, spreadNS.SheetArea.rowHeader).text('清单' + i);
 
-                         posSheet.getCell(0, i + 2 - 1, spreadNS.SheetArea.colHeader).text('清单' + i);
 
-                     }
 
-                 }
 
-                 if (info.cellRange.col === 0 && info.cellRange.colCount === 1) {
 
-                     const dealBills = self.dealSpread.getActiveSheet().zh_data;
 
-                     if (dealBills && dealBills.length > 0) {
 
-                         for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
 
-                             const curRow = iRow + info.cellRange.row;
 
-                             const bills = _.find(dealBills, {code: info.sheet.getText(curRow, 0)});
 
-                             if (bills) {
 
-                                 info.sheet.getCell(curRow, 1).value(bills.name);
 
-                                 info.sheet.getCell(curRow, 2).value(bills.unit);
 
-                                 info.sheet.getCell(curRow, 3).value(bills.unit_price);
 
-                             }
 
-                         }
 
-                     }
 
-                 }
 
-             });
 
-             this.qdSpread.bind(spreadNS.Events.EditEnded, function (e, info) {
 
-                 if (info.col === 0) {
 
-                     const dealBills = self.dealSpread.getActiveSheet().zh_data;
 
-                     if (dealBills && dealBills.length > 0) {
 
-                         const bills = _.find(dealBills, {code: info.editingText});
 
-                         if (bills) {
 
-                             info.sheet.getCell(info.row, 1).value(bills.name);
 
-                             info.sheet.getCell(info.row, 2).value(bills.unit);
 
-                             info.sheet.getCell(info.row, 3).value(bills.unit_price);
 
-                         }
 
-                     }
 
-                 }
 
-             });
 
-             this.obj.bind('shown.bs.modal', function () {
 
-                 self.qdSpread.refresh();
 
-                 self.posSpread.refresh();
 
-                 self.dealSpread.refresh();
 
-             });
 
-             $('#batch-ok').click(function () {
 
-                 const sheet = ledgerSpread.getActiveSheet();
 
-                 const sel = sheet.getSelections()[0];
 
-                 const row = sel.row;
 
-                 const select = ledgerTree.nodes[row];
 
-                 if (select) {
 
-                     const insertData = {};
 
-                     insertData.batchType = (select.code && select.code !== '') ? 'child' : 'next';
 
-                     insertData.id = ledgerTree.getNodeKey(select);
 
-                     insertData.batchData = self.getBatchData();
 
-                     if (insertData.batchData.length > 0) {
 
-                         postData(window.location.pathname + '/update', {postType: 'batch-insert', postData: insertData}, function (data) {
 
-                             pos.updateDatas(data.pos);
 
-                             const result = ledgerTree.loadPostData(data.ledger);
 
-                             treeOperationObj.refreshTree(sheet, result);
 
-                             sheet.setSelection(result.create[0].index, sel.col, sel.rowCount, sel.colCount);
 
-                             SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, result.create[0].index]);
 
-                             treeOperationObj.refreshOperationValid(sheet);
 
-                             self.obj.modal('hide');
 
-                         }, null, true);
 
-                     } else {
 
-                         self.obj.modal('hide');
 
-                     }
 
-                 }
 
-             });
 
-             $('input[name=batch-filter]').change(function () {
 
-                 setLocalCache('zh-calc-batch-filter', this.checked ? 1 : 0);
 
-             });
 
-         }
 
-         // 初始化左侧表格
 
-         initView () {
 
-             // 初始化 清单编号
 
-             const qdSheet = this.qdSpread.getActiveSheet();
 
-             qdSheet.setColumnWidth(0, 45, spreadNS.SheetArea.rowHeader);
 
-             SpreadJsObj.initSheet(qdSheet, this.qdSpreadSetting);
 
-             SpreadJsObj.refreshColumnAlign(qdSheet);
 
-             // 清理原有数据
 
-             SpreadJsObj.beginMassOperation(qdSheet);
 
-             qdSheet.clear(0, 0, qdSheet.getRowCount(), qdSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
 
-             for (let iRow = 1; iRow <= this.billsCount; iRow++) {
 
-                 qdSheet.getCell(iRow - 1, 0, GC.Spread.Sheets.SheetArea.rowHeader).text('清单' + iRow);
 
-             }
 
-             qdSheet.setSelection(0, 0, 1 ,1);
 
-             SpreadJsObj.endMassOperation(qdSheet);
 
-             // 初始化 部位数量复核表
 
-             const posSheet = this.posSpread.getActiveSheet();
 
-             SpreadJsObj.initSheet(posSheet, this.posSpreadSetting);
 
-             SpreadJsObj.refreshColumnAlign(posSheet);
 
-             // 清理原有数据
 
-             SpreadJsObj.beginMassOperation(posSheet);
 
-             posSheet.setColumnWidth(0, 45, GC.Spread.Sheets.SheetArea.rowHeader);
 
-             posSheet.clear(0, 0, posSheet.getRowCount(), posSheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data);
 
-             posSheet.setSelection(0, 0, 1 ,1);
 
-             SpreadJsObj.endMassOperation(posSheet);
 
-             // 检查签约清单数据,以工具栏数据为准
 
-             if (dealBills) {
 
-                 SpreadJsObj.loadSheetData(this.dealSpread.getActiveSheet(), 'data', dealBills.data);
 
-             }
 
-             this.dealSpread.getActiveSheet().setSelection(0, 0, 1, 1);
 
-         }
 
-         // 获取界面数据
 
-         getBatchData () {
 
-             const result = [];
 
-             const qdSheet = this.qdSpread.getActiveSheet(), posSheet = this.posSpread.getActiveSheet();
 
-             for (let iRow = 0; iRow < qdSheet.getRowCount(); iRow++) {
 
-                 if (qdSheet.getText(iRow, 0) === '') { continue; }
 
-                 const qd = {
 
-                     b_code: qdSheet.getText(iRow, 0),
 
-                     name: qdSheet.getText(iRow, 1),
 
-                     unit: qdSheet.getText(iRow, 2),
 
-                     price: _.toNumber(qdSheet.getText(iRow, 3)),
 
-                     pos: [],
 
-                 };
 
-                 for (let iPosRow = 0; iPosRow < posSheet.getRowCount(); iPosRow++) {
 
-                     const value = _.toNumber(posSheet.getText(iPosRow, iRow + 2));
 
-                     if (value !== 0 && !isNaN(value)) {
 
-                         qd.pos.push({
 
-                             name: posSheet.getText(iPosRow, 0),
 
-                             drawing_code: posSheet.getText(iPosRow, 1),
 
-                             quantity: value, porder: qd.pos.length + 1,
 
-                         });
 
-                     }
 
-                 }
 
-                 if (!$('input[name=batch-filter]')[0].checked || qd.pos.length > 0) result.push(qd);
 
-             }
 
-             return result;
 
-         }
 
-      }
 
-     $('#searchAccount').click(() => {
 
-         const data = {
 
-             keyword: $('#searchName').val(),
 
-         };
 
-         postData('/search/user', data, (data) => {
 
-             const resultDiv = $('#searchResult');
 
-             if (data) {
 
-                 $('h5>span', resultDiv).text(data.name);
 
-                 $('#addAuditor').attr('auditorId', data.id);
 
-                 $('h6', resultDiv).text(data.role);
 
-                 $('p', resultDiv).text(data.company);
 
-                 resultDiv.show();
 
-             } else {
 
-                 toastr.info('未查询到该审核人');
 
-                 resultDiv.hide();
 
-             }
 
-         }, () => {
 
-             $('#searchResult').hide();
 
-         });
 
-     });
 
-     // 审批人分组选择
 
-     $('#account_group').change(function () {
 
-         let account_html = '<option value="0">选择审批人</option>';
 
-         for (const account of accountList) {
 
-             if (parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) {
 
-                 const role = account.role !== '' ? '(' + account.role + ')' : '';
 
-                 const company = account.company !== '' ? ' -' + account.company : '';
 
-                 account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>';
 
-             }
 
-         }
 
-         $('#account_list').html(account_html);
 
-     });
 
-     // 添加到审批流程中
 
-     $('body').on('change', '#account_list', function () {
 
-         let id = $(this).val();
 
-         id = parseInt(id);
 
-         if (id !== 0) {
 
-             const data = {
 
-                 auditorId: $(this).val(),
 
-             };
 
-             postData('/tender/' + getTenderId() + '/ledger/audit/add', data, (data) => {
 
-                 const html = [];
 
-                 html.push('<li class="list-group-item" auditorId="' + data.audit_id + '"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
 
-                 html.push('<span>');
 
-                 html.push(data.audit_order + ' ');
 
-                 html.push(data.name + ' ');
 
-                 html.push('</span>');
 
-                 html.push('<small class="text-muted">');
 
-                 html.push(data.role);
 
-                 html.push('</small></li>');
 
-                 $('#auditors').append(html.join(''));
 
-                 // 如果是重新上报,添加到重新上报列表中
 
-                 const auditorshtml = [];
 
-                 // 重新上报时。令其它的审批人流程图标转换
 
-                 $('#auditors-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
 
-                 for (let i = 0; i < $('#auditors-list li').length; i++) {
 
-                     $('#auditors-list li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
 
-                     $('#auditors-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
 
-                 }
 
-                 // 添加新审批人
 
-                 auditorshtml.push('<li class="list-group-item" data-auditid="' + data.audit_id + '">');
 
-                 auditorshtml.push('<i class="fa fa-stop-circle"></i> ');
 
-                 auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
 
-                 auditorshtml.push('<span class="pull-right">终审</span>');
 
-                 auditorshtml.push('</li>');
 
-                 $('#auditors-list').append(auditorshtml.join(''));
 
-                 const auditorshtml2 = [];
 
-                 // 重新上报时。令其它的审批人流程图标转换
 
-                 $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
 
-                 // 添加新审批人
 
-                 auditorshtml2.push('<li class="list-group-item" data-auditid="' + data.audit_id + '">');
 
-                 auditorshtml2.push('<h5 class="card-title"><i class="fa fa-stop-circle"></i> ');
 
-                 auditorshtml2.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
 
-                 auditorshtml2.push('<span class="pull-right">终审</span>');
 
-                 auditorshtml2.push('</h5></li>');
 
-                 $('#auditors-list2').append(auditorshtml2.join(''));
 
-             });
 
-         }
 
-     });
 
-     $('body').on('click', '#auditors li>a', function () {
 
-         const li = $(this).parent();
 
-         const data = {
 
-             auditorId: parseInt(li.attr('auditorId')),
 
-         };
 
-         postData('/tender/' + getTenderId() + '/ledger/audit/delete', data, (data2) => {
 
-             li.remove();
 
-             for (const a of data2) {
 
-                 const aLi = $('li[auditorId=' + a.audit_id + ']');
 
-                 $('span', aLi).text(a.audit_order + ' ' + a.name + ' ');
 
-             }
 
-             // 如果是重新上报
 
-             // 令最后一个图标转换
 
-             $('#auditors-list li[data-auditid="' + data.auditorId + '"]').remove();
 
-             if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) {
 
-                 $('#auditors-list li').eq($('#auditors-list li').length-1).children('i')
 
-                     .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
 
-             }
 
-             $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove();
 
-             if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) {
 
-                 $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i')
 
-                     .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
 
-             }
 
-             for (let i = 0; i < $('#auditors-list li').length; i++) {
 
-                 $('#auditors-list li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i+1)) + '审')
 
-                 $('#auditors-list2 li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2 li').length ? '终' : transFormToChinese(i+1)) + '审')
 
-             }
 
-         });
 
-     });
 
-     $('#hideSp').click(function () {
 
-         $('#sp-list2').modal('hide');
 
-     });
 
-     // 多层modal关闭后的滚动bug修复
 
-     $('#sp-list2').on('hidden.bs.modal', function (e) {
 
-         $(document.body).addClass('modal-open');
 
-     });
 
-     // 显示层次
 
-     (function (select, sheet) {
 
-         $(select).click(function () {
 
-             const tag = $(this).attr('tag');
 
-             const tree = sheet.zh_tree;
 
-             if (!tree) return;
 
-             switch (tag) {
 
-                 case "1":
 
-                 case "2":
 
-                 case "3":
 
-                 case "4":
 
-                 case "5":
 
-                     tree.expandByLevel(parseInt(tag));
 
-                     SpreadJsObj.refreshTreeRowVisible(sheet);
 
-                     break;
 
-                 case "last":
 
-                     tree.expandByCustom(() => { return true; });
 
-                     SpreadJsObj.refreshTreeRowVisible(sheet);
 
-                     break;
 
-                 case "leafXmj":
 
-                     tree.expandToLeafXmj();
 
-                     SpreadJsObj.refreshTreeRowVisible(sheet);
 
-                     break;
 
-             }
 
-         });
 
-     })('a[name=showLevel]', ledgerSpread.getActiveSheet());
 
-     // $('#exportLedger').click(function () {
 
-     //     const data = [];
 
-     //     const setting = {
 
-     //         header: ['项目节编号', '清单子目号', '部位明细', '名称', '单位', '清单数量', '设计数量1', '设计数量2', '单价', '合价', '图号', '备注'],
 
-     //         width: [100, 70, 70, 300, 60, 80, 80, 80, 80, 80, 100, 100],
 
-     //         hAlign: ['left', 'left', 'left', 'left','center', 'right', 'right', 'right', 'right', 'right', 'left', 'left'],
 
-     //     };
 
-     //     for (const node of ledgerTree.nodes) {
 
-     //         data.push([node.code, node.b_code, '', node.name, node.unit,
 
-     //             node.quantity, node.dgn_qty1, node.dgn_qty2, node.unit_price, node.total_price,
 
-     //             node.drawing_code, node.memo
 
-     //         ]);
 
-     //         const posRange = pos.getLedgerPos(node.id);
 
-     //         if (posRange && posRange.length > 0) {
 
-     //             for (const [i, p] of posRange.entries()) {
 
-     //                 data.push(['', '', (i + 1) + '', p.name, '',
 
-     //                     p.quantity, '', '', '', '',
 
-     //                     p.drawing_code, p.memo
 
-     //                 ]);
 
-     //             }
 
-     //         }
 
-     //     }
 
-     //
 
-     //     XLSXObj.exportXlsxSheet(setting, data, "台账分解.xlsx");
 
-     // });
 
-     $('#exportLedger').click(function () {
 
-         const data = [];
 
-         const setting = {
 
-             cols: [
 
-                 {title: '项目节编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 100, formatter: '@'},
 
-                 {title: '清单子目号', colSpan: '1', rowSpan: '1', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
 
-                 {title: '计量单元', colSpan: '1', rowSpan: '1', field: 'pos_code', hAlign: 1, width: 70, formatter: '@'},
 
-                 {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 300, formatter: '@'},
 
-                 {title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
 
-                 {title: '清单数量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
 
-                 {title: '设计数量1', colSpan: '1', rowSpan: '1', field: 'dgn_qty1', hAlign: 2, width: 80, type: 'Number'},
 
-                 {title: '设计数量2', colSpan: '1', rowSpan: '1', field: 'dgn_qty2', hAlign: 2, width: 80, type: 'Number'},
 
-                 {title: '单价', colSpan: '1', rowSpan: '1', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
 
-                 {title: '合价', colSpan: '1', rowSpan: '1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
 
-                 {title: '图号', colSpan: '1', rowSpan: '1', field: 'drawing_code', hAlign: 0, width: 100, formatter: '@'},
 
-                 {title: '备注', colSpan: '1', rowSpan: '1', field: 'memo', hAlign: 0, width: 100, formatter: '@'},
 
-             ],
 
-             headRows: 1,
 
-             headRowHeight: [32],
 
-             defaultRowHeight: 21,
 
-             headerFont: 'bold 10px 微软雅黑',
 
-             font: '10px 微软雅黑'
 
-         };
 
-         for (const node of ledgerTree.nodes) {
 
-             data.push({
 
-                 code: node.code, b_code: node.b_code, name: node.name, unit: node.unit,
 
-                 unit_price: node.unit_price, quantity: node.quantity, total_price: node.total_price,
 
-                 dgn_qty1: node.dgn_qty1, dgn_qty2: node.dgn_qty2,
 
-                 drawing_code: node.drawing_code, memo: node.memo
 
-             });
 
-             const posRange = pos.getLedgerPos(node.id);
 
-             if (posRange && posRange.length > 0) {
 
-                 for (const [i, p] of posRange.entries()) {
 
-                     data.push({
 
-                         pos_code: (i + 1) + '', name: p.name,
 
-                         quantity: p.quantity, drawing_code: p.drawing_code, memo: p.memo
 
-                     });
 
-                 }
 
-             }
 
-         }
 
-         SpreadExcelObj.exportSimpleXlsxSheet(setting, data, "台账分解.xlsx");
 
-     });
 
-     const dataChecker = DataChecker({
 
-         checkUrl: window.location.pathname + '/check',
 
-         completeData: function (data) {
 
-             pos.updateDatas({update: data.source.pos});
 
-             const loadResult = ledgerTree.loadPostData({update: data.source.bills});
 
-             treeOperationObj.refreshTree(ledgerSpread.getActiveSheet(), loadResult);
 
-             posOperationObj.loadCurPosData();
 
-             for (const e of data.error) {
 
-                 e.serialNo = ledgerTree.getNodeIndex(ledgerTree.getItems(e.ledger_id)) + 1;
 
-             }
 
-         },
 
-         errorList: errorList,
 
-     });
 
-     $('[name=audit-start]').submit(function (e) {
 
-         if (checkAuditorFrom()) {
 
-             $(this).parent().parent().parent().modal('hide');
 
-             dataChecker.checkAndPost(this.action, {});
 
-             $('#hide-all').hide();
 
-         }
 
-         return false;
 
-     });
 
- });
 
- // 检查上报情况
 
- function checkAuditorFrom () {
 
-     if ($('#auditors li').length === 0) {
 
-         toastr.error('请先选择审批人,再上报数据');
 
-         return false;
 
-     } else {
 
-         $('#hide-all').show();
 
-         return true;
 
-     }
 
- }
 
 
  |