checkCreateHelper.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import {
  2. audit,
  3. getBillDetailList,
  4. QueryStock,
  5. save,
  6. submit
  7. } from '../api/production_replenishment.js';
  8. import modal from '../plugins/modal.js';
  9. import {
  10. audioUrls,
  11. playVoice
  12. } from './audio2.js';
  13. import {
  14. getSaveParam,
  15. getSubmitParam,
  16. getAuditParam,
  17. get2SaveParam,
  18. getCreateParam,
  19. getQueryStockParam,
  20. getBillDetailListParam
  21. } from './checkParams.js';
  22. export default {
  23. async create(FormId, selectedFID) {
  24. try {
  25. modal.loading("创建中,请耐心等待...");
  26. const createParam = getCreateParam(FormId);
  27. console.log(createParam)
  28. const createRes = await this.saveData(createParam);
  29. if (!createRes.IsSuccess) {
  30. throw new Error(createRes.Errors[0].Message);
  31. }
  32. console.log(createRes)
  33. //查询库存
  34. const queryStockParam = getQueryStockParam(createRes["SuccessEntitys"][0]["Id"], selectedFID);
  35. const queryStockRes = await this.queryStock(queryStockParam);
  36. if (queryStockRes["success"] !== "成功") {
  37. throw new Error(queryStockRes["result"]);
  38. }
  39. //查询盘点单明细
  40. const condition = this.createQueryBillDetailListCondition(createRes["SuccessEntitys"][0]["Id"]);
  41. const billDetailListParam = getBillDetailListParam(condition)
  42. const res = await this.fetchBillDetails(billDetailListParam)
  43. // if (res["success"] !== "成功") {
  44. // throw new Error(res["result"]);
  45. // }
  46. return res
  47. // this.handleSuccess(FID, indexList);
  48. } catch (error) {
  49. // this.handleError(error);
  50. throw new Error(error);
  51. } finally {
  52. modal.closeLoading();
  53. }
  54. },
  55. saveData(params) {
  56. return save(JSON.stringify(params))
  57. .then(res => res.Result.ResponseStatus);
  58. },
  59. submitData(params) {
  60. return submit(JSON.stringify(params))
  61. .then(res => res.Result.ResponseStatus);
  62. },
  63. queryStock(params) {
  64. return QueryStock(params)
  65. .then(res => res);
  66. },
  67. fetchBillDetails(billDetailListParam) {
  68. return getBillDetailList(JSON.stringify(billDetailListParam));
  69. },
  70. createQueryBillDetailListCondition(selected) {
  71. return {
  72. FormId: uni.getStorageSync('formId'),
  73. selectedFID: selected,
  74. FBillType: uni.getStorageSync('fbillType')
  75. };
  76. },
  77. auditData(params) {
  78. return audit(JSON.stringify(params))
  79. .then(res => res.Result.ResponseStatus);
  80. },
  81. handleSuccess(FID, indexList) {
  82. // Assuming that you pass indexList back to where it's needed
  83. uni.showModal({
  84. title: "提示",
  85. content: "提交成功",
  86. showCancel: true,
  87. success: (res) => {
  88. if (res.confirm) {
  89. // 用户点击确定
  90. } else {
  91. // 用户点击取消
  92. }
  93. }
  94. });
  95. playVoice(audioUrls.warningSuccessUrl);
  96. },
  97. handleError(error) {
  98. uni.showToast({
  99. title: error.message || '操作失败',
  100. duration: 3000,
  101. icon: "error"
  102. });
  103. playVoice(audioUrls.successVoiceUrl)
  104. console.error('操作失败:', error);
  105. }
  106. };