detail.vue 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  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 (requesting.value) {
  823. return
  824. }
  825. if(form.services.length == 0){
  826. ElMessage.error('请选择服务内容')
  827. return
  828. }
  829. // 埋点:开始生成详情页
  830. clickLog({
  831. describe: {
  832. action: '点击开始生成详情页',
  833. services: form.services,
  834. dataType: form.dataType,
  835. template_name: form.selectTemplate?.template_name,
  836. goods_count: goods_art_nos.value.length,
  837. goods_art_nos: goods_art_nos.value
  838. }
  839. }, route);
  840. // 必填验证
  841. if (form.services.includes('is_upper_footer') && !( selectedModels.value && selectedModels.value.male?.id && selectedModels.value.female?.id)) {
  842. openModelDialog();
  843. setTimeout(()=>{
  844. ElMessage.error('请选择模特')
  845. },200)
  846. return
  847. }
  848. if (form.services.includes('is_product_scene') && !scenePrompt.value) {
  849. openScenePromptDialog();
  850. setTimeout(()=>{
  851. ElMessage.error('请设置场景提示词')
  852. },200)
  853. return
  854. }
  855. if(form.services.includes('is_detail')){
  856. if ( form.dataType == '1' && !form.excel_path) {
  857. ElMessage.error('请上传商品基础资料')
  858. return
  859. }
  860. }
  861. // 先进行检测
  862. try {
  863. // ElMessage.info('正在检测参数,请稍候...');
  864. await checkParams();
  865. // ElMessage.success('检测通过,开始生成...');
  866. } catch (error) {
  867. ElMessage.error(error.message || '检测失败,请检查参数');
  868. return;
  869. }
  870. const useConfigInfoStore = configInfo();
  871. console.log(useConfigInfoStore.appConfig);
  872. const tokenInfoStore = tokenInfo();
  873. const token = tokenInfoStore.getToken; // 使用 getToken() 获取 token
  874. let temp_list = []
  875. templates.value.map(item => {
  876. temp_list.push({
  877. template_id: item.template_id,
  878. template_local_classes: item.template_local_classes,
  879. })
  880. })
  881. // 根据选择的服务内容设置参数
  882. const isDetail = form.services.includes('is_detail') ? 1 : 0
  883. const isProductScene = form.services.includes('is_product_scene') ? 1 : 0
  884. const isUpperFooter = form.services.includes('is_upper_footer') ? 1 : 0
  885. const params = {
  886. goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
  887. logo_path: form.logo_path || '',
  888. temp_name: form.selectTemplate?.template_id || '',
  889. excel_path: form.dataType == '1' ? form.excel_path : '',
  890. template_image_order: form.selectTemplate?.template_image_order,
  891. temp_list,
  892. token,
  893. uuid: uuidStore.getUuid || '',
  894. // 新增服务参数 - 合并国内和国外平台
  895. online_stores: [...(domesticPlatforms.value || []), ...(foreignPlatforms.value || [])],
  896. is_detail: isDetail,
  897. is_product_scene: isProductScene,
  898. is_upper_footer: isUpperFooter,
  899. upper_footer_params: selectedModels.value ? {
  900. man_id: selectedModels.value.male?.id || "",
  901. women_id: selectedModels.value.female?.id || ""
  902. } : {},
  903. product_scene_prompt: scenePrompt.value || '',
  904. is_check: 0 // 正式生成
  905. }
  906. console.log(params)
  907. // 开启进度弹窗
  908. requesting.value = true
  909. partErrList.value = []
  910. message.value = '正在为您处理,请稍后'
  911. progress.value = 0
  912. // 清空之前的进度消息
  913. progressMessages.value = []
  914. showMessageHistory.value = true
  915. openLoadingDialog(goods_art_nos.value.length * 10)
  916. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  917. clientStore.ipc.send(icpList.generate.generatePhotoDetail, params);
  918. /*
  919. * detail_result_progress
  920. *
  921. * */
  922. // 监听进度消息
  923. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  924. clientStore.ipc.on(icpList.socket.message + '_detail_progress', (event, data) => {
  925. console.log('_detail_progress',data);
  926. handleProgressMessage(data)
  927. });
  928. // 监听抠图进度消息
  929. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  930. clientStore.ipc.on(icpList.socket.message + '_segment_progress', (event, data) => {
  931. console.log('_segment_progress',data);
  932. handleSegmentProgressMessage(data)
  933. });
  934. // 监听上脚图进度消息
  935. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  936. clientStore.ipc.on(icpList.socket.message + '_upper_footer_progress', (event, data) => {
  937. console.log('_upper_footer_progress',data);
  938. handleUpperFooterProgressMessage(data)
  939. });
  940. // 监听场景图进度消息
  941. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  942. clientStore.ipc.on(icpList.socket.message + '_scene_progress', (event, data) => {
  943. console.log('_scene_progress',data);
  944. handleSceneProgressMessage(data)
  945. });
  946. // 监听商品上传进度消息
  947. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  948. clientStore.ipc.on(icpList.socket.message + '_upload_goods_progress', (event, data) => {
  949. console.log('_upload_goods_progress',data);
  950. handleUploadGoodsProgressMessage(data)
  951. });
  952. clientStore.ipc.on(icpList.socket.message + '_detail_result_progress', (event, result) => {
  953. if(result.code !== 0 ){
  954. if(result.msg){
  955. handleFail(result.msg)
  956. message.value = 'result.msg'
  957. }
  958. progress.value = 0
  959. loadingDialogVisible.value = false
  960. requesting.value = false
  961. return;
  962. }
  963. console.log('result', result)
  964. requesting.value = true
  965. setTimeout(() => {
  966. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  967. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  968. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  969. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  970. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  971. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  972. }, 100)
  973. clearInterval(INTERVAL.value)
  974. if (result.code === 0) {
  975. const { output_folder, list } = result.data
  976. const allSuccess = list.every(item => item.success);
  977. const allFailure = list.every(item => !item.success);
  978. if (allSuccess) {
  979. console.log("全部成功")
  980. handleSuccess(output_folder, '全部生成成功')
  981. } else if (allFailure) {
  982. console.log("全部失败");
  983. handleFailure(list)
  984. } else {
  985. console.log("部分成功,部分失败");
  986. handlePartSuccess(output_folder, list)
  987. }
  988. } else {
  989. console.log('code全部生成失败')
  990. handleFail(result.msg)
  991. }
  992. //生成失败 (接口请求失败)
  993. function handleFail(errorMsg: string) {
  994. // loadingDialogVisible.value = false
  995. // disabledButton.value = false
  996. if (errorMsg) {
  997. ElMessage.error(errorMsg)
  998. }
  999. // 处理完成后停止监听进度消息
  1000. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  1001. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  1002. }
  1003. // 全部生成成功
  1004. function handleSuccess(href, loadingMsg) {
  1005. // 埋点:生成完成
  1006. setLogInfo(route, { action: '生成完成', output_folder: href, message: loadingMsg });
  1007. completeDirectory.value = href
  1008. progress.value = 100
  1009. disabledButton.value = false
  1010. message.value = loadingMsg
  1011. handleComplete()
  1012. }
  1013. // 部分成功
  1014. function handlePartSuccess(output_folder: string, partSuccessList) {
  1015. let errorList = []
  1016. partSuccessList.map(item => {
  1017. if (!item.success) {
  1018. errorList.push(item)
  1019. }
  1020. })
  1021. partErrList.value = errorList
  1022. handleSuccess(output_folder, '部分货号生成失败')
  1023. }
  1024. // 全部生成失败
  1025. function handleFailure(partSuccessList) {
  1026. // 埋点:生成失败(携带货号)
  1027. const failedGoods = (partSuccessList || []).map(item => item.goods_art_no).filter(Boolean)
  1028. setLogInfo(route, { action: '生成失败', error_count: partSuccessList.length, goods_art_nos: goods_art_nos.value, failed_goods_art_nos: failedGoods });
  1029. let errorList = []
  1030. partSuccessList.map(item => {
  1031. if (!item.success) {
  1032. errorList.push(item)
  1033. }
  1034. })
  1035. partErrList.value = errorList
  1036. completeDirectory.value = ''
  1037. progress.value = 100
  1038. disabledButton.value = true
  1039. message.value = '全部货号生成失败'
  1040. }
  1041. requesting.value = false
  1042. });
  1043. }
  1044. const openLoadingDialog = (timer: number) => {
  1045. loadingDialogVisible.value = true
  1046. disabledButton.value = true
  1047. // 根据传入的秒数计算每次增加的进度值
  1048. const step = 100 / timer
  1049. INTERVAL.value = setInterval(() => {
  1050. if (progress.value < 50) {
  1051. progress.value = Math.min(progress.value + step, 100)
  1052. } else if (progress.value < 70) {
  1053. progress.value = Math.min(progress.value + step / 2, 100)
  1054. } if (progress.value < 85) {
  1055. progress.value = Math.min(progress.value + step / 5, 100)
  1056. } else if (progress.value < 90) {
  1057. progress.value = Math.min(progress.value + step / 10, 100)
  1058. } else if (progress.value < 95) {
  1059. progress.value = Math.min(progress.value + step / 50, 100)// 新增中间阶段
  1060. } else {
  1061. progress.value = Math.min(progress.value + step / 100, 100)
  1062. }
  1063. }, 1000)
  1064. }
  1065. //logo
  1066. const logoList = ref([])
  1067. const onInput = (value) => {
  1068. addLogo(value)
  1069. }
  1070. const onRemove = (index) => {
  1071. if(logoList.value[index] === form.logo_path){
  1072. form.logo_path = ''
  1073. }
  1074. clientStore.ipc.send(icpList.generate.deleteLogo,{
  1075. path:logoList.value[index]
  1076. });
  1077. logoList.value.splice(index, 1)
  1078. clientStore.ipc.on(icpList.generate.deleteLogo, async (event, result) => {
  1079. console.log('deleteLogo');
  1080. console.log(result);
  1081. clientStore.ipc.removeAllListeners(icpList.generate.deleteLogo);
  1082. })
  1083. }
  1084. const getLogolist = async () => {
  1085. clientStore.ipc.send(icpList.generate.getLogoList);
  1086. clientStore.ipc.on(icpList.generate.getLogoList, async (event, result) => {
  1087. logoList.value = result.data || []
  1088. console.log('getLogoList')
  1089. console.log(result.data)
  1090. if(logoList.value.length && !form.logo_path){
  1091. form.logo_path = logoList.value[0]
  1092. // 保存默认LOGO到缓存
  1093. saveLogoToCache(form.logo_path)
  1094. }
  1095. clientStore.ipc.removeAllListeners(icpList.generate.getLogoList);
  1096. })
  1097. }
  1098. const addLogo = async (path) => {
  1099. console.log(path);
  1100. clientStore.ipc.send(icpList.generate.addLogo,{
  1101. logo_path:path
  1102. });
  1103. clientStore.ipc.on(icpList.generate.addLogo, async (event, result) => {
  1104. console.log(result);
  1105. if (result.code === 0) {
  1106. console.log("添加成功")
  1107. console.log(result)
  1108. if(result.data.logo){
  1109. form.logo_path = result.data.logo
  1110. // 保存新添加的LOGO到缓存
  1111. saveLogoToCache(form.logo_path)
  1112. if(logoList.value.indexOf(result.data.logo) <0){
  1113. logoList.value.push(result.data.logo)
  1114. }
  1115. }
  1116. }
  1117. clientStore.ipc.removeAllListeners(icpList.generate.addLogo);
  1118. })
  1119. }
  1120. function selectExcel() {
  1121. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1122. clientStore.ipc.send(icpList.utils.openFile, {
  1123. filters: [
  1124. { name: '支持xls,xlsx', extensions: ['xlsx', 'xls'] }
  1125. ],
  1126. title: "选择基础文件资料"
  1127. });
  1128. clientStore.ipc.on(icpList.utils.openFile, async (event, result) => {
  1129. form.excel_path = result
  1130. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1131. })
  1132. }
  1133. const Router = useRouter()
  1134. //打开主图详情
  1135. function openPhotographySeniorDetail() {
  1136. const { href } = Router.resolve({
  1137. name: 'PhotographySeniorDetail'
  1138. })
  1139. clientStore.ipc.removeAllListeners(icpList.utils.openMain);
  1140. let params = {
  1141. title: '详情高级配置',
  1142. width: 1000,
  1143. height: 630,
  1144. frame: true,
  1145. id: "PhotographySeniorDetail",
  1146. url: getRouterUrl(href)
  1147. }
  1148. clientStore.ipc.send(icpList.utils.openMain, params);
  1149. }
  1150. const handleComplete = () => {
  1151. // loadingDialogVisible.value = false
  1152. // 这里可以添加打开目录的逻辑
  1153. if(!completeDirectory.value){
  1154. openOutputDir()
  1155. return
  1156. }
  1157. clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
  1158. let params = {
  1159. action: 'openPath',
  1160. params: completeDirectory.value?.replace(/\//g, '\\')
  1161. }
  1162. clientStore.ipc.send(icpList.utils.shellFun, params);
  1163. }
  1164. const selectFolder = () => {
  1165. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1166. clientStore.ipc.send(icpList.utils.openDirectory);
  1167. clientStore.ipc.on(icpList.utils.openDirectory, async (event, result) => {
  1168. folderPath.value = result
  1169. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1170. })
  1171. }
  1172. </script>
  1173. <style lang="scss" scoped>
  1174. .detail-container {
  1175. background-color: #EAECED;
  1176. width: 100%;
  1177. min-width: 600px;
  1178. padding: 20px;
  1179. overflow: hidden;
  1180. min-height: calc(100vh - 30px);
  1181. }
  1182. .service-section {
  1183. margin-bottom: 20px;
  1184. .service-cards {
  1185. display: flex;
  1186. gap: 60px;
  1187. margin-top: 16px;
  1188. }
  1189. .service-card {
  1190. width: 240px;
  1191. height: 140px;
  1192. border-radius: 8px;
  1193. background: #fff;
  1194. border: 1px solid #e0e0e0;
  1195. display: flex;
  1196. align-items: flex-start;
  1197. padding: 12px;
  1198. cursor: pointer;
  1199. transition: all 0.3s ease;
  1200. position: relative;
  1201. &:hover {
  1202. border-color: #2957FF;
  1203. box-shadow: 0 2px 8px rgba(41, 87, 255, 0.1);
  1204. }
  1205. &.active {
  1206. border: 3px solid #2957FF;
  1207. background: #f8f9ff;
  1208. box-shadow: 0 4px 12px rgba(41, 87, 255, 0.25);
  1209. }
  1210. .service-checkbox {
  1211. position: absolute;
  1212. left: -40px;
  1213. top: 10px;
  1214. width: 30px;
  1215. transform: scale(1.5);
  1216. z-index: 10;
  1217. ::v-deep{
  1218. .el-checkbox {
  1219. display: block;
  1220. margin-right: 0;
  1221. }
  1222. .el-checkbox__input {
  1223. cursor: pointer;
  1224. }
  1225. }
  1226. }
  1227. .service-content {
  1228. flex: 1;
  1229. display: flex;
  1230. flex-direction: column;
  1231. align-items: center;
  1232. position: absolute;
  1233. left: 0;
  1234. top: 0;
  1235. right: 0;
  1236. bottom: 0;;
  1237. }
  1238. .service-image {
  1239. position: absolute;
  1240. width: 100%;
  1241. height: 100%;
  1242. img {
  1243. width: 100%;
  1244. height: 100%;
  1245. object-fit: cover;
  1246. border-radius: 4px;
  1247. }
  1248. .service-icon {
  1249. position: absolute;
  1250. top: 10px;
  1251. right: 10px;
  1252. width: 30px;
  1253. height: 30px;
  1254. background: #2957FF;
  1255. border-radius: 50%;
  1256. display: flex;
  1257. align-items: center;
  1258. justify-content: center;
  1259. color: white;
  1260. font-size: 18px;
  1261. }
  1262. }
  1263. .service-name {
  1264. font-size: 14px;
  1265. font-weight: 500;
  1266. text-align: center;
  1267. position: absolute;
  1268. background: rgba(0,0,0,.5);
  1269. height: 30px;
  1270. line-height: 30px;
  1271. color: #fff;
  1272. left: 0;
  1273. right: 0;
  1274. bottom:0px
  1275. }
  1276. }
  1277. }
  1278. .logo-section,
  1279. .template-section,
  1280. .data-prep-section {
  1281. margin-bottom: 20px;
  1282. }
  1283. .logo-template-row {
  1284. display: flex;
  1285. gap: 24px;
  1286. align-items: flex-start;
  1287. .logo-col { flex: 2; min-width: 300px; }
  1288. .template-col { flex: 3; }
  1289. }
  1290. .logo-section {
  1291. .upload-item {
  1292. border: 2px solid rgba(0,0,0,0);
  1293. }
  1294. .active {
  1295. border: 2px solid #2957FF;
  1296. border-radius: 6px;
  1297. overflow: hidden;;
  1298. }
  1299. &.multi-line {
  1300. flex-direction: row; // 默认横向排列
  1301. flex-wrap: wrap; // 允许换行
  1302. align-items: flex-start; // 对齐方式调整为顶部对齐
  1303. .upload-item {
  1304. margin-bottom: 10px; // 每行之间增加间距
  1305. width: 90px; // 每行显示 4 个元素,减去外边距
  1306. box-sizing: border-box; // 确保宽度计算包含 padding 和 border
  1307. }
  1308. }
  1309. }
  1310. .logo-upload {
  1311. border: 1px dashed #ccc;
  1312. border-radius: 5px;
  1313. padding: 50px 0;
  1314. text-align: center;
  1315. cursor: pointer;
  1316. }
  1317. .template-pagination button {
  1318. margin-right: 5px;
  1319. }
  1320. .template-pagination span {
  1321. display: inline-block;
  1322. width: 20px;
  1323. height: 20px;
  1324. line-height: 20px;
  1325. text-align: center;
  1326. border: 1px solid #ccc;
  1327. border-radius: 5px;
  1328. margin-right: 5px;
  1329. cursor: pointer;
  1330. }
  1331. .template-list {
  1332. display: flex;
  1333. flex-wrap: wrap;
  1334. gap: 20px;
  1335. margin-top: 10px;
  1336. .template-item {
  1337. width: calc(25% - 18px);
  1338. border: 1px solid #ccc;
  1339. border-radius: 10px;
  1340. cursor: pointer;
  1341. background: #f0f0f0;
  1342. position: relative;
  1343. overflow: hidden;
  1344. .template-info {
  1345. position: absolute;
  1346. bottom: 0;
  1347. left: 0;
  1348. background: rgba($color: #000000, $alpha: .3);
  1349. width: 100%;
  1350. height: 36px;
  1351. line-height: 36px;
  1352. color: #eee;
  1353. display: flex;
  1354. align-items: center;
  1355. justify-content: space-between;
  1356. .template-view {
  1357. background: #DFE2E3;
  1358. color: #3366FF;
  1359. height: 30px;
  1360. line-height: 30px;
  1361. padding: 0 10px;
  1362. border-radius: 4px;
  1363. margin-right: 10px;
  1364. font-size: 14px;
  1365. }
  1366. }
  1367. }
  1368. }
  1369. .publish-section {
  1370. .label {
  1371. min-width: 120px;
  1372. margin-right: 12px;
  1373. }
  1374. }
  1375. .excel-upload {
  1376. width: 100%;
  1377. background: #F7F7F7;
  1378. padding: 20px 0;
  1379. }
  1380. .generate-button {
  1381. padding: 10px 20px;
  1382. color: white;
  1383. border: none;
  1384. border-radius: 5px;
  1385. cursor: pointer;
  1386. }
  1387. .select-button {
  1388. background: #DFE2E3 !important;
  1389. color: #3366FF !important;
  1390. height: 30px;
  1391. line-height: 30px;
  1392. padding: 0 10px;
  1393. border-radius: 4px;
  1394. margin-right: 10px;
  1395. font-size: 14px;
  1396. font-weight: 550;
  1397. }
  1398. .select-warp {
  1399. width: 18px;
  1400. height: 18px;
  1401. border-radius: 4px;
  1402. background-color: #fff;
  1403. position: absolute;
  1404. top: 10px;
  1405. left: 10px;
  1406. &.active {
  1407. background-color: #1677FF;
  1408. }
  1409. }
  1410. .section-title {
  1411. display: flex;
  1412. align-items: center;
  1413. gap: 8px;
  1414. font-weight: bold;
  1415. margin-bottom: 16px;
  1416. color: #474747;
  1417. }
  1418. .section {
  1419. margin-bottom: 24px;
  1420. .section-title {
  1421. display: flex;
  1422. align-items: center;
  1423. gap: 8px;
  1424. font-weight: bold;
  1425. margin-bottom: 16px;
  1426. color: #474747;
  1427. }
  1428. .section-content {
  1429. padding-left: 16px;
  1430. }
  1431. }
  1432. .instruction-out {
  1433. background: #EAF3FF;
  1434. border-radius: 4px;
  1435. border: 1px solid #CBE1FF;
  1436. padding: 10px 20px;
  1437. width: 80%;
  1438. position: relative;
  1439. .instruction-list {
  1440. margin: 0px 0 0 10px;
  1441. padding-left: 20px;
  1442. padding-right: 40px;
  1443. width: 100%;
  1444. li {
  1445. margin-bottom: 4px;
  1446. text-align: left;
  1447. font-size: 14px;
  1448. }
  1449. }
  1450. .close-icon {
  1451. position: absolute;
  1452. top: 12px;
  1453. right: 19px;
  1454. }
  1455. }
  1456. .form-item {
  1457. margin: 16px 0;
  1458. display: flex;
  1459. .label {
  1460. min-width: 120px;
  1461. margin-right: 12px;
  1462. }
  1463. .folder-warp {
  1464. width: 100%;
  1465. display: flex;
  1466. flex-direction: column;
  1467. .folder-input {
  1468. flex: 1;
  1469. display: flex;
  1470. align-items: center;
  1471. .check-button {
  1472. background: #DFE2E3;
  1473. border-radius: 6px;
  1474. padding: 6px 12px;
  1475. color: #2957FF;
  1476. margin-left: 20px;
  1477. }
  1478. }
  1479. }
  1480. .hint {
  1481. text-align: left;
  1482. color: #999;
  1483. margin-top: 6px;
  1484. font-size: 14px;
  1485. color: #FF4C00;
  1486. font-style: normal;
  1487. }
  1488. .specific-page-input {
  1489. flex: 1;
  1490. }
  1491. }
  1492. .image-order {
  1493. flex: 1;
  1494. display: flex;
  1495. justify-content: space-between;
  1496. align-items: center;
  1497. }
  1498. .footer {
  1499. display: flex;
  1500. justify-content: center;
  1501. margin-top: 24px;
  1502. .footer-button {
  1503. padding: 10px 20px;
  1504. }
  1505. }
  1506. .explain-btn {
  1507. padding-left: 20px;
  1508. padding-right: 20px;
  1509. color: #2957FF !important;
  1510. }
  1511. .progress-messages {
  1512. margin-top: 20px;
  1513. border-top: 1px solid #e4e7ed;
  1514. padding-top: 20px;
  1515. width: 100%;
  1516. .message-header {
  1517. display: flex;
  1518. justify-content: space-between;
  1519. align-items: center;
  1520. margin-bottom: 15px;
  1521. font-weight: 500;
  1522. color: #606266;
  1523. }
  1524. .message-list {
  1525. max-height: 200px;
  1526. overflow-y: auto;
  1527. border: 1px solid #e4e7ed;
  1528. border-radius: 4px;
  1529. padding: 10px;
  1530. background: #fafafa;
  1531. .message-item {
  1532. margin-bottom: 12px;
  1533. padding-bottom: 12px;
  1534. border-bottom: 1px solid #f0f0f0;
  1535. &:last-child {
  1536. margin-bottom: 0;
  1537. padding-bottom: 0;
  1538. border-bottom: none;
  1539. }
  1540. .message-time {
  1541. font-size: 12px;
  1542. color: #909399;
  1543. margin-bottom: 4px;
  1544. }
  1545. .message-content {
  1546. font-size: 14px;
  1547. line-height: 1.4;
  1548. .goods-no {
  1549. color: #2957FF;
  1550. font-weight: 500;
  1551. }
  1552. .message-text {
  1553. color: #606266;
  1554. }
  1555. }
  1556. }
  1557. }
  1558. }
  1559. </style>