Procházet zdrojové kódy

feat(photography): 添加拍摄历史记录同步功能并优化商品配置检查

- 实现了拍摄历史记录同步接口和功能
- 在商品列表中添加了配置同步状态检查
- 优化了重拍按钮的显示逻辑,仅在有效配置时显示
- 为下载模板按钮添加了title提示信息
- 修复了商品配置缺失时的提示显示问题
- 添加了对action_name为空情况的处理和按钮显示控制
panqiuyao před 4 dny
rodič
revize
846df52f2d

+ 16 - 0
electron/api/setting.js

@@ -123,6 +123,22 @@ module.exports = {
   },
 
 
+  //同步配置接口
+  syncPhotoRecord(data){
+    console.log("syncPhotoRecord===============", data);
+    return post({
+      url: '/syncPhotoRecord',
+      data: {
+        ...data,
+        env:readConfigFile().env
+      }
+    })
+  },
+
+
+
+
+
 
   //同步左右脚配置
   syncActions(data){

+ 16 - 0
electron/controller/setting.js

@@ -18,6 +18,7 @@ const {
   updateLeftRightConfig,
   updateTabName,
   syncSysConfigs,
+  syncPhotoRecord,
   syncActions
 } = require('../api/setting');
 
@@ -186,6 +187,21 @@ class SettingController extends Controller {
     }
   }
 
+  /**
+   * 同步创作历史
+   * @param {Object} token
+   */
+  async syncPhotoRecord(args) {
+    try {
+      const result = await syncPhotoRecord(args);
+      if(result.data)  return result.data
+      return errData;
+    } catch (error) {
+      Log.error('同步配置接口:', error);
+      return errData;
+    }
+  }
+
 
   /**
    * 同步配置接口

+ 6 - 0
frontend/src/apis/setting.ts

@@ -255,6 +255,12 @@ export async function syncAfterLogin() {
             token: token
         });
 
+
+        // 拍摄历史记录同步
+        await clientStore.ipc.invoke(icpList.setting.syncPhotoRecord, {
+            token: token
+        });
+
         console.log('登录后数据同步成功');
     } catch (error) {
         console.error('登录后数据同步失败:', error);

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

@@ -325,8 +325,9 @@
                       </el-button>
                     </div>
                     <el-button type="text" class="download-link" @click="downloadExcel"
+                               title="用于非自定义详情页的商品基础资料模版"
                       v-log="{ describe: { action: '点击下载Excel模板' } }">
-                      下载商品基础资料模版
+                      下载通用商品基础资料模版
                     </el-button>
                   </div>
                 </div>

+ 15 - 1
frontend/src/views/Photography/mixin/usePhotography.ts

@@ -124,7 +124,21 @@ export default function usePhotography() {
           //console.log('getPhotoRecords  print_time:' + new Date().toLocaleString())
           // console.log('getPhotoRecords  print_time:' + JSON.stringify(result.data.list))
           console.log(result.data)
-          goodsList.value = result.data.list
+
+          // 在设置 goodsList.value 之前,检查 items 数组中的 action_name 是否为 null
+          const modifiedList = result.data.list.map(item => {
+            // 检查 items 数组中是否有 action_name 为 null 的情况
+            const hasNullActionName = item.items && Array.isArray(item.items) &&
+              item.items.some(image => image.action_name === null || image.action_name === undefined);
+
+            // 根据检查结果设置 syncConfig
+            return {
+              ...item,
+              syncConfig: hasNullActionName ? false : true
+            };
+          });
+
+          goodsList.value = modifiedList;
           // update pagination info if provided by API
           if (result.data) {
             currentPage.value = result.data.current_page || page

+ 3 - 2
frontend/src/views/Photography/shot.vue

@@ -80,6 +80,7 @@
                     <span class="image-count mar-left-10 flex left">
                        <img src="@/assets/images/processImage.vue/tup.png" />
                       {{ item.items?.length || 0 }}张图片</span>
+                    <span v-if="!item.syncConfig" class="mar-left-10">无法读取到该商品拍摄配置,如需重新生成请删除该商品并重新拍摄</span>
                   </div>
                 </div>
                 <div class="history-item-right">
@@ -94,7 +95,7 @@
                     </template>
                   </el-dropdown>
 
-                  <el-button size="small"  class="mar-left-10"  :disabled="runLoading || takePictureLoading"  type="primary"  @click="reTakePictureNos(item.goods_art_no,item)" plain v-log="{ describe: { action: '重拍货号', goods_art_no: item.goods_art_no } }">重拍</el-button>
+                  <el-button size="small" v-if="item.syncConfig"  class="mar-left-10"  :disabled="runLoading || takePictureLoading"  type="primary"  @click="reTakePictureNos(item.goods_art_no,item)" plain v-log="{ describe: { action: '重拍货号', goods_art_no: item.goods_art_no } }">重拍</el-button>
                   <el-button style="color: #FF4C00"  size="small" class="mar-left-10" :disabled="runLoading || takePictureLoading" @click="delGoods({goods_art_nos:[item.goods_art_no]})" v-log="{ describe: { action: '删除货号', goods_art_no: item.goods_art_no } }">删除</el-button>
                 </div>
               </div>
@@ -123,7 +124,7 @@
                         </div>
                       </template>
                     </el-image>
-                    <el-button :disabled="runLoading || takePictureLoading" class="reset-button" @click="reTakePicture(image.PhotoRecord)" v-log="{ describe: { action: '重拍单张图片', goods_art_no: image.PhotoRecord.goods_art_no, action_name: image.action_name } }">重拍</el-button>
+                    <el-button v-if="image.action_name" :disabled="runLoading || takePictureLoading" class="reset-button" @click="reTakePicture(image.PhotoRecord)" v-log="{ describe: { action: '重拍单张图片', goods_art_no: image.PhotoRecord.goods_art_no, action_name: image.action_name } }">重拍</el-button>
                   </div>
                   <div v-else class="image-placeholder">
                     <span class="tag">{{ image.action_name }}</span>