Browse Source

fix: 暂存

Hello小健 2 months ago
parent
commit
2a3357376e

+ 92 - 0
components/printerListScan.vue

@@ -0,0 +1,92 @@
+<template>
+	<uni-popup v-model="printerList!.visible">
+		<uni-popup-dialog ref="inputClose" mode="input" title="输入内容" value="对话框预置提示内容!" placeholder="请输入内容" @confirm="dialogInputConfirm">
+			<template #default>
+				<text class="title">
+					{{ printerList.title }}
+					<text class="ml-2">{{ printerList?.postData?.order_no }}</text>
+				</text>
+			</template>
+			<view v-if="printerList">
+				<view><el-checkbox label="下载文件" v-model="downloadFile" :disabled="true"></el-checkbox></view>
+				<view class="ml-4">
+			<!-- 		<view>
+						<el-checkbox label="发送到标签打印机打印" v-model="sendToPeinter" @change="sendToPeinterFun"></el-checkbox>
+					</view>
+					<el-radio-group v-model="printer_code">
+						<el-radio v-for="(item, i) in printerList.printers as any" :key="i" :label="item.value">{{ item.name }}</el-radio>
+					</el-radio-group> -->
+				</view>
+			</view>
+		</uni-popup-dialog>
+
+		
+		<!-- <template #footer>
+			<div>
+				<el-button @click="printerList.visible = false">{{ t('Cancel') }}</el-button>
+				<el-button :loading="submitLoading" @click="toPrint()" type="primary" v-blur>
+					{{ '打印' }}
+				</el-button>
+			</div>
+		</template> -->
+	</uni-popup>
+</template>
+<script setup lang="ts">
+import { inject, ref } from 'vue';
+const printerList = inject('printerList') as any;
+const printer_code = ref('');
+const submitLoading = ref(false);
+const downloadFile = ref(true);
+const sendToPeinter = ref(true);
+const sendToPeinterFun = () => {
+	if (!sendToPeinter.value) {
+		printer_code.value = '';
+	} else {
+		printer_code.value = Object.keys(printerList.value.printers)[0];
+	}
+};
+const dialogInputConfirm = () => {
+	printerList.value && (printer_code.value = Object.keys(printerList.value.printers)[0]);
+};
+const openPrinterSelect = () => {
+	printerList.value && (printer_code.value = Object.keys(printerList.value.printers)[0]);
+};
+const toPrint = async () => {
+	const { postPrint, postData, resetForm } = printerList.value;
+	/*
+    const loading = ElLoading.service({
+        lock: true,
+        text: 'Loading',
+        background: 'rgba(0, 0, 0, 0.7)',
+    })
+    */
+	submitLoading.value = true;
+	await postPrint({
+		...postData,
+		printer_code: printer_code.value
+	})
+		.then((res: any) => {
+			//loading.close()
+			const list = res.data?.label_path || res.data?.labels || (res.data?.express_label ? [res.data?.express_label] : []);
+			if (list.length === 0) {
+				// ElMessage.error('没有可打印的文件');
+				return;
+			}
+
+			list.map((url: string) => {
+				let path = fullUrl(url);
+				window.open(path, '_blank');
+			});
+			submitLoading.value = false;
+			printerList.value.visible = false;
+			resetForm();
+		})
+		.catch((error: any) => {
+			console.log('error--', error);
+			//loading.close()
+			submitLoading.value = false;
+		});
+};
+</script>
+
+<style scoped lang="scss"></style>

+ 9 - 1
pages/instock/index.vue

@@ -97,11 +97,12 @@
 				@close="dialogClose"
 			></uni-popup-dialog>
 		</uni-popup>
+		<PrinterListScan></PrinterListScan>
 	</view>
 </template>
 <script>
 import permision from '@/common/permission.js';
-import { ref, reactive, nextTick } from 'vue';
+import { ref, reactive, nextTick, provide } from 'vue';
 import { instockScanURL, outStockScanURL, weighScanURL, checkWaybillGoodsURL, getWarehouseSpaceURL, getBindParamsURL } from '@/utils/api.js';
 export default {
 	data() {
@@ -115,6 +116,7 @@ export default {
 			messageText: '',
 			batchOptions: [],
 			spaces: [],
+			printerList: {},
 			instockHistory: [],
 			focusType: true,
 			loading,
@@ -146,6 +148,11 @@ export default {
 			]
 		};
 	},
+	provide() {
+		return {
+			printerList: this.printerList
+		};
+	},
 	computed: {
 		rules: function () {
 			return {
@@ -361,6 +368,7 @@ export default {
 
 						if (res.data.data.labels && res.data.data.labels.length > 0) {
 							console.log('有打印面单');
+
 							// res.data.data.labels.map((url: string) => {
 							// 	let path = fullUrl(url);
 							// 	window.open(path, '_blank');

+ 3 - 3
unpackage/dist/cache/.vite/deps/_metadata.json

@@ -1,8 +1,8 @@
 {
-  "hash": "dcd2c785",
-  "configHash": "942b9c46",
+  "hash": "adf7464e",
+  "configHash": "fd42d985",
   "lockfileHash": "e3b0c442",
-  "browserHash": "23c10dde",
+  "browserHash": "d1f8efbb",
   "optimized": {},
   "chunks": {}
 }