sunChengjie 11 months ago
parent
commit
20398cbb01
1 changed files with 38 additions and 3 deletions
  1. 38 3
      src/pages/inexpress.vue

+ 38 - 3
src/pages/inexpress.vue

@@ -66,7 +66,7 @@
 		</div>
 		<!-- 寄件 -->
 		<div class="btn-jj">
-			<van-button type="info" color="#00c4b8" @click="save()">立即寄件</van-button>
+			<van-button type="info" color="#00c4b8" @click="printer()">立即寄件</van-button>
 		</div>
 		<!-- 弹窗物品类型 -->
 		<van-popup v-model="wpshow" position="bottom">
@@ -108,13 +108,22 @@
 				退出
 			</van-button>
 		</van-popup>
+
+		<!-- 打印机选择器 -->
+		<van-popup v-model="printerShow" position="bottom">
+			<van-picker show-toolbar :columns="getPrintersList" @confirm="onPrinter" @cancel="printerShow = false">
+				<template v-slot:option="value">
+					{{ value.printerName }}
+				</template>
+			</van-picker>
+		</van-popup>
 	</div>
 </template>
 
 <script>
 import areaList from "@/script/areas.js"
 import { Stepper, Toast } from 'vant';
-import { saveInternal, getUserByName } from '../api/index'
+import { saveInternal, getUserByName, getListOfPrinters } from '../api/index'
 export default {
 	data() {
 		return {
@@ -174,6 +183,9 @@ export default {
 			searchNameList: [],//搜索后的数据
 			searchNameListPhone: [],//手机号搜索后的数据
 			groupValue: {},//点击后的数据
+
+			getPrintersList: [],// 打印机列表
+			printerShow: false
 		}
 	},
 	created: function () {
@@ -267,8 +279,29 @@ export default {
 		link(obj) {
 			this.$router.push({ path: '/Inaddressbook', query: { active: obj } })
 		},
+		async printer() {
+			const getPrinters = await getListOfPrinters({})
+			if (getPrinters.code == 0) {
+				this.getPrintersList = getPrinters.data.map((item) => {
+					return { printerName: item.printerName, id: item.id }
+				})
+				if (this.getPrintersList.length === 1) {
+					this.save(this.getPrintersList[0].id)
+					return
+				}
+				this.printerShow = true
+			} else {
+				Toast('系统异常')
+			}
+			return
+		},
+		async onPrinter(e) {
+			const printerId = e.id;
+			this.save(printerId)
+
+		},
 		//立即寄件交互
-		async save() {
+		async save(printerId) {
 
 			if (this.recipientsName == '' || this.recipientsName == undefined) {
 				return Toast('请输入收件人姓名')
@@ -289,6 +322,7 @@ export default {
 				return
 			}
 
+
 			const toast = Toast.loading({
 				message: '保存中...',
 				forbidClick: true,
@@ -306,6 +340,7 @@ export default {
 				expressNum: this.stepper, //快递数量
 				expressRemark: this.bz,//快递备注
 				expressWeight: this.Kilogram,//公斤
+				printId: printerId
 
 			}
 			const res = await saveInternal({ ...parmas })