checkCreateHelper.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. //入库、出库盘点
  56. async create2(FormId, date) {
  57. try {
  58. modal.loading("创建中,请耐心等待...");
  59. const createParam = getCreateParam(FormId);
  60. console.log(createParam)
  61. const createRes = await this.saveData(createParam);
  62. if (!createRes.IsSuccess) {
  63. throw new Error(createRes.Errors[0].Message);
  64. }
  65. console.log(createRes)
  66. //查询库存
  67. const queryStockParam = getQueryStockParam(createRes["SuccessEntitys"][0]["Id"], '',date);
  68. const queryStockRes = await this.queryStock(queryStockParam);
  69. if (queryStockRes["success"] !== "成功") {
  70. throw new Error(queryStockRes["result"]);
  71. }
  72. //查询盘点单明细
  73. const condition = this.createQueryBillDetailListCondition(createRes["SuccessEntitys"][0]["Id"]);
  74. const billDetailListParam = getBillDetailListParam(condition)
  75. const res = await this.fetchBillDetails(billDetailListParam)
  76. // if (res["success"] !== "成功") {
  77. // throw new Error(res["result"]);
  78. // }
  79. return res
  80. // this.handleSuccess(FID, indexList);
  81. } catch (error) {
  82. // this.handleError(error);
  83. throw new Error(error);
  84. } finally {
  85. modal.closeLoading();
  86. }
  87. },
  88. saveData(params) {
  89. return save(JSON.stringify(params))
  90. .then(res => res.Result.ResponseStatus);
  91. },
  92. submitData(params) {
  93. return submit(JSON.stringify(params))
  94. .then(res => res.Result.ResponseStatus);
  95. },
  96. queryStock(params) {
  97. return QueryStock(params)
  98. .then(res => res);
  99. },
  100. fetchBillDetails(billDetailListParam) {
  101. return getBillDetailList(JSON.stringify(billDetailListParam));
  102. },
  103. createQueryBillDetailListCondition(selected) {
  104. return {
  105. FormId: uni.getStorageSync('formId'),
  106. selectedFID: selected,
  107. FBillType: uni.getStorageSync('fbillType')
  108. };
  109. },
  110. auditData(params) {
  111. return audit(JSON.stringify(params))
  112. .then(res => res.Result.ResponseStatus);
  113. },
  114. handleSuccess(FID, indexList) {
  115. // Assuming that you pass indexList back to where it's needed
  116. uni.showModal({
  117. title: "提示",
  118. content: "提交成功",
  119. showCancel: true,
  120. success: (res) => {
  121. if (res.confirm) {
  122. // 用户点击确定
  123. } else {
  124. // 用户点击取消
  125. }
  126. }
  127. });
  128. playVoice(audioUrls.warningSuccessUrl);
  129. },
  130. handleError(error) {
  131. uni.showToast({
  132. title: error.message || '操作失败',
  133. duration: 3000,
  134. icon: "error"
  135. });
  136. playVoice(audioUrls.successVoiceUrl)
  137. console.error('操作失败:', error);
  138. }
  139. };