浏览代码

mod:拍摄商品 调整

panqiuyao 7 月之前
父节点
当前提交
83d2ff57b5

+ 10 - 0
electron/api/takephoto.js

@@ -26,4 +26,14 @@ module.exports = {
     })
   },
 
+  getLastPhotoRecord(data){
+    return get({
+      url: '/get_last_photo_record',
+      data: data
+    })
+  },
+
+
+
+
 }

+ 16 - 1
electron/controller/takephoto.js

@@ -1,6 +1,6 @@
 'use strict';
 const { Controller } = require('ee-core');
-const  { getPhotoRecords,delectGoodsArts,createMainImage } =  require('../api/takephoto');
+const  { getPhotoRecords,delectGoodsArts,createMainImage,getLastPhotoRecord } =  require('../api/takephoto');
 const errData = {
   msg :'请求失败,请联系管理员',
   code:999
@@ -69,6 +69,21 @@ class takePhotoController extends Controller {
     }
   }
 
+  async getLastPhotoRecord (params) {
+    console.log('getLastPhotoRecord')
+    try {
+      const result = await getLastPhotoRecord(params);
+      console.log('result')
+      console.log(result)
+      if(result.data)  return result.data
+      return errData;
+    } catch (error) {
+      console.log('error')
+      console.log(error)
+      return errData;
+    }
+  }
+
 
 }
 

+ 2 - 1
frontend/src/utils/ipc.ts

@@ -32,7 +32,8 @@ const icpList = {
     takePhoto:{
         getPhotoRecords: 'controller.takephoto.getPhotoRecords',
         delectGoodsArts: 'controller.takephoto.delectGoodsArts',
-        createMainImage: 'controller.takephoto.createMainImage'
+        createMainImage: 'controller.takephoto.createMainImage',
+        getLastPhotoRecord: 'controller.takephoto.getLastPhotoRecord'
     },
     generate:{
         generatePhotoDetail: 'controller.generate.generatePhotoDetail',

+ 2 - 0
frontend/src/views/Photography/detail.vue

@@ -14,6 +14,8 @@
           <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
           主图LOGO:
         </div>
+      </div>
+      <div class="logo-section flex left top">
         <upload :value="form.logo_path" @input="onInput"></upload>
       </div>
 

+ 82 - 4
frontend/src/views/Photography/shot.vue

@@ -62,6 +62,11 @@
         </div>
 
       </div>
+
+      <div class="last-photo" v-show="showlastPhoto" v-key="lastPhoto.image_path">
+        <div>{{lastPhtotoName[lastPhoto.image_index] || ''}}</div>
+        <el-image  :src="getFilePath(lastPhoto.image_path)"  fit="contain" ></el-image>
+      </div>
       <div class="history-section flex-col">
           <span class="history-title flex between">
             <div>拍摄记录</div>
@@ -266,6 +271,12 @@ async function getPhotoRecords(params?:{}) {
     clientStore.ipc.removeAllListeners(icpList.takePhoto.getPhotoRecords);
     if(result.code === 0){
      goodsList.value = result.data.list
+      if(isDelGoodsGetList.value){
+        isDelGoodsGetList.value = false;
+        return;
+      }
+      getLastPhotoRecord()
+
     }else if(result.msg) {
       ElMessage.error(result.msg)
     }
@@ -290,6 +301,7 @@ async function runGoods(data) {
   })
   ElMessage.success('开始拍摄,请稍后')
   runLoading.value = true;
+  console.log(runAction.value);
   runAction.value = data
   goods_art_no.value = ''
   goods_art_no_tpl.value = ''
@@ -351,6 +363,7 @@ const delGoods = async function(params){
  * 删除指定的商品货号。
  * @param params - 包含需要删除的货号列表的对象。
  */
+const isDelGoodsGetList = ref(false)
 const del = async function(params){
 
   clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
@@ -358,6 +371,7 @@ const del = async function(params){
   clientStore.ipc.on(icpList.takePhoto.delectGoodsArts, (event, result) => {
     clientStore.ipc.removeAllListeners(icpList.takePhoto.delectGoodsArts);
     if(result.code === 0){
+      isDelGoodsGetList.value =true
       ElMessage.info('货号删除成功')
       getPhotoRecords()
       if(reNosObj.value.goods_art_no){
@@ -391,6 +405,9 @@ const reTakePicture = async (record_id)=>{
     console.log(result)
     if(result.code === 0){
       getPhotoRecords()
+      setTimeout(()=>{
+        showlastPhoto.value = false
+      },6000)
     }else if(result.msg) {
       ElMessage.error(result.msg)
     }
@@ -489,13 +506,18 @@ onMounted(async () => {
   clientStore.ipc.on(icpList.socket.message + '_photo_take_finish', (event, result) => {
     console.log('_photo_take_finish')
     console.log(result)
-    if(result.code === 0) runLoading.value = false;
+    if(result.code === 0) {
+      runLoading.value = false;
+      setTimeout(()=>{
+        showlastPhoto.value = false
+      },5000)
+    }
 
   })
 
   // 监听手动触发拍照事件
   clientStore.ipc.on(icpList.socket.message + '_handler_take_picture', async (event, result) => {
-    console.log('_photo_take_finish')
+    console.log('_handler_take_picture')
     console.log(result)
     if(result.code === 0){
       if(runLoading.value || takePictureLoading.value){
@@ -523,6 +545,21 @@ onMounted(async () => {
 
 
 const onRemoteControl = (type)=>{
+  if(type == 'take_picture'){
+
+    if(runLoading.value || takePictureLoading.value){
+      ElMessage.error('拍摄程序正在运行,请稍候')
+      return
+    }
+
+    ElMessage.success('正在拍摄中,请稍候')
+    socketStore.sendMessage({
+      type: 'handler_take_picture',
+    })
+    return;
+  }
+
+
   if(!goods_art_no.value){
     ElMessage.error('请先扫描货号或者手动输入货号!')
     return;
@@ -577,6 +614,40 @@ onBeforeUnmount(() => {
 
 })
 
+/*
+* 打开最近一张拍摄图
+* */
+const lastPhoto = ref({})
+const showlastPhoto = ref(false)
+const lastPhtotoName = ref({
+  0:"俯视图",
+  1:"侧视图",
+  2:"后视图",
+  3:"鞋底",
+  4:"内里",
+})
+const  getLastPhotoRecord = async ()=>{
+  if(goodsList.value && goodsList.value.length === 0) return;
+  clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
+  clientStore.ipc.send(icpList.takePhoto.getLastPhotoRecord,);
+
+  clientStore.ipc.on(icpList.takePhoto.getLastPhotoRecord, (event, result) => {
+    console.log('getLastPhotoRecord')
+    console.log(result)
+    clientStore.ipc.removeAllListeners(icpList.takePhoto.getLastPhotoRecord);
+    if(result.code === 0){
+      if(lastPhoto.value.image_path){
+        if(  lastPhoto.value.image_path == result.data.image_path) return;
+        showlastPhoto.value = true
+      }
+      lastPhoto.value = result.data
+    }else if(result.msg) {
+      ElMessage.error(result.msg)
+    }
+  });
+}
+
+
 /**
  * 打开主图详情页面。
  */
@@ -1049,9 +1120,9 @@ function openPhotographyDetail() {
           height: 1px;
           margin-top: 9px;
         }
+  width: 100%;
 
         .history-warp {
-          width: 100%;
           flex-grow: 1;
           overflow: auto;
           height: calc(100% - 125px);
@@ -1190,6 +1261,13 @@ function openPhotographyDetail() {
           }
         }
       }
+.last-photo{
+  position: fixed;
+  left: 20px;
+  top: 50px;
+  bottom: 20px;
+  right: 350px;
+  z-index: 10;
+}
 </style>
 
-<style lang="scss" scoped></style>

+ 1 - 3
frontend/src/views/RemoteControl/index.vue

@@ -44,9 +44,7 @@ const runRight = async () => {
 
 
 const run_take_picture = () => {
-  socketStore.sendMessage({
-    type: 'handler_take_picture',
-  })
+  emit('onRemoteControl','take_picture')
 }
 
 </script>