detail.vue 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762
  1. <template>
  2. <headerBar title="主图与详情生成" />
  3. <div class="detail-container">
  4. <div>
  5. <!-- 顶部:勾选服务内容(多选) -->
  6. <div class="service-section flex between top">
  7. <div class="section-title">
  8. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  9. 勾选服务内容(多选):
  10. </div>
  11. <div class="service-cards">
  12. <div class="service-card" :class="{ active: form.services.includes('is_product_scene') }" @click="toggleService('is_product_scene')" v-log="{ describe: { action: '点击服务卡片', service: '场景图生成' } }">
  13. <div class="service-checkbox" @click.stop>
  14. <el-checkbox size="large" :model-value="form.services.includes('is_product_scene')" @change="toggleService('is_product_scene')" />
  15. </div>
  16. <div class="service-content">
  17. <div class="service-image">
  18. <img src="@/assets/images/Photography/cj.png" alt="场景图生成" />
  19. <div class="service-icon" @click.stop="openScenePromptDialog" v-log="{ describe: { action: '点击服务卡片图标', service: '场景图生成-弹窗' } }">
  20. <el-icon><EditPen /></el-icon>
  21. </div>
  22. </div>
  23. <div class="service-name">场景图生成</div>
  24. </div>
  25. </div>
  26. <div class="service-card" :class="{ active: form.services.includes('is_upper_footer') }" @click="toggleService('is_upper_footer')" v-log="{ describe: { action: '点击服务卡片', service: '模特图生成' } }">
  27. <div class="service-checkbox" @click.stop>
  28. <el-checkbox size="large" :model-value="form.services.includes('is_upper_footer')" @change="toggleService('is_upper_footer')" />
  29. </div>
  30. <div class="service-content">
  31. <div class="service-image">
  32. <img src="@/assets/images/Photography/mt.png" alt="模特图生成" />
  33. <div class="service-icon" @click.stop="openModelDialog" v-log="{ describe: { action: '点击服务卡片图标', service: '模特图生成-弹窗' } }">
  34. <el-icon><EditPen /></el-icon>
  35. </div>
  36. </div>
  37. <div class="service-name">模特图生成</div>
  38. </div>
  39. </div>
  40. <div class="service-card" :class="{ active: form.services.includes('is_detail') }" @click="toggleService('is_detail')" v-log="{ describe: { action: '点击服务卡片', service: '详情页生成' } }">
  41. <div class="service-checkbox" @click.stop>
  42. <el-checkbox size="large" :model-value="form.services.includes('is_detail')" @change="toggleService('is_detail')" />
  43. </div>
  44. <div class="service-content">
  45. <div class="service-image">
  46. <img src="@/assets/images/Photography/xq.png" alt="详情页生成" />
  47. </div>
  48. <div class="service-name">详情页生成</div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <!-- 主图LOGO部分 -->
  54. <!--
  55. <div class="logo-section flex left top" >
  56. <div class="section-title" style="margin-bottom: 0px;">
  57. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  58. 主图LOGO 与 选择详情模板:
  59. </div>
  60. </div>
  61. <div class="logo-section flex left top multi-line">
  62. <upload v-for="item,index in logoList" :value="item" :key="item"
  63. v-show="item"
  64. @input="onRemove(index)"
  65. class="mar-right-10 upload-item"
  66. :class="{
  67. active: item === form.logo_path
  68. }"
  69. @click.native="form.logo_path = item"
  70. ></upload>
  71. <upload @input="onInput"></upload>
  72. </div>
  73. -->
  74. <el-divider />
  75. <!-- &lt;!&ndash; 图片抠图与货号图生成 &ndash;&gt;
  76. <div class="section">
  77. <div class="section-title">
  78. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  79. 图片抠图与货号图生成
  80. </div>
  81. <div class="section-content">
  82. <div v-if="showTips" class="instruction-out flex top left">
  83. <img style="fill: #000" src="@/assets/images/xinxi.svg" />
  84. <ol class="instruction-list">
  85. <li>请在下方确认图片拍摄过程中的顺序,确保所有拍摄的图片的顺序一致。</li>
  86. <li>使用中英文语号分隔。</li>
  87. <li>图片的名称不能随意修改,否则无法正常生成详情页。</li>
  88. <li>现有图片名称有:俯视、侧视、后视、鞋底、内里</li>
  89. </ol>
  90. <el-icon @click="showTips = false" class="close-icon">
  91. <Close />
  92. </el-icon>
  93. </div>
  94. &lt;!&ndash; 货号文件夹 &ndash;&gt;
  95. &lt;!&ndash; <div class="form-item">
  96. <div class="label">货号文件夹:</div>
  97. <div class="folder-warp">
  98. <div class="folder-input">
  99. <el-input style="width: 60%;" v-model="folderPath" type="textarea" :rows="2" readonly
  100. placeholder="请选择货号文件夹" />
  101. <el-button class="check-button" type="primary" @click="selectFolder">
  102. <img src="@/assets/images/Photography/wenjian.png" style="width: 14px; " />
  103. 选择目标文件夹</el-button>
  104. </div>
  105. <div class="hint">
  106. <el-icon>
  107. <Warning />
  108. </el-icon> <text>选择货号的上级文件夹</text>
  109. </div>
  110. </div>
  111. </div>
  112. &ndash;&gt;
  113. </div>
  114. </div>
  115. <el-divider />-->
  116. <!-- 主图LOGO 与 选择详情模板:左右布局 -->
  117. <div class="logo-template-row">
  118. <!-- 左:主图LOGO -->
  119. <div class="logo-col">
  120. <div class="logo-section flex left top" >
  121. <div class="section-title" style="margin-bottom: 0px;">
  122. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  123. 主图LOGO:
  124. </div>
  125. </div>
  126. <div class="logo-section flex left top multi-line">
  127. <upload v-for="item,index in logoList" :value="item" :key="item"
  128. v-show="item"
  129. @input="onRemove(index)"
  130. class="mar-right-10 upload-item"
  131. :class="{
  132. active: item === form.logo_path
  133. }"
  134. @click.native="selectLogo(item)"
  135. ></upload>
  136. <upload @input="onInput"></upload>
  137. </div>
  138. </div>
  139. <!-- 右:选择详情模板 -->
  140. <div class="template-col">
  141. <div class="template-section ">
  142. <div class="flex between">
  143. <div class="section-title">
  144. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  145. 选择详情模版
  146. </div>
  147. <div class="template-pagination">
  148. <el-pagination background layout="prev, pager, next" v-model:current-page="queryParams.current"
  149. v-model:page-size.sync="queryParams.size" :total="totalPage" @current-change="onCurrentChange"
  150. @size-change="onSizeChange" />
  151. </div>
  152. </div>
  153. <div class="template-list">
  154. <div v-for="(template, index) in visibleTemplates" :key="index" class="template-item"
  155. @click="selectTemplate(template)" v-log="{ describe: { action: '点击选择详情模板', template_name: template.template_name } }">
  156. <el-image :src="template.template_cover_image" fit="contain" class="cur-p"
  157. style="width: 100%; display: block;" />
  158. <div class="select-warp" :class="form.selectTemplate?.id == template.id ? 'active' : ''">
  159. <el-icon color="#FFFFFF">
  160. <Select />
  161. </el-icon>
  162. </div>
  163. <div class="template-info">
  164. <span class="mar-left-10 chaochu_1">{{ template.template_name }}</span>
  165. <div class="template-view" @click="viewTemplate(template)" v-log="{ describe: { action: '点击查看模板详情', template_name: template.template_name } }">查看</div>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="template-tips c-333 fs-14 line-20 te-l mar-top-20 flex left">
  170. <el-icon><WarningFilled /></el-icon>
  171. <span class="mar-left-10">该模版要求拍摄图片:{{form.selectTemplate?.template_image_order}}
  172. <template v-if="form.selectTemplate?.template_image_order">,共{{form.selectTemplate?.template_image_order.split(',').length}}张。</template>
  173. </span>
  174. </div>
  175. <!-- 模板下:一键上架 和 电商平台(多选) -->
  176. <div class="publish-section flex left" v-if="onlineStoreTempList.length || onlineStoreTempListForeign.length">
  177. <div class="form-item flex left">
  178. <div class="fw-b">一键上架:</div>
  179. </div>
  180. <div class="form-item flex left mar-top-10" style="margin-right: 10px !important;" v-if="onlineStoreTempList.length">
  181. <div class="label">国内电商平台:</div>
  182. <el-select v-model="domesticPlatforms" multiple placeholder="请选择平台" style="min-width: 200px;">
  183. <el-option
  184. v-for="store in onlineStoreTempList"
  185. :key="store.show_name"
  186. :label="store.show_name"
  187. :value="store.online_store_name"
  188. :disabled="!store.channel_status"
  189. />
  190. </el-select>
  191. </div>
  192. <div class="form-item flex left mar-top-10" v-if="onlineStoreTempListForeign.length">
  193. <div class="label">国外电商平台:</div>
  194. <el-select v-model="foreignPlatforms" multiple placeholder="请选择平台" style="min-width: 200px;">
  195. <el-option
  196. v-for="store in onlineStoreTempListForeign"
  197. :key="store.show_name"
  198. :label="store.show_name"
  199. :value="store.online_store_name"
  200. :disabled="!store.channel_status"
  201. />
  202. </el-select>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </div>
  208. <el-divider />
  209. <!-- 详情高级配置 -->
  210. <!-- <div class="section">
  211. <div class="section-title">
  212. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  213. 详情高级配置
  214. </div>
  215. <div class="section-content">
  216. &lt;!&ndash; 图片顺序 &ndash;&gt;
  217. <div class="form-item">
  218. <div class="label">图片顺序:</div>
  219. <el-input v-model="imageOrder" placeholder="请输入图片顺序" class="specific-page-input">
  220. <template #append>
  221. <el-button class="explain-btn" link type="primary">说明</el-button>
  222. </template>
  223. </el-input>
  224. </div>
  225. &lt;!&ndash; 同款检验 &ndash;&gt;
  226. &lt;!&ndash; <div class="form-item">
  227. <div class="label">同款检验:</div>
  228. <el-checkbox v-model="checkSimilar">同款下货号必须齐全</el-checkbox>
  229. </div>
  230. &ndash;&gt;
  231. &lt;!&ndash; 可指定页面独修改 &ndash;&gt;
  232. &lt;!&ndash; <div class="form-item">
  233. <div class="label">可指定页面独修改:</div>
  234. <el-input v-model="specificPage" placeholder="请输入入需要单独修改的页面,示例:4:1 (需修改模版的编号:第一张)"
  235. class="specific-page-input">
  236. <template #append>
  237. <el-button class="explain-btn" link type="primary">说明</el-button>
  238. </template>
  239. </el-input>
  240. </div>
  241. &ndash;&gt;
  242. </div>
  243. </div>
  244. <el-divider />-->
  245. <!-- 详情资料准备部分 -->
  246. <div class="data-prep-section">
  247. <div class="flex-item left">
  248. <div class="section-title">
  249. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  250. 详情资料准备 (2选1)
  251. <el-button v-if="form.dataType == '1'" type="text" class="mar-left-10 fs-16" @click="downloadExcel" v-log="{ describe: { action: '点击下载Excel模板' } }">下载商品基础资料模版</el-button>
  252. </div>
  253. </div>
  254. <div class="flex-item left">
  255. <el-radio-group v-model="form.dataType" class="ml-4">
  256. <el-radio label="1" size="large">EXCEL文件选择</el-radio>
  257. <el-radio label="2" size="large">系统对接(和业务员联系)</el-radio>
  258. </el-radio-group>
  259. </div>
  260. <div v-if="form.dataType == '1'" class="excel-upload">
  261. <div class="flex bottom between">
  262. <div style="max-width: 160px;" class="mar-left-20">商品基础资料EXCEL文件选择:</div>
  263. <div class="flex bottom mar-left-20" style="flex-grow: 1;">
  264. <el-input type="textarea" v-model="form.excel_path" />
  265. </div>
  266. <el-button class="select-button button--primary1 mar-left-20" type="primary" @click="selectExcel" v-log="{ describe: { action: '点击选择Excel文件' } }">
  267. <img src="@/assets/images/Photography/wenjian.png" style="width: 16px; margin-right: 4px;" />
  268. 选择</el-button>
  269. </div>
  270. </div>
  271. </div>
  272. </div>
  273. <!-- 底部按钮 -->
  274. <div class="footer">
  275. <!-- <el-button class="button--primary1 footer-button" type="primary" @click="saveConfig">保存配置</el-button> -->
  276. <!-- <el-button class="button--primary1 footer-button" type="primary" @click="startProcess">开始处理</el-button> -->
  277. <el-button class="button--primary1 footer-button" type="primary" @click="generate" v-log="{ describe: { action: '点击开始生成详情页' } }">开始生成</el-button>
  278. </div>
  279. </div>
  280. <loading-dialog v-if="loadingDialogVisible" v-model="loadingDialogVisible" :requesting="requesting" :progress="progress" :message="message"
  281. :disabled-button="disabledButton" @button-click="handleComplete">
  282. <template v-if="partErrList && partErrList.length > 0" #errList>
  283. <div v-for="(item, idx) in partErrList" :key="idx">
  284. <span v-if="item.goods_art_no">{{ item.goods_art_no }}:</span><span>{{ item.info }}</span>
  285. </div>
  286. </template>
  287. <template #progressMessages>
  288. <div class="progress-messages" v-if="progressMessages.length">
  289. <div class="message-header">
  290. <span>处理进度</span>
  291. <div class="flex right" style="gap:8px; align-items:center;">
  292. <el-button type="text" @click="openOutputDir" v-log="{ describe: { action: '点击打开输出目录' } }">打开目录</el-button>
  293. <el-button type="text" @click="showMessageHistory = !showMessageHistory" v-log="{ describe: { action: '点击查看进度详情' } }">
  294. {{ showMessageHistory ? '收起' : '查看详情' }}
  295. </el-button>
  296. </div>
  297. </div>
  298. <div class="message-list" v-if="showMessageHistory" ref="messageListRef">
  299. <div v-for="(msg, index) in progressMessages" :key="index" class="message-item flex left">
  300. <div class="message-time">{{ formatTime(msg.timestamp) }}</div>
  301. <div class="message-content mar-left-10">
  302. <span class="goods-no">货号{{ msg.goods_art_nos.join(', ') }}:</span>
  303. <span class="message-text">{{ msg.msg }}</span>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. </template>
  309. </loading-dialog>
  310. <el-dialog v-model="dialogVisible">
  311. <img style="width: 100%;" :src="dialogImageUrl" alt="Preview Image" />
  312. </el-dialog>
  313. <!-- 模特生成弹窗 -->
  314. <ModelGenerationDialog
  315. v-model="modelDialogVisible"
  316. :initial-models="selectedModels"
  317. @confirm="handleModelSelection"
  318. @cancel="modelDialogVisible = false"
  319. />
  320. <!-- 场景提示词弹窗 -->
  321. <ScenePromptDialog
  322. v-model="scenePromptDialogVisible"
  323. :initial-prompt="scenePrompt"
  324. @confirm="handleScenePromptConfirm"
  325. @cancel="scenePromptDialogVisible = false"
  326. />
  327. </template>
  328. <script lang="ts" setup>
  329. import { getCompanyTemplatesApi } from '@/apis/other'
  330. import tokenInfo from '@/stores/modules/token';
  331. import useUserInfo from "@/stores/modules/user";
  332. import { useRoute, useRouter } from 'vue-router'
  333. import { clickLog, setLogInfo } from '@/utils/log'
  334. import { ElMessage, ElMessageBox } from 'element-plus'
  335. import headerBar from '@/components/header-bar/index.vue'
  336. import { ref, computed, reactive, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
  337. import { Select, EditPen } from '@element-plus/icons-vue'
  338. import upload from '@/components/upload'
  339. import client from "@/stores/modules/client";
  340. import icpList from '@/utils/ipc'
  341. const clientStore = client();
  342. import { getRouterUrl } from '@/utils/appfun'
  343. import { useUuidStore } from '@/stores/modules/uuid'
  344. import socket from "@/stores/modules/socket";
  345. const socketStore = socket();
  346. import ModelGenerationDialog from '@/components/ModelGeneration/index.vue'
  347. import ScenePromptDialog from '@/components/ScenePromptDialog/index.vue'
  348. import { Close, Warning } from '@element-plus/icons-vue'
  349. import LoadingDialog from '@/views/Photography/components/LoadingDialog.vue'
  350. import configInfo from "@/stores/modules/config";
  351. const useConfigInfoStore = configInfo();
  352. import { useCheckInfo } from '@/composables/userCheck';
  353. useCheckInfo();
  354. const showTips = ref(true)
  355. const folderPath = ref('') //货号文件夹
  356. // const reportMode = ref('normal') // 抠图模式
  357. const imageOrder = ref('俯视、侧视、后跟、鞋底、内里、组合、组合2、组合3') // 图片顺序
  358. const checkSimilar = ref(false) // 同款检验
  359. const specificPage = ref('') // 可指定页面独修改
  360. // 路由和状态管理初始化
  361. const route = useRoute();
  362. const router = useRouter();
  363. const uuidStore = useUuidStore();
  364. // 完成目录
  365. const completeDirectory = ref('')
  366. const loadingDialogVisible = ref(false)
  367. const progress = ref(0)
  368. const message = ref('正在为您处理,请稍后')
  369. const disabledButton = ref(true)
  370. // 进度消息队列
  371. const progressMessages = ref<Array<{
  372. goods_no: string
  373. temp_name: string
  374. status: string
  375. goods_art_nos: string[]
  376. msg: string
  377. timestamp: number
  378. }>>([])
  379. const showMessageHistory = ref(true)
  380. const messageListRef = ref<HTMLElement | null>(null)
  381. // 新消息时自动滚动到底部
  382. const scrollMessageListToBottom = () => {
  383. nextTick(() => {
  384. const el = messageListRef.value
  385. if (el) {
  386. el.scrollTop = el.scrollHeight
  387. }
  388. })
  389. }
  390. let templates = ref([])
  391. let goods_art_nos = ref([])
  392. let partErrList = ref([])
  393. const excel_template_url = ref('')
  394. // 是否正在请求接口
  395. const requesting = ref(false)
  396. // 定义一个定时器变量
  397. const INTERVAL = ref<number | NodeJS.Timeout | null>(null);
  398. // 状态变量
  399. const totalPage = ref(0);
  400. const itemsPerPage = 4; // 每页显示的模板数量
  401. const dialogVisible = ref(false);
  402. const dialogImageUrl = ref('');
  403. const queryParams = reactive({ // 分页查询参数
  404. size: 1,
  405. current: 1,
  406. })
  407. const form = reactive({
  408. selectTemplate: {}, //选中的模板
  409. dataType: '1', // 1: 选择excel文件 2: 系统对接
  410. logo_path: '', // 主图LOGO
  411. excel_path: '', // 商品基础资料EXCEL文件选择
  412. services: ['is_detail'], // 勾选服务内容(多选)默认包含详情页生成
  413. })
  414. onMounted(() => {
  415. // 页面访问埋点
  416. const goods_art_data = route.query.goods_art_nos
  417. goods_art_nos.value = Array.isArray(goods_art_data) ? goods_art_data : [goods_art_data]
  418. getCompanyTemplates()
  419. getLogolist()
  420. loadDetailCache()
  421. })
  422. // 监听数据类型变化,自动保存到缓存
  423. watch(() => form.dataType, (newValue) => {
  424. if (newValue) {
  425. saveDataTypeToCache(newValue)
  426. }
  427. })
  428. // 页面卸载时清理监听器
  429. onBeforeUnmount(() => {
  430. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  431. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  432. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  433. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  434. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  435. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  436. clearInterval(INTERVAL.value);
  437. })
  438. // 计算属性,获取当前页可见的模板
  439. const visibleTemplates = computed(() => {
  440. const startIndex = (queryParams.current - 1) * itemsPerPage;
  441. const data = templates.value.slice(startIndex, startIndex + itemsPerPage);
  442. return data
  443. });
  444. // 查看模板详情
  445. const viewTemplate = (template) => {
  446. // 展示大图
  447. dialogVisible.value = true
  448. dialogImageUrl.value = template.template_preview_image
  449. };
  450. // 获取模版列表
  451. const getCompanyTemplates = async () => {
  452. const { data } = await getCompanyTemplatesApi()
  453. console.log(data);
  454. templates.value = data.list
  455. // 获取电商平台列表 - 支持新的数据结构
  456. if (data.online_store_temp_list) {
  457. onlineStoreTempList.value = data.online_store_temp_list
  458. }
  459. if (data.online_store_temp_list_foreign) {
  460. onlineStoreTempListForeign.value = data.online_store_temp_list_foreign
  461. }
  462. // 默认选中第一个模板
  463. if (templates.value.length > 0) {
  464. form.selectTemplate = templates.value[0]
  465. }
  466. excel_template_url.value = data.excel_template_url
  467. // 计算总页数
  468. totalPage.value = Math.ceil(templates.value.length / itemsPerPage);
  469. }
  470. const downloadExcel = () => {
  471. const a = document.createElement('a')
  472. a.href = excel_template_url.value,
  473. a.download = '商品基础资料模版'
  474. document.body.appendChild(a)
  475. a.click()
  476. setTimeout(() => {
  477. document.body.removeChild(a);
  478. }, 1000);
  479. }
  480. // 服务内容切换
  481. const toggleService = (key: string) => {
  482. const idx = form.services.indexOf(key)
  483. if (idx > -1) form.services.splice(idx, 1)
  484. else form.services.push(key)
  485. // 保存服务选择状态到缓存
  486. saveServicesToCache(form.services)
  487. }
  488. // 电商平台多选与一键上架
  489. const domesticPlatforms = ref<string[]>([])
  490. const foreignPlatforms = ref<string[]>([])
  491. const onlineStoreTempList = ref<any[]>([]) // 国内电商平台列表
  492. const onlineStoreTempListForeign = ref<any[]>([]) // 国外电商平台列表
  493. // 模特与场景弹窗
  494. const modelDialogVisible = ref(false)
  495. const scenePromptDialogVisible = ref(false)
  496. const selectedModels = ref<{ female: any; male: any } | null>(null)
  497. const scenePrompt = ref('')
  498. // 本地缓存键(与弹窗组件保持一致)
  499. const DETAIL_MODEL_CACHE_KEY = 'model_selection_cache'
  500. const DETAIL_SCENE_PROMPT_CACHE_KEY = 'scene_prompt_cache'
  501. const DETAIL_LOGO_CACHE_KEY = 'detail_logo_cache'
  502. const DETAIL_DATA_TYPE_CACHE_KEY = 'detail_data_type_cache'
  503. const DETAIL_SERVICES_CACHE_KEY = 'detail_services_cache'
  504. // 读取本地缓存
  505. const loadDetailCache = () => {
  506. console.log('loadDetailCache');
  507. try {
  508. const m = localStorage.getItem(DETAIL_MODEL_CACHE_KEY)
  509. if (m) {
  510. const parsed = JSON.parse(m)
  511. if (parsed && (parsed.female || parsed.male)) {
  512. selectedModels.value = parsed
  513. console.log('loadDetailCache');
  514. console.log(selectedModels.value);
  515. }
  516. }
  517. } catch {}
  518. try {
  519. const p = localStorage.getItem(DETAIL_SCENE_PROMPT_CACHE_KEY)
  520. if (p) {
  521. console.log('scenePrompt');
  522. scenePrompt.value = p
  523. console.log(scenePrompt.value);
  524. }
  525. } catch {}
  526. // 加载LOGO缓存
  527. try {
  528. const logo = localStorage.getItem(DETAIL_LOGO_CACHE_KEY)
  529. if (logo) {
  530. form.logo_path = logo
  531. console.log('loadDetailCache - logo:', logo);
  532. }
  533. } catch {}
  534. // 加载数据类型缓存
  535. try {
  536. const dataType = localStorage.getItem(DETAIL_DATA_TYPE_CACHE_KEY)
  537. if (dataType) {
  538. form.dataType = dataType
  539. console.log('loadDetailCache - dataType:', dataType);
  540. }
  541. } catch {}
  542. // 加载模板缓存
  543. try {
  544. const template = localStorage.getItem('detail_template_cache')
  545. if (template) {
  546. const parsed = JSON.parse(template)
  547. if (parsed && parsed.id) {
  548. form.selectTemplate = parsed
  549. console.log('loadDetailCache - template:', parsed);
  550. }
  551. }
  552. } catch {}
  553. // 加载服务选择状态缓存
  554. try {
  555. const services = localStorage.getItem(DETAIL_SERVICES_CACHE_KEY)
  556. if (services) {
  557. const parsed = JSON.parse(services)
  558. if (Array.isArray(parsed)) {
  559. form.services = parsed
  560. console.log('loadDetailCache - services:', parsed);
  561. }
  562. }
  563. } catch {}
  564. }
  565. // 保存到本地缓存(仅保存必要字段)
  566. const saveModelsToCache = (models: { female: any; male: any }) => {
  567. try {
  568. const payload = {
  569. female: models?.female ? {
  570. id: models.female.id,
  571. name: models.female.name,
  572. image_url: models.female.image_url,
  573. gender: models.female.gender,
  574. keywords: models.female.keywords,
  575. status: models.female.status
  576. } : null,
  577. male: models?.male ? {
  578. id: models.male.id,
  579. name: models.male.name,
  580. image_url: models.male.image_url,
  581. gender: models.male.gender,
  582. keywords: models.male.keywords,
  583. status: models.male.status
  584. } : null
  585. }
  586. localStorage.setItem(DETAIL_MODEL_CACHE_KEY, JSON.stringify(payload))
  587. } catch {}
  588. }
  589. const saveScenePromptToCache = (prompt: string) => {
  590. try {
  591. const v = (prompt || '').trim()
  592. if (v) localStorage.setItem(DETAIL_SCENE_PROMPT_CACHE_KEY, v)
  593. } catch {}
  594. }
  595. // 保存LOGO到缓存
  596. const saveLogoToCache = (logoPath: string) => {
  597. try {
  598. if (logoPath) {
  599. localStorage.setItem(DETAIL_LOGO_CACHE_KEY, logoPath)
  600. console.log('saveLogoToCache:', logoPath);
  601. }
  602. } catch {}
  603. }
  604. // 保存数据类型到缓存
  605. const saveDataTypeToCache = (dataType: string) => {
  606. try {
  607. if (dataType) {
  608. localStorage.setItem(DETAIL_DATA_TYPE_CACHE_KEY, dataType)
  609. console.log('saveDataTypeToCache:', dataType);
  610. }
  611. } catch {}
  612. }
  613. const saveServicesToCache = (services: string[]) => {
  614. try {
  615. localStorage.setItem(DETAIL_SERVICES_CACHE_KEY, JSON.stringify(services))
  616. console.log('saveServicesToCache:', services);
  617. } catch {}
  618. }
  619. const openModelDialog = () => {
  620. modelDialogVisible.value = true
  621. }
  622. const openScenePromptDialog = () => {
  623. scenePromptDialogVisible.value = true
  624. }
  625. // 选择模板
  626. const selectTemplate = (template: any) => {
  627. form.selectTemplate = template
  628. // 保存模板选择到缓存
  629. try {
  630. localStorage.setItem('detail_template_cache', JSON.stringify(template))
  631. console.log('selectTemplate - saved to cache:', template);
  632. } catch {}
  633. }
  634. // 选择LOGO
  635. const selectLogo = (logoPath: string) => {
  636. form.logo_path = logoPath
  637. // 保存LOGO选择到缓存
  638. saveLogoToCache(logoPath)
  639. }
  640. const handleModelSelection = (models: { female: any; male: any }) => {
  641. selectedModels.value = models
  642. saveModelsToCache(models)
  643. modelDialogVisible.value = false
  644. ElMessage.success('模特选择完成!')
  645. }
  646. const handleScenePromptConfirm = (prompt: string) => {
  647. scenePrompt.value = prompt
  648. saveScenePromptToCache(prompt)
  649. }
  650. const onCurrentChange = (page) => {
  651. queryParams.current = page;
  652. };
  653. const onSizeChange = (data) => {
  654. };
  655. // 格式化时间
  656. const formatTime = (timestamp: number) => {
  657. const date = new Date(timestamp)
  658. return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
  659. }
  660. // 处理进度消息
  661. const handleProgressMessage = (data: any) => {
  662. console.log("detail_progress", data);
  663. if (data.code === 0 && data.msg_type === 'detail_progress') {
  664. const messageData = {
  665. goods_no: data.data.goods_no,
  666. temp_name: data.data.temp_name,
  667. status: data.data.status,
  668. goods_art_nos: data.data.goods_art_nos,
  669. msg: data.msg,
  670. timestamp: Date.now()
  671. }
  672. progressMessages.value.push(messageData)
  673. // 更新当前显示的消息
  674. message.value = `货号${data.data.goods_art_nos.join(', ')}:${data.msg}`
  675. scrollMessageListToBottom()
  676. }
  677. }
  678. // 处理抠图进度消息
  679. const handleSegmentProgressMessage = (data: any) => {
  680. console.log("segment_progress", data);
  681. if (data.code === 0 && data.msg_type === 'segment_progress') {
  682. const messageData = {
  683. goods_no: '',
  684. temp_name: '',
  685. status: data.data.status,
  686. goods_art_nos: data.data.goods_art_nos,
  687. msg: data.msg,
  688. timestamp: Date.now()
  689. }
  690. progressMessages.value.push(messageData)
  691. // 更新当前显示的消息
  692. message.value = `货号${data.data.goods_art_nos.join(', ')}:${data.msg}`
  693. scrollMessageListToBottom()
  694. }
  695. }
  696. // 处理上脚图进度
  697. const handleUpperFooterProgressMessage = (data: any) => {
  698. console.log("upper_footer_progress", data);
  699. if (data.code === 0 && data.msg_type === 'upper_footer_progress') {
  700. const messageData = {
  701. goods_no: '',
  702. temp_name: '',
  703. status: data.data?.status || '',
  704. goods_art_nos: data.data?.goods_art_nos || [],
  705. msg: data.msg,
  706. timestamp: Date.now()
  707. }
  708. progressMessages.value.push(messageData)
  709. message.value = `货号${(data.data?.goods_art_nos || []).join(', ')}:${data.msg}`
  710. scrollMessageListToBottom()
  711. }
  712. }
  713. // 处理场景图进度
  714. const handleSceneProgressMessage = (data: any) => {
  715. console.log("scene_progress", data);
  716. if (data.code === 0 && data.msg_type === 'scene_progress') {
  717. const messageData = {
  718. goods_no: '',
  719. temp_name: '',
  720. status: data.data?.status || '',
  721. goods_art_nos: data.data?.goods_art_nos || [],
  722. msg: data.msg,
  723. timestamp: Date.now()
  724. }
  725. progressMessages.value.push(messageData)
  726. message.value = `货号${(data.data?.goods_art_nos || []).join(', ')}:${data.msg}`
  727. scrollMessageListToBottom()
  728. }
  729. }
  730. // 处理商品上传进度
  731. const handleUploadGoodsProgressMessage = (data: any) => {
  732. console.log("upload_goods_progress", data);
  733. if (data.code === 0 && data.msg_type === 'upload_goods_progress') {
  734. const messageData = {
  735. goods_no: '',
  736. temp_name: '',
  737. status: data.data?.status || '',
  738. goods_art_nos: data.data?.goods_art_nos || [],
  739. msg: data.msg,
  740. timestamp: Date.now()
  741. }
  742. progressMessages.value.push(messageData)
  743. message.value = `货号${(data.data?.goods_art_nos || []).join(', ')}:${data.msg}`
  744. scrollMessageListToBottom()
  745. }
  746. }
  747. // 打开输出目录:appConfig.appPath + '/build/extraResources/py/output'
  748. const openOutputDir = () => {
  749. try {
  750. const pyPath = useConfigInfoStore?.appConfig?.pyPath || ''
  751. if (!pyPath) {
  752. ElMessage.error('未获取到应用目录 appPath')
  753. return
  754. }
  755. console.log(pyPath);
  756. const fullPath = `${pyPath}\\output`
  757. console.log(fullPath);
  758. clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
  759. clientStore.ipc.send(icpList.utils.shellFun, {
  760. action: 'openPath',
  761. params: fullPath.replace(/\//g, '\\')
  762. });
  763. } catch (e) {
  764. console.error(e)
  765. ElMessage.error('打开目录失败')
  766. }
  767. }
  768. // 检测参数是否有效
  769. const checkParams = async function () {
  770. const useConfigInfoStore = configInfo();
  771. const tokenInfoStore = tokenInfo();
  772. const token = tokenInfoStore.getToken;
  773. let temp_list = []
  774. templates.value.map(item => {
  775. temp_list.push({
  776. template_id: item.template_id,
  777. template_local_classes: item.template_local_classes,
  778. })
  779. })
  780. // 根据选择的服务内容设置参数
  781. const isDetail = form.services.includes('is_detail') ? 1 : 0
  782. const isProductScene = form.services.includes('is_product_scene') ? 1 : 0
  783. const isUpperFooter = form.services.includes('is_upper_footer') ? 1 : 0
  784. const params = {
  785. goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
  786. logo_path: form.logo_path || '',
  787. temp_name: form.selectTemplate?.template_id || '',
  788. excel_path: form.dataType == '1' ? form.excel_path : '',
  789. template_image_order: form.selectTemplate?.template_image_order,
  790. temp_list,
  791. token,
  792. uuid: uuidStore.getUuid || '',
  793. // 新增服务参数 - 合并国内和国外平台
  794. online_stores: [...(domesticPlatforms.value || []), ...(foreignPlatforms.value || [])],
  795. is_detail: isDetail,
  796. is_product_scene: isProductScene,
  797. is_upper_footer: isUpperFooter,
  798. upper_footer_params: selectedModels.value ? {
  799. man_id: selectedModels.value.male?.id || "",
  800. women_id: selectedModels.value.female?.id || ""
  801. } : {},
  802. product_scene_prompt: scenePrompt.value || '',
  803. is_check: 1 // 仅检测,不生成
  804. }
  805. try {
  806. // 直接调用API进行检测,因为检测模式会直接返回结果
  807. const response = await clientStore.ipc.invoke(icpList.generate.generatePhotoDetail, params);
  808. console.log('=======checkParamscheckParamscheckParamscheckParams===========');
  809. console.log(params);
  810. console.log(response);
  811. if (response.code === 0) {
  812. return response;
  813. } else {
  814. throw new Error(response.msg || '检测失败');
  815. }
  816. } catch (error) {
  817. throw new Error(error.message || '检测失败');
  818. }
  819. }
  820. // 开始生成操作
  821. const generate = async function () {
  822. if(form.services.length == 0){
  823. ElMessage.error('请选择服务内容')
  824. return
  825. }
  826. // 埋点:开始生成详情页
  827. clickLog({
  828. describe: {
  829. action: '点击开始生成详情页',
  830. services: form.services,
  831. dataType: form.dataType,
  832. template_name: form.selectTemplate?.template_name,
  833. goods_count: goods_art_nos.value.length,
  834. goods_art_nos: goods_art_nos.value
  835. }
  836. }, route);
  837. // 必填验证
  838. if (form.services.includes('is_upper_footer') && !( selectedModels.value && selectedModels.value.male?.id && selectedModels.value.female?.id)) {
  839. openModelDialog();
  840. setTimeout(()=>{
  841. ElMessage.error('请选择模特')
  842. },200)
  843. return
  844. }
  845. if (form.services.includes('is_product_scene') && !scenePrompt.value) {
  846. openScenePromptDialog();
  847. setTimeout(()=>{
  848. ElMessage.error('请设置场景提示词')
  849. },200)
  850. return
  851. }
  852. if(form.services.includes('is_detail')){
  853. if ( form.dataType == '1' && !form.excel_path) {
  854. ElMessage.error('请上传商品基础资料')
  855. return
  856. }
  857. }
  858. // 先进行检测
  859. try {
  860. // ElMessage.info('正在检测参数,请稍候...');
  861. await checkParams();
  862. // ElMessage.success('检测通过,开始生成...');
  863. } catch (error) {
  864. ElMessage.error(error.message || '检测失败,请检查参数');
  865. return;
  866. }
  867. const useConfigInfoStore = configInfo();
  868. console.log(useConfigInfoStore.appConfig);
  869. const tokenInfoStore = tokenInfo();
  870. const token = tokenInfoStore.getToken; // 使用 getToken() 获取 token
  871. let temp_list = []
  872. templates.value.map(item => {
  873. temp_list.push({
  874. template_id: item.template_id,
  875. template_local_classes: item.template_local_classes,
  876. })
  877. })
  878. // 根据选择的服务内容设置参数
  879. const isDetail = form.services.includes('is_detail') ? 1 : 0
  880. const isProductScene = form.services.includes('is_product_scene') ? 1 : 0
  881. const isUpperFooter = form.services.includes('is_upper_footer') ? 1 : 0
  882. const params = {
  883. goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
  884. logo_path: form.logo_path || '',
  885. temp_name: form.selectTemplate?.template_id || '',
  886. excel_path: form.dataType == '1' ? form.excel_path : '',
  887. template_image_order: form.selectTemplate?.template_image_order,
  888. temp_list,
  889. token,
  890. uuid: uuidStore.getUuid || '',
  891. // 新增服务参数 - 合并国内和国外平台
  892. online_stores: [...(domesticPlatforms.value || []), ...(foreignPlatforms.value || [])],
  893. is_detail: isDetail,
  894. is_product_scene: isProductScene,
  895. is_upper_footer: isUpperFooter,
  896. upper_footer_params: selectedModels.value ? {
  897. man_id: selectedModels.value.male?.id || "",
  898. women_id: selectedModels.value.female?.id || ""
  899. } : {},
  900. product_scene_prompt: scenePrompt.value || '',
  901. is_check: 0 // 正式生成
  902. }
  903. console.log(params)
  904. // 开启进度弹窗
  905. requesting.value = false
  906. partErrList.value = []
  907. message.value = '正在为您处理,请稍后'
  908. progress.value = 0
  909. // 清空之前的进度消息
  910. progressMessages.value = []
  911. showMessageHistory.value = true
  912. openLoadingDialog(goods_art_nos.value.length * 10)
  913. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  914. clientStore.ipc.send(icpList.generate.generatePhotoDetail, params);
  915. /*
  916. * detail_result_progress
  917. *
  918. * */
  919. // 监听进度消息
  920. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  921. clientStore.ipc.on(icpList.socket.message + '_detail_progress', (event, data) => {
  922. console.log('_detail_progress',data);
  923. handleProgressMessage(data)
  924. });
  925. // 监听抠图进度消息
  926. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  927. clientStore.ipc.on(icpList.socket.message + '_segment_progress', (event, data) => {
  928. console.log('_segment_progress',data);
  929. handleSegmentProgressMessage(data)
  930. });
  931. // 监听上脚图进度消息
  932. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  933. clientStore.ipc.on(icpList.socket.message + '_upper_footer_progress', (event, data) => {
  934. console.log('_upper_footer_progress',data);
  935. handleUpperFooterProgressMessage(data)
  936. });
  937. // 监听场景图进度消息
  938. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  939. clientStore.ipc.on(icpList.socket.message + '_scene_progress', (event, data) => {
  940. console.log('_scene_progress',data);
  941. handleSceneProgressMessage(data)
  942. });
  943. // 监听商品上传进度消息
  944. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  945. clientStore.ipc.on(icpList.socket.message + '_upload_goods_progress', (event, data) => {
  946. console.log('_upload_goods_progress',data);
  947. handleUploadGoodsProgressMessage(data)
  948. });
  949. clientStore.ipc.on(icpList.socket.message + '_detail_result_progress', (event, result) => {
  950. if(result.code !== 0 ){
  951. if(result.msg){
  952. handleFail(result.msg)
  953. message.value = 'result.msg'
  954. }
  955. progress.value = 0
  956. loadingDialogVisible.value = false
  957. return;
  958. }
  959. console.log('result', result)
  960. requesting.value = true
  961. setTimeout(() => {
  962. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  963. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  964. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  965. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  966. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  967. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  968. }, 100)
  969. clearInterval(INTERVAL.value)
  970. if (result.code === 0) {
  971. const { output_folder, list } = result.data
  972. const allSuccess = list.every(item => item.success);
  973. const allFailure = list.every(item => !item.success);
  974. if (allSuccess) {
  975. console.log("全部成功")
  976. handleSuccess(output_folder, '全部生成成功')
  977. } else if (allFailure) {
  978. console.log("全部失败");
  979. handleFailure(list)
  980. } else {
  981. console.log("部分成功,部分失败");
  982. handlePartSuccess(output_folder, list)
  983. }
  984. } else {
  985. console.log('code全部生成失败')
  986. handleFail(result.msg)
  987. }
  988. //生成失败 (接口请求失败)
  989. function handleFail(errorMsg: string) {
  990. // loadingDialogVisible.value = false
  991. // disabledButton.value = false
  992. if (errorMsg) {
  993. ElMessage.error(errorMsg)
  994. }
  995. // 处理完成后停止监听进度消息
  996. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  997. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  998. }
  999. // 全部生成成功
  1000. function handleSuccess(href, loadingMsg) {
  1001. // 埋点:生成完成
  1002. setLogInfo(route, { action: '生成完成', output_folder: href, message: loadingMsg });
  1003. completeDirectory.value = href
  1004. progress.value = 100
  1005. disabledButton.value = false
  1006. message.value = loadingMsg
  1007. handleComplete()
  1008. }
  1009. // 部分成功
  1010. function handlePartSuccess(output_folder: string, partSuccessList) {
  1011. let errorList = []
  1012. partSuccessList.map(item => {
  1013. if (!item.success) {
  1014. errorList.push(item)
  1015. }
  1016. })
  1017. partErrList.value = errorList
  1018. handleSuccess(output_folder, '部分货号生成失败')
  1019. }
  1020. // 全部生成失败
  1021. function handleFailure(partSuccessList) {
  1022. // 埋点:生成失败(携带货号)
  1023. const failedGoods = (partSuccessList || []).map(item => item.goods_art_no).filter(Boolean)
  1024. setLogInfo(route, { action: '生成失败', error_count: partSuccessList.length, goods_art_nos: goods_art_nos.value, failed_goods_art_nos: failedGoods });
  1025. let errorList = []
  1026. partSuccessList.map(item => {
  1027. if (!item.success) {
  1028. errorList.push(item)
  1029. }
  1030. })
  1031. partErrList.value = errorList
  1032. completeDirectory.value = ''
  1033. progress.value = 100
  1034. disabledButton.value = true
  1035. message.value = '全部货号生成失败'
  1036. }
  1037. });
  1038. }
  1039. const openLoadingDialog = (timer: number) => {
  1040. loadingDialogVisible.value = true
  1041. disabledButton.value = true
  1042. // 根据传入的秒数计算每次增加的进度值
  1043. const step = 100 / timer
  1044. INTERVAL.value = setInterval(() => {
  1045. if (progress.value < 50) {
  1046. progress.value = Math.min(progress.value + step, 100)
  1047. } else if (progress.value < 70) {
  1048. progress.value = Math.min(progress.value + step / 2, 100)
  1049. } if (progress.value < 85) {
  1050. progress.value = Math.min(progress.value + step / 5, 100)
  1051. } else if (progress.value < 90) {
  1052. progress.value = Math.min(progress.value + step / 10, 100)
  1053. } else if (progress.value < 95) {
  1054. progress.value = Math.min(progress.value + step / 50, 100)// 新增中间阶段
  1055. } else {
  1056. progress.value = Math.min(progress.value + step / 100, 100)
  1057. }
  1058. }, 1000)
  1059. }
  1060. //logo
  1061. const logoList = ref([])
  1062. const onInput = (value) => {
  1063. addLogo(value)
  1064. }
  1065. const onRemove = (index) => {
  1066. if(logoList.value[index] === form.logo_path){
  1067. form.logo_path = ''
  1068. }
  1069. clientStore.ipc.send(icpList.generate.deleteLogo,{
  1070. path:logoList.value[index]
  1071. });
  1072. logoList.value.splice(index, 1)
  1073. clientStore.ipc.on(icpList.generate.deleteLogo, async (event, result) => {
  1074. console.log('deleteLogo');
  1075. console.log(result);
  1076. clientStore.ipc.removeAllListeners(icpList.generate.deleteLogo);
  1077. })
  1078. }
  1079. const getLogolist = async () => {
  1080. clientStore.ipc.send(icpList.generate.getLogoList);
  1081. clientStore.ipc.on(icpList.generate.getLogoList, async (event, result) => {
  1082. logoList.value = result.data || []
  1083. console.log('getLogoList')
  1084. console.log(result.data)
  1085. if(logoList.value.length && !form.logo_path){
  1086. form.logo_path = logoList.value[0]
  1087. // 保存默认LOGO到缓存
  1088. saveLogoToCache(form.logo_path)
  1089. }
  1090. clientStore.ipc.removeAllListeners(icpList.generate.getLogoList);
  1091. })
  1092. }
  1093. const addLogo = async (path) => {
  1094. console.log(path);
  1095. clientStore.ipc.send(icpList.generate.addLogo,{
  1096. logo_path:path
  1097. });
  1098. clientStore.ipc.on(icpList.generate.addLogo, async (event, result) => {
  1099. console.log(result);
  1100. if (result.code === 0) {
  1101. console.log("添加成功")
  1102. console.log(result)
  1103. if(result.data.logo){
  1104. form.logo_path = result.data.logo
  1105. // 保存新添加的LOGO到缓存
  1106. saveLogoToCache(form.logo_path)
  1107. if(logoList.value.indexOf(result.data.logo) <0){
  1108. logoList.value.push(result.data.logo)
  1109. }
  1110. }
  1111. }
  1112. clientStore.ipc.removeAllListeners(icpList.generate.addLogo);
  1113. })
  1114. }
  1115. function selectExcel() {
  1116. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1117. clientStore.ipc.send(icpList.utils.openFile, {
  1118. filters: [
  1119. { name: '支持xls,xlsx', extensions: ['xlsx', 'xls'] }
  1120. ],
  1121. title: "选择基础文件资料"
  1122. });
  1123. clientStore.ipc.on(icpList.utils.openFile, async (event, result) => {
  1124. form.excel_path = result
  1125. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1126. })
  1127. }
  1128. const Router = useRouter()
  1129. //打开主图详情
  1130. function openPhotographySeniorDetail() {
  1131. const { href } = Router.resolve({
  1132. name: 'PhotographySeniorDetail'
  1133. })
  1134. clientStore.ipc.removeAllListeners(icpList.utils.openMain);
  1135. let params = {
  1136. title: '详情高级配置',
  1137. width: 1000,
  1138. height: 630,
  1139. frame: true,
  1140. id: "PhotographySeniorDetail",
  1141. url: getRouterUrl(href)
  1142. }
  1143. clientStore.ipc.send(icpList.utils.openMain, params);
  1144. }
  1145. const handleComplete = () => {
  1146. // loadingDialogVisible.value = false
  1147. // 这里可以添加打开目录的逻辑
  1148. if(!completeDirectory.value){
  1149. openOutputDir()
  1150. return
  1151. }
  1152. clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
  1153. let params = {
  1154. action: 'openPath',
  1155. params: completeDirectory.value?.replace(/\//g, '\\')
  1156. }
  1157. clientStore.ipc.send(icpList.utils.shellFun, params);
  1158. }
  1159. const selectFolder = () => {
  1160. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1161. clientStore.ipc.send(icpList.utils.openDirectory);
  1162. clientStore.ipc.on(icpList.utils.openDirectory, async (event, result) => {
  1163. folderPath.value = result
  1164. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1165. })
  1166. }
  1167. </script>
  1168. <style lang="scss" scoped>
  1169. .detail-container {
  1170. background-color: #EAECED;
  1171. width: 100%;
  1172. min-width: 600px;
  1173. padding: 20px;
  1174. overflow: hidden;
  1175. min-height: calc(100vh - 30px);
  1176. }
  1177. .service-section {
  1178. margin-bottom: 20px;
  1179. .service-cards {
  1180. display: flex;
  1181. gap: 60px;
  1182. margin-top: 16px;
  1183. }
  1184. .service-card {
  1185. width: 240px;
  1186. height: 140px;
  1187. border-radius: 8px;
  1188. background: #fff;
  1189. border: 1px solid #e0e0e0;
  1190. display: flex;
  1191. align-items: flex-start;
  1192. padding: 12px;
  1193. cursor: pointer;
  1194. transition: all 0.3s ease;
  1195. position: relative;
  1196. &:hover {
  1197. border-color: #2957FF;
  1198. box-shadow: 0 2px 8px rgba(41, 87, 255, 0.1);
  1199. }
  1200. &.active {
  1201. border: 3px solid #2957FF;
  1202. background: #f8f9ff;
  1203. box-shadow: 0 4px 12px rgba(41, 87, 255, 0.25);
  1204. }
  1205. .service-checkbox {
  1206. position: absolute;
  1207. left: -40px;
  1208. top: 10px;
  1209. width: 30px;
  1210. transform: scale(1.5);
  1211. z-index: 10;
  1212. ::v-deep{
  1213. .el-checkbox {
  1214. display: block;
  1215. margin-right: 0;
  1216. }
  1217. .el-checkbox__input {
  1218. cursor: pointer;
  1219. }
  1220. }
  1221. }
  1222. .service-content {
  1223. flex: 1;
  1224. display: flex;
  1225. flex-direction: column;
  1226. align-items: center;
  1227. position: absolute;
  1228. left: 0;
  1229. top: 0;
  1230. right: 0;
  1231. bottom: 0;;
  1232. }
  1233. .service-image {
  1234. position: absolute;
  1235. width: 100%;
  1236. height: 100%;
  1237. img {
  1238. width: 100%;
  1239. height: 100%;
  1240. object-fit: cover;
  1241. border-radius: 4px;
  1242. }
  1243. .service-icon {
  1244. position: absolute;
  1245. top: 10px;
  1246. right: 10px;
  1247. width: 30px;
  1248. height: 30px;
  1249. background: #2957FF;
  1250. border-radius: 50%;
  1251. display: flex;
  1252. align-items: center;
  1253. justify-content: center;
  1254. color: white;
  1255. font-size: 18px;
  1256. }
  1257. }
  1258. .service-name {
  1259. font-size: 14px;
  1260. font-weight: 500;
  1261. text-align: center;
  1262. position: absolute;
  1263. background: rgba(0,0,0,.5);
  1264. height: 30px;
  1265. line-height: 30px;
  1266. color: #fff;
  1267. left: 0;
  1268. right: 0;
  1269. bottom:0px
  1270. }
  1271. }
  1272. }
  1273. .logo-section,
  1274. .template-section,
  1275. .data-prep-section {
  1276. margin-bottom: 20px;
  1277. }
  1278. .logo-template-row {
  1279. display: flex;
  1280. gap: 24px;
  1281. align-items: flex-start;
  1282. .logo-col { flex: 2; min-width: 300px; }
  1283. .template-col { flex: 3; }
  1284. }
  1285. .logo-section {
  1286. .upload-item {
  1287. border: 2px solid rgba(0,0,0,0);
  1288. }
  1289. .active {
  1290. border: 2px solid #2957FF;
  1291. border-radius: 6px;
  1292. overflow: hidden;;
  1293. }
  1294. &.multi-line {
  1295. flex-direction: row; // 默认横向排列
  1296. flex-wrap: wrap; // 允许换行
  1297. align-items: flex-start; // 对齐方式调整为顶部对齐
  1298. .upload-item {
  1299. margin-bottom: 10px; // 每行之间增加间距
  1300. width: 90px; // 每行显示 4 个元素,减去外边距
  1301. box-sizing: border-box; // 确保宽度计算包含 padding 和 border
  1302. }
  1303. }
  1304. }
  1305. .logo-upload {
  1306. border: 1px dashed #ccc;
  1307. border-radius: 5px;
  1308. padding: 50px 0;
  1309. text-align: center;
  1310. cursor: pointer;
  1311. }
  1312. .template-pagination button {
  1313. margin-right: 5px;
  1314. }
  1315. .template-pagination span {
  1316. display: inline-block;
  1317. width: 20px;
  1318. height: 20px;
  1319. line-height: 20px;
  1320. text-align: center;
  1321. border: 1px solid #ccc;
  1322. border-radius: 5px;
  1323. margin-right: 5px;
  1324. cursor: pointer;
  1325. }
  1326. .template-list {
  1327. display: flex;
  1328. flex-wrap: wrap;
  1329. gap: 20px;
  1330. margin-top: 10px;
  1331. .template-item {
  1332. width: calc(25% - 18px);
  1333. border: 1px solid #ccc;
  1334. border-radius: 10px;
  1335. cursor: pointer;
  1336. background: #f0f0f0;
  1337. position: relative;
  1338. overflow: hidden;
  1339. .template-info {
  1340. position: absolute;
  1341. bottom: 0;
  1342. left: 0;
  1343. background: rgba($color: #000000, $alpha: .3);
  1344. width: 100%;
  1345. height: 36px;
  1346. line-height: 36px;
  1347. color: #eee;
  1348. display: flex;
  1349. align-items: center;
  1350. justify-content: space-between;
  1351. .template-view {
  1352. background: #DFE2E3;
  1353. color: #3366FF;
  1354. height: 30px;
  1355. line-height: 30px;
  1356. padding: 0 10px;
  1357. border-radius: 4px;
  1358. margin-right: 10px;
  1359. font-size: 14px;
  1360. }
  1361. }
  1362. }
  1363. }
  1364. .publish-section {
  1365. .label {
  1366. min-width: 120px;
  1367. margin-right: 12px;
  1368. }
  1369. }
  1370. .excel-upload {
  1371. width: 100%;
  1372. background: #F7F7F7;
  1373. padding: 20px 0;
  1374. }
  1375. .generate-button {
  1376. padding: 10px 20px;
  1377. color: white;
  1378. border: none;
  1379. border-radius: 5px;
  1380. cursor: pointer;
  1381. }
  1382. .select-button {
  1383. background: #DFE2E3 !important;
  1384. color: #3366FF !important;
  1385. height: 30px;
  1386. line-height: 30px;
  1387. padding: 0 10px;
  1388. border-radius: 4px;
  1389. margin-right: 10px;
  1390. font-size: 14px;
  1391. font-weight: 550;
  1392. }
  1393. .select-warp {
  1394. width: 18px;
  1395. height: 18px;
  1396. border-radius: 4px;
  1397. background-color: #fff;
  1398. position: absolute;
  1399. top: 10px;
  1400. left: 10px;
  1401. &.active {
  1402. background-color: #1677FF;
  1403. }
  1404. }
  1405. .section-title {
  1406. display: flex;
  1407. align-items: center;
  1408. gap: 8px;
  1409. font-weight: bold;
  1410. margin-bottom: 16px;
  1411. color: #474747;
  1412. }
  1413. .section {
  1414. margin-bottom: 24px;
  1415. .section-title {
  1416. display: flex;
  1417. align-items: center;
  1418. gap: 8px;
  1419. font-weight: bold;
  1420. margin-bottom: 16px;
  1421. color: #474747;
  1422. }
  1423. .section-content {
  1424. padding-left: 16px;
  1425. }
  1426. }
  1427. .instruction-out {
  1428. background: #EAF3FF;
  1429. border-radius: 4px;
  1430. border: 1px solid #CBE1FF;
  1431. padding: 10px 20px;
  1432. width: 80%;
  1433. position: relative;
  1434. .instruction-list {
  1435. margin: 0px 0 0 10px;
  1436. padding-left: 20px;
  1437. padding-right: 40px;
  1438. width: 100%;
  1439. li {
  1440. margin-bottom: 4px;
  1441. text-align: left;
  1442. font-size: 14px;
  1443. }
  1444. }
  1445. .close-icon {
  1446. position: absolute;
  1447. top: 12px;
  1448. right: 19px;
  1449. }
  1450. }
  1451. .form-item {
  1452. margin: 16px 0;
  1453. display: flex;
  1454. .label {
  1455. min-width: 120px;
  1456. margin-right: 12px;
  1457. }
  1458. .folder-warp {
  1459. width: 100%;
  1460. display: flex;
  1461. flex-direction: column;
  1462. .folder-input {
  1463. flex: 1;
  1464. display: flex;
  1465. align-items: center;
  1466. .check-button {
  1467. background: #DFE2E3;
  1468. border-radius: 6px;
  1469. padding: 6px 12px;
  1470. color: #2957FF;
  1471. margin-left: 20px;
  1472. }
  1473. }
  1474. }
  1475. .hint {
  1476. text-align: left;
  1477. color: #999;
  1478. margin-top: 6px;
  1479. font-size: 14px;
  1480. color: #FF4C00;
  1481. font-style: normal;
  1482. }
  1483. .specific-page-input {
  1484. flex: 1;
  1485. }
  1486. }
  1487. .image-order {
  1488. flex: 1;
  1489. display: flex;
  1490. justify-content: space-between;
  1491. align-items: center;
  1492. }
  1493. .footer {
  1494. display: flex;
  1495. justify-content: center;
  1496. margin-top: 24px;
  1497. .footer-button {
  1498. padding: 10px 20px;
  1499. }
  1500. }
  1501. .explain-btn {
  1502. padding-left: 20px;
  1503. padding-right: 20px;
  1504. color: #2957FF !important;
  1505. }
  1506. .progress-messages {
  1507. margin-top: 20px;
  1508. border-top: 1px solid #e4e7ed;
  1509. padding-top: 20px;
  1510. width: 100%;
  1511. .message-header {
  1512. display: flex;
  1513. justify-content: space-between;
  1514. align-items: center;
  1515. margin-bottom: 15px;
  1516. font-weight: 500;
  1517. color: #606266;
  1518. }
  1519. .message-list {
  1520. max-height: 200px;
  1521. overflow-y: auto;
  1522. border: 1px solid #e4e7ed;
  1523. border-radius: 4px;
  1524. padding: 10px;
  1525. background: #fafafa;
  1526. .message-item {
  1527. margin-bottom: 12px;
  1528. padding-bottom: 12px;
  1529. border-bottom: 1px solid #f0f0f0;
  1530. &:last-child {
  1531. margin-bottom: 0;
  1532. padding-bottom: 0;
  1533. border-bottom: none;
  1534. }
  1535. .message-time {
  1536. font-size: 12px;
  1537. color: #909399;
  1538. margin-bottom: 4px;
  1539. }
  1540. .message-content {
  1541. font-size: 14px;
  1542. line-height: 1.4;
  1543. .goods-no {
  1544. color: #2957FF;
  1545. font-weight: 500;
  1546. }
  1547. .message-text {
  1548. color: #606266;
  1549. }
  1550. }
  1551. }
  1552. }
  1553. }
  1554. </style>