change_information_approval.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. 'use strict';
  2. /**
  3. * 变更令详细页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. function getPasteHint (str, row = '') {
  10. let returnObj = str;
  11. if (row) {
  12. returnObj.msg = '清单第' + (row+1) + '行' + str.msg;
  13. }
  14. return returnObj;
  15. }
  16. $(document).ready(() => {
  17. const changeSpreadSetting = {
  18. cols: [
  19. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@', readOnly: true},
  20. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  21. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
  22. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price', readOnly: true},
  23. {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  24. {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@', readOnly: true},
  25. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.oamount', readOnly: true},
  26. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.oa_tp', readOnly: true},
  27. {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount', readOnly: true},
  28. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, type: 'Number', getValue: 'getValue.ca_tp', readOnly: true},
  29. {title: '变更后|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.changed_amount'},
  30. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.changed_tp'},
  31. ],
  32. emptyRows: 0,
  33. headRows: 2,
  34. headRowHeight: [25, 25],
  35. defaultRowHeight: 21,
  36. headerFont: '12px 微软雅黑',
  37. font: '12px 微软雅黑',
  38. // readOnly: true,
  39. rowHeader:[
  40. {
  41. rowHeaderType: 'circle',
  42. setting: {
  43. size: 5,
  44. indent: 16,
  45. getColor: function (index, data) {
  46. if (!data) return;
  47. if (_.findIndex(changeLedgerList, { id: data.gcl_id }) !== -1 || _.findIndex(changePosList, { id: data.mx_id }) !== -1) {
  48. return '#dc3545';
  49. }
  50. if(data.lid != 0) return;
  51. return '#007bff';
  52. }
  53. },
  54. },
  55. ],
  56. localCache: {
  57. key: 'changes-spread',
  58. colWidth: true,
  59. }
  60. };
  61. for (const aid of aidList) {
  62. const userinfo = _.find(auditList2, { 'uid': aid });
  63. const newColcount = {
  64. title: userinfo.name + ' 审批|数量',
  65. colSpan: '2|1', rowSpan: '1|1',
  66. field: 'audit_amount_' + aid,
  67. hAlign: 2, width: 60, type: 'Number',
  68. readOnly: aid !== parseInt(accountId)
  69. };
  70. const newColTp = {
  71. title: '|金额',
  72. colSpan: '|1', rowSpan: '|1',
  73. field: 'sa_tp_' + aid,
  74. hAlign: 2, width: 80, type: 'Number',
  75. readOnly: true
  76. };
  77. changeSpreadSetting.cols.push(newColcount);
  78. changeSpreadSetting.cols.push(newColTp);
  79. }
  80. const changeCol = {
  81. getValue: {
  82. unit_price: function(data) {
  83. return ZhCalc.round(data.unit_price, unitPriceUnit);
  84. },
  85. oa_tp: function (data) {
  86. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.oamount, findDecimal(data.unit))), totalPriceUnit);
  87. },
  88. ca_tp: function (data) {
  89. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(data.camount, findDecimal(data.unit))), totalPriceUnit);
  90. },
  91. oamount: function (data) {
  92. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  93. },
  94. camount: function (data) {
  95. return ZhCalc.round(data.camount, findDecimal(data.unit));
  96. },
  97. changed_amount: function (data) {
  98. return ZhCalc.round(ZhCalc.add(data.oamount, data.spamount), findDecimal(data.unit));
  99. },
  100. changed_tp: function (data) {
  101. return ZhCalc.round(ZhCalc.mul(ZhCalc.round(data.unit_price, unitPriceUnit), ZhCalc.round(ZhCalc.add(data.oamount, data.spamount), findDecimal(data.unit))), totalPriceUnit);
  102. },
  103. },
  104. };
  105. const changeSpreadObj = {
  106. makeSjsFooter: function () {
  107. // 增加汇总行并设为锁定禁止编辑状态
  108. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  109. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
  110. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  111. changeSpreadObj.countSum();
  112. },
  113. setAuditValue: function () {
  114. for (const c of changeList) {
  115. for (const j of aidList) {
  116. c['audit_amount_' + j] = ZhCalc.round(c['audit_amount_' + j], findDecimal(c.unit));
  117. c['sa_tp_' + j] = ZhCalc.round(ZhCalc.mul(c['audit_amount_' + j], ZhCalc.round(c.unit_price, unitPriceUnit)), totalPriceUnit);
  118. }
  119. }
  120. // const rowCount = changeSpreadSheet.getRowCount();
  121. // // 用户的数据合计
  122. // for (const j in aidList) {
  123. // for(let i = 0; i <= rowCount - 1; i++){
  124. // const data = {
  125. // unit_price: changeSpreadSheet.getValue(i, 5),
  126. // amount: parseFloat(changeSpreadSheet.getValue(i, 10 + parseInt(j)*2)),
  127. // };
  128. // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.amount), totalPriceUnit);
  129. // changeSpreadSheet.setValue(i, 11 + j*2, sum !== 0 ? sum : null);
  130. // }
  131. // }
  132. },
  133. resetXmjSpread: function(data = null) {
  134. const xmj = [];
  135. if (data && data.lid != 0 && data.xmj_code !== '' && data.xmj_code !== null) {
  136. if (data.bwmx === data.xmj_jldy) {
  137. data.bwmx = '';
  138. }
  139. xmj.push(data);
  140. }
  141. SpreadJsObj.loadSheetData(xmjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, xmj);
  142. },
  143. selectionChanged: function (e, info) {
  144. const data = SpreadJsObj.getSelectObject(info.sheet);
  145. changeSpreadObj.resetXmjSpread(data);
  146. },
  147. setRowValueAndSum: function (data, row, col) {
  148. for (const j in aidList) {
  149. const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, parseFloat(changeSpreadSheet.getValue(row, 12 + parseInt(j)*2))), totalPriceUnit);
  150. changeSpreadSheet.setValue(row, 13 + j*2, sum !== 0 ? sum : null);
  151. }
  152. // const sum = ZhCalc.round(ZhCalc.mul(data.unit_price, data.spamount), totalPriceUnit);
  153. // changeSpreadSheet.setValue(row, col+1, sum !== 0 ? sum : null);
  154. const rowCount = changeSpreadSheet.getRowCount();
  155. // 用户的数据合计
  156. // 变更后数据合计
  157. let audit_sum = 0;
  158. let changed_sum = 0;
  159. for(let i = 0; i < rowCount - 1; i++){
  160. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
  161. changed_sum = ZhCalc.add(changed_sum, changeSpreadSheet.getValue(i, 11));
  162. }
  163. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
  164. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, changed_sum !== 0 ? changed_sum : null);
  165. },
  166. countSum: function() {
  167. const rowCount = changeSpreadSheet.getRowCount();
  168. let oSum = 0,
  169. cSum = 0,
  170. cdSum = 0;
  171. for(let i = 0; i < rowCount - 1; i++){
  172. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
  173. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
  174. cdSum = ZhCalc.add(cdSum, changeSpreadSheet.getValue(i, 11));
  175. }
  176. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
  177. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
  178. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, cdSum !== 0 ? cdSum : null);
  179. // 用户的数据合计
  180. for (const j in aidList) {
  181. let audit_sum = 0;
  182. for(let i = 0; i < rowCount - 1; i++){
  183. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
  184. }
  185. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
  186. }
  187. },
  188. deletePress: function (sheet) {
  189. return;
  190. },
  191. editEnded: function (e, info) {
  192. if (info.sheet.zh_setting) {
  193. const select = SpreadJsObj.getSelectObject(info.sheet);
  194. const col = info.sheet.zh_setting.cols[info.col];
  195. // 未改变值则不提交
  196. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  197. const orgValue = select[col.field];
  198. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  199. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  200. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  201. return;
  202. }
  203. // 判断部分值是否输入的是数字判断和数据计算
  204. if (col.type === 'Number') {
  205. if (isNaN(validText)) {
  206. toastr.error('不能输入其它非数字类型字符');
  207. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  208. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  209. return;
  210. }
  211. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  212. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  213. const usedInfo = _.find(changeUsedData, { cbid: select.id });
  214. if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
  215. toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
  216. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  217. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  218. return;
  219. } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
  220. toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
  221. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  222. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  223. return;
  224. }
  225. }
  226. select[col.field] = validText;
  227. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  228. const data = {
  229. id: select.id,
  230. spamount: select.spamount,
  231. };
  232. console.log(data);
  233. // 更新至服务器
  234. postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
  235. changeList.splice(info.row, 1, select);
  236. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  237. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  238. }, function () {
  239. select[col.field] = orgValue;
  240. select.spamount = orgValue;
  241. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  242. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  243. });
  244. }
  245. },
  246. clipboardPasted(e, info) {
  247. const hint = {
  248. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  249. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  250. qtyError: {type: 'error', msg: '变更数值必须大于等于已调用值'},
  251. };
  252. const range = info.cellRange;
  253. const sortData = info.sheet.zh_data || [];
  254. // console.log(info, range);
  255. // if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  256. // toastMessageUniq(hint.cellError);
  257. // // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
  258. // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  259. // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  260. // changeSpreadObj.setAuditValue();
  261. // changeSpreadObj.makeSjsFooter();
  262. // return;
  263. // }
  264. // if (sortData.length > 0 && range.col + range.colCount > 10) {
  265. // toastMessageUniq(hint.cellError);
  266. // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  267. // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  268. // changeSpreadObj.setAuditValue();
  269. // changeSpreadObj.makeSjsFooter();
  270. // return;
  271. // }
  272. const data = [];
  273. // const rowData = [];
  274. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  275. let bPaste = true;
  276. const curRow = range.row + iRow;
  277. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  278. const cLData = { id: sortData[curRow].id };
  279. const hintRow = range.rowCount > 1 ? curRow : '';
  280. let sameCol = 0;
  281. for (let iCol = 0; iCol < range.colCount; iCol++) {
  282. const curCol = range.col + iCol;
  283. const colSetting = info.sheet.zh_setting.cols[curCol];
  284. if (!colSetting) continue;
  285. let validText = info.sheet.getText(curRow, curCol);
  286. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
  287. const orgValue = sortData[curRow][colSetting.field];
  288. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  289. sameCol++;
  290. if (range.colCount === sameCol) {
  291. bPaste = false;
  292. }
  293. continue;
  294. }
  295. if (colSetting.type === 'Number') {
  296. if (isNaN(validText)) {
  297. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  298. bPaste = false;
  299. continue;
  300. }
  301. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  302. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  303. const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
  304. if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
  305. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
  306. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  307. changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
  308. bPaste = false;
  309. continue;
  310. } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
  311. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
  312. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  313. changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
  314. bPaste = false;
  315. continue;
  316. }
  317. }
  318. // cLData[colSetting.field] = validText;
  319. sortData[curRow][colSetting.field] = validText;
  320. cLData.spamount = validText;
  321. }
  322. if (bPaste) {
  323. data.push(cLData);
  324. // rowData.push(curRow);
  325. } else {
  326. // SpreadJsObj.reLoadRowData(info.sheet, curRow);
  327. }
  328. }
  329. if (data.length === 0) {
  330. // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  331. return;
  332. }
  333. console.log(data);
  334. // 更新至服务器
  335. postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
  336. changeList = result;
  337. changeSpreadObj.setAuditValue();
  338. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  339. changeSpreadObj.makeSjsFooter();
  340. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  341. }, function () {
  342. changeSpreadObj.setAuditValue();
  343. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  344. return;
  345. });
  346. },
  347. };
  348. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  349. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  350. changeSpreadObj.setAuditValue();
  351. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  352. console.log(changeList);
  353. changeSpreadObj.makeSjsFooter();
  354. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  355. const userIndex = aidList.indexOf(parseInt(accountId));
  356. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  357. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  358. changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
  359. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  360. // 审批提交与判断
  361. $('.approval-btn').on('click', function () {
  362. // 判断审批状态
  363. let returnflag = true;
  364. if ($(this).hasClass('btn-success')) {
  365. const sdesc = $('#success-approval').find('textarea').val();
  366. if (sdesc === '') {
  367. toastr.error('审批意见不能为空!');
  368. returnflag = false;
  369. }
  370. if ($('input[name="p_code"]').val() === '') {
  371. toastr.error('变更令号(批复编号)不能为空!');
  372. returnflag = false;
  373. } else if ($('input[name="p_code"]').val() !== undefined) {
  374. $('input[name="p_code"]').val($.trim($('input[name="p_code"]').val()));
  375. const postData = {
  376. p_code: $('input[name="p_code"]').val(),
  377. };
  378. postDataWithAsync('/tender/' + $('#tenderId').val() + '/change/' + $('#changeId').val() + '/check/codeRepeat',postData, function (result) {
  379. }, function (data) {
  380. returnflag = false;
  381. });
  382. }
  383. // 判断并提交变更清单表格数据到表单中
  384. const clist = [];
  385. for(const [i,cl] of changeList.entries()) {
  386. // if (cl['audit_amount_' + accountId] === null || cl['audit_amount_' + accountId] === '') {
  387. // toastr.error('清单第' + (i+1) + '行审批变更数量不能为空');
  388. // returnflag = false;
  389. // } else {
  390. clist.push(cl.id + '_' + cl['audit_amount_' + accountId]);
  391. // }
  392. }
  393. $('#change-list-approval').val(clist.join(','));
  394. if(returnflag) {
  395. $('input[name="w_code"]').val($.trim($('#w_code').val()));
  396. $('#success-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
  397. if ($('#warning-text').length) $('#warning-text').remove()
  398. $('#success-approval').submit();
  399. }
  400. } else {
  401. const sdesc = $('#fail-approval').find('textarea').val();
  402. if (sdesc === '') {
  403. toastr.error('审批意见不能为空!');
  404. returnflag = false;
  405. }
  406. const type = $('#fail-approval').find('input[name="status"]:checked').val();
  407. if (type === undefined) {
  408. // toastr.error('请选择退回类型!');
  409. if (!$('#warning-text').length) {
  410. $('#change-back-content').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  411. }
  412. returnflag = false;
  413. }
  414. if(returnflag) {
  415. $('#fail-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
  416. $('input[name="w_code"]').val($.trim($('#w_code').val()));
  417. $('#fail-approval').submit();
  418. }
  419. }
  420. })
  421. });
  422. const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
  423. if (showWaiting) showWaitingView();
  424. $.ajax({
  425. type:"POST",
  426. url: url,
  427. data: {'data': JSON.stringify(data)},
  428. dataType: 'json',
  429. cache: false,
  430. async: false,
  431. timeout: 60000,
  432. beforeSend: function(xhr) {
  433. let csrfToken = Cookies.get('csrfToken_j');
  434. xhr.setRequestHeader('x-csrf-token', csrfToken);
  435. },
  436. success: function(result){
  437. if (result.err === 0) {
  438. if (successCallback) {
  439. successCallback(result.data);
  440. }
  441. } else {
  442. toastr.error(result.msg);
  443. if (errorCallBack) {
  444. errorCallBack(result.msg);
  445. }
  446. }
  447. if (showWaiting) closeWaitingView();
  448. },
  449. error: function(jqXHR, textStatus, errorThrown){
  450. toastr.error('error: ' + textStatus + " " + errorThrown);
  451. if (errorCallBack) {
  452. errorCallBack();
  453. }
  454. if (showWaiting) closeWaitingView();
  455. }
  456. });
  457. };
  458. function auditCheck(i) {
  459. const inlineRadio1 = $('#change-back:checked').val()
  460. const inlineRadio2 = $('#chagne-backnew:checked').val()
  461. const opinion = $('textarea[name="sdesc"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
  462. $('textarea[name="sdesc"]').eq(i).val(opinion);
  463. if (i === 1) {
  464. if (!inlineRadio1 && !inlineRadio2) {
  465. if (!$('#warning-text').length) {
  466. $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  467. }
  468. return false;
  469. }
  470. if ($('#warning-text').length) $('#warning-text').remove()
  471. }
  472. return true;
  473. }