|
@@ -2,12 +2,16 @@
|
|
|
|
|
|
|
|
<headerBar
|
|
<headerBar
|
|
|
title="拍摄商品"
|
|
title="拍摄商品"
|
|
|
|
|
+ showUser
|
|
|
:menu="[
|
|
:menu="[
|
|
|
{
|
|
{
|
|
|
type:'setting'
|
|
type:'setting'
|
|
|
}
|
|
}
|
|
|
]"
|
|
]"
|
|
|
/>
|
|
/>
|
|
|
|
|
+
|
|
|
|
|
+ <hardware-check/>
|
|
|
|
|
+
|
|
|
<div class="photography-page flex-col">
|
|
<div class="photography-page flex-col">
|
|
|
<div class="main-container">
|
|
<div class="main-container">
|
|
|
<div class="content-wrapper flex-row">
|
|
<div class="content-wrapper flex-row">
|
|
@@ -155,13 +159,15 @@
|
|
|
</template>
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import headerBar from '@/components/header-bar/index.vue'
|
|
import headerBar from '@/components/header-bar/index.vue'
|
|
|
-import { ref, reactive, onMounted, onBeforeUnmount } from 'vue'
|
|
|
|
|
|
|
+import { ref, reactive, onMounted, onBeforeUnmount,watchEffect } from 'vue'
|
|
|
import icpList from '@/utils/ipc'
|
|
import icpList from '@/utils/ipc'
|
|
|
import client from "@/stores/modules/client";
|
|
import client from "@/stores/modules/client";
|
|
|
import socket from "@/stores/modules/socket";
|
|
import socket from "@/stores/modules/socket";
|
|
|
import { ElMessage ,ElMessageBox } from 'element-plus'
|
|
import { ElMessage ,ElMessageBox } from 'element-plus'
|
|
|
import { getFilePath,getRouterUrl } from '@/utils/appfun'
|
|
import { getFilePath,getRouterUrl } from '@/utils/appfun'
|
|
|
import {useRouter} from "vue-router";
|
|
import {useRouter} from "vue-router";
|
|
|
|
|
+import HardwareCheck from '@/components/check/index.vue'
|
|
|
|
|
+import checkInfo from "@/stores/modules/check";
|
|
|
|
|
|
|
|
|
|
|
|
|
const loading = ref(false)
|
|
const loading = ref(false)
|
|
@@ -183,13 +189,20 @@ const runAction = ref({
|
|
|
// 初始化 WebSocket 状态管理
|
|
// 初始化 WebSocket 状态管理
|
|
|
const socketStore = socket()
|
|
const socketStore = socket()
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 保存货号模板到货号变量中。
|
|
|
|
|
+ */
|
|
|
function saveGoodsArtNo(){
|
|
function saveGoodsArtNo(){
|
|
|
- if(goods_art_no_tpl.value) goods_art_no.value = goods_art_no_tpl.value
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if(goods_art_no_tpl.value){
|
|
|
|
|
+ goods_art_no.value = goods_art_no_tpl.value
|
|
|
|
|
+ ElMessage.success('商品货号'+goods_art_no.value+'获取成功,请在遥控器上按下左或右脚按键,启动拍摄')
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//获取拍照记录
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 获取拍照记录。
|
|
|
|
|
+ * @param params - 可选参数,用于分页或其他筛选条件。
|
|
|
|
|
+ */
|
|
|
async function getPhotoRecords(params?:{}) {
|
|
async function getPhotoRecords(params?:{}) {
|
|
|
clientStore.ipc.removeAllListeners(icpList.takePhoto.getPhotoRecords);
|
|
clientStore.ipc.removeAllListeners(icpList.takePhoto.getPhotoRecords);
|
|
|
loading.true = true;
|
|
loading.true = true;
|
|
@@ -210,7 +223,10 @@ async function getPhotoRecords(params?:{}) {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-//执行拍照 扫了货号,点击遥控器
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 执行拍照操作。
|
|
|
|
|
+ * @param data - 包含拍摄所需的数据对象。
|
|
|
|
|
+ */
|
|
|
async function runGoods(data) {
|
|
async function runGoods(data) {
|
|
|
console.log('aa2')
|
|
console.log('aa2')
|
|
|
await socketStore.connectSocket();
|
|
await socketStore.connectSocket();
|
|
@@ -220,19 +236,42 @@ async function runGoods(data) {
|
|
|
type: 'run_mcu',
|
|
type: 'run_mcu',
|
|
|
data,
|
|
data,
|
|
|
})
|
|
})
|
|
|
- console.log('aa4')
|
|
|
|
|
|
|
+
|
|
|
|
|
+ ElMessage.success('开始拍摄,请稍后')
|
|
|
runLoading.value = true;
|
|
runLoading.value = true;
|
|
|
runAction.value = data
|
|
runAction.value = data
|
|
|
goods_art_no.value = ''
|
|
goods_art_no.value = ''
|
|
|
goods_art_no_tpl.value = ''
|
|
goods_art_no_tpl.value = ''
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ clientStore.ipc.on(icpList.socket.message + '_run_mcu', (event, result) => {
|
|
|
|
|
+
|
|
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu');
|
|
|
|
|
+ console.log('_run_mcu');
|
|
|
|
|
+ console.log(result);
|
|
|
|
|
+ if(result.code !== 0 && result.msg){
|
|
|
|
|
+ ElMessage.error(result.msg)
|
|
|
|
|
+ runLoading.value = false
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 格式化时间字符串。
|
|
|
|
|
+ * @param time - 原始时间字符串。
|
|
|
|
|
+ * @returns 格式化后的时间字符串,若输入为空则返回 null。
|
|
|
|
|
+ */
|
|
|
const getTime = function(time){
|
|
const getTime = function(time){
|
|
|
if(!time) return null
|
|
if(!time) return null
|
|
|
return time.replace('T',' ').substr(5,11)
|
|
return time.replace('T',' ').substr(5,11)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 删除所有商品货号的历史记录。
|
|
|
|
|
+ */
|
|
|
async function delAll(){
|
|
async function delAll(){
|
|
|
let params = goodsList.value.map(item=>item.goods_art_no)
|
|
let params = goodsList.value.map(item=>item.goods_art_no)
|
|
|
await ElMessageBox.confirm('确定要删除当下的历史记录吗?', '提示', {
|
|
await ElMessageBox.confirm('确定要删除当下的历史记录吗?', '提示', {
|
|
@@ -241,6 +280,11 @@ async function delAll(){
|
|
|
})
|
|
})
|
|
|
del({goods_art_nos:params})
|
|
del({goods_art_nos:params})
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 删除指定的商品货号。
|
|
|
|
|
+ * @param params - 包含需要删除的货号列表的对象。
|
|
|
|
|
+ */
|
|
|
const del = async function(params){
|
|
const del = async function(params){
|
|
|
|
|
|
|
|
clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
|
|
clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
|
|
@@ -257,6 +301,9 @@ const del = async function(params){
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 检查是否可以进入下一步操作。
|
|
|
|
|
+ */
|
|
|
const next = async function(){
|
|
const next = async function(){
|
|
|
if(runLoading.value){
|
|
if(runLoading.value){
|
|
|
ElMessage.error('正在拍摄中,请稍候')
|
|
ElMessage.error('正在拍摄中,请稍候')
|
|
@@ -268,54 +315,44 @@ const next = async function(){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 页面挂载时初始化事件监听器并获取初始数据。
|
|
|
|
|
+ */
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
- //扫货号
|
|
|
|
|
|
|
+ // 监听蓝牙扫描事件
|
|
|
clientStore.ipc.on(icpList.socket.message + '_blue_tooth_scan', (event, result) => {
|
|
clientStore.ipc.on(icpList.socket.message + '_blue_tooth_scan', (event, result) => {
|
|
|
|
|
|
|
|
console.log('_blue_tooth_scan')
|
|
console.log('_blue_tooth_scan')
|
|
|
if (result.code === 0 && result.data?.data) {
|
|
if (result.code === 0 && result.data?.data) {
|
|
|
- if(result.data?.data.goods_art_no) runGoods(result.data?.data)
|
|
|
|
|
- if(!result.data?.data.goods_art_no && goods_art_no.value){
|
|
|
|
|
- console.log('aa')
|
|
|
|
|
- console.log('手工')
|
|
|
|
|
- console.log({
|
|
|
|
|
- ...result.data?.data,
|
|
|
|
|
- goods_art_no: goods_art_no.value
|
|
|
|
|
- })
|
|
|
|
|
- runGoods({
|
|
|
|
|
- ...result.data?.data,
|
|
|
|
|
- goods_art_no: goods_art_no.value
|
|
|
|
|
- })
|
|
|
|
|
- console.log('aa1')
|
|
|
|
|
|
|
+ console.log(goods_art_no.value);
|
|
|
|
|
+ if(!goods_art_no.value){
|
|
|
|
|
+ ElMessage.error('请先扫描货号或者手动输入货号!')
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+ runGoods({
|
|
|
|
|
+ ...result.data?.data,
|
|
|
|
|
+ goods_art_no: goods_art_no.value
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+
|
|
|
await getPhotoRecords();
|
|
await getPhotoRecords();
|
|
|
- // 扫码后 货号入库
|
|
|
|
|
|
|
+ // 监听图片处理完成事件
|
|
|
clientStore.ipc.on(icpList.socket.message + '_image_process', (event, result) => {
|
|
clientStore.ipc.on(icpList.socket.message + '_image_process', (event, result) => {
|
|
|
console.log('_image_process')
|
|
console.log('_image_process')
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
getPhotoRecords()
|
|
getPhotoRecords()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-/*
|
|
|
|
|
- clientStore.ipc.on(icpList.socket.message + '_mcu', (event, result) => {
|
|
|
|
|
- console.log('_mcu')
|
|
|
|
|
- console.log(result)
|
|
|
|
|
-
|
|
|
|
|
- })
|
|
|
|
|
-*/
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 监听拍照完成事件
|
|
|
clientStore.ipc.on(icpList.socket.message + '_photo_take', (event, result) => {
|
|
clientStore.ipc.on(icpList.socket.message + '_photo_take', (event, result) => {
|
|
|
console.log('_photo_take')
|
|
console.log('_photo_take')
|
|
|
console.log(result)
|
|
console.log(result)
|
|
|
if(result.status === 2 && result.msg.includes('执行完成')){
|
|
if(result.status === 2 && result.msg.includes('执行完成')){
|
|
|
getPhotoRecords()
|
|
getPhotoRecords()
|
|
|
- //延迟两秒在获取一遍
|
|
|
|
|
|
|
+ // 延迟两秒再获取一遍数据
|
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
|
getPhotoRecords()
|
|
getPhotoRecords()
|
|
|
},2000)
|
|
},2000)
|
|
@@ -324,7 +361,7 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 监听拍照完成后的最终状态事件
|
|
|
clientStore.ipc.on(icpList.socket.message + '_photo_take_finish', (event, result) => {
|
|
clientStore.ipc.on(icpList.socket.message + '_photo_take_finish', (event, result) => {
|
|
|
console.log('_photo_take_finish')
|
|
console.log('_photo_take_finish')
|
|
|
console.log(result)
|
|
console.log(result)
|
|
@@ -332,7 +369,7 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // 监听手动触发拍照事件
|
|
|
clientStore.ipc.on(icpList.socket.message + '_handler_take_picture', async (event, result) => {
|
|
clientStore.ipc.on(icpList.socket.message + '_handler_take_picture', async (event, result) => {
|
|
|
console.log('_photo_take_finish')
|
|
console.log('_photo_take_finish')
|
|
|
console.log(result)
|
|
console.log(result)
|
|
@@ -341,6 +378,9 @@ onMounted(async () => {
|
|
|
ElMessage.error('拍摄程序正在运行,请稍候')
|
|
ElMessage.error('拍摄程序正在运行,请稍候')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ ElMessage.success('正在拍摄中,请稍候')
|
|
|
|
|
+
|
|
|
await socketStore.connectSocket();
|
|
await socketStore.connectSocket();
|
|
|
socketStore.sendMessage(result.data)
|
|
socketStore.sendMessage(result.data)
|
|
|
takePictureLoading.value = true;
|
|
takePictureLoading.value = true;
|
|
@@ -349,25 +389,35 @@ onMounted(async () => {
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+const checkInfoStore = checkInfo()
|
|
|
|
|
+checkInfoStore.set_blue_tooth_scan_NO('')
|
|
|
|
|
+watchEffect(async ()=>{
|
|
|
|
|
+ if(checkInfoStore.blue_tooth_scan_NO){
|
|
|
|
|
+ ElMessage.success('商品货号'+checkInfoStore.blue_tooth_scan_NO+'获取成功,请在遥控器上按下左或右脚按键,启动拍摄')
|
|
|
|
|
+ goods_art_no.value = checkInfoStore.blue_tooth_scan_NO
|
|
|
|
|
+ checkInfoStore.set_blue_tooth_scan_NO('')
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-//关闭页面 去掉监听
|
|
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 页面卸载时移除所有事件监听器。
|
|
|
|
|
+ */
|
|
|
onBeforeUnmount(() => {
|
|
onBeforeUnmount(() => {
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_blue_tooth_scan');
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_blue_tooth_scan');
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_image_process');
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_image_process');
|
|
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu');
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take');
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take');
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take_finish');
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_photo_take_finish');
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-//打开主图详情
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 打开主图详情页面。
|
|
|
|
|
+ */
|
|
|
function openPhotographyDetail() {
|
|
function openPhotographyDetail() {
|
|
|
|
|
|
|
|
const { href } = Router.resolve({
|
|
const { href } = Router.resolve({
|
|
@@ -391,6 +441,7 @@ function openPhotographyDetail() {
|
|
|
|
|
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
|
|
+
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
|
.shot-image-popper {
|
|
.shot-image-popper {
|
|
|
width: calc(100vw - 370px) !important;
|
|
width: calc(100vw - 370px) !important;
|