commonSubmitHelper.js 2.2 KB

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