From dcf1ad6b38b1c9c78dc866ecb5ed28ab06b09011 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 13 Oct 2024 09:47:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E3=80=91=E5=95=86=E5=9F=8E=EF=BC=9A=E9=97=A8=E5=BA=97=E8=87=AA?= =?UTF-8?q?=E6=8F=90=E7=9A=84=E5=91=98=E5=B7=A5=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/trade/delivery/pickUpStore/index.ts | 14 +- .../mall/trade/delivery/pickUpOrder/index.vue | 140 ++++++++++-------- .../DeliveryPickUpStoreBindForm.vue | 78 ++++------ .../components/StoreStaffTableSelect.vue | 15 +- .../mall/trade/delivery/pickUpStore/index.vue | 7 +- src/views/mall/trade/order/index.vue | 2 +- .../member/user/detail/UserOrderList.vue | 2 +- 7 files changed, 122 insertions(+), 136 deletions(-) diff --git a/src/api/mall/trade/delivery/pickUpStore/index.ts b/src/api/mall/trade/delivery/pickUpStore/index.ts index 01e59522..ea6c852b 100644 --- a/src/api/mall/trade/delivery/pickUpStore/index.ts +++ b/src/api/mall/trade/delivery/pickUpStore/index.ts @@ -13,10 +13,11 @@ export interface DeliveryPickUpStoreVO { latitude: number longitude: number status: number + verifyUserIds: number[] // 绑定用户编号组数 } // 查询自提门店列表 -export const getDeliveryPickUpStorePage = async (params) => { +export const getDeliveryPickUpStorePage = async (params: any) => { return await request.get({ url: '/trade/delivery/pick-up-store/page', params }) } @@ -26,8 +27,8 @@ export const getDeliveryPickUpStore = async (id: number) => { } // 查询自提门店精简列表 -export const getListAllSimple = async (): Promise => { - return await request.get({ url: '/trade/delivery/pick-up-store/list-all-simple' }) +export const getSimpleDeliveryPickUpStoreList = async (): Promise => { + return await request.get({ url: '/trade/delivery/pick-up-store/simple-list' }) } // 新增自提门店 @@ -45,12 +46,7 @@ export const deleteDeliveryPickUpStore = async (id: number) => { return await request.delete({ url: '/trade/delivery/pick-up-store/delete?id=' + id }) } -//绑定自提店员 +// 绑定自提店员 export const bindStoreStaffId = async (data: any) => { return await request.post({ url: '/trade/delivery/pick-up-store/bind', data }) } - -//查询门店绑定情况 -export const getDeliveryPickUpStoreStaff = async (id: number) => { - return await request.get({ url: '/trade/delivery/pick-up-store/get-store-staff?id=' + id }) -} diff --git a/src/views/mall/trade/delivery/pickUpOrder/index.vue b/src/views/mall/trade/delivery/pickUpOrder/index.vue index 06ec835b..e864dd3e 100644 --- a/src/views/mall/trade/delivery/pickUpOrder/index.vue +++ b/src/views/mall/trade/delivery/pickUpOrder/index.vue @@ -72,7 +72,13 @@ 重置 - + 核销 @@ -221,26 +227,20 @@ import { DeliveryTypeEnum } from '@/utils/constants' import { TradeOrderSummaryRespVO } from '@/api/mall/trade/order' import { DeliveryPickUpStoreVO } from '@/api/mall/trade/delivery/pickUpStore' import OrderPickUpForm from '@/views/mall/trade/order/form/OrderPickUpForm.vue' -import { ref, onMounted } from "vue"; +import { ref, onMounted } from 'vue' +import { useUserStore } from '@/store/modules/user' const message = useMessage() // 消息弹窗 -const port = ref(""); -const ports = ref([]); -const reader = ref(""); +const port = ref('') +const ports = ref([]) +const reader = ref('') defineOptions({ name: 'PickUpOrder' }) -// 列表的加载中 -const loading = ref(true) -// 列表的总页数 -const total = ref(2) -// 列表的数据 -const list = ref([]) -// 搜索的表单 -const queryFormRef = ref() -const serialPort = ref(false) -const isUse = ref(true) -// 初始表单参数 +const loading = ref(true) // 列表的加载中 +const total = ref(2) // 列表的总页数 +const list = ref([]) // 列表的数据 +const queryFormRef = ref() // 搜索的表单 const INIT_QUERY_PARAMS = { // 页数 pageNo: 1, @@ -251,15 +251,15 @@ const INIT_QUERY_PARAMS = { // 配送方式 deliveryType: DeliveryTypeEnum.PICK_UP.type, // 自提门店 - pickUpStoreId: undefined -} + pickUpStoreId: -1 +} // 初始表单参数 -// 表单搜索 -const queryParams = ref({ ...INIT_QUERY_PARAMS }) -// 订单搜索类型 queryParam -const queryType = reactive({ queryParam: 'no' }) -// 订单统计数据 -const summary = ref() +const queryParams = ref({ ...INIT_QUERY_PARAMS }) // 表单搜索 +const queryType = reactive({ queryParam: 'no' }) // 订单搜索类型 queryParam +const summary = ref() // 订单统计数据 + +const serialPort = ref(false) // 是否连接扫码枪 +const isUse = ref(true) // 是否可核销 // 订单聚合搜索 select 类型配置(动态搜索) const dynamicSearchList = ref([ @@ -308,7 +308,7 @@ const handleQuery = async () => { const resetQuery = () => { queryFormRef.value?.resetFields() queryParams.value = { ...INIT_QUERY_PARAMS } - if(pickUpStoreList.value.length > 0) { + if (pickUpStoreList.value.length > 0) { queryParams.value.pickUpStoreId = pickUpStoreList.value[0].id } handleQuery() @@ -317,7 +317,12 @@ const resetQuery = () => { /** 自提门店精简列表 */ const pickUpStoreList = ref([]) const getPickUpStoreList = async () => { - pickUpStoreList.value = await PickUpStoreApi.getListAllSimple() + pickUpStoreList.value = await PickUpStoreApi.getSimpleDeliveryPickUpStoreList() + // 移除自己无法核销的门店 + const userId = useUserStore().getUser.id + pickUpStoreList.value = pickUpStoreList.value.filter((item) => + item.verifyUserIds?.includes(userId) + ) } /** 显示核销表单 */ @@ -330,85 +335,92 @@ const handlePickup = () => { const connectToSerialPort = async () => { try { // 判断浏览器支持串口通信 - if ("serial" in navigator && navigator.serial != null && typeof navigator.serial === 'object' && "requestPort" in navigator.serial) { + if ( + 'serial' in navigator && + navigator.serial != null && + typeof navigator.serial === 'object' && + 'requestPort' in navigator.serial + ) { // 提示用户选择一个串口 - port.value = await navigator.serial.requestPort(); + port.value = await navigator.serial.requestPort() } else { - message.error("浏览器不支持扫码枪连接,请更换浏览器重试") + message.error('浏览器不支持扫码枪连接,请更换浏览器重试') return } // 获取用户之前授予该网站访问权限的所有串口。 - ports.value = await navigator.serial.getPorts(); + ports.value = await navigator.serial.getPorts() // console.log(port.value, ports.value); - console.log(port.value); + // console.log(port.value) // 等待串口打开 - await port.value.open({ baudRate: 9600 , dataBits: 8 , stopBits: 2}); + await port.value.open({ baudRate: 9600, dataBits: 8, stopBits: 2 }) // console.log(typeof port.value); - message.success("成功连接扫码枪") - serialPort.value = true; + message.success('成功连接扫码枪') + serialPort.value = true // readData(port.value); - readData(); + readData() } catch (error) { // 处理连接串口出错的情况 - console.log("Error connecting to serial port:", error); + console.log('Error connecting to serial port:', error) } -}; +} /** 监听扫码枪输入 */ const readData = async () => { - reader.value = port.value.readable.getReader(); - let data = ""; //扫码数据 + reader.value = port.value.readable.getReader() + let data = '' //扫码数据 // 监听来自串口的数据 while (true) { - const { value, done } = await reader.value.read(); + const { value, done } = await reader.value.read() if (done) { // 允许稍后关闭串口 - reader.value.releaseLock(); - break; + reader.value.releaseLock() + break } // 获取发送的数据 - const serialData = new TextDecoder().decode(value); - data = `${data}${serialData}`; - if (serialData.includes("\r")) { + const serialData = new TextDecoder().decode(value) + data = `${data}${serialData}` + if (serialData.includes('\r')) { //读取结束 - let codeData = data.replace("\r",""); - data = ""; //清空下次读取不会叠加 - console.log(`二维码数据:${codeData}`); + let codeData = data.replace('\r', '') + data = '' //清空下次读取不会叠加 + console.log(`二维码数据:${codeData}`) //处理拿到数据逻辑 pickUpForm.value.open(codeData) } } -}; +} /** 断开扫码枪 */ const cutPort = async () => { - if (port.value !== "") { - await reader.value.cancel(); - await port.value.close(); - port.value = ""; - console.log("断开扫码枪连接"); - message.success("已成功断开扫码枪连接") - serialPort.value = false; + if (port.value !== '') { + await reader.value.cancel() + await port.value.close() + port.value = '' + console.log('断开扫码枪连接') + message.success('已成功断开扫码枪连接') + serialPort.value = false } else { - message.warning("请先连接或打开扫码枪") + message.warning('请先连接或打开扫码枪') } -}; +} /** 初始化 **/ onMounted(async () => { await getPickUpStoreList() - if(pickUpStoreList.value.length > 0){ - queryParams.value.pickUpStoreId = pickUpStoreList.value[0].id - isUse.value = false - await getList() - }else{ - message.error("当前登录人没绑定任何自提点") + if (pickUpStoreList.value.length === 0) { + message.error('当前登录人没绑定任何自提点') loading.value = false isUse.value = true + return } + + // 查询 + queryParams.value.pickUpStoreId = pickUpStoreList.value[0].id + isUse.value = false + await getList() })