123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- import {
- audit,
- getBillDetailList,
- QueryStock,
- save,
- submit
- } from '../api/production_replenishment.js';
- import modal from '../plugins/modal.js';
- import {
- audioUrls,
- playVoice
- } from './audio2.js';
- import {
- getSaveParam,
- getSubmitParam,
- getAuditParam,
- get2SaveParam,
- getCreateParam,
- getQueryStockParam,
- getBillDetailListParam
- } from './checkParams.js';
- export default {
- async create(FormId, selectedFID) {
- try {
- modal.loading("创建中,请耐心等待...");
- const createParam = getCreateParam(FormId);
- console.log(createParam)
- const createRes = await this.saveData(createParam);
- if (!createRes.IsSuccess) {
- throw new Error(createRes.Errors[0].Message);
- }
- console.log(createRes)
- //查询库存
- const queryStockParam = getQueryStockParam(createRes["SuccessEntitys"][0]["Id"], selectedFID);
- const queryStockRes = await this.queryStock(queryStockParam);
- if (queryStockRes["success"] !== "成功") {
- throw new Error(queryStockRes["result"]);
- }
- //查询盘点单明细
- const condition = this.createQueryBillDetailListCondition(createRes["SuccessEntitys"][0]["Id"]);
- const billDetailListParam = getBillDetailListParam(condition)
- const res = await this.fetchBillDetails(billDetailListParam)
- // if (res["success"] !== "成功") {
- // throw new Error(res["result"]);
- // }
- return res
- // this.handleSuccess(FID, indexList);
- } catch (error) {
- // this.handleError(error);
- throw new Error(error);
- } finally {
- modal.closeLoading();
- }
- },
- saveData(params) {
- return save(JSON.stringify(params))
- .then(res => res.Result.ResponseStatus);
- },
- submitData(params) {
- return submit(JSON.stringify(params))
- .then(res => res.Result.ResponseStatus);
- },
- queryStock(params) {
- return QueryStock(params)
- .then(res => res);
- },
- fetchBillDetails(billDetailListParam) {
- return getBillDetailList(JSON.stringify(billDetailListParam));
- },
- createQueryBillDetailListCondition(selected) {
- return {
- FormId: uni.getStorageSync('formId'),
- selectedFID: selected,
- FBillType: uni.getStorageSync('fbillType')
- };
- },
- auditData(params) {
- return audit(JSON.stringify(params))
- .then(res => res.Result.ResponseStatus);
- },
- handleSuccess(FID, indexList) {
- // Assuming that you pass indexList back to where it's needed
- uni.showModal({
- title: "提示",
- content: "提交成功",
- showCancel: true,
- success: (res) => {
- if (res.confirm) {
- // 用户点击确定
- } else {
- // 用户点击取消
- }
- }
- });
- playVoice(audioUrls.warningSuccessUrl);
- },
- handleError(error) {
- uni.showToast({
- title: error.message || '操作失败',
- duration: 3000,
- icon: "error"
- });
- playVoice(audioUrls.successVoiceUrl)
- console.error('操作失败:', error);
- }
- };
|