|
@@ -434,5 +434,73 @@ export default {
|
|
|
</div>
|
|
|
`;
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 备份方法
|
|
|
+ * 获取需要打印数据详情
|
|
|
+ * @param {Array} ids
|
|
|
+ */
|
|
|
+ async getDateils(ids, funcType = "getDeliverDetail") {
|
|
|
+ this.$startLoading();
|
|
|
+ let loadingLen;
|
|
|
+ // 兼容多个打印数据
|
|
|
+ ids = ids instanceof Array ? ids : [ids];
|
|
|
+ console.log(ids);
|
|
|
+ // 清空之前打印的数据
|
|
|
+ this.outputData = [];
|
|
|
+ // 筛选id
|
|
|
+ let formatting = [];
|
|
|
+
|
|
|
+ // 仓库认证请求接口参数
|
|
|
+ let params = [];
|
|
|
+
|
|
|
+ // 获取数据id
|
|
|
+ for (let i = ids.length; i > 0; i--) {
|
|
|
+ formatting.push(ids[i - 1].id || ids[i - 1]);
|
|
|
+ if (funcType === "getDtailPrintDis") {
|
|
|
+ params.push({
|
|
|
+ id: ids[i - 1].id,
|
|
|
+ invoiceId: ids[i - 1].invoiceId,
|
|
|
+ });
|
|
|
+ this.addIds.push(ids[i - 1].id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (funcType === "getDtailPrintDis") {
|
|
|
+ const requestParams = params;
|
|
|
+ try {
|
|
|
+ const { data } = await getDtailPrintDis(requestParams);
|
|
|
+ loadingLen = data.length;
|
|
|
+ for (let i = data.length; i > 0; i--) {
|
|
|
+ const newData = data[i - 1];
|
|
|
+ await this.setPrintData(newData);
|
|
|
+ loadingLen--;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$endLoading();
|
|
|
+ console.error("获取打印数据失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // id 去重
|
|
|
+ formatting = [...new Set(formatting)];
|
|
|
+ loadingLen = formatting.length;
|
|
|
+ for (let i = formatting.length; i > 0; i--) {
|
|
|
+ const requestParams = {
|
|
|
+ id: formatting[i - 1],
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ const { data } = await getDeliverDetail(requestParams);
|
|
|
+ this.setPrintData(data);
|
|
|
+ } catch (error) {
|
|
|
+ this.$endLoading();
|
|
|
+ this.$errorMsg(error)
|
|
|
+ console.error("获取打印数据失败");
|
|
|
+ }
|
|
|
+ loadingLen--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (loadingLen == 0) {
|
|
|
+ return Promise.resolve();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|