change_information_approval.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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(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(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. let audit_sum = 0;
  157. for(let i = 0; i < rowCount - 1; i++){
  158. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, col+1));
  159. }
  160. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, col+1, audit_sum !== 0 ? audit_sum : null);
  161. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, audit_sum !== 0 ? audit_sum : null);
  162. },
  163. countSum: function() {
  164. const rowCount = changeSpreadSheet.getRowCount();
  165. let oSum = 0,
  166. cSum = 0,
  167. cdSum = 0;
  168. for(let i = 0; i < rowCount - 1; i++){
  169. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
  170. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
  171. cdSum = ZhCalc.add(cdSum, changeSpreadSheet.getValue(i, 11));
  172. }
  173. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
  174. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
  175. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, cdSum !== 0 ? cdSum : null);
  176. // 用户的数据合计
  177. for (const j in aidList) {
  178. let audit_sum = 0;
  179. for(let i = 0; i < rowCount - 1; i++){
  180. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
  181. }
  182. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
  183. }
  184. },
  185. deletePress: function (sheet) {
  186. return;
  187. },
  188. editEnded: function (e, info) {
  189. if (info.sheet.zh_setting) {
  190. const select = SpreadJsObj.getSelectObject(info.sheet);
  191. const col = info.sheet.zh_setting.cols[info.col];
  192. // 未改变值则不提交
  193. let validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : '');
  194. const orgValue = select[col.field];
  195. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  196. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  197. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  198. return;
  199. }
  200. // 判断部分值是否输入的是数字判断和数据计算
  201. if (col.type === 'Number') {
  202. if (isNaN(validText)) {
  203. toastr.error('不能输入其它非数字类型字符');
  204. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  205. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  206. return;
  207. }
  208. validText = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  209. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  210. const usedInfo = _.find(changeUsedData, { cbid: select.id });
  211. if (usedInfo && validText >= 0 && validText < usedInfo.qty) {
  212. toastr.error('清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
  213. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  214. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  215. return;
  216. } else if (usedInfo && validText < 0 && validText > usedInfo.qty) {
  217. toastr.error('清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
  218. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  219. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  220. return;
  221. }
  222. }
  223. select[col.field] = validText;
  224. select.spamount = ZhCalc.round(validText, findDecimal(select.unit)) || 0;
  225. const data = {
  226. id: select.id,
  227. spamount: select.spamount,
  228. };
  229. console.log(data);
  230. // 更新至服务器
  231. postData(window.location.pathname + '/save', { type:'update', updateData: data }, function (result) {
  232. changeList.splice(info.row, 1, select);
  233. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  234. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  235. }, function () {
  236. select[col.field] = orgValue;
  237. select.spamount = orgValue;
  238. SpreadJsObj.reLoadRowData(info.sheet, info.row);
  239. changeSpreadObj.setRowValueAndSum(select, info.row, info.col);
  240. });
  241. }
  242. },
  243. clipboardPasted(e, info) {
  244. const hint = {
  245. cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
  246. numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
  247. qtyError: {type: 'error', msg: '变更数值必须大于等于已调用值'},
  248. };
  249. const range = info.cellRange;
  250. const sortData = info.sheet.zh_data || [];
  251. // console.log(info, range);
  252. // if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
  253. // toastMessageUniq(hint.cellError);
  254. // // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
  255. // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  256. // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  257. // changeSpreadObj.setAuditValue();
  258. // changeSpreadObj.makeSjsFooter();
  259. // return;
  260. // }
  261. // if (sortData.length > 0 && range.col + range.colCount > 10) {
  262. // toastMessageUniq(hint.cellError);
  263. // SpreadJsObj.reLoadSheetHeader(changeSpreadSheet);
  264. // SpreadJsObj.reLoadSheetData(changeSpreadSheet);
  265. // changeSpreadObj.setAuditValue();
  266. // changeSpreadObj.makeSjsFooter();
  267. // return;
  268. // }
  269. const data = [];
  270. // const rowData = [];
  271. for (let iRow = 0; iRow < range.rowCount; iRow++) {
  272. let bPaste = true;
  273. const curRow = range.row + iRow;
  274. // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
  275. const cLData = { id: sortData[curRow].id };
  276. const hintRow = range.rowCount > 1 ? curRow : '';
  277. let sameCol = 0;
  278. for (let iCol = 0; iCol < range.colCount; iCol++) {
  279. const curCol = range.col + iCol;
  280. const colSetting = info.sheet.zh_setting.cols[curCol];
  281. if (!colSetting) continue;
  282. let validText = info.sheet.getText(curRow, curCol);
  283. validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
  284. const orgValue = sortData[curRow][colSetting.field];
  285. if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
  286. sameCol++;
  287. if (range.colCount === sameCol) {
  288. bPaste = false;
  289. }
  290. continue;
  291. }
  292. if (colSetting.type === 'Number') {
  293. if (isNaN(validText)) {
  294. toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
  295. bPaste = false;
  296. continue;
  297. }
  298. validText = ZhCalc.round(validText, findDecimal(sortData[curRow].unit)) || 0;
  299. // 判断是否 正数必须大于等于限制值,负数必须小于等于限制值,否则无法更改
  300. const usedInfo = _.find(changeUsedData, { id: sortData[curRow].id });
  301. if (usedInfo && usedInfo.qty >= 0 && validText < usedInfo.qty) {
  302. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须大于等于已调用值 ' + usedInfo.qty : '清单变更数值必须大于等于已调用值 ' + usedInfo.qty);
  303. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  304. changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
  305. bPaste = false;
  306. continue;
  307. } else if (usedInfo && usedInfo.qty < 0 && validText > usedInfo.qty) {
  308. toastr.error(hintRow ? '清单' + (hintRow+1) + '行变更数值必须小于等于已调用值 ' + usedInfo.qty : '清单变更数值必须小于等于已调用值 ' + usedInfo.qty);
  309. SpreadJsObj.reLoadRowData(info.sheet, curRow);
  310. changeSpreadObj.setRowValueAndSum(sortData[curRow], curRow, curCol);
  311. bPaste = false;
  312. continue;
  313. }
  314. }
  315. // cLData[colSetting.field] = validText;
  316. sortData[curRow][colSetting.field] = validText;
  317. cLData.spamount = validText;
  318. }
  319. if (bPaste) {
  320. data.push(cLData);
  321. // rowData.push(curRow);
  322. } else {
  323. // SpreadJsObj.reLoadRowData(info.sheet, curRow);
  324. }
  325. }
  326. if (data.length === 0) {
  327. // SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  328. return;
  329. }
  330. console.log(data);
  331. // 更新至服务器
  332. postData(window.location.pathname + '/save', { type:'paste_amount_rows', updateData: data }, function (result) {
  333. changeList = result;
  334. changeSpreadObj.setAuditValue();
  335. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  336. changeSpreadObj.makeSjsFooter();
  337. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  338. }, function () {
  339. changeSpreadObj.setAuditValue();
  340. SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
  341. return;
  342. });
  343. },
  344. };
  345. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  346. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  347. changeSpreadObj.setAuditValue();
  348. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  349. console.log(changeList);
  350. changeSpreadObj.makeSjsFooter();
  351. changeSpreadObj.resetXmjSpread(SpreadJsObj.getSelectObject(changeSpreadSheet));
  352. const userIndex = aidList.indexOf(parseInt(accountId));
  353. changeSpread.bind(spreadNS.Events.EditEnded, changeSpreadObj.editEnded);
  354. changeSpread.bind(spreadNS.Events.ClipboardPasted, changeSpreadObj.clipboardPasted);
  355. changeSpread.bind(spreadNS.Events.SelectionChanged, changeSpreadObj.selectionChanged);
  356. SpreadJsObj.addDeleteBind(changeSpread, changeSpreadObj.deletePress);
  357. // 审批提交与判断
  358. $('.approval-btn').on('click', function () {
  359. // 判断审批状态
  360. let returnflag = true;
  361. if ($(this).hasClass('btn-success')) {
  362. const sdesc = $('#success-approval').find('textarea').val();
  363. if (sdesc === '') {
  364. toastr.error('审批意见不能为空!');
  365. returnflag = false;
  366. }
  367. if ($('input[name="p_code"]').val() === '') {
  368. toastr.error('变更令号(批复编号)不能为空!');
  369. returnflag = false;
  370. } else if ($('input[name="p_code"]').val() !== undefined) {
  371. $('input[name="p_code"]').val($.trim($('input[name="p_code"]').val()));
  372. const postData = {
  373. p_code: $('input[name="p_code"]').val(),
  374. };
  375. postDataWithAsync('/tender/' + $('#tenderId').val() + '/change/' + $('#changeId').val() + '/check/codeRepeat',postData, function (result) {
  376. }, function (data) {
  377. returnflag = false;
  378. });
  379. }
  380. // 判断并提交变更清单表格数据到表单中
  381. const clist = [];
  382. for(const [i,cl] of changeList.entries()) {
  383. // if (cl['audit_amount_' + accountId] === null || cl['audit_amount_' + accountId] === '') {
  384. // toastr.error('清单第' + (i+1) + '行审批变更数量不能为空');
  385. // returnflag = false;
  386. // } else {
  387. clist.push(cl.id + '_' + cl['audit_amount_' + accountId]);
  388. // }
  389. }
  390. $('#change-list-approval').val(clist.join(','));
  391. if(returnflag) {
  392. $('input[name="w_code"]').val($.trim($('#w_code').val()));
  393. $('#success-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
  394. if ($('#warning-text').length) $('#warning-text').remove()
  395. $('#success-approval').submit();
  396. }
  397. } else {
  398. const sdesc = $('#fail-approval').find('textarea').val();
  399. if (sdesc === '') {
  400. toastr.error('审批意见不能为空!');
  401. returnflag = false;
  402. }
  403. const type = $('#fail-approval').find('input[name="status"]:checked').val();
  404. if (type === undefined) {
  405. // toastr.error('请选择退回类型!');
  406. if (!$('#warning-text').length) {
  407. $('#change-back-content').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  408. }
  409. returnflag = false;
  410. }
  411. if(returnflag) {
  412. $('#fail-approval').find('textarea').val(sdesc.replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' '));
  413. $('input[name="w_code"]').val($.trim($('#w_code').val()));
  414. $('#fail-approval').submit();
  415. }
  416. }
  417. })
  418. });
  419. const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
  420. if (showWaiting) showWaitingView();
  421. $.ajax({
  422. type:"POST",
  423. url: url,
  424. data: {'data': JSON.stringify(data)},
  425. dataType: 'json',
  426. cache: false,
  427. async: false,
  428. timeout: 60000,
  429. beforeSend: function(xhr) {
  430. let csrfToken = Cookies.get('csrfToken_j');
  431. xhr.setRequestHeader('x-csrf-token', csrfToken);
  432. },
  433. success: function(result){
  434. if (result.err === 0) {
  435. if (successCallback) {
  436. successCallback(result.data);
  437. }
  438. } else {
  439. toastr.error(result.msg);
  440. if (errorCallBack) {
  441. errorCallBack(result.msg);
  442. }
  443. }
  444. if (showWaiting) closeWaitingView();
  445. },
  446. error: function(jqXHR, textStatus, errorThrown){
  447. toastr.error('error: ' + textStatus + " " + errorThrown);
  448. if (errorCallBack) {
  449. errorCallBack();
  450. }
  451. if (showWaiting) closeWaitingView();
  452. }
  453. });
  454. };
  455. function auditCheck(i) {
  456. const inlineRadio1 = $('#change-back:checked').val()
  457. const inlineRadio2 = $('#chagne-backnew:checked').val()
  458. const opinion = $('textarea[name="sdesc"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
  459. $('textarea[name="sdesc"]').eq(i).val(opinion);
  460. if (i === 1) {
  461. if (!inlineRadio1 && !inlineRadio2) {
  462. if (!$('#warning-text').length) {
  463. $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  464. }
  465. return false;
  466. }
  467. if ($('#warning-text').length) $('#warning-text').remove()
  468. }
  469. return true;
  470. }