change_information_approval.js 25 KB

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