phase_pay_detail.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  1. 'use strict';
  2. const showSideTools = function (show) {
  3. const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
  4. if (show) {
  5. right.show();
  6. autoFlashHeight();
  7. /**
  8. * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
  9. * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
  10. * 故需要通过最终的parent.width再计算一次left.width
  11. *
  12. * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
  13. * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
  14. *
  15. */
  16. //left.css('width', parent.width() - right.outerWidth());
  17. //left.css('width', parent.width() - right.outerWidth());
  18. const percent = 100 - right.outerWidth() /parent.width() * 100;
  19. left.css('width', percent + '%');
  20. } else {
  21. left.width(parent.width());
  22. right.hide();
  23. }
  24. };
  25. $(document).ready(() => {
  26. autoFlashHeight();
  27. const payUtils = {
  28. tips: {
  29. name: function(data) {
  30. const tips = [];
  31. if (data) {
  32. if (data.pause) tips.push('当前项已停用');
  33. if (!data.is_yf) tips.push('当前项不参与本期应付计算');
  34. }
  35. return tips.join('<br/>');
  36. },
  37. range_tp: function (data) {
  38. if (!data || (!data.range_expr && !data.range_tp) || !data.dl_type) return '';
  39. if (data.dl_type === 1) {
  40. return '计提期限为(当 计量期数 ≥ ' + data.dl_count + ')';
  41. } else if (data.dl_type === 2) {
  42. switch (data.dl_tp_type) {
  43. case 'contract':
  44. return '计提期限为(累计合同计量 ≥ ' + data.dl_tp + ')';
  45. case 'qc':
  46. return '计提期限为(累计变更计量 ≥ ' + data.dl_tp + ')';
  47. case 'gather':
  48. return '计提期限为(累计完成计量 ≥ ' + data.dl_tp + ')';
  49. }
  50. }
  51. }
  52. },
  53. check: {
  54. isFixed: function(data) {
  55. return data.is_fixed;
  56. },
  57. isStarted: function (data) {
  58. return data.pre_used;
  59. },
  60. isYf: function(data) {
  61. return data.pay_type === 'bqyf';
  62. },
  63. isSf: function(data) {
  64. return data.pay_type === 'bqsf';
  65. },
  66. isGatherValid: function(data) {
  67. return !data.pay_type && (!data.children || data.children.length === 0);
  68. },
  69. isOwner: function(data) {
  70. return data.create_user_id === userID;
  71. },
  72. isFinish: function(data) {
  73. return data.pre_finish;
  74. },
  75. isYB: function() {
  76. return userID === phasePay.create_user_id;
  77. },
  78. isOld: function(data) {
  79. return data.phase_id !== data.create_phase_id;
  80. },
  81. isLock: function (data) {
  82. const result = !!lockPayExpr && payUtils.check.isStarted(data) && payCalc.hasBase(data.expr);
  83. return result;
  84. },
  85. tpReadOnly: function(data) {
  86. return payUtils.check.isYf(data) || (data.children && data.children.length > 0) || payUtils.check.isLock(data);
  87. },
  88. startTpReadOnly: function(data) {
  89. if (payUtils.check.isOld(data)) {
  90. return payUtils.check.isStarted(data) || !payUtils.check.isYB(data) || payUtils.check.isLock(data);
  91. } else {
  92. return payUtils.check.isSf(data) || payUtils.check.isYf(data) || !(payUtils.check.isOwner(data) || payUtils.check.isYB());
  93. }
  94. },
  95. rangeTpReadOnly: function(data) {
  96. if (payUtils.check.isOld(data)) {
  97. return !payUtils.check.isYB(data) || payUtils.check.isLock(data);
  98. } else {
  99. return payUtils.check.isYf(data) || !(payUtils.check.isOwner(data) || payUtils.check.isYB());
  100. }
  101. },
  102. },
  103. menuVisible: {
  104. pause: function (data) {
  105. if (payUtils.check.isOld(data)) {
  106. return payUtils.check.isYB();
  107. } else {
  108. return payUtils.check.isOwner(data) || payUtils.check.isYB();
  109. }
  110. },
  111. deadline: function (data) {
  112. if (payUtils.check.isOld(data)) {
  113. return !payUtils.check.isFinish(data) && payUtils.check.isYB();
  114. } else {
  115. return payUtils.check.isOwner(data) || payUtils.check.isYB();
  116. }
  117. }
  118. },
  119. };
  120. const payCalc = (function (b, a) {
  121. class PayCalc {
  122. constructor (bases, add) {
  123. this.percentReg = /((\d+)|((\d+)(\.\d+)))%/g;
  124. this.bases = bases;
  125. this.bases.sort(function (a, b) {
  126. return a.sort - b.sort;
  127. });
  128. for (const b of this.bases) {
  129. b.reg = new RegExp(b.code, 'igm');
  130. }
  131. this.addBase = add;
  132. this.orderReg = /f\d+/ig;
  133. this.nodeReg = /<<[a-z0-9\-]+>>/ig;
  134. this.firstNodeReg = /^<<[a-z0-9\-]+>>/ig;
  135. }
  136. hasBase(expr) {
  137. if (!expr) return false;
  138. for (const b of this.bases) {
  139. if (data.expr.indexOf(b.code) >= 0) return true;
  140. }
  141. return false;
  142. }
  143. trans2OrderExpr(expr, payTree) {
  144. const nodeParam = expr.match(this.nodeReg);
  145. if (nodeParam) {
  146. for (const op of nodeParam) {
  147. const id = op.substring(2, op.length - 2);
  148. const payNode = payTree.nodes.find(x => { return x.uuid === id; });
  149. expr = expr.replace(op, payNode ? `f${payTree.getNodeIndex(payNode) + 1}` || '' : 0);
  150. }
  151. }
  152. return expr;
  153. }
  154. trans2NodeExpr(expr, payTree) {
  155. const orderParam = expr.match(this.orderReg);
  156. if (orderParam) {
  157. for (const op of orderParam) {
  158. const order = parseInt(op.substring(1, op.length));
  159. const payNode = payTree.nodes[order - 1];
  160. expr = expr.replace(op, payNode ? `<<${payNode.uuid}>>` || '' : 0);
  161. }
  162. }
  163. return expr;
  164. }
  165. checkExprValid(expr, invalidParam, selfId, payTree) {
  166. if (!expr) return [true, ''];
  167. const param = [];
  168. let num = '', base = '';
  169. let fixedIdParam;
  170. for (let i = 0, iLen = expr.length; i < iLen; i++) {
  171. const subExpr = expr.substring(i, expr.length);
  172. if (/^[\d\.%]+/.test(expr[i])) {
  173. if (base !== '') {
  174. param.push({type: 'base', value: base});
  175. base = '';
  176. }
  177. num = num + expr[i];
  178. } else if (this.firstNodeReg.test(subExpr)) {
  179. if (num !== '') {
  180. param.push({type: 'num', value: num});
  181. num = '';
  182. }
  183. if (base !== '') {
  184. param.push({type: 'base', value: base});
  185. base = '';
  186. }
  187. // const node = this.nodeReg.exec(subExpr);
  188. const node = subExpr.match(this.firstNodeReg);
  189. param.push({type: 'node', value: node[0]});
  190. i = i + node[0].length - 1;
  191. } else if (/^[a-z]/.test(expr[i])) {
  192. if (num !== '') {
  193. param.push({type: 'num', value: num});
  194. num = '';
  195. }
  196. base = base + expr[i];
  197. } else if (expr[i] === '(') {
  198. if (num !== '') {
  199. param.push({type: 'num', value: num});
  200. num = '';
  201. }
  202. if (base !== '') {
  203. param.push({type: 'base', value: base});
  204. base = '';
  205. }
  206. param.push({type: 'left', value: '('});
  207. } else if (expr[i] === ')') {
  208. if (num !== '') {
  209. param.push({type: 'num', value: num});
  210. num = '';
  211. }
  212. if (base !== '') {
  213. param.push({type: 'base', value: base});
  214. base = '';
  215. }
  216. param.push({type: 'right', value: ')'});
  217. } else if (/^[\+\-*\/]/.test(expr[i])) {
  218. if (num !== '') {
  219. param.push({type: 'num', value: num});
  220. num = '';
  221. }
  222. if (base !== '') {
  223. param.push({type: 'base', value: base});
  224. base = '';
  225. }
  226. param.push({type: 'calc', value: expr[i]});
  227. } else {
  228. return [false, '输入的表达式含有非法字符: ' + expr[i]];
  229. }
  230. }
  231. if (num !== '') {
  232. param.push({type: 'num', value: num});
  233. num = '';
  234. }
  235. if (base !== '') {
  236. param.push({type: 'base', value: base});
  237. base = '';
  238. }
  239. if (param.length === 0) return [true, ''];
  240. if (param.length > 1) {
  241. if (param[0].value === '-' && param[1].type === 'num') {
  242. param[1].value = '-' + param[1].value;
  243. param.shift();
  244. }
  245. }
  246. const iLen = param.length;
  247. let iLeftCount = 0, iRightCount = 0;
  248. for (const [i, p] of param.entries()) {
  249. if (p.type === 'calc') {
  250. if (i === 0 || i === iLen - 1)
  251. return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字或计算基数'];
  252. }
  253. if (p.type === 'num') {
  254. num = p.value.replace('%', '');
  255. if (p.value.length - num.length > 1)
  256. return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
  257. num = _.toNumber(num);
  258. if (num === undefined || num === null || _.isNaN(num))
  259. return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
  260. if (i > 0) {
  261. if (param[i - 1].type !== 'calc' && param[i - 1].type !== 'left') {
  262. return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
  263. } else if (param[i - 1].value === '/' && num === 0) {
  264. return [false, '输入的表达式非法:请勿除0'];
  265. }
  266. }
  267. }
  268. if (p.type === 'base') {
  269. const baseParam = _.find(calcBase, {code: p.value});
  270. if (!baseParam)
  271. return [false, '输入的表达式非法:不存在计算基数' + p.value];
  272. if (invalidParam && invalidParam.indexOf(p.value) >= 0)
  273. return [false, '不可使用计算基数' + p.value];
  274. if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
  275. return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
  276. }
  277. if (p.type === 'node') {
  278. if (!selfId) return [false, '输入的表达式错误:不支持行号引用'];
  279. if ([`<<${selfId}>>`].indexOf(p.value) >= 0) return [false, '输入的表达式非法:请勿引用自己'];
  280. if (!fixedIdParam) {
  281. fixedIdParam = payTree.nodes.filter(x => { return x.is_fixed; }).map(x => { return `<<${x.uuid}>>`});
  282. }
  283. if (fixedIdParam.indexOf(p.value) >= 0) return [false, '输入的表达式非法:请勿引用固定项'];
  284. }
  285. if (p.type === 'left') {
  286. iLeftCount += 1;
  287. if (i !== 0 && (param[i-1].type !== 'calc' || param[i-1].type !== 'left'))
  288. return [false, '输入的表达式非法:(前应有运算符'];
  289. }
  290. if (p.type === 'right') {
  291. iRightCount += 1;
  292. if (i !== iLen - 1 && param[i+1].type !== 'calc')
  293. return [false, '输入的表达式非法:)后应有运算符'];
  294. if (iRightCount > iLeftCount)
  295. return [false, '输入的表达式非法:")"前无对应的"("'];
  296. }
  297. }
  298. if (iLeftCount > iRightCount)
  299. return [false, '输入的表达式非法:"("后无对应的")"'];
  300. if (selfId) {
  301. const circular = payCalc.checkCircularExpr(expr, selfId, payTree);
  302. // 当前循环计算不检查父项
  303. if (circular) return [false, '输入的表达式非法:循环引用'];
  304. }
  305. return [true, ''];
  306. }
  307. checkSfExpr(text, data, payNode, payTree) {
  308. if (text) {
  309. const num = _.toNumber(text);
  310. if (num) {
  311. data.expr = num;
  312. } else {
  313. const expr = this.trans2NodeExpr($.trim(text).replace('\t', '').replace('=', '').toLowerCase(), payTree);
  314. const [valid, msg] = this.checkExprValid(expr, [], payNode.uuid, payTree);
  315. if (!valid) return [valid, msg];
  316. data.expr = expr;
  317. }
  318. } else {
  319. data.tp = 0;
  320. data.expr = '';
  321. }
  322. return [true, ''];
  323. }
  324. checkExpr(text, data, payNode, payTree) {
  325. if (text) {
  326. const num = _.toNumber(text);
  327. if (num) {
  328. data.tp = num;
  329. data.expr = '';
  330. } else {
  331. const expr = this.trans2NodeExpr($.trim(text).replace('\t', '').replace('=', '').toLowerCase(), payTree);
  332. const [valid, msg] = this.checkExprValid(expr, ['bqyf'], payNode.uuid, payTree);
  333. if (!valid) return [valid, msg];
  334. data.expr = expr;
  335. data.tp = 0;
  336. }
  337. } else {
  338. data.tp = 0;
  339. data.expr = '';
  340. }
  341. return [true, ''];
  342. }
  343. checkRangeExpr(payNode, text, data) {
  344. if (!payNode) return [false, '数据错误'];
  345. const num = text ? _.toNumber(text) || 0 : 0;
  346. let expr = text ? (num ? '' : text) : '';
  347. expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
  348. const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
  349. if (!valid) return [valid, msg];
  350. if (payUtils.check.isStarted(payNode)) {
  351. if (payUtils.check.isSf(payNode)) {
  352. const value = expr ? payCalc.calculateExpr(expr) : num;
  353. if (payNode.pre_tp && value < payNode.pre_tp) return [false, '截止上期已计量' + payNode.pre_tp + ',扣款限额请勿少于改值'];
  354. data.range_tp = num;
  355. data.range_expr = expr;
  356. return [true, ''];
  357. } else {
  358. // if (payNode.pre_finish) return [false, '已达扣款限额,请勿修改'];
  359. // const value = expr ? payCalc.calculateExpr(expr) : num;
  360. // if (payNode.pre_tp && value < payNode.pre_tp) return [false, '截止上期已计量' + payNode.pre_tp + ',扣款限额请勿少于改值'];
  361. // data.range_tp = num;
  362. // data.range_expr = expr;
  363. return [false, '已经开始使用,请勿修改扣款限额'];
  364. }
  365. } else {
  366. data.range_tp = num;
  367. data.range_expr = expr;
  368. return [true, ''];
  369. }
  370. }
  371. checkStartExpr(payNode, text, data) {
  372. if (!payNode) return [false, '数据错误'];
  373. const num = text ? _.toNumber(text) || 0 : 0;
  374. let expr = text ? (num ? '' : text) : '';
  375. expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
  376. const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
  377. if (!valid) return [valid, msg];
  378. if (payUtils.check.isStarted(payNode)) {
  379. return [false, '已经开始计量,请勿修改起扣金额'];
  380. } else {
  381. if (this.addBase.pre_gather_tp) {
  382. const value = expr ? payCalc.calculateExpr(expr) : num;
  383. if (this.addBase.pre_gather_tp && value < this.addBase.pre_gather_tp)
  384. return [false, '起扣金额请勿少于本期完成截止上期计量金额' + this.addBase.pre_gather_tp];
  385. data.start_tp = num;
  386. data.start_expr = expr;
  387. return [true, ''];
  388. } else {
  389. data.start_tp = num;
  390. data.start_expr = expr;
  391. return [true, ''];
  392. }
  393. }
  394. }
  395. getExprInfo(field, converse = false) {
  396. const exprField = [
  397. {qty: 'tp', expr: 'expr'},
  398. {qty: 'start_tp', expr: 'start_expr'},
  399. {qty: 'range_qty', expr: 'range_expr'},
  400. ];
  401. if (converse) return _.find(exprField, { expr: field });
  402. return _.find(exprField, {qty: field});
  403. }
  404. getLeafOrder(data, parentReg, tree) {
  405. if (!data) return [];
  406. const defaultResult = data.uuid ? [`<<${data.uuid}>>`] : [];
  407. if (!data.expr) return defaultResult;
  408. const nodeParam = data.expr.match(this.nodeReg);
  409. if (!nodeParam || nodeParam.length === 0) return defaultResult;
  410. const result = [];
  411. for (const op of nodeParam) {
  412. const id = op.substring(2, op.length - 2);
  413. if (data.uuid === id || op === parentReg) {
  414. result.push(op);
  415. } else {
  416. const payNode = tree.nodes.find(x => {return x.uuid === id; });
  417. const subOrderParam = this.getLeafOrder(payNode, data.uuid ? `<<${data.uuid}>>` : parentReg, tree);
  418. result.push(...subOrderParam);
  419. }
  420. }
  421. return result;
  422. }
  423. checkCircularExpr(expr, selfId, tree) {
  424. const leafOrder = this.getLeafOrder({expr}, `<<${selfId}>>`, tree);
  425. if (leafOrder.indexOf(`<<${selfId}>>`) >= 0) return true;
  426. return false;
  427. }
  428. calculateExpr(expr) {
  429. let formula = expr;
  430. for (const b of this.bases) {
  431. formula = formula.replace(b.reg, b.value);
  432. }
  433. const percent = formula.match(this.percentReg);
  434. if (percent) {
  435. for (const p of percent) {
  436. const v = math.evaluate(p.replace(new RegExp('%', 'gm'), '/100'));
  437. formula = formula.replace(p, v);
  438. }
  439. }
  440. try {
  441. const value = ZhCalc.mathCalcExpr(formula);
  442. return value;
  443. } catch(err) {
  444. return 0;
  445. }
  446. }
  447. refreshBaseHtml() {
  448. const html = [];
  449. for (const [i, b] of this.bases.entries()) {
  450. html.push('<tr>');
  451. html.push(`<td>${i+1}</td><td>${b.name}</td><td>${b.code}</td>`);
  452. if (b.code === 'bqyf') {
  453. html.push('<td class="text-right">--</td>');
  454. } else {
  455. html.push(`<td class="text-right">${b.formatValue}</td>`);
  456. }
  457. html.push('</tr>');
  458. }
  459. $('#base-list').html(html.join(''));
  460. }
  461. reloadBase(bases, add) {
  462. this.bases = bases;
  463. this.refreshBaseHtml();
  464. this.bases.sort(function (a, b) {
  465. return a.sort - b.sort;
  466. });
  467. for (const b of this.bases) {
  468. b.reg = new RegExp(b.code, 'igm');
  469. }
  470. this.addBase = add;
  471. }
  472. }
  473. return new PayCalc(b, a);
  474. })(calcBase, addBase);
  475. const payObj = (function() {
  476. const spread = SpreadJsObj.createNewSpread($('#pay-spread')[0]);
  477. const sheet = spread.getActiveSheet();
  478. const spreadSetting = {
  479. cols: [
  480. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', cellType: 'tree', getTip: payUtils.tips.name},
  481. {title: '本期金额(F)', colSpan: '1', rowSpan: '1', field: 'tp', hAlign: 2, width: 100, type: 'Number'},
  482. {title: '截止上期金额', colSpan: '1', rowSpan: '1', field: 'pre_tp', hAlign: 2, width: 100, readOnly: true, type: 'Number'},
  483. {title: '截止本期金额', colSpan: '1', rowSpan: '1', field: 'end_tp', hAlign: 2, width: 100, readOnly: true, type: 'Number'},
  484. {title: '起扣金额', colSpan: '1', rowSpan: '1', field: 'start_tp', hAlign: 2, width: 100, type: 'Number'},
  485. {title: '付(扣)款限额', colSpan: '1', rowSpan: '1', field: 'range_tp', hAlign: 2, width: 100, cellType: 'tip', type: 'Number', getTip: payUtils.tips.range_tp},
  486. {title: '汇总', colSpan: '1', rowSpan: '1', field: 'is_gather', hAlign: 1, width: 60, cellType: 'signalCheckbox', show: payUtils.check.isGatherValid},
  487. {title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 120, formatter: '@', cellType: 'autoTip'},
  488. ],
  489. emptyRows: 0,
  490. headRows: 1,
  491. headRowHeight: [32],
  492. headColWidth: [30],
  493. defaultRowHeight: 21,
  494. headerFont: '12px 微软雅黑',
  495. font: '12px 微软雅黑',
  496. readOnly: readOnly,
  497. localCache: {
  498. key: 'phase-pay',
  499. colWidth: true,
  500. },
  501. pos: SpreadJsObj.getObjPos($('#pay-spread')[0]),
  502. getColor: function (sheet, data, row, col, defaultColor) {
  503. if (!data) return defaultColor;
  504. if (data.expr && data.expr.indexOf('#ref!') >= 0) {
  505. return spreadColor.pay.expr_err;
  506. } else if (data.is_pause) {
  507. return '#f2f2f2';
  508. } else if (data.create_phase_order > 1 && data.create_phase_order === phasePay.phase_order) {
  509. return '#FFFFE1';
  510. } else {
  511. return defaultColor;
  512. }
  513. }
  514. };
  515. sjsSettingObj.setFxTreeStyle(spreadSetting, sjsSettingObj.FxTreeStyle.phasePay);
  516. SpreadJsObj.initSheet(sheet, spreadSetting);
  517. const payTree = createNewPathTree('base', {
  518. id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
  519. level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
  520. rootId: -1,
  521. });
  522. const payEvent = {
  523. refreshActn: function() {
  524. const setObjEnable = function (obj, enable) {
  525. if (enable) {
  526. obj.removeClass('disabled');
  527. } else {
  528. obj.addClass('disabled');
  529. }
  530. };
  531. const select = SpreadJsObj.getSelectObject(sheet);
  532. if (!select) {
  533. setObjEnable($('a[name=base-opr][type=add]'), false);
  534. setObjEnable($('a[name=base-opr][type=del]'), false);
  535. setObjEnable($('a[name=base-opr][type=up-move]'), false);
  536. setObjEnable($('a[name=base-opr][type=down-move]'), false);
  537. return;
  538. }
  539. const preNode = payTree.getPreSiblingNode(select);
  540. setObjEnable($('a[name=base-opr][type=add]'), !readOnly && !payUtils.check.isSf(select) && !payUtils.check.isYf(select));
  541. const delValid = !payUtils.check.isFixed(select) && !payUtils.check.isStarted(select) && payUtils.check.isOwner(select);
  542. setObjEnable($('a[name=base-opr][type=delete]'), !readOnly && delValid);
  543. setObjEnable($('a[name=base-opr][type=up-move]'), !readOnly && !payUtils.check.isFixed(select) && preNode);
  544. setObjEnable($('a[name=base-opr][type=down-move]'), !readOnly && !payUtils.check.isFixed(select) && !payTree.isLastSibling(select));
  545. },
  546. loadExprToInput: function() {
  547. const sel = sheet.getSelections()[0];
  548. const col = sheet.zh_setting.cols[sel.col];
  549. const data = SpreadJsObj.getSelectObject(sheet);
  550. if (data && (!data.children || data.children.length === 0)) {
  551. if (col.field === 'tp') {
  552. const expr = payCalc.trans2OrderExpr(data.expr, payTree);
  553. $('#pay-expr').val(expr).attr('field', 'expr').attr('org', expr)
  554. .attr('readOnly', readOnly|| payUtils.check.tpReadOnly(data));
  555. } else if (col.field === 'start_tp') {
  556. const expr = payCalc.trans2OrderExpr(data.start_expr, payTree) || data.start_tp;
  557. $('#pay-expr').val(expr).attr('field', 'start_expr').attr('org', expr)
  558. .attr('readOnly', readOnly|| payUtils.check.startTpReadOnly(data) || payUtils.check.isYf(data));
  559. } else if (col.field === 'range_tp') {
  560. const expr = payCalc.trans2OrderExpr(data.range_expr, payTree);
  561. $('#pay-expr').val(expr).attr('field', 'range_expr').attr('org', expr)
  562. .attr('readOnly', readOnly|| payUtils.check.rangeTpReadOnly(data) || payUtils.check.isYf(data));
  563. } else {
  564. $('#pay-expr').val('').attr('readOnly', true);
  565. }
  566. $('#pay-expr').attr('data-row', sel.row);
  567. } else {
  568. $('#pay-expr').val('').attr('readOnly', true);
  569. $('#pay-expr').removeAttr('data-row');
  570. }
  571. },
  572. refreshTree: function (data) {
  573. SpreadJsObj.massOperationSheet(sheet, function () {
  574. const tree = sheet.zh_tree;
  575. // 处理删除
  576. if (data.delete) {
  577. data.delete.sort(function (a, b) {
  578. return b.deleteIndex - a.deleteIndex;
  579. });
  580. for (const d of data.delete) {
  581. sheet.deleteRows(d.deleteIndex, 1);
  582. }
  583. }
  584. // 处理新增
  585. if (data.create) {
  586. const newNodes = data.create;
  587. if (newNodes) {
  588. newNodes.sort(function (a, b) {
  589. return a.index - b.index;
  590. });
  591. for (const node of newNodes) {
  592. sheet.addRows(node.index, 1);
  593. SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
  594. }
  595. }
  596. }
  597. // 处理更新
  598. if (data.update) {
  599. const rows = [];
  600. for (const u of data.update) {
  601. rows.push(tree.nodes.indexOf(u));
  602. }
  603. SpreadJsObj.reLoadRowsData(sheet, rows);
  604. }
  605. });
  606. },
  607. editStarting: function(e, info) {
  608. const col = info.sheet.zh_setting.cols[info.col];
  609. const select = SpreadJsObj.getSelectObject(info.sheet);
  610. switch (col.field) {
  611. case 'name':
  612. info.cancel = payUtils.check.isFixed(select);
  613. break;
  614. case 'tp':
  615. info.cancel = payUtils.check.tpReadOnly(select);
  616. break;
  617. case 'is_gather':
  618. info.cancel = !payUtils.check.isGatherValid(select);
  619. break;
  620. case 'start_tp':
  621. info.cancel = payUtils.check.startTpReadOnly(select);
  622. break;
  623. case 'range_tp':
  624. info.cancel = payUtils.check.rangeTpReadOnly(select);
  625. break;
  626. case 'is_gather':
  627. info.cancel = true;
  628. break;
  629. }
  630. if (col.field === 'tp') {
  631. if (select.expr && select.expr !== '') {
  632. info.sheet.getCell(info.row, info.col).text(payCalc.trans2OrderExpr(select.expr, payTree));
  633. }
  634. } else if (col.field === 'start_tp') {
  635. if (select.start_expr && select.start_expr !== '') {
  636. info.sheet.getCell(info.row, info.col).text(select.start_expr);
  637. }
  638. } else if (col.field === 'range_tp') {
  639. if (select.range_expr && select.range_expr !== '') {
  640. info.sheet.getCell(info.row, info.col).text(select.range_expr);
  641. }
  642. }
  643. },
  644. editEnded: function(e, info) {
  645. if (!info.sheet.zh_setting) return;
  646. const select = SpreadJsObj.getSelectObject(info.sheet);
  647. const col = info.sheet.zh_setting.cols[info.col];
  648. if (col.field === 'is_gather') return;
  649. // 未改变值则不提交
  650. const validText = info.editingText ? info.editingText.replace('\n', '') : '';
  651. let orgValue;
  652. if (col.field === 'tp') {
  653. orgValue = select.expr ? payCalc.trans2OrderExpr(select.expr, payTree) : select.tp;
  654. } else if (col.field === 'start_tp') {
  655. orgValue = select.start_expr ? select.start_expr : select.start_tp;
  656. } else if (col.field === 'range_tp') {
  657. orgValue = select.range_expr ? select.range_expr : select.range_tp;
  658. } else {
  659. orgValue = select[col.field];
  660. }
  661. orgValue = orgValue || '';
  662. if (orgValue == validText) {
  663. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  664. return;
  665. }
  666. const data = { postType: 'update', postData: { id: select.id } };
  667. switch(col.field) {
  668. case 'tp':
  669. const [tpValid, tpMsg] = payUtils.check.isSf(select)
  670. ? payCalc.checkSfExpr(validText, data.postData, select, payTree)
  671. : payCalc.checkExpr(validText, data.postData, select, payTree);
  672. if (!tpValid) {
  673. toastr.warning(tpMsg);
  674. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  675. return;
  676. }
  677. break;
  678. case 'start_tp':
  679. const [sValid, sMsg] = payCalc.checkStartExpr(select, validText, data.postData);
  680. if (!sValid) {
  681. toastr.warning(sMsg);
  682. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  683. return;
  684. }
  685. break;
  686. case 'range_tp':
  687. const [rValid, rMsg] = payCalc.checkRangeExpr(select, validText, data.postData);
  688. if (!rValid) {
  689. toastr.warning(rMsg);
  690. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  691. return;
  692. }
  693. break;
  694. default:
  695. if (col.type === 'Number') {
  696. data.postData[col.field] = _.toNumber(validText) || 0;
  697. } else {
  698. data.postData[col.field] = validText || '';
  699. }
  700. break;
  701. }
  702. postData('update', data, function (result) {
  703. if (result.reload) {
  704. payEvent.reloadPays(result.reload);
  705. } else {
  706. const refreshData = payTree.loadPostData(result);
  707. payEvent.refreshTree(refreshData);
  708. }
  709. }, function () {
  710. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  711. });
  712. },
  713. selectionChanged: function(e, info) {
  714. if (info.newSelections) {
  715. if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row) {
  716. payEvent.refreshActn();
  717. payFile.getCurAttHtml(SpreadJsObj.getSelectObject(info.sheet))
  718. }
  719. }
  720. payEvent.loadExprToInput();
  721. },
  722. buttonClicked: function (e, info) {
  723. if (!info.sheet.zh_setting) return;
  724. const select = SpreadJsObj.getSelectObject(info.sheet);
  725. const col = info.sheet.zh_setting.cols[info.col];
  726. if (col.field !== 'is_gather') return;
  727. if (!payUtils.check.isGatherValid(select)) return;
  728. if (info.sheet.isEditing()) info.sheet.endEdit(true);
  729. const data = {
  730. postType: 'update',
  731. postData: { id: select.id },
  732. };
  733. data.postData[col.field] = info.sheet.getValue(info.row, info.col) || 0;
  734. // 更新至服务器
  735. postData('update', data, function (result) {
  736. if (result.reload) payEvent.reloadPays(result.reload);
  737. });
  738. },
  739. deletePress: function (sheet) {
  740. if (!sheet.zh_setting) return;
  741. const sel = sheet.getSelections()[0];
  742. if (!sel) return;
  743. const col = sheet.zh_setting.cols[sel.col];
  744. if (col.readOnly === true) return;
  745. if (sel.colCount > 1) toastr.warning('请勿同时删除多列数据');
  746. const data = { postType: 'update', postData: [] };
  747. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow ++) {
  748. const node = sheet.zh_tree.nodes[iRow];
  749. if (node && (!node.pay_type || col.field === 'postil')) {
  750. const updateData = { id: node.id };
  751. switch(col.field) {
  752. case 'tp':
  753. updateData.tp = 0;
  754. updateData.expr = '';
  755. break;
  756. case 'start_tp':
  757. updateData.start_tp = 0;
  758. updateData.start_expr = '';
  759. break;
  760. case 'range_tp':
  761. updateData.range_tp = 0;
  762. updateData.range_expr = '';
  763. break;
  764. case 'is_gather':
  765. updateData.is_gather = 0;
  766. break;
  767. default:
  768. updateData[col.field] = col.type === 'Number' ? 0 : '';
  769. }
  770. data.postData.push(updateData);
  771. }
  772. }
  773. postData('update', data, function (result) {
  774. if (result.reload) {
  775. payEvent.reloadPays(result.reload);
  776. } else {
  777. const refreshData = payTree.loadPostData(result);
  778. payEvent.refreshTree(refreshData);
  779. }
  780. }, function () {
  781. SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
  782. });
  783. },
  784. baseOpr: function(type) {
  785. const self = this;
  786. const node = SpreadJsObj.getSelectObject(sheet);
  787. if (type === 'delete') {
  788. postData('update', { postType: 'delete', postData: { id: node.tree_id }}, function(result) {
  789. payEvent.reloadPays(result.reload);
  790. });
  791. } else {
  792. postData('update', { postType: type, postData: { id: node.tree_id }}, function (result) {
  793. const refreshData = payTree.loadPostData(result);
  794. payEvent.refreshTree(refreshData);
  795. const sel = sheet.getSelections()[0];
  796. if (sel) {
  797. if (['up-move', 'down-move'].indexOf(type) > -1) {
  798. sheet.setSelection(payTree.getNodeIndex(node), sel.col, sel.rowCount, sel.colCount);
  799. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, payTree.getNodeIndex(node)]);
  800. } else if (type === 'add') {
  801. sheet.setSelection(payTree.getNodeIndex(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  802. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, payTree.getNodeIndex(refreshData.create[0])]);
  803. }
  804. }
  805. self.refreshActn(sheet);
  806. });
  807. }
  808. },
  809. calculateAll: function() {
  810. postData('update', { postType: 'calc', postData: {}}, function (result) {
  811. payEvent.reloadPays(result.reload);
  812. });
  813. },
  814. reloadCalcBase: function() {
  815. postData('update', { postType: 'refreshBase', postData: {}}, function (result) {
  816. payEvent.reloadPays(result.reload);
  817. payCalc.reloadBase(result.calcBase, result.addBase);
  818. });
  819. },
  820. reloadPays: function(datas){
  821. payTree.loadDatas(datas);
  822. SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Tree, payTree);
  823. payEvent.refreshActn();
  824. },
  825. };
  826. spread.bind(spreadNS.Events.SelectionChanged, payEvent.selectionChanged);
  827. if (!readOnly) {
  828. spread.bind(spreadNS.Events.EditStarting, payEvent.editStarting);
  829. spread.bind(spreadNS.Events.EditEnded, payEvent.editEnded);
  830. spread.bind(spreadNS.Events.ButtonClicked, payEvent.buttonClicked);
  831. SpreadJsObj.addDeleteBind(spread, payEvent.deletePress);
  832. $('a[name="base-opr"]').click(function () {
  833. payEvent.baseOpr(this.getAttribute('type'));
  834. });
  835. $('#pay-expr').bind('change onblur', function () {
  836. if (this.readOnly) return;
  837. const expr = $(this);
  838. const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
  839. const select = payTree.nodes[row];
  840. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
  841. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  842. const data = { postType: 'update' };
  843. if (field === 'expr') {
  844. data.postData = { id: select.id, tp: 0, expr: newValue };
  845. const [valid, msg] = payUtils.check.isSf(select)
  846. ? payCalc.checkSfExpr(newValue, data.postData, select, payTree)
  847. : payCalc.checkExpr(newValue, data.postData, select, payTree);
  848. if (!valid) {
  849. toastr.warning(msg);
  850. this.value = select.expr;
  851. return;
  852. }
  853. } else if (field === 'start_expr') {
  854. data.updateData = {id: select.id};
  855. const [valid, msg] = payCalc.checkStartExpr(select, newValue, data.postData);
  856. if (!valid) {
  857. toastr.warning(msg);
  858. this.value = select.start_expr;
  859. return;
  860. }
  861. } else if (field === 'range_expr') {
  862. data.updateData = {id: select.id};
  863. const [valid, msg] = payCalc.checkRangeExpr(select, newValue, data.postData);
  864. if (!valid) {
  865. toastr.warning(msg);
  866. this.value = select.range_expr;
  867. return;
  868. }
  869. } else {
  870. expr.val('');
  871. return;
  872. }
  873. // 更新至服务器
  874. postData('update', data, function (result) {
  875. if (result.reload) {
  876. payEvent.reloadPays(result.reload);
  877. } else {
  878. const refreshData = payTree.loadPostData(result);
  879. payEvent.refreshTree(refreshData);
  880. }
  881. });
  882. });
  883. $('#calc-all').click(function() {
  884. payEvent.calculateAll();
  885. });
  886. $('#reload-calc-base').click(function() {
  887. payEvent.reloadCalcBase();
  888. });
  889. const deadlineObj = {
  890. payNode: null,
  891. refreshHint: function() {
  892. const dlType = $('[name=dl-type]:checked').val();
  893. const dt = deadlineType[dlType];
  894. if (dlType && dt) {
  895. const dlValue = $('#dl-value').val();
  896. $('#range-hint').text(`当 ${dt.name} >= ${dlValue} 时 `);
  897. $('#dl-hint').show();
  898. } else {
  899. $('#dl-hint').hide();
  900. }
  901. },
  902. initView: function(data) {
  903. this.payNode = data;
  904. $('#dl-pay-name').html(data.name);
  905. // 模式
  906. if (data.dl_type) {
  907. $('[name=dl-type][value=' + data.dl_type +']')[0].checked = true;
  908. } else {
  909. $('#dl-type-none')[0].checked = true;
  910. }
  911. $('#dl-value').val(data.dl_value);
  912. this.refreshHint();
  913. },
  914. getDlCount: function() {
  915. try {
  916. const result = parseInt($('#dl-value').val());
  917. if (result <= 0) throw '限制值请输入正整数';
  918. return result;
  919. } catch (err) {
  920. toastr.warning('限制值请输入正整数');
  921. return 0;
  922. }
  923. },
  924. getDlTp: function() {
  925. try {
  926. const result = parseFloat($('#dl-value').val());
  927. return result;
  928. } catch (err) {
  929. toastr.warning('限制值请输入数值');
  930. return 0;
  931. }
  932. },
  933. getUpdateData: function() {
  934. const result = { postType: 'update', postData: { id: this.payNode.id } };
  935. result.postData.dl_type = $('[name=dl-type]:checked').val();
  936. if (result.postData.dl_type) {
  937. if (result.postData.dl_type === deadlineType.phaseCount.key) {
  938. result.postData.dl_value = this.getDlCount();
  939. if (result.postData.dl_value < phasePay.phase_order) {
  940. toastr.warning(`已计量至第${phasePay.phase_order}期,计提期限不可小于该期`);
  941. return null;
  942. }
  943. } else if (result.postData.dl_type === deadlineType.stageCount.key) {
  944. result.postData.dl_value = this.getDlCount();
  945. if (result.postData.dl_value < maxStageOrder) {
  946. toastr.warning(`已计量至第${maxStageOrder}期,计提期限不可小于该期`);
  947. return null;
  948. }
  949. } else {
  950. result.postData.dl_value = this.getDlTp();
  951. const dt = deadlineType[result.postData.dl_type];
  952. if (!dt) {
  953. toastr.warning('限制模式错误,请刷新页面重试');
  954. return null;
  955. }
  956. const compareValue = payCalc.addBase[`pre_${dt.key}_tp`];
  957. if (result.postData.dl_type < compareValue) {
  958. toastr.warning(`截止上期,${dt.name}已计量${compareValue},计提期限不可小于该值`);
  959. return null;
  960. }
  961. }
  962. } else {
  963. result.postData.dl_value = 0;
  964. }
  965. return result;
  966. },
  967. };
  968. $('[name=dl-type]').change(deadlineObj.refreshHint);
  969. $('#dl-value').change(deadlineObj.refreshHint);
  970. $('#deadline-ok').click(function() {
  971. const updateData = deadlineObj.getUpdateData();
  972. if (!updateData) return;
  973. postData('update', updateData, function(result) {
  974. payEvent.reloadPays(result.reload);
  975. $('#deadline').modal('hide');
  976. });
  977. });
  978. // 右键菜单
  979. $.contextMenu({
  980. selector: '#pay-spread',
  981. build: function ($trigger, e) {
  982. const target = SpreadJsObj.safeRightClickSelection($trigger, e, spread);
  983. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  984. },
  985. items: {
  986. 'start': {
  987. name: '启用',
  988. icon: 'fa-play',
  989. callback: function (key, opt) {
  990. const select = SpreadJsObj.getSelectObject(sheet);
  991. const data = {
  992. postType: 'update',
  993. postData: { id: select.id, is_pause: 0 }
  994. };
  995. // 更新至服务器
  996. postData('update', data, function (result) {
  997. payEvent.reloadPays(result.reload);
  998. });
  999. },
  1000. visible: function (key, opt) {
  1001. const select = SpreadJsObj.getSelectObject(sheet);
  1002. return (!select.children || select.children.length ===0) && !readOnly && select.is_pause && payUtils.menuVisible.pause(select);
  1003. }
  1004. },
  1005. 'stop': {
  1006. name: '停用',
  1007. icon: 'fa-pause',
  1008. callback: function (key, opt) {
  1009. const select = SpreadJsObj.getSelectObject(sheet);
  1010. const data = {
  1011. postType: 'update',
  1012. postData: { id: select.id, is_pause: 1 }
  1013. };
  1014. // 更新至服务器
  1015. postData('update', data, function (result) {
  1016. payEvent.reloadPays(result.reload);
  1017. });
  1018. },
  1019. visible: function (key, opt) {
  1020. const select = SpreadJsObj.getSelectObject(sheet);
  1021. return (!select.children || select.children.length === 0) && !readOnly && !select.is_pause && payUtils.menuVisible.pause(select);
  1022. },
  1023. },
  1024. 'setDeadline': {
  1025. name: '设置计提期限',
  1026. icon: 'fa-clipboard',
  1027. callback: function (key, opt) {
  1028. const select = SpreadJsObj.getSelectObject(sheet);
  1029. if (select.range_tp) {
  1030. deadlineObj.initView(select);
  1031. $('#deadline').modal('show');
  1032. } else {
  1033. toastr.warning('计提期限用于达到条件时,即刻计量至付(扣)款限额,应先设置付(扣)款限额');
  1034. }
  1035. },
  1036. visible: function (key, opt) {
  1037. const select = SpreadJsObj.getSelectObject(sheet);
  1038. return (!select.children || select.children.length === 0) && !readOnly && payUtils.menuVisible.deadline(select);
  1039. }
  1040. },
  1041. }
  1042. });
  1043. }
  1044. return { spread, sheet, payTree, loadDatas: payEvent.reloadPays }
  1045. })();
  1046. payObj.loadDatas(details);
  1047. const payFile = $.ledger_att({
  1048. selector: '#fujian',
  1049. key: 'uuid',
  1050. masterKey: 'rela_id',
  1051. uploadUrl: 'file/upload',
  1052. deleteUrl: 'file/delete',
  1053. checked: false,
  1054. zipName: `附件.zip`,
  1055. readOnly: false,
  1056. fileIdType: 'string',
  1057. fileInfo: {
  1058. user_name: 'user_name',
  1059. user_id: 'user_id',
  1060. create_time: 'create_time',
  1061. },
  1062. getCurHint: function(node) {
  1063. return`${node.name || ''}`;
  1064. },
  1065. locate: function (att) {
  1066. if (!att) return;
  1067. SpreadJsObj.locateTreeNode(payObj.sheet, att.node.tree_id, true);
  1068. payFile.getCurAttHtml(att.node);
  1069. }
  1070. });
  1071. // 展开收起标准清单
  1072. $('a', '#side-menu').bind('click', function (e) {
  1073. e.preventDefault();
  1074. const tab = $(this), tabPanel = $(tab.attr('content'));
  1075. // 展开工具栏、切换标签
  1076. if (!tab.hasClass('active')) {
  1077. // const close = $('.active', '#side-menu').length === 0;
  1078. $('a', '#side-menu').removeClass('active');
  1079. $('.tab-content .tab-select-show.tab-pane.active').removeClass('active');
  1080. tab.addClass('active');
  1081. tabPanel.addClass('active');
  1082. // $('.tab-content .tab-pane').removeClass('active');
  1083. showSideTools(tab.hasClass('active'));
  1084. } else { // 收起工具栏
  1085. tab.removeClass('active');
  1086. tabPanel.removeClass('active');
  1087. showSideTools(tab.hasClass('active'));
  1088. }
  1089. payObj.spread.refresh();
  1090. });
  1091. postData('load', {filter: 'file'}, function(result) {
  1092. for (const f of result.file) {
  1093. f.node = payObj.payTree.datas.find(x => { return x.uuid === f.rela_id; });
  1094. }
  1095. payFile.loadDatas(result.file);
  1096. payFile.getCurAttHtml(SpreadJsObj.getSelectObject(payObj.sheet));
  1097. });
  1098. // 工具栏spr
  1099. $.divResizer({
  1100. select: '#right-spr',
  1101. callback: function () {
  1102. payObj.spread.refresh();
  1103. }
  1104. });
  1105. // todo 加载审批列表
  1106. $.subMenu({
  1107. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  1108. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  1109. key: 'menu.1.0.0',
  1110. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  1111. callback: function (info) {
  1112. if (info.mini) {
  1113. $('.panel-title').addClass('fluid');
  1114. $('#sub-menu').removeClass('panel-sidebar');
  1115. } else {
  1116. $('.panel-title').removeClass('fluid');
  1117. $('#sub-menu').addClass('panel-sidebar');
  1118. }
  1119. autoFlashHeight();
  1120. payObj.spread.refresh();
  1121. }
  1122. });
  1123. });