checkSubmitHelper.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import {
  2. audit,
  3. save,
  4. submit
  5. } from '../api/production_replenishment.js';
  6. import modal from '../plugins/modal.js';
  7. import {
  8. audioUrls,
  9. playVoice
  10. } from './audio2.js';
  11. import {
  12. getSaveParam,
  13. getSubmitParam,
  14. getAuditParam,
  15. get2SaveParam
  16. } from './checkParams.js';
  17. export default {
  18. async submit(FormId,FID, indexList,fbillType) {
  19. try {
  20. modal.loading("提交中,请耐心等待...");
  21. const saveParam = getSaveParam(FormId,FID, indexList);
  22. console.log(saveParam)
  23. const saveRes = await this.saveData(saveParam);
  24. if (!saveRes.IsSuccess) {
  25. throw new Error(saveRes.Errors[0].Message);
  26. }
  27. const submitParam = getSubmitParam(FormId,FID);
  28. const submitRes = await this.submitData(submitParam);
  29. if (!submitRes.IsSuccess) {
  30. throw new Error(submitRes.Errors[0].Message);
  31. }
  32. const auditParam = getAuditParam(FormId,submitRes.SuccessEntitys[0].Id);
  33. const auditRes = await this.auditData(auditParam);
  34. if (!auditRes.IsSuccess) {
  35. throw new Error(auditRes.Errors[0].Message);
  36. }
  37. this.handleSuccess(FID, indexList);
  38. } catch (error) {
  39. // this.handleError(error);
  40. throw new Error(error);
  41. } finally {
  42. modal.closeLoading();
  43. }
  44. },
  45. saveData(params) {
  46. return save(JSON.stringify(params))
  47. .then(res => res.Result.ResponseStatus);
  48. },
  49. submitData(params) {
  50. return submit(JSON.stringify(params))
  51. .then(res => res.Result.ResponseStatus);
  52. },
  53. auditData(params) {
  54. return audit(JSON.stringify(params))
  55. .then(res => res.Result.ResponseStatus);
  56. },
  57. handleSuccess(FID, indexList) {
  58. // Assuming that you pass indexList back to where it's needed
  59. uni.showModal({
  60. title: "提示",
  61. content: "提交成功",
  62. showCancel: true,
  63. success: (res) => {
  64. if (res.confirm) {
  65. // 用户点击确定
  66. } else {
  67. // 用户点击取消
  68. }
  69. }
  70. });
  71. playVoice(audioUrls.warningSuccessUrl);
  72. },
  73. handleError(error) {
  74. uni.showToast({
  75. title: error.message || '操作失败',
  76. duration: 3000,
  77. icon: "error"
  78. });
  79. playVoice(audioUrls.successVoiceUrl)
  80. console.error('操作失败:', error);
  81. }
  82. };