processImage.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <template>
  2. <headerBar
  3. title="处理图像"
  4. showUser
  5. :menu="menu"
  6. />
  7. <hardware-check/>
  8. <div class="photography-page flex-col ">
  9. <div class="main-container page—wrap max-w-full">
  10. <div class="history-section flex-col koutu-section">
  11. <div class="history-warp">
  12. <div v-if="!goodsList.length" class="fs-14 c-666 mar-top-50">
  13. {{ loading ? '数据正在加载中,请稍候...' : '暂无数据,请先进行拍摄'}}
  14. </div>
  15. <div v-else class="history-item" v-for="item in goodsList" :key="item.goods_art_no" >
  16. <div class="history-item-header">
  17. <div class="history-item-left">
  18. <el-checkbox
  19. :model-value="selectedGoods.has(item.goods_art_no)"
  20. @change="toggleGoods(item.goods_art_no)"
  21. class="goods-checkbox"
  22. />
  23. <span class="goods-art-no">{{ item.goods_art_no }}</span>
  24. <div class="history-item-meta ">
  25. <span class="action-time flex left">
  26. <img src="@/assets/images/processImage.vue/riq.png" />
  27. {{ getTime(item.action_time) }}</span>
  28. <span class="image-count mar-left-10 flex left">
  29. <img src="@/assets/images/processImage.vue/tup.png" />
  30. {{ item.items?.length || 0 }}张图片</span>
  31. </div>
  32. </div>
  33. <div class="history-item-right">
  34. <el-dropdown :disabled="runLoading || takePictureLoading" trigger="click">
  35. <el-button :disabled="runLoading || takePictureLoading" size="small" plain>高级生成</el-button>
  36. <template #dropdown>
  37. <el-dropdown-menu>
  38. <el-dropdown-item
  39. v-for="menu in generate.children"
  40. @click.native="onGenerateCLick(menu,item)">{{ menu.name }}</el-dropdown-item>
  41. </el-dropdown-menu>
  42. </template>
  43. </el-dropdown>
  44. <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>
  45. </div>
  46. </div>
  47. <div class="history-item-images" >
  48. <div
  49. v-for="(image, index) in item.items"
  50. :key="image.action_id || image.action_name"
  51. class="history-item_image"
  52. v-loading="!image.PhotoRecord.image_path && runAction.goods_art_no == item.goods_art_no"
  53. >
  54. <span class="tag" v-if="!image.PhotoRecord.image_path">{{ image.action_name }}</span>
  55. <el-image
  56. v-if="image.PhotoRecord.image_path"
  57. :src="getFilePath(image.PhotoRecord.image_path)"
  58. :preview-src-list="getPreviewImageList(item)"
  59. :initial-index="getPreviewIndex(item, index)"
  60. class="preview-image"
  61. fit="contain"
  62. :preview-teleported="true"
  63. lazy
  64. >
  65. <template #error>
  66. <div class="image-slot">
  67. <span class="tag">{{ image.action_name }}</span>
  68. </div>
  69. </template>
  70. </el-image>
  71. <div v-else class="image-placeholder">
  72. <span class="tag">{{ image.action_name }}</span>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="footer-controls">
  79. <div class="footer-left">
  80. <el-checkbox
  81. :model-value="isSelectAll"
  82. :indeterminate="isIndeterminate"
  83. @change="toggleSelectAll"
  84. class="select-all-checkbox"
  85. >
  86. 全选
  87. </el-checkbox>
  88. <span class="image-count-text">
  89. 已选择 <span style="color: #2957FF">{{ selectedImageCount }}</span> 张图片 共 <span style="color: #2957FF">{{ totalImageCount }}</span> 张图片
  90. </span>
  91. </div>
  92. <div class="footer-right">
  93. <el-button
  94. :disabled="selectedGoods.size === 0 || runLoading || takePictureLoading"
  95. @click="deleteSelected"
  96. v-log="{ describe: { action: '删除选中货号' } }"
  97. >
  98. 删除
  99. </el-button>
  100. <el-button
  101. type="primary"
  102. :disabled="!goodsList.length || runLoading || takePictureLoading"
  103. @click="openPhotographyDetail()"
  104. v-log="{ describe: { action: '点击开始生成' } }"
  105. >
  106. <img src="@/assets/images/processImage.vue/sc.png" />
  107. 开始生成
  108. <img src="@/assets/images/processImage.vue/go.png" class="go"/>
  109. </el-button>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script setup lang="ts">
  117. import headerBar from '@/components/header-bar/index.vue'
  118. import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
  119. import HardwareCheck from '@/components/check/index.vue'
  120. import usePhotography from './mixin/usePhotography'
  121. import generate from '@/utils/menus/generate'
  122. import { ElMessageBox } from 'element-plus'
  123. const {
  124. loading,
  125. runLoading,
  126. takePictureLoading,
  127. goodsList,
  128. runAction,
  129. menu,
  130. getTime,
  131. getFilePath,
  132. getPhotoRecords,
  133. delGoods,
  134. openPhotographyDetail,
  135. onGenerateCLick,
  136. initEventListeners,
  137. cleanupEventListeners,
  138. } = usePhotography()
  139. // 选中的货号列表
  140. const selectedGoods = ref<Set<string>>(new Set())
  141. // 全选状态
  142. const isSelectAll = computed(() => {
  143. return goodsList.value.length > 0 && selectedGoods.value.size === goodsList.value.length
  144. })
  145. // 是否半选状态
  146. const isIndeterminate = computed(() => {
  147. return selectedGoods.value.size > 0 && selectedGoods.value.size < goodsList.value.length
  148. })
  149. // 切换单个货号的选中状态
  150. const toggleGoods = (goodsArtNo: string) => {
  151. if (selectedGoods.value.has(goodsArtNo)) {
  152. selectedGoods.value.delete(goodsArtNo)
  153. } else {
  154. selectedGoods.value.add(goodsArtNo)
  155. }
  156. }
  157. // 全选/取消全选
  158. const toggleSelectAll = () => {
  159. if (isSelectAll.value) {
  160. selectedGoods.value.clear()
  161. } else {
  162. goodsList.value.forEach((item: any) => {
  163. selectedGoods.value.add(item.goods_art_no)
  164. })
  165. }
  166. }
  167. // 计算已选择的图片数量
  168. const selectedImageCount = computed(() => {
  169. let count = 0
  170. goodsList.value.forEach((item: any) => {
  171. if (selectedGoods.value.has(item.goods_art_no)) {
  172. count += item.items?.length || 0
  173. }
  174. })
  175. return count
  176. })
  177. // 计算总图片数量
  178. const totalImageCount = computed(() => {
  179. let count = 0
  180. goodsList.value.forEach((item: any) => {
  181. count += item.items?.length || 0
  182. })
  183. return count
  184. })
  185. // 删除选中的货号
  186. const deleteSelected = async () => {
  187. if (selectedGoods.value.size === 0) {
  188. return
  189. }
  190. try {
  191. await ElMessageBox.confirm(
  192. `确定要删除选中的 ${selectedGoods.value.size} 个货号的拍摄数据吗?`,
  193. '提示',
  194. {
  195. confirmButtonText: '确定',
  196. cancelButtonText: '取消',
  197. }
  198. )
  199. const goodsArtNos = Array.from(selectedGoods.value)
  200. await delGoods({ goods_art_nos: goodsArtNos })
  201. // 删除成功后清空选中状态
  202. selectedGoods.value.clear()
  203. } catch (e) {
  204. // 用户取消
  205. }
  206. }
  207. // 获取预览图片列表(只包含有图片路径的,保持原始顺序)
  208. const getPreviewImageList = (item: any) => {
  209. if (!item || !item.items) return []
  210. return item.items
  211. .filter((img: any) => img.PhotoRecord?.image_path)
  212. .map((img: any) => getFilePath(img.PhotoRecord.image_path))
  213. }
  214. // 获取当前图片在预览列表中的索引
  215. const getPreviewIndex = (item: any, currentIndex: number) => {
  216. if (!item || !item.items) return 0
  217. // 计算当前图片在过滤后的预览列表中的索引
  218. let previewIndex = 0
  219. for (let i = 0; i <= currentIndex; i++) {
  220. if (item.items[i]?.PhotoRecord?.image_path) {
  221. if (i === currentIndex) break
  222. previewIndex++
  223. }
  224. }
  225. return previewIndex
  226. }
  227. onMounted(async () => {
  228. await getPhotoRecords()
  229. initEventListeners()
  230. })
  231. onBeforeUnmount(() => {
  232. cleanupEventListeners()
  233. })
  234. </script>
  235. <style lang="scss">
  236. .koutu-image-popper {
  237. width: calc(100vw - 470px) !important;
  238. right: 70px !important;
  239. top: 100px !important;
  240. height: calc(100vh - 170px) !important;
  241. transform: translate(0px, 0px) !important;
  242. .el-image {
  243. width: 100%;
  244. height:100%;
  245. display: block;
  246. .el-image__inner {
  247. width: 100%;
  248. height:100%;
  249. display: block;
  250. }
  251. }
  252. }
  253. </style>
  254. <style scoped lang="scss">
  255. .photography-page {
  256. background-color:#F5F6F7;
  257. position: relative;
  258. .main-container {
  259. position: relative;
  260. display: flex;
  261. }
  262. }
  263. .history-section {
  264. width: 100%;
  265. height: calc(100vh - 30px);
  266. display: flex;
  267. flex-direction: column;
  268. padding: 20px;
  269. overflow-y: auto;
  270. ::v-deep {
  271. .el-checkbox__input {
  272. transform: scale(1.4);
  273. }
  274. }
  275. .history-warp {
  276. flex: 1;
  277. .history-item {
  278. background: #FFFFFF;
  279. box-shadow: 0px 2px 4px 0px rgba(23,33,71,0.1);
  280. border-radius: 10px;
  281. border: 1px solid #D9DEE6;
  282. margin-bottom: 20px;
  283. .history-item-header {
  284. display: flex;
  285. justify-content: space-between;
  286. align-items: center;
  287. height: 40px;
  288. padding: 0 10px;
  289. background: linear-gradient( 90deg, #F4ECFF 0%, #DFEDFF 100%);
  290. border-radius: 10px 10px 0px 0px;
  291. .history-item-left {
  292. display: flex;
  293. align-items: center;
  294. gap: 10px;
  295. .goods-checkbox {
  296. margin-right: 0;
  297. }
  298. .goods-art-no {
  299. font-size: 16px;
  300. font-weight: 500;
  301. color: #333;
  302. }
  303. }
  304. .history-item-right {
  305. display: flex;
  306. align-items: center;
  307. ::v-deep {
  308. .el-button { height: 30px; line-height: 30px;}
  309. }
  310. }
  311. }
  312. .history-item-meta {
  313. display: flex;
  314. justify-content: space-between;
  315. align-items: center;
  316. font-size: 12px;
  317. color: #666;
  318. img {
  319. height: 14px;
  320. margin-right: 2px;
  321. }
  322. .action-time {
  323. color: #666;
  324. }
  325. .image-count {
  326. color: #666;
  327. }
  328. }
  329. .history-item-images {
  330. display: grid;
  331. grid-template-columns: repeat(5, 1fr);
  332. gap: 10px;
  333. padding: 15px;
  334. border-top: 1px solid #f0f0f0;
  335. overflow-x: auto;
  336. // 如果图片数量超过5个,允许横向滚动
  337. @media (min-width: 1200px) {
  338. grid-template-columns: repeat(5, 1fr);
  339. }
  340. // 响应式:小屏幕时每行3个
  341. @media (max-width: 768px) {
  342. grid-template-columns: repeat(3, 1fr);
  343. }
  344. }
  345. .history-item_image_wrap {
  346. padding-bottom: 0;
  347. border-bottom: none;
  348. }
  349. .history-item_image {
  350. position: relative;
  351. width: 100%;
  352. aspect-ratio: 1;
  353. background: #F7F7F7;
  354. border-radius: 10px;
  355. overflow: hidden;
  356. cursor: pointer;
  357. border: 1px solid #D9DEE6;
  358. transition: all 0.3s;
  359. .tag {
  360. color: #bbb;
  361. position: absolute;
  362. left: 0;
  363. right: 0;
  364. top: 50%;
  365. margin-top: -10px;
  366. line-height: 20px;
  367. text-align: center;
  368. font-size: 12px;
  369. z-index: 1;
  370. pointer-events: none;
  371. }
  372. .preview-image {
  373. width: 100%;
  374. height: 100%;
  375. :deep(.el-image__inner) {
  376. width: 100%;
  377. height: 100%;
  378. object-fit: cover;
  379. }
  380. }
  381. .image-placeholder {
  382. width: 100%;
  383. height: 100%;
  384. display: flex;
  385. align-items: center;
  386. justify-content: center;
  387. background: #F7F7F7;
  388. }
  389. .image-slot {
  390. width: 100%;
  391. height: 100%;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. background: #F7F7F7;
  396. }
  397. &:hover {
  398. border-color: #409eff;
  399. transform: scale(1.02);
  400. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
  401. }
  402. &.el-loading-parent--relative{
  403. ::v-deep {
  404. .el-loading-mask { display: none}
  405. }
  406. }
  407. }
  408. .el-image_view {
  409. display: flex;
  410. width: 100%;
  411. height: 100%;
  412. .reset-button {
  413. width: 40px;
  414. text-align: center;
  415. height: 20px;
  416. position: absolute;
  417. left:50%;
  418. top:50%;
  419. padding: 0px;
  420. margin-left:-20px;
  421. margin-top:-10px;
  422. color: #ffffff;
  423. font-size: 14px;
  424. background: rgba(0,0,0,0.6);
  425. border-radius: 12px;
  426. display: none;
  427. cursor: pointer;
  428. }
  429. &:hover {
  430. .reset-button {
  431. display: block;
  432. }
  433. }
  434. }
  435. p:first-of-type {
  436. ::v-deep {
  437. .el-loading-mask { display: block !important;}
  438. }
  439. }
  440. }
  441. }
  442. .footer-controls {
  443. display: flex;
  444. justify-content: space-between;
  445. align-items: center;
  446. padding: 0px 20px;
  447. border-top: 1px solid #D9DEE6;
  448. background-color: #fff;
  449. min-height: 50px;
  450. flex-shrink: 0;
  451. position: fixed;
  452. bottom:0;
  453. left: 0;
  454. right: 0;
  455. font-size: 14px;
  456. z-index: 100;
  457. img {
  458. height: 12px;
  459. margin: 0 5px;
  460. }
  461. .go {
  462. height: 12px;
  463. opacity: .8;
  464. }
  465. ::v-deep {
  466. .el-button {
  467. border-radius: 10px;
  468. height: 40px;
  469. line-height: 40px;
  470. }
  471. }
  472. .footer-left {
  473. display: flex;
  474. align-items: center;
  475. gap: 10px;
  476. .select-all-checkbox {
  477. margin-right: 0;
  478. ::v-deep {
  479. .el-checkbox__label {
  480. font-size: 14px;
  481. color: #666;
  482. }
  483. }
  484. }
  485. .image-count-text {
  486. font-size: 14px;
  487. color: #333;
  488. margin-left: 0;
  489. }
  490. }
  491. .footer-right {
  492. display: flex;
  493. align-items: center;
  494. gap: 10px;
  495. }
  496. }
  497. }
  498. </style>