panqiuyao пре 8 месеци
родитељ
комит
bbcf35a006
1 измењених фајлова са 49 додато и 29 уклоњено
  1. 49 29
      frontend/src/views/Photography/shot.vue

+ 49 - 29
frontend/src/views/Photography/shot.vue

@@ -183,13 +183,17 @@ const runAction = ref({
 // 初始化 WebSocket 状态管理
 const socketStore = socket()
 
-
+/**
+ * 保存货号模板到货号变量中。
+ */
 function saveGoodsArtNo(){
   if(goods_art_no_tpl.value) goods_art_no.value = goods_art_no_tpl.value
-
 }
 
-//获取拍照记录
+/**
+ * 获取拍照记录。
+ * @param params - 可选参数,用于分页或其他筛选条件。
+ */
 async function getPhotoRecords(params?:{}) {
   clientStore.ipc.removeAllListeners(icpList.takePhoto.getPhotoRecords);
   loading.true = true;
@@ -210,7 +214,10 @@ async function getPhotoRecords(params?:{}) {
   });
 }
 
-//执行拍照   扫了货号,点击遥控器
+/**
+ * 执行拍照操作。
+ * @param data - 包含拍摄所需的数据对象。
+ */
 async function runGoods(data) {
   console.log('aa2')
   await socketStore.connectSocket();
@@ -220,6 +227,11 @@ async function runGoods(data) {
     type: 'run_mcu',
     data,
   })
+
+  ElMessage({
+    message: '开始拍摄,请稍后',
+    type: 'success',
+  })
   console.log('aa4')
   runLoading.value = true;
   runAction.value = data
@@ -227,12 +239,19 @@ async function runGoods(data) {
   goods_art_no_tpl.value = ''
 }
 
-
-
+/**
+ * 格式化时间字符串。
+ * @param time - 原始时间字符串。
+ * @returns 格式化后的时间字符串,若输入为空则返回 null。
+ */
 const getTime = function(time){
   if(!time) return null
   return time.replace('T',' ').substr(5,11)
 }
+
+/**
+ * 删除所有商品货号的历史记录。
+ */
 async function delAll(){
     let params = goodsList.value.map(item=>item.goods_art_no)
     await ElMessageBox.confirm('确定要删除当下的历史记录吗?', '提示', {
@@ -241,6 +260,11 @@ async function delAll(){
     })
     del({goods_art_nos:params})
 }
+
+/**
+ * 删除指定的商品货号。
+ * @param params - 包含需要删除的货号列表的对象。
+ */
 const del = async function(params){
 
   clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
@@ -257,6 +281,9 @@ const del = async function(params){
 
 }
 
+/**
+ * 检查是否可以进入下一步操作。
+ */
 const  next = async function(){
   if(runLoading.value){
     ElMessage.error('正在拍摄中,请稍候')
@@ -268,9 +295,11 @@ const  next = async function(){
   }
 }
 
-
+/**
+ * 页面挂载时初始化事件监听器并获取初始数据。
+ */
 onMounted(async () => {
-  //扫货号
+  // 监听蓝牙扫描事件
   clientStore.ipc.on(icpList.socket.message + '_blue_tooth_scan', (event, result) => {
 
     console.log('_blue_tooth_scan')
@@ -294,28 +323,20 @@ onMounted(async () => {
   });
 
   await getPhotoRecords();
-  // 扫码后 货号入库
+  // 监听图片处理完成事件
   clientStore.ipc.on(icpList.socket.message + '_image_process', (event, result) => {
     console.log('_image_process')
     console.log(result)
     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) => {
     console.log('_photo_take')
     console.log(result)
     if(result.status === 2 && result.msg.includes('执行完成')){
       getPhotoRecords()
-      //延迟两秒在获取一遍
+      // 延迟两秒再获取一遍数据
       setTimeout(()=>{
         getPhotoRecords()
       },2000)
@@ -324,7 +345,7 @@ onMounted(async () => {
 
   })
 
-
+  // 监听拍照完成后的最终状态事件
   clientStore.ipc.on(icpList.socket.message + '_photo_take_finish', (event, result) => {
     console.log('_photo_take_finish')
     console.log(result)
@@ -332,7 +353,7 @@ onMounted(async () => {
 
   })
 
-
+  // 监听手动触发拍照事件
   clientStore.ipc.on(icpList.socket.message + '_handler_take_picture', async (event, result) => {
     console.log('_photo_take_finish')
     console.log(result)
@@ -349,13 +370,11 @@ onMounted(async () => {
 
   })
 
-
-
-
-
 })
 
-//关闭页面  去掉监听
+/**
+ * 页面卸载时移除所有事件监听器。
+ */
 onBeforeUnmount(() => {
   clientStore.ipc.removeAllListeners(icpList.socket.message + '_blue_tooth_scan');
   clientStore.ipc.removeAllListeners(icpList.socket.message + '_image_process');
@@ -365,9 +384,9 @@ onBeforeUnmount(() => {
 
 })
 
-
-
-//打开主图详情
+/**
+ * 打开主图详情页面。
+ */
 function openPhotographyDetail() {
 
   const { href } = Router.resolve({
@@ -391,6 +410,7 @@ function openPhotographyDetail() {
 
 </script>
 
+
 <style  lang="scss">
 .shot-image-popper {
   width: calc(100vw - 370px) !important;