phase_pay_detail.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  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) || 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.isWC(data) || 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.isWC(data) || 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. if (i !== 0 && param[i-1].type !== 'calc')
  289. return [false, '输入的表达式非法:(前应有运算符'];
  290. }
  291. if (p.type === 'right') {
  292. iRightCount += 1;
  293. if (i !== iLen - 1 && param[i+1].type !== 'calc')
  294. return [false, '输入的表达式非法:)后应有运算符'];
  295. if (iRightCount > iLeftCount)
  296. return [false, '输入的表达式非法:")"前无对应的"("'];
  297. }
  298. }
  299. if (iLeftCount > iRightCount)
  300. return [false, '输入的表达式非法:"("后无对应的")"'];
  301. if (selfId) {
  302. const circular = payCalc.checkCircularExpr(expr, selfId, payTree);
  303. // 当前循环计算不检查父项
  304. if (circular) return [false, '输入的表达式非法:循环引用'];
  305. }
  306. return [true, ''];
  307. }
  308. checkSfExpr(text, data, payNode, payTree) {
  309. if (text) {
  310. const num = _.toNumber(text);
  311. if (num) {
  312. data.expr = num;
  313. } else {
  314. const expr = this.trans2NodeExpr($.trim(text).replace('\t', '').replace('=', '').toLowerCase(), payTree);
  315. const [valid, msg] = this.checkExprValid(expr, [], payNode.uuid, payTree);
  316. if (!valid) return [valid, msg];
  317. data.expr = expr;
  318. }
  319. } else {
  320. data.tp = 0;
  321. data.expr = '';
  322. }
  323. return [true, ''];
  324. }
  325. checkExpr(text, data, payNode, payTree) {
  326. if (text) {
  327. const num = _.toNumber(text);
  328. if (num) {
  329. data.tp = num;
  330. data.expr = '';
  331. } else {
  332. const expr = this.trans2NodeExpr($.trim(text).replace('\t', '').replace('=', '').toLowerCase(), payTree);
  333. const [valid, msg] = this.checkExprValid(expr, ['bqyf'], payNode.uuid, payTree);
  334. if (!valid) return [valid, msg];
  335. data.expr = expr;
  336. data.tp = 0;
  337. }
  338. } else {
  339. data.tp = 0;
  340. data.expr = '';
  341. }
  342. return [true, ''];
  343. }
  344. checkRangeExpr(payNode, text, data) {
  345. if (!payNode) return [false, '数据错误'];
  346. const num = text ? _.toNumber(text) : 0;
  347. let expr = text ? (num ? '' : text) : '';
  348. expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
  349. const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
  350. if (!valid) return [valid, msg];
  351. if (payUtils.check.isStarted(payNode)) {
  352. if (payUtils.check.isSf(payNode)) {
  353. const value = expr ? payCalc.calculateExpr(expr) : num;
  354. if (payNode.pre_tp && value < payNode.pre_tp) return [false, '截止上期已计量' + payNode.pre_tp + ',扣款限额请勿少于改值'];
  355. data.range_tp = num;
  356. data.range_expr = expr;
  357. return [true, ''];
  358. } else {
  359. // if (payNode.pre_finish) return [false, '已达扣款限额,请勿修改'];
  360. // const value = expr ? payCalc.calculateExpr(expr) : num;
  361. // if (payNode.pre_tp && value < payNode.pre_tp) return [false, '截止上期已计量' + payNode.pre_tp + ',扣款限额请勿少于改值'];
  362. // data.range_tp = num;
  363. // data.range_expr = expr;
  364. return [false, '已经开始使用,请勿修改扣款限额'];
  365. }
  366. } else {
  367. data.range_tp = num;
  368. data.range_expr = expr;
  369. return [true, ''];
  370. }
  371. }
  372. checkStartExpr(payNode, text, data) {
  373. if (!payNode) return [false, '数据错误'];
  374. const num = text ? _.toNumber(text) : 0;
  375. let expr = text ? (num ? '' : text) : '';
  376. expr = expr ? $.trim(expr).replace('\t', '').replace('=', '').toLowerCase() : '';
  377. const [valid, msg] = this.checkExprValid(expr, ['bqwc', 'ybbqwc', 'bqht', 'bqbg', 'bqyf']);
  378. if (!valid) return [valid, msg];
  379. if (payUtils.check.isStarted(payNode)) {
  380. return [false, '已经开始计量,请勿修改起扣金额'];
  381. } else {
  382. if (this.addBase.pre_gather_tp) {
  383. const value = expr ? payCalc.calculateExpr(expr) : num;
  384. if (this.addBase.pre_gather_tp && value < this.addBase.pre_gather_tp)
  385. return [false, '起扣金额请勿少于本期完成截止上期计量金额' + this.addBase.pre_gather_tp];
  386. data.start_tp = num;
  387. data.start_expr = expr;
  388. return [true, ''];
  389. } else {
  390. data.start_tp = num;
  391. data.start_expr = expr;
  392. return [true, ''];
  393. }
  394. }
  395. }
  396. getExprInfo(field, converse = false) {
  397. const exprField = [
  398. {qty: 'tp', expr: 'expr'},
  399. {qty: 'start_tp', expr: 'start_expr'},
  400. {qty: 'range_qty', expr: 'range_expr'},
  401. ];
  402. if (converse) return _.find(exprField, { expr: field });
  403. return _.find(exprField, {qty: field});
  404. }
  405. getLeafOrder(data, parentReg, tree) {
  406. if (!data) return [];
  407. const defaultResult = data.uuid ? [`<<${data.uuid}>>`] : [];
  408. if (!data.expr) return defaultResult;
  409. const nodeParam = data.expr.match(this.nodeReg);
  410. if (!nodeParam || nodeParam.length === 0) return defaultResult;
  411. const result = [];
  412. for (const op of nodeParam) {
  413. const id = op.substring(2, op.length - 2);
  414. if (data.uuid === id || op === parentReg) {
  415. result.push(op);
  416. } else {
  417. const payNode = tree.nodes.find(x => {return x.uuid === id; });
  418. const subOrderParam = this.getLeafOrder(payNode, data.uuid ? `<<${data.uuid}>>` : parentReg, tree);
  419. result.push(...subOrderParam);
  420. }
  421. }
  422. return result;
  423. }
  424. checkCircularExpr(expr, selfId, tree) {
  425. const leafOrder = this.getLeafOrder({expr}, `<<${selfId}>>`, tree);
  426. if (leafOrder.indexOf(`<<${selfId}>>`) >= 0) return true;
  427. return false;
  428. }
  429. calculateExpr(expr) {
  430. let formula = expr;
  431. for (const b of this.bases) {
  432. formula = formula.replace(b.reg, b.value);
  433. }
  434. const percent = formula.match(this.percentReg);
  435. if (percent) {
  436. for (const p of percent) {
  437. const v = math.evaluate(p.replace(new RegExp('%', 'gm'), '/100'));
  438. formula = formula.replace(p, v);
  439. }
  440. }
  441. try {
  442. const value = ZhCalc.mathCalcExpr(formula);
  443. return value;
  444. } catch(err) {
  445. return 0;
  446. }
  447. }
  448. refreshBaseHtml() {
  449. const html = [];
  450. for (const [i, b] of this.bases.entries()) {
  451. html.push('<tr>');
  452. html.push(`<td>${i+1}</td><td>${b.name}</td><td>${b.code}</td>`);
  453. if (b.code === 'bqyf') {
  454. html.push('<td class="text-right">--</td>');
  455. } else {
  456. html.push(`<td class="text-right">${b.formatValue}</td>`);
  457. }
  458. html.push('</tr>');
  459. }
  460. $('#base-list').html(html.join(''));
  461. }
  462. reloadBase(bases, add) {
  463. this.bases = bases;
  464. this.refreshBaseHtml();
  465. this.bases.sort(function (a, b) {
  466. return a.sort - b.sort;
  467. });
  468. for (const b of this.bases) {
  469. b.reg = new RegExp(b.code, 'igm');
  470. }
  471. this.addBase = add;
  472. }
  473. }
  474. return new PayCalc(b, a);
  475. })(calcBase, addBase);
  476. const payObj = (function() {
  477. const spread = SpreadJsObj.createNewSpread($('#pay-spread')[0]);
  478. const sheet = spread.getActiveSheet();
  479. const spreadSetting = {
  480. cols: [
  481. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', cellType: 'tree', getTip: payUtils.tips.name},
  482. {title: '本期金额(F)', colSpan: '1', rowSpan: '1', field: 'tp', hAlign: 2, width: 100, type: 'Number'},
  483. {title: '截止上期金额', colSpan: '1', rowSpan: '1', field: 'pre_tp', hAlign: 2, width: 100, readOnly: true, type: 'Number'},
  484. {title: '截止本期金额', colSpan: '1', rowSpan: '1', field: 'end_tp', hAlign: 2, width: 100, readOnly: true, type: 'Number'},
  485. {title: '起扣金额', colSpan: '1', rowSpan: '1', field: 'start_tp', hAlign: 2, width: 100, type: 'Number'},
  486. {title: '付(扣)款限额', colSpan: '1', rowSpan: '1', field: 'range_tp', hAlign: 2, width: 100, cellType: 'tip', type: 'Number', getTip: payUtils.tips.range_tp},
  487. {title: '汇总', colSpan: '1', rowSpan: '1', field: 'is_gather', hAlign: 1, width: 60, cellType: 'signalCheckbox', show: payUtils.check.isGatherValid},
  488. {title: '本期批注', colSpan: '1', rowSpan: '1', field: 'postil', hAlign: 0, width: 120, formatter: '@', cellType: 'autoTip'},
  489. ],
  490. emptyRows: 0,
  491. headRows: 1,
  492. headRowHeight: [32],
  493. headColWidth: [30],
  494. defaultRowHeight: 21,
  495. headerFont: '12px 微软雅黑',
  496. font: '12px 微软雅黑',
  497. readOnly: readOnly,
  498. localCache: {
  499. key: 'phase-pay',
  500. colWidth: true,
  501. },
  502. pos: SpreadJsObj.getObjPos($('#pay-spread')[0]),
  503. getColor: function (sheet, data, row, col, defaultColor) {
  504. if (!data) return defaultColor;
  505. if (data.expr && data.expr.indexOf('#ref!') >= 0) {
  506. return spreadColor.pay.expr_err;
  507. } else if (data.is_pause) {
  508. return '#f2f2f2';
  509. } else if (data.create_phase_order > 1 && data.create_phase_order === phasePay.phase_order) {
  510. return '#FFFFE1';
  511. } else {
  512. return defaultColor;
  513. }
  514. }
  515. };
  516. sjsSettingObj.setFxTreeStyle(spreadSetting, sjsSettingObj.FxTreeStyle.phasePay);
  517. SpreadJsObj.initSheet(sheet, spreadSetting);
  518. const payTree = createNewPathTree('base', {
  519. id: 'tree_id', pid: 'tree_pid', order: 'tree_order',
  520. level: 'tree_level', isLeaf: 'tree_is_leaf', fullPath: 'tree_full_path',
  521. rootId: -1,
  522. });
  523. const payEvent = {
  524. refreshActn: function() {
  525. const setObjEnable = function (obj, enable) {
  526. if (enable) {
  527. obj.removeClass('disabled');
  528. } else {
  529. obj.addClass('disabled');
  530. }
  531. };
  532. const select = SpreadJsObj.getSelectObject(sheet);
  533. if (!select) {
  534. setObjEnable($('a[name=base-opr][type=add]'), false);
  535. setObjEnable($('a[name=base-opr][type=del]'), false);
  536. setObjEnable($('a[name=base-opr][type=up-move]'), false);
  537. setObjEnable($('a[name=base-opr][type=down-move]'), false);
  538. return;
  539. }
  540. const preNode = payTree.getPreSiblingNode(select);
  541. setObjEnable($('a[name=base-opr][type=add]'), !readOnly && !payUtils.check.isSf(select) && !payUtils.check.isYf(select));
  542. const delValid = !payUtils.check.isFixed(select) && !payUtils.check.isStarted(select);
  543. setObjEnable($('a[name=base-opr][type=delete]'), !readOnly && delValid);
  544. setObjEnable($('a[name=base-opr][type=up-move]'), !readOnly && !payUtils.check.isFixed(select) && preNode);
  545. setObjEnable($('a[name=base-opr][type=down-move]'), !readOnly && !payUtils.check.isFixed(select) && !payTree.isLastSibling(select));
  546. },
  547. loadExprToInput: function() {
  548. const sel = sheet.getSelections()[0];
  549. const col = sheet.zh_setting.cols[sel.col];
  550. const data = SpreadJsObj.getSelectObject(sheet);
  551. if (data && (!data.children || data.children.length === 0)) {
  552. if (col.field === 'tp') {
  553. const expr = payCalc.trans2OrderExpr(data.expr, payTree);
  554. $('#pay-expr').val(expr).attr('field', 'expr').attr('org', expr)
  555. .attr('readOnly', readOnly|| payUtils.check.tpReadOnly(data));
  556. } else if (col.field === 'start_tp') {
  557. const expr = payCalc.trans2OrderExpr(data.start_expr, payTree) || data.start_tp;
  558. $('#pay-expr').val(expr).attr('field', 'start_expr').attr('org', expr)
  559. .attr('readOnly', readOnly|| payUtils.check.startTpReadOnly(data) || payUtils.check.isYf(data));
  560. } else if (col.field === 'range_tp') {
  561. const expr = payCalc.trans2OrderExpr(data.range_expr, payTree);
  562. $('#pay-expr').val(expr).attr('field', 'range_expr').attr('org', expr)
  563. .attr('readOnly', readOnly|| payUtils.check.rangeTpReadOnly(data) || payUtils.check.isYf(data));
  564. } else {
  565. $('#pay-expr').val('').attr('readOnly', true);
  566. }
  567. $('#pay-expr').attr('data-row', sel.row);
  568. } else {
  569. $('#pay-expr').val('').attr('readOnly', true);
  570. $('#pay-expr').removeAttr('data-row');
  571. }
  572. },
  573. refreshTree: function (data) {
  574. SpreadJsObj.massOperationSheet(sheet, function () {
  575. const tree = sheet.zh_tree;
  576. // 处理删除
  577. if (data.delete) {
  578. data.delete.sort(function (a, b) {
  579. return b.deleteIndex - a.deleteIndex;
  580. });
  581. for (const d of data.delete) {
  582. sheet.deleteRows(d.deleteIndex, 1);
  583. }
  584. }
  585. // 处理新增
  586. if (data.create) {
  587. const newNodes = data.create;
  588. if (newNodes) {
  589. newNodes.sort(function (a, b) {
  590. return a.index - b.index;
  591. });
  592. for (const node of newNodes) {
  593. sheet.addRows(node.index, 1);
  594. SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
  595. }
  596. }
  597. }
  598. // 处理更新
  599. if (data.update) {
  600. const rows = [];
  601. for (const u of data.update) {
  602. rows.push(tree.nodes.indexOf(u));
  603. }
  604. SpreadJsObj.reLoadRowsData(sheet, rows);
  605. }
  606. });
  607. },
  608. editStarting: function(e, info) {
  609. const col = info.sheet.zh_setting.cols[info.col];
  610. const select = SpreadJsObj.getSelectObject(info.sheet);
  611. switch (col.field) {
  612. case 'name':
  613. info.cancel = payUtils.check.isFixed(select);
  614. break;
  615. case 'tp':
  616. case 'is_gather':
  617. info.cancel = !payUtils.check.isGatherValid(select);
  618. break;
  619. case 'start_tp':
  620. case 'range_tp':
  621. info.cancel = (select.children && select.children.length > 0) || payUtils.check.isYf(select);
  622. break;
  623. case 'is_gather':
  624. info.cancel = true;
  625. break;
  626. }
  627. if (col.field === 'tp') {
  628. if (select.expr && select.expr !== '') {
  629. info.sheet.getCell(info.row, info.col).text(payCalc.trans2OrderExpr(select.expr, payTree));
  630. }
  631. } else if (col.field === 'start_tp') {
  632. if (select.start_expr && select.start_expr !== '') {
  633. info.sheet.getCell(info.row, info.col).text(select.start_expr);
  634. }
  635. } else if (col.field === 'range_tp') {
  636. if (select.range_expr && select.range_expr !== '') {
  637. info.sheet.getCell(info.row, info.col).text(select.range_expr);
  638. }
  639. }
  640. },
  641. editEnded: function(e, info) {
  642. if (!info.sheet.zh_setting) return;
  643. const select = SpreadJsObj.getSelectObject(info.sheet);
  644. const col = info.sheet.zh_setting.cols[info.col];
  645. if (col.field === 'is_gather') return;
  646. // 未改变值则不提交
  647. const validText = info.editingText ? info.editingText.replace('\n', '') : '';
  648. let orgValue;
  649. if (col.field === 'tp') {
  650. orgValue = select.expr ? payCalc.trans2OrderExpr(select.expr, payTree) : select.tp;
  651. } else if (col.field === 'start_tp') {
  652. orgValue = select.start_expr ? select.start_expr : select.start_tp;
  653. } else if (col.field === 'range_tp') {
  654. orgValue = select.range_expr ? select.range_expr : select.range_tp;
  655. } else {
  656. orgValue = select[col.field];
  657. }
  658. orgValue = orgValue || '';
  659. if (orgValue == validText) {
  660. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  661. return;
  662. }
  663. const data = { postType: 'update', postData: { id: select.id } };
  664. switch(col.field) {
  665. case 'tp':
  666. const [tpValid, tpMsg] = payUtils.check.isSf(select)
  667. ? payCalc.checkSfExpr(validText, data.postData, select, payTree)
  668. : payCalc.checkExpr(validText, data.postData, select, payTree);
  669. if (!tpValid) {
  670. toastr.warning(tpMsg);
  671. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  672. return;
  673. }
  674. break;
  675. case 'start_tp':
  676. const [sValid, sMsg] = payCalc.checkStartExpr(select, validText, data.postData);
  677. if (!sValid) {
  678. toastr.warning(sMsg);
  679. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  680. return;
  681. }
  682. break;
  683. case 'range_tp':
  684. const [rValid, rMsg] = payCalc.checkRangeExpr(select, validText, data.postData);
  685. if (!rValid) {
  686. toastr.warning(rMsg);
  687. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  688. return;
  689. }
  690. break;
  691. default:
  692. if (col.type === 'Number') {
  693. data.postData[col.field] = _.toNumber(validText) || 0;
  694. } else {
  695. data.postData[col.field] = validText || '';
  696. }
  697. break;
  698. }
  699. postData('update', data, function (result) {
  700. if (result.reload) {
  701. payEvent.reloadPays(result.reload);
  702. } else {
  703. const refreshData = payTree.loadPostData(result);
  704. payEvent.refreshTree(refreshData);
  705. }
  706. }, function () {
  707. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  708. });
  709. },
  710. selectionChanged: function(e, info) {
  711. if (info.newSelections) {
  712. if (!info.oldSelections || info.newSelections[0].row !== info.oldSelections[0].row) {
  713. payEvent.refreshActn();
  714. }
  715. }
  716. payEvent.loadExprToInput();
  717. },
  718. buttonClicked: function (e, info) {
  719. if (!info.sheet.zh_setting) return;
  720. const select = SpreadJsObj.getSelectObject(info.sheet);
  721. const col = info.sheet.zh_setting.cols[info.col];
  722. if (col.field !== 'is_gather') return;
  723. if (!payUtils.check.isGatherValid(select)) return;
  724. if (info.sheet.isEditing()) info.sheet.endEdit(true);
  725. const data = {
  726. postType: 'update',
  727. postData: { id: select.id },
  728. };
  729. data.postData[col.field] = info.sheet.getValue(info.row, info.col) || 0;
  730. // 更新至服务器
  731. postData('update', data, function (result) {
  732. if (result.reload) payEvent.reloadPays(result.reload);
  733. });
  734. },
  735. deletePress: function (sheet) {
  736. if (!sheet.zh_setting) return;
  737. const sel = sheet.getSelections()[0];
  738. if (!sel) return;
  739. const col = sheet.zh_setting.cols[sel.col];
  740. if (col.readOnly === true) return;
  741. if (sel.colCount > 1) toastr.warning('请勿同时删除多列数据');
  742. const data = { postType: 'update', postData: [] };
  743. for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow ++) {
  744. const node = sheet.zh_tree.nodes[iRow];
  745. if (node && (!node.pay_type || col.field === 'postil')) {
  746. const updateData = { id: node.id };
  747. switch(col.field) {
  748. case 'tp':
  749. updateData.tp = 0;
  750. updateData.expr = '';
  751. break;
  752. case 'start_tp':
  753. updateData.start_tp = 0;
  754. updateData.start_expr = '';
  755. break;
  756. case 'range_tp':
  757. updateData.range_tp = 0;
  758. updateData.range_expr = '';
  759. break;
  760. case 'is_gather':
  761. updateData.is_gather = 0;
  762. break;
  763. default:
  764. updateData[col.field] = col.type === 'Number' ? 0 : '';
  765. }
  766. data.postData.push(updateData);
  767. }
  768. }
  769. postData('update', data, function (result) {
  770. if (result.reload) {
  771. payEvent.reloadPays(result.reload);
  772. } else {
  773. const refreshData = payTree.loadPostData(result);
  774. payEvent.refreshTree(refreshData);
  775. }
  776. }, function () {
  777. SpreadJsObj.reLoadRowData(sheet, sel.row, sel.rowCount);
  778. });
  779. },
  780. baseOpr: function(type) {
  781. const self = this;
  782. const node = SpreadJsObj.getSelectObject(sheet);
  783. if (type === 'delete') {
  784. postData('update', { postType: 'delete', postData: { id: node.tree_id }}, function(result) {
  785. payEvent.reloadPays(result.reload);
  786. });
  787. } else {
  788. postData('update', { postType: type, postData: { id: node.tree_id }}, function (result) {
  789. const refreshData = payTree.loadPostData(result);
  790. payEvent.refreshTree(refreshData);
  791. const sel = sheet.getSelections()[0];
  792. if (sel) {
  793. if (['up-move', 'down-move'].indexOf(type) > -1) {
  794. sheet.setSelection(payTree.getNodeIndex(node), sel.col, sel.rowCount, sel.colCount);
  795. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, payTree.getNodeIndex(node)]);
  796. } else if (type === 'add') {
  797. sheet.setSelection(payTree.getNodeIndex(refreshData.create[0]), sel.col, sel.rowCount, sel.colCount);
  798. SpreadJsObj.reloadRowsBackColor(sheet, [sel.row, payTree.getNodeIndex(refreshData.create[0])]);
  799. }
  800. }
  801. self.refreshActn(sheet);
  802. });
  803. }
  804. },
  805. calculateAll: function() {
  806. postData('update', { postType: 'calc', postData: {}}, function (result) {
  807. payEvent.reloadPays(result.reload);
  808. });
  809. },
  810. reloadCalcBase: function() {
  811. postData('update', { postType: 'refreshBase', postData: {}}, function (result) {
  812. payEvent.reloadPays(result.reload);
  813. payCalc.reloadBase(result.calcBase, result.addBase);
  814. });
  815. },
  816. reloadPays: function(datas){
  817. payTree.loadDatas(datas);
  818. SpreadJsObj.loadSheetData(sheet, SpreadJsObj.DataType.Tree, payTree);
  819. payEvent.refreshActn();
  820. },
  821. };
  822. spread.bind(spreadNS.Events.SelectionChanged, payEvent.selectionChanged);
  823. if (!readOnly) {
  824. spread.bind(spreadNS.Events.EditStarting, payEvent.editStarting);
  825. spread.bind(spreadNS.Events.EditEnded, payEvent.editEnded);
  826. spread.bind(spreadNS.Events.ButtonClicked, payEvent.buttonClicked);
  827. SpreadJsObj.addDeleteBind(spread, payEvent.deletePress);
  828. $('a[name="base-opr"]').click(function () {
  829. payEvent.baseOpr(this.getAttribute('type'));
  830. });
  831. $('#pay-expr').bind('change onblur', function () {
  832. if (this.readOnly) return;
  833. const expr = $(this);
  834. const row = expr.attr('data-row') ? _.toInteger(expr.attr('data-row')) : -1;
  835. const select = payTree.nodes[row];
  836. const field = expr.attr('field'), orgValue = expr.attr('org'), newValue = expr.val();
  837. if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
  838. const data = { postType: 'update' };
  839. if (field === 'expr') {
  840. data.postData = { id: select.id, tp: 0, expr: newValue };
  841. const [valid, msg] = payUtils.check.isSf(select)
  842. ? payCalc.checkSfExpr(newValue, data.postData, select, payTree)
  843. : payCalc.checkExpr(newValue, data.postData, select, payTree);
  844. if (!valid) {
  845. toastr.warning(msg);
  846. this.value = select.expr;
  847. return;
  848. }
  849. } else if (field === 'start_expr') {
  850. data.updateData = {id: select.id};
  851. const [valid, msg] = payCalc.checkStartExpr(select, newValue, data.postData);
  852. if (!valid) {
  853. toastr.warning(msg);
  854. this.value = select.start_expr;
  855. return;
  856. }
  857. } else if (field === 'range_expr') {
  858. data.updateData = {id: select.id};
  859. const [valid, msg] = payCalc.checkRangeExpr(select, newValue, data.postData);
  860. if (!valid) {
  861. toastr.warning(msg);
  862. this.value = select.range_expr;
  863. return;
  864. }
  865. } else {
  866. expr.val('');
  867. return;
  868. }
  869. // 更新至服务器
  870. postData('update', data, function (result) {
  871. if (result.reload) {
  872. payEvent.reloadPays(result.reload);
  873. } else {
  874. const refreshData = payTree.loadPostData(result);
  875. payEvent.refreshTree(refreshData);
  876. }
  877. });
  878. });
  879. $('#calc-all').click(function() {
  880. payEvent.calculateAll();
  881. });
  882. $('#reload-calc-base').click(function() {
  883. payEvent.reloadCalcBase();
  884. });
  885. const deadlineObj = {
  886. payNode: null,
  887. refreshHint: function() {
  888. const dlType = $('[name=dl-type]:checked').val();
  889. const dt = deadlineType[dlType];
  890. if (dlType && dt) {
  891. const dlValue = $('#dl-value').val();
  892. $('#range-hint').text(`当 ${dt.name} >= ${dlValue} 时 `);
  893. $('#dl-hint').show();
  894. } else {
  895. $('#dl-hint').hide();
  896. }
  897. },
  898. initView: function(data) {
  899. this.payNode = data;
  900. $('#dl-pay-name').html(data.name);
  901. // 模式
  902. if (data.dl_type) {
  903. $('[name=dl-type][value=' + data.dl_type +']')[0].checked = true;
  904. } else {
  905. $('#dl-type-none')[0].checked = true;
  906. }
  907. $('#dl-value').val(data.dl_value);
  908. this.refreshHint();
  909. },
  910. getDlCount: function() {
  911. try {
  912. const result = parseInt($('#dl-value').val());
  913. if (result <= 0) throw '限制值请输入正整数';
  914. return result;
  915. } catch (err) {
  916. toastr.warning('限制值请输入正整数');
  917. return 0;
  918. }
  919. },
  920. getDlTp: function() {
  921. try {
  922. const result = parseFloat($('#dl-value').val());
  923. return result;
  924. } catch (err) {
  925. toastr.warning('限制值请输入数值');
  926. return 0;
  927. }
  928. },
  929. getUpdateData: function() {
  930. const result = { postType: 'update', postData: { id: this.payNode.id } };
  931. result.postData.dl_type = $('[name=dl-type]:checked').val();
  932. if (result.postData.dl_type) {
  933. if (result.postData.dl_type === deadlineType.phaseCount.key) {
  934. result.postData.dl_value = this.getDlCount();
  935. if (result.postData.dl_value < phasePay.phase_order) {
  936. toastr.warning(`已计量至第${phasePay.phase_order}期,计提期限不可小于该期`);
  937. return null;
  938. }
  939. } else if (result.postData.dl_type === deadlineType.stageCount.key) {
  940. result.postData.dl_value = this.getDlCount();
  941. if (result.postData.dl_value < maxStageOrder) {
  942. toastr.warning(`已计量至第${maxStageOrder}期,计提期限不可小于该期`);
  943. return null;
  944. }
  945. } else {
  946. result.postData.dl_value = this.getDlTp();
  947. const dt = deadlineType[result.postData.dl_type];
  948. if (!dt) {
  949. toastr.warning('限制模式错误,请刷新页面重试');
  950. return null;
  951. }
  952. const compareValue = payCalc.addBase[`pre_${dt.key}_tp`];
  953. if (result.postData.dl_type < compareValue) {
  954. toastr.warning(`截止上期,${dt.name}已计量${compareValue},计提期限不可小于该值`);
  955. return null;
  956. }
  957. }
  958. } else {
  959. result.postData.dl_value = 0;
  960. }
  961. return result;
  962. },
  963. };
  964. $('[name=dl-type]').change(deadlineObj.refreshHint);
  965. $('#dl-value').change(deadlineObj.refreshHint);
  966. $('#deadline-ok').click(function() {
  967. const updateData = deadlineObj.getUpdateData();
  968. if (!updateData) return;
  969. postData('update', updateData, function(result) {
  970. payEvent.reloadPays(result.reload);
  971. $('#deadline').modal('hide');
  972. });
  973. });
  974. // 右键菜单
  975. $.contextMenu({
  976. selector: '#pay-spread',
  977. build: function ($trigger, e) {
  978. const target = SpreadJsObj.safeRightClickSelection($trigger, e, spread);
  979. return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
  980. },
  981. items: {
  982. 'start': {
  983. name: '启用',
  984. icon: 'fa-play',
  985. callback: function (key, opt) {
  986. const select = SpreadJsObj.getSelectObject(sheet);
  987. const data = {
  988. postType: 'update',
  989. postData: { id: select.id, is_pause: 0 }
  990. };
  991. // 更新至服务器
  992. postData('update', data, function (result) {
  993. payEvent.reloadPays(result.reload);
  994. });
  995. },
  996. visible: function (key, opt) {
  997. const select = SpreadJsObj.getSelectObject(sheet);
  998. return (!select.children || select.children.length ===0) && !readOnly && select.is_pause && payUtils.menuVisible.pause(select);
  999. }
  1000. },
  1001. 'stop': {
  1002. name: '停用',
  1003. icon: 'fa-pause',
  1004. callback: function (key, opt) {
  1005. const select = SpreadJsObj.getSelectObject(sheet);
  1006. const data = {
  1007. postType: 'update',
  1008. postData: { id: select.id, is_pause: 1 }
  1009. };
  1010. // 更新至服务器
  1011. postData('update', data, function (result) {
  1012. payEvent.reloadPays(result.reload);
  1013. });
  1014. },
  1015. visible: function (key, opt) {
  1016. const select = SpreadJsObj.getSelectObject(sheet);
  1017. return (!select.children || select.children.length === 0) && !readOnly && !select.is_pause && payUtils.menuVisible.pause(select);
  1018. },
  1019. },
  1020. 'setDeadline': {
  1021. name: '设置计提期限',
  1022. icon: 'fa-clipboard',
  1023. callback: function (key, opt) {
  1024. const select = SpreadJsObj.getSelectObject(sheet);
  1025. if (select.range_tp) {
  1026. deadlineObj.initView(select);
  1027. $('#deadline').modal('show');
  1028. } else {
  1029. toastr.warning('计提期限用于达到条件时,即刻计量至付(扣)款限额,应先设置付(扣)款限额');
  1030. }
  1031. },
  1032. visible: function (key, opt) {
  1033. const select = SpreadJsObj.getSelectObject(sheet);
  1034. return (!select.children || select.children.length === 0) && !readOnly && payUtils.menuVisible.deadline(select);
  1035. }
  1036. },
  1037. }
  1038. });
  1039. }
  1040. return { spread, sheet, payTree, loadDatas: payEvent.reloadPays }
  1041. })();
  1042. payObj.loadDatas(details);
  1043. const payFile = $.ledger_att({
  1044. selector: '#fujian',
  1045. key: 'uuid',
  1046. masterKey: 'rela_id',
  1047. uploadUrl: 'file/upload',
  1048. deleteUrl: 'file/delete',
  1049. checked: false,
  1050. zipName: `附件.zip`,
  1051. readOnly: false,
  1052. fileIdType: 'string',
  1053. fileInfo: {
  1054. user_name: 'user_name',
  1055. user_id: 'user_id',
  1056. create_time: 'create_time',
  1057. },
  1058. getCurHint: function(node) {
  1059. return`${node.name || ''}`;
  1060. },
  1061. locate: function (att) {
  1062. if (!att) return;
  1063. SpreadJsObj.locateTreeNode(payObj.sheet, att.node.tree_id, true);
  1064. payFile.getCurAttHtml(att.node);
  1065. }
  1066. });
  1067. // 展开收起标准清单
  1068. $('a', '#side-menu').bind('click', function (e) {
  1069. e.preventDefault();
  1070. const tab = $(this), tabPanel = $(tab.attr('content'));
  1071. // 展开工具栏、切换标签
  1072. if (!tab.hasClass('active')) {
  1073. // const close = $('.active', '#side-menu').length === 0;
  1074. $('a', '#side-menu').removeClass('active');
  1075. $('.tab-content .tab-select-show.tab-pane.active').removeClass('active');
  1076. tab.addClass('active');
  1077. tabPanel.addClass('active');
  1078. // $('.tab-content .tab-pane').removeClass('active');
  1079. showSideTools(tab.hasClass('active'));
  1080. } else { // 收起工具栏
  1081. tab.removeClass('active');
  1082. tabPanel.removeClass('active');
  1083. showSideTools(tab.hasClass('active'));
  1084. }
  1085. payObj.spread.refresh();
  1086. });
  1087. postData('load', {filter: 'file'}, function(result) {
  1088. for (const f of result.file) {
  1089. f.node = payObj.payTree.datas.find(x => { return x.uuid === f.rela_id; });
  1090. }
  1091. payFile.loadDatas(result.file);
  1092. payFile.getCurAttHtml(SpreadJsObj.getSelectObject(payObj.sheet));
  1093. });
  1094. // 工具栏spr
  1095. $.divResizer({
  1096. select: '#right-spr',
  1097. callback: function () {
  1098. payObj.spread.refresh();
  1099. }
  1100. });
  1101. // todo 加载审批列表
  1102. $.subMenu({
  1103. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  1104. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  1105. key: 'menu.1.0.0',
  1106. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  1107. callback: function (info) {
  1108. if (info.mini) {
  1109. $('.panel-title').addClass('fluid');
  1110. $('#sub-menu').removeClass('panel-sidebar');
  1111. } else {
  1112. $('.panel-title').removeClass('fluid');
  1113. $('#sub-menu').addClass('panel-sidebar');
  1114. }
  1115. autoFlashHeight();
  1116. payObj.spread.refresh();
  1117. }
  1118. });
  1119. });