Browse Source

feat(photography): 重构拍摄记录页面UI和功能

- 重新设计历史记录项布局,添加复选框支持批量选择
- 实现全选/半选状态控制和删除选中货号功能
- 添加图片预览功能,支持点击查看大图
- 优化图片展示区域,使用网格布局并支持响应式
- 更新页脚控件,固定在页面底部并显示图片统计
- 修改页面背景色和卡片样式,提升视觉效果
- 调整主容器宽度并支持最大宽度自适应
- 移除旧的一键删除所有记录按钮
- 添加时间戳和图片数量显示
- 优化加载状态和错误占位符显示
panqiuyao 1 week ago
parent
commit
13ab3e52e9

BIN
frontend/src/assets/images/processImage.vue/go.png


BIN
frontend/src/assets/images/processImage.vue/riq.png


BIN
frontend/src/assets/images/processImage.vue/sc.png


BIN
frontend/src/assets/images/processImage.vue/tup.png


+ 4 - 1
frontend/src/styles/pub.scss

@@ -120,9 +120,12 @@
 .anm { transition: 0.5s;  }
 
 .page—wrap {
-  width: 1200px;
+  width: 1360px;
   margin:  0 auto;
 }
+.max-w-full{
+  max-width: 100%;
+}
 
 .el-button__primary {
   background: #2CFFFC;

+ 395 - 144
frontend/src/views/Photography/processImage.vue

@@ -7,103 +7,116 @@
 
   <hardware-check/>
 
-  <div class="photography-page flex-col">
-    <div class="main-container">
+  <div class="photography-page flex-col ">
+    <div class="main-container page—wrap max-w-full">
       <div class="history-section flex-col koutu-section">
-          <span class="history-title flex between">
-            <div>拍摄记录</div>
-            <div class="c-666 fs-12" v-if="goodsList.length" >
-                    <el-button :disabled="runLoading || takePictureLoading" @click="delAll" class="input-button" type="danger" size="mini" v-log="{ describe: { action: '一键删除所有记录' } }">一键删除</el-button>
-            </div>
-          </span>
-          <img class="divider-line" referrerpolicy="no-referrer" src="@/assets/images/Photography/divider-line.png" />
 
           <div class="history-warp">
             <div v-if="!goodsList.length" class="fs-14 c-666 mar-top-50">
               {{ loading ? '数据正在加载中,请稍候...' : '暂无数据,请先进行拍摄'}}
             </div>
-              <div v-else class="history-item clearfix"  v-for="item in goodsList" :key="item.goods_art_no" style="padding:10px;">
-                <div class="flex  between flex-item  c-333">
-                  <div class="chaochu flex-item flex left">货号:{{ item.goods_art_no }}</div>
-                  <div >
-                    <el-dropdown :disabled="runLoading || takePictureLoading" >
-                      <el-button :disabled="runLoading || takePictureLoading" size="small"  plain style="margin-right: 5px" >高级生成</el-button>
-                      <template #dropdown>
-                        <el-dropdown-menu>
-                          <el-dropdown-item
-                              v-for="menu in generate.children"
-                              @click.native="onGenerateCLick(menu,item)">{{ menu.name }}</el-dropdown-item>
-                        </el-dropdown-menu>
-                      </template>
-                    </el-dropdown>
-
-                    <el-button size="small" :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 v-else class="history-item"  v-for="item in goodsList" :key="item.goods_art_no"   >
+              <div class="history-item-header">
+                <div class="history-item-left">
+                  <el-checkbox
+                      :model-value="selectedGoods.has(item.goods_art_no)"
+                      @change="toggleGoods(item.goods_art_no)"
+                      class="goods-checkbox"
+                  />
+                  <span class="goods-art-no">{{ item.goods_art_no }}</span>
+
+                  <div class="history-item-meta ">
+                    <span class="action-time flex left">
+
+                       <img src="@/assets/images/processImage.vue/riq.png" />
+                      {{ getTime(item.action_time) }}</span>
+                    <span class="image-count mar-left-10 flex left">
+                       <img src="@/assets/images/processImage.vue/tup.png" />
+                      {{ item.items?.length || 0 }}张图片</span>
                   </div>
                 </div>
-                <div class="flex  between flex-item  c-333" style="margin-top: 5px">
-                  <div class="c-999 fs-12">{{ getTime(item.action_time) }}</div>
+                <div class="history-item-right">
+                  <el-dropdown :disabled="runLoading || takePictureLoading" trigger="click">
+                    <el-button :disabled="runLoading || takePictureLoading" size="small" plain>高级生成</el-button>
+                    <template #dropdown>
+                      <el-dropdown-menu>
+                        <el-dropdown-item
+                            v-for="menu in generate.children"
+                            @click.native="onGenerateCLick(menu,item)">{{ menu.name }}</el-dropdown-item>
+                      </el-dropdown-menu>
+                    </template>
+                  </el-dropdown>
+
+                  <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 class="mar-top-10 clearfix history-item_image_wrap" style="width: 100%" >
-                    <component class="history-item_image"
-                         v-for="image in item.items"
-                               :key="image.action_id || image.action_name"
-                               v-loading="!image.PhotoRecord.image_path && runAction.goods_art_no == item.goods_art_no"
-                               :is="image.PhotoRecord.image_path ? 'div' : 'p'"
-                    >
-                      <span class="tag">{{ image.action_name }}</span>
-                      <el-popover
-                          popper-class="koutu-image-popper"
-                          placement="right"
-                          :hide-after="0"
-                          width="50%"
-                          offset="20"
-                          v-if="image.PhotoRecord.image_path"
-                      >
-                        <template #reference>
-                          <div class="flex el-image_view">
-                            <el-image  :src="getFilePath(image.PhotoRecord.image_path)"  fit="contain" >
-                              <template #error>
-                                <div class="image-slot"></div>
-                              </template>
-                            </el-image>
-                          </div>
-                        </template>
-
-                        <el-image  :src="getFilePath(image.PhotoRecord.image_path)"  fit="contain" >
-                          <template #error>
-                            <div class="image-slot"></div>
-                          </template>
-                        </el-image>
-                      </el-popover>
-
-                      <div class="flex el-image_view"  v-else>
-                      <el-image :src="getFilePath(image.PhotoRecord.image_path)"  fit="contain">
-                        <template #error>
-                          <div class="image-slot"></div>
-                        </template>
-                      </el-image>
+              </div>
+              <div class="history-item-images" >
+                <div
+                  v-for="(image, index) in item.items"
+                  :key="image.action_id || image.action_name"
+                  class="history-item_image"
+                  v-loading="!image.PhotoRecord.image_path && runAction.goods_art_no == item.goods_art_no"
+                >
+                  <span class="tag" v-if="!image.PhotoRecord.image_path">{{ image.action_name }}</span>
+                  <el-image
+                    v-if="image.PhotoRecord.image_path"
+                    :src="getFilePath(image.PhotoRecord.image_path)"
+                    :preview-src-list="getPreviewImageList(item)"
+                    :initial-index="getPreviewIndex(item, index)"
+                    class="preview-image"
+                    fit="contain"
+                    :preview-teleported="true"
+                    lazy
+                  >
+                    <template #error>
+                      <div class="image-slot">
+                        <span class="tag">{{ image.action_name }}</span>
                       </div>
-                    </component>
-                    <div v-if="item.items.length < 5"
-                      v-for="n in (5 - item.items.length)"
-                         :key="n"
-                         class="history-item_image"
-                    >
-                      <span class="tag" style="font-size: 12px;">暂未配置</span>
-
-                    </div>
+                    </template>
+                  </el-image>
+                  <div v-else class="image-placeholder">
+                    <span class="tag">{{ image.action_name }}</span>
+                  </div>
                 </div>
               </div>
+            </div>
 
           </div>
 
-          <div
-            class="next-step button--primary1 flex-col"
-            :class="{ 'is-disabled': !goodsList.length || runLoading || takePictureLoading }"
-            @click="(!goodsList.length || runLoading || takePictureLoading) ? null : openPhotographyDetail()"
-            v-log="{ describe: { action: '点击开始生成' } }"
-          >
-            <span class="next-step-text">开始生成</span>
+          <div class="footer-controls">
+            <div class="footer-left">
+              <el-checkbox
+                :model-value="isSelectAll"
+                :indeterminate="isIndeterminate"
+                @change="toggleSelectAll"
+                class="select-all-checkbox"
+              >
+                全选
+              </el-checkbox>
+              <span class="image-count-text">
+                已选择 <span style="color: #2957FF">{{ selectedImageCount }}</span> 张图片 共 <span style="color: #2957FF">{{ totalImageCount }}</span> 张图片
+              </span>
+            </div>
+            <div class="footer-right">
+              <el-button
+                :disabled="selectedGoods.size === 0 || runLoading || takePictureLoading"
+                @click="deleteSelected"
+                v-log="{ describe: { action: '删除选中货号' } }"
+              >
+                删除
+              </el-button>
+              <el-button
+                type="primary"
+                :disabled="!goodsList.length || runLoading || takePictureLoading"
+                @click="openPhotographyDetail()"
+                v-log="{ describe: { action: '点击开始生成' } }"
+              >
+
+                <img src="@/assets/images/processImage.vue/sc.png" />
+                开始生成
+                <img src="@/assets/images/processImage.vue/go.png"  class="go"/>
+              </el-button>
+            </div>
           </div>
         </div>
     </div>
@@ -111,10 +124,11 @@
 </template>
 <script setup lang="ts">
 import headerBar from '@/components/header-bar/index.vue'
-import { onMounted, onBeforeUnmount } from 'vue'
+import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
 import HardwareCheck from '@/components/check/index.vue'
 import usePhotography from './mixin/usePhotography'
 import generate from '@/utils/menus/generate'
+import { ElMessageBox } from 'element-plus'
 
 const {
   loading,
@@ -126,15 +140,113 @@ const {
   getTime,
   getFilePath,
   getPhotoRecords,
-  delAll,
   delGoods,
-  oneClickStop,
   openPhotographyDetail,
   onGenerateCLick,
   initEventListeners,
   cleanupEventListeners,
 } = usePhotography()
 
+// 选中的货号列表
+const selectedGoods = ref<Set<string>>(new Set())
+
+// 全选状态
+const isSelectAll = computed(() => {
+  return goodsList.value.length > 0 && selectedGoods.value.size === goodsList.value.length
+})
+
+// 是否半选状态
+const isIndeterminate = computed(() => {
+  return selectedGoods.value.size > 0 && selectedGoods.value.size < goodsList.value.length
+})
+
+// 切换单个货号的选中状态
+const toggleGoods = (goodsArtNo: string) => {
+  if (selectedGoods.value.has(goodsArtNo)) {
+    selectedGoods.value.delete(goodsArtNo)
+  } else {
+    selectedGoods.value.add(goodsArtNo)
+  }
+}
+
+// 全选/取消全选
+const toggleSelectAll = () => {
+  if (isSelectAll.value) {
+    selectedGoods.value.clear()
+  } else {
+    goodsList.value.forEach((item: any) => {
+      selectedGoods.value.add(item.goods_art_no)
+    })
+  }
+}
+
+// 计算已选择的图片数量
+const selectedImageCount = computed(() => {
+  let count = 0
+  goodsList.value.forEach((item: any) => {
+    if (selectedGoods.value.has(item.goods_art_no)) {
+      count += item.items?.length || 0
+    }
+  })
+  return count
+})
+
+// 计算总图片数量
+const totalImageCount = computed(() => {
+  let count = 0
+  goodsList.value.forEach((item: any) => {
+    count += item.items?.length || 0
+  })
+  return count
+})
+
+// 删除选中的货号
+const deleteSelected = async () => {
+  if (selectedGoods.value.size === 0) {
+    return
+  }
+
+  try {
+    await ElMessageBox.confirm(
+      `确定要删除选中的 ${selectedGoods.value.size} 个货号的拍摄数据吗?`,
+      '提示',
+      {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+      }
+    )
+
+    const goodsArtNos = Array.from(selectedGoods.value)
+    await delGoods({ goods_art_nos: goodsArtNos })
+    // 删除成功后清空选中状态
+    selectedGoods.value.clear()
+  } catch (e) {
+    // 用户取消
+  }
+}
+
+// 获取预览图片列表(只包含有图片路径的,保持原始顺序)
+const getPreviewImageList = (item: any) => {
+  if (!item || !item.items) return []
+  return item.items
+    .filter((img: any) => img.PhotoRecord?.image_path)
+    .map((img: any) => getFilePath(img.PhotoRecord.image_path))
+}
+
+// 获取当前图片在预览列表中的索引
+const getPreviewIndex = (item: any, currentIndex: number) => {
+  if (!item || !item.items) return 0
+  // 计算当前图片在过滤后的预览列表中的索引
+  let previewIndex = 0
+  for (let i = 0; i <= currentIndex; i++) {
+    if (item.items[i]?.PhotoRecord?.image_path) {
+      if (i === currentIndex) break
+      previewIndex++
+    }
+  }
+  return previewIndex
+}
+
 onMounted(async () => {
   await getPhotoRecords()
   initEventListeners()
@@ -170,7 +282,7 @@ onBeforeUnmount(() => {
 
 <style scoped lang="scss">
 .photography-page {
-  background-color: rgba(255, 255, 255, 1);
+  background-color:#F5F6F7;
   position: relative;
   .main-container {
     position: relative;
@@ -179,72 +291,173 @@ onBeforeUnmount(() => {
 }
 
 .history-section {
-        background-color: rgba(234, 236, 237, 1);
         width: 100%;
         height: calc(100vh - 30px);
-
-        .history-title {
-          width: calc(100% - 20px);
-          height: 22px;
-          overflow-wrap: break-word;
-          color: rgba(51, 51, 51, 1);
-          font-size: 16px;
-          font-family: PingFangSC-Semibold;
-          font-weight: 600;
-          text-align: center;
-          white-space: nowrap;
-          line-height: 22px;
-          margin: 9px 0 0 10px;
-        }
-
-        .divider-line {
-          width: 100%;
-          height: 1px;
-          margin-top: 9px;
+        display: flex;
+        flex-direction: column;
+        padding: 20px;
+        overflow-y: auto;
+
+        ::v-deep {
+          .el-checkbox__input {
+            transform: scale(1.4);
+          }
         }
-
         .history-warp {
-          flex-grow: 1;
-          overflow: auto;
-          height: calc(100% - 125px);
+          flex: 1;
 
           .history-item {
+            background: #FFFFFF;
+            box-shadow: 0px 2px 4px 0px rgba(23,33,71,0.1);
+            border-radius: 10px;
+            border: 1px solid #D9DEE6;
+            margin-bottom: 20px;
+
+            .history-item-header {
+              display: flex;
+              justify-content: space-between;
+              align-items: center;
+              height: 40px;
+              padding: 0 10px;
+
+              background: linear-gradient( 90deg, #F4ECFF 0%, #DFEDFF 100%);
+              border-radius: 10px 10px 0px 0px;
+
+              .history-item-left {
+                display: flex;
+                align-items: center;
+                gap: 10px;
+
+                .goods-checkbox {
+                  margin-right: 0;
+                }
+
+                .goods-art-no {
+                  font-size: 16px;
+                  font-weight: 500;
+                  color: #333;
+                }
+              }
+
+              .history-item-right {
+                display: flex;
+                align-items: center;
+                ::v-deep {
+                  .el-button { height: 30px; line-height: 30px;}
+                }
+              }
+            }
+
+            .history-item-meta {
+              display: flex;
+              justify-content: space-between;
+              align-items: center;
+              font-size: 12px;
+              color: #666;
+
+              img {
+                height: 14px;
+                margin-right: 2px;
+              }
+
+              .action-time {
+                color: #666;
+              }
+
+              .image-count {
+                color: #666;
+              }
+            }
+
+            .history-item-images {
+              display: grid;
+              grid-template-columns: repeat(5, 1fr);
+              gap: 10px;
+              padding: 15px;
+              border-top: 1px solid #f0f0f0;
+              overflow-x: auto;
+
+              // 如果图片数量超过5个,允许横向滚动
+              @media (min-width: 1200px) {
+                grid-template-columns: repeat(5, 1fr);
+              }
+
+              // 响应式:小屏幕时每行3个
+              @media (max-width: 768px) {
+                grid-template-columns: repeat(3, 1fr);
+              }
+            }
+
             .history-item_image_wrap {
-              padding-bottom: 20px;
-              border-bottom: 1px solid #CCCCCC;
+              padding-bottom: 0;
+              border-bottom: none;
             }
             .history-item_image {
+              position: relative;
+              width: 100%;
+              aspect-ratio: 1;
+              background: #F7F7F7;
+              border-radius: 10px;
+              overflow: hidden;
+              cursor: pointer;
+              border: 1px solid #D9DEE6;
+              transition: all 0.3s;
+
+
               .tag {
                 color: #bbb;
                 position: absolute;
                 left: 0;
                 right: 0;
-                top:50%;
-                margin-top: -15px;
+                top: 50%;
+                margin-top: -10px;
                 line-height: 20px;
+                text-align: center;
+                font-size: 12px;
+                z-index: 1;
+                pointer-events: none;
               }
 
-              position: relative;
-              width: 70px;
-              height: 70px;
-              float: left;
-              margin: 6px 0 0 6px;
-              background: #F7F7F7;
-              .el-image {
-                display: block;
-                width:100%;
+              .preview-image {
+                width: 100%;
                 height: 100%;
+
+                :deep(.el-image__inner) {
+                  width: 100%;
+                  height: 100%;
+                  object-fit: cover;
+                }
               }
-              &:first-child {
-                width: 146px;
-                height: 146px;
+
+              .image-placeholder {
+                width: 100%;
+                height: 100%;
+                display: flex;
+                align-items: center;
+                justify-content: center;
+                background: #F7F7F7;
               }
+
+              .image-slot {
+                width: 100%;
+                height: 100%;
+                display: flex;
+                align-items: center;
+                justify-content: center;
+                background: #F7F7F7;
+              }
+
+              &:hover {
+                border-color: #409eff;
+                transform: scale(1.02);
+                box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
+              }
+
               &.el-loading-parent--relative{
                 ::v-deep {
                   .el-loading-mask { display: none}
                 }
               }
-
             }
 
 
@@ -286,26 +499,64 @@ onBeforeUnmount(() => {
           }
         }
 
-        .next-step {
-          height: 50px;
-          background-size: 100% 100%;
-          width: 100%;
-          line-height: 50px;
-          cursor: pointer;
-
-          &.is-disabled {
-            opacity: 0.5;
-            cursor: not-allowed;
-            pointer-events: none;
+        .footer-controls {
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+          padding: 0px 20px;
+          border-top: 1px solid #D9DEE6;
+          background-color: #fff;
+          min-height: 50px;
+          flex-shrink: 0;
+          position: fixed;
+          bottom:0;
+          left: 0;
+          right: 0;
+          font-size: 14px;
+          z-index: 100;
+          img {
+            height: 12px;
+            margin: 0 5px;
           }
+          .go {
+            height: 12px;
+            opacity: .8;
+          }
+          ::v-deep {
+            .el-button {
+              border-radius: 10px;
+              height: 40px;
+              line-height: 40px;
+            }
+          }
+
+          .footer-left {
+            display: flex;
+            align-items: center;
+            gap: 10px;
+
+            .select-all-checkbox {
+              margin-right: 0;
+              ::v-deep {
+                .el-checkbox__label {
 
-          .next-step-text {
-            width: 100%;
-            overflow-wrap: break-word;
-            color: rgba(255, 255, 255, 1);
-            text-align: center;
-            white-space: nowrap;
+                  font-size: 14px;
+                  color: #666;
+                }
+              }
+            }
+
+            .image-count-text {
+              font-size: 14px;
+              color: #333;
+              margin-left: 0;
+            }
+          }
 
+          .footer-right {
+            display: flex;
+            align-items: center;
+            gap: 10px;
           }
         }