detail.vue 95 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315
  1. <template>
  2. <BlueHeaderBar />
  3. <div class="bg-F5F6F7 detail-page">
  4. <div class="page—wrap max-w-full">
  5. <!-- 服务标签页 -->
  6. <div class="service-tabs">
  7. <div
  8. class="service-tab"
  9. :class="{
  10. 'active': form.services.includes('is_product_scene'),
  11. 'disabled': false
  12. }"
  13. @click="toggleService('is_product_scene')"
  14. v-log="{ describe: { action: '点击服务标签', service: '场景图生成' } }"
  15. >
  16. <el-checkbox
  17. :model-value="form.services.includes('is_product_scene')"
  18. @change="toggleService('is_product_scene')"
  19. @click.stop
  20. class="tab-checkbox"
  21. />
  22. <div class="tab-content">
  23. <div class="tab-img flex">
  24. <img v-if="form.services.includes('is_product_scene')" src="@/assets/images/detail/cjt_h.svg" alt="场景图生成" class="tab-icon" />
  25. <img v-else src="@/assets/images/detail/cjt.svg" alt="场景图生成" class="tab-icon" />
  26. </div>
  27. <span class="tab-name">场景图生成</span>
  28. </div>
  29. <div class="tab-edit-btn" @click.stop="openScenePromptDialog" v-log="{ describe: { action: '点击编辑场景图', service: '场景图生成-弹窗' } }">
  30. <el-icon><EditPen /></el-icon>
  31. </div>
  32. </div>
  33. <div
  34. class="service-tab"
  35. :class="{
  36. 'active': form.services.includes('is_upper_footer'),
  37. 'disabled': false
  38. }"
  39. @click="toggleService('is_upper_footer')"
  40. v-log="{ describe: { action: '点击服务标签', service: '模特图生成' } }"
  41. >
  42. <el-checkbox
  43. :model-value="form.services.includes('is_upper_footer')"
  44. @change="toggleService('is_upper_footer')"
  45. @click.stop
  46. class="tab-checkbox"
  47. />
  48. <div class="tab-content">
  49. <div class="tab-img flex">
  50. <img v-if="form.services.includes('is_upper_footer')" src="@/assets/images/detail/mtt_h.svg" alt="模特图生成" class="tab-icon" />
  51. <img v-else src="@/assets/images/detail/mtt.svg" alt="模特图生成" class="tab-icon" />
  52. </div>
  53. <span class="tab-name">模特图生成</span>
  54. </div>
  55. <div class="tab-edit-btn" @click.stop="openModelDialog" v-log="{ describe: { action: '点击编辑模特图', service: '模特图生成-弹窗' } }">
  56. <el-icon><EditPen /></el-icon>
  57. </div>
  58. </div>
  59. <div
  60. class="service-tab"
  61. :class="{
  62. 'active': form.services.includes('is_detail'),
  63. 'disabled': false
  64. }"
  65. @click="toggleService('is_detail')"
  66. v-log="{ describe: { action: '点击服务标签', service: '详情页生成' } }"
  67. >
  68. <el-checkbox
  69. :model-value="form.services.includes('is_detail')"
  70. @change="toggleService('is_detail')"
  71. @click.stop
  72. class="tab-checkbox"
  73. />
  74. <div class="tab-content">
  75. <div class="tab-img flex">
  76. <img v-if="form.services.includes('is_detail')" src="@/assets/images/detail/xqy_h.svg" alt="详情页生成" class="tab-icon" />
  77. <img v-else src="@/assets/images/detail/xqy.svg" alt="详情页生成" class="tab-icon" />
  78. </div>
  79. <span class="tab-name">详情页生成</span>
  80. </div>
  81. </div>
  82. <!-- 未开发的功能 -->
  83. <div class="service-tab " title="新增自定义详情页模板"
  84. @click="addCustomTemplate"
  85. v-log="{ describe: { action: '点击新增自定义详情页模板', service: '新增自定义详情页模板' } }"
  86. >
  87. <div class="tab-content">
  88. <div class="tab-img flex">
  89. <img src="@/assets/images/detail/xqmb.svg" alt="详情页模板自定义" class="tab-icon" />
  90. </div>
  91. <span class="tab-name">新增自定义详情页模板</span>
  92. </div>
  93. </div>
  94. <div
  95. class="service-tab external-tool"
  96. title="白底图批量导出"
  97. @click="handleWhiteBgExportClick"
  98. v-log="{ describe: { action: '点击白底图批量导出', service: '白底图批量导出' } }"
  99. >
  100. <div class="tab-content">
  101. <div class="tab-img flex">
  102. <img src="@/assets/images/detail/bdt.svg" alt="白底图批量导出" class="tab-icon" />
  103. </div>
  104. <span class="tab-name">白底图批量导出</span>
  105. </div>
  106. </div>
  107. <div
  108. class="service-tab external-tool"
  109. title="产品图册生成"
  110. @click="handleProductAlbumClick"
  111. v-log="{ describe: { action: '点击产品图册生成', service: '产品图册生成' } }"
  112. >
  113. <div class="tab-content">
  114. <div class="tab-img flex">
  115. <img src="@/assets/images/detail/cptc.svg" alt="产品图册生成" class="tab-icon" />
  116. </div>
  117. <span class="tab-name">产品图册生成</span>
  118. </div>
  119. </div>
  120. </div>
  121. <div class="detail-container">
  122. <div class="detail-content">
  123. <!-- 主图LOGO部分 -->
  124. <!--
  125. <div class="logo-section flex left top" >
  126. <div class="section-title" style="margin-bottom: 0px;">
  127. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  128. 主图LOGO 与 选择详情模板:
  129. </div>
  130. </div>
  131. <div class="logo-section flex left top multi-line">
  132. <upload v-for="item,index in logoList" :value="item" :key="item"
  133. v-show="item"
  134. @input="onRemove(index)"
  135. class="mar-right-10 upload-item"
  136. :class="{
  137. active: item === form.logo_path
  138. }"
  139. @click.native="form.logo_path = item"
  140. ></upload>
  141. <upload @input="onInput"></upload>
  142. </div>
  143. -->
  144. <!-- &lt;!&ndash; 图片抠图与货号图生成 &ndash;&gt;
  145. <div class="section">
  146. <div class="section-title">
  147. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  148. 图片抠图与货号图生成
  149. </div>
  150. <div class="section-content">
  151. <div v-if="showTips" class="instruction-out flex top left">
  152. <img style="fill: #000" src="@/assets/images/xinxi.svg" />
  153. <ol class="instruction-list">
  154. <li>请在下方确认图片拍摄过程中的顺序,确保所有拍摄的图片的顺序一致。</li>
  155. <li>使用中英文语号分隔。</li>
  156. <li>图片的名称不能随意修改,否则无法正常生成详情页。</li>
  157. <li>现有图片名称有:俯视、侧视、后视、鞋底、内里</li>
  158. </ol>
  159. <el-icon @click="showTips = false" class="close-icon">
  160. <Close />
  161. </el-icon>
  162. </div>
  163. &lt;!&ndash; 货号文件夹 &ndash;&gt;
  164. &lt;!&ndash; <div class="form-item">
  165. <div class="label">货号文件夹:</div>
  166. <div class="folder-warp">
  167. <div class="folder-input">
  168. <el-input style="width: 60%;" v-model="folderPath" type="textarea" :rows="2" readonly
  169. placeholder="请选择货号文件夹" />
  170. <el-button class="check-button" type="primary" @click="selectFolder">
  171. <img src="@/assets/images/Photography/wenjian.png" style="width: 14px; " />
  172. 选择目标文件夹</el-button>
  173. </div>
  174. <div class="hint">
  175. <el-icon>
  176. <Warning />
  177. </el-icon> <text>选择货号的上级文件夹</text>
  178. </div>
  179. </div>
  180. </div>
  181. &ndash;&gt;
  182. </div>
  183. </div>
  184. <el-divider />-->
  185. <!-- 左右布局 -->
  186. <div class="main-layout">
  187. <!-- 左侧:选择详情模板 -->
  188. <div class="left-panel">
  189. <div :class="['template-section', { 'template-section--disabled': !isDetailServiceSelected }]">
  190. <div class="section-header">
  191. <div class="section-title">
  192. 选择详情模版
  193. </div>
  194. <div class="template-pagination">
  195. <el-pagination
  196. background
  197. layout="prev, pager, next"
  198. v-model:current-page="queryParams.current"
  199. v-model:page-size.sync="queryParams.size"
  200. :total="totalPage"
  201. @current-change="onCurrentChange"
  202. @size-change="onSizeChange"
  203. />
  204. </div>
  205. </div>
  206. <div class="template-list">
  207. <div
  208. v-for="(template, index) in visibleTemplates"
  209. :key="index"
  210. class="template-item"
  211. :class="form.selectTemplate?.id == template.id ? 'active' : ''"
  212. @click="handleTemplateItemClick(template)"
  213. v-log="{ describe: { action: '点击选择详情模板', template_name: template.template_name } }"
  214. >
  215. <el-image :src="template.template_preview_image" fit="contain" class="cur-p" style="width: 100%; display: block;" />
  216. <div class="select-warp" :class="form.selectTemplate?.id == template.id ? 'active' : ''">
  217. <el-icon color="#FFFFFF">
  218. <Select />
  219. </el-icon>
  220. </div>
  221. <div class="template-info">
  222. <span class="mar-left-10 chaochu_1">{{ template.template_name }}</span>
  223. <div
  224. class="template-view"
  225. v-if="isDetailServiceSelected && template.template_type == 0"
  226. @click.stop="viewTemplate(template)"
  227. v-log="{ describe: { action: '点击查看模板详情', template_name: template.template_name } }"
  228. >
  229. 查看
  230. </div>
  231. <div
  232. class="template-actions flex"
  233. v-if="isDetailServiceSelected && template.template_type == 1"
  234. >
  235. <div
  236. class="template-view"
  237. @click.stop="editTemplate(template)"
  238. v-log="{ describe: { action: '点击编辑模板详情', template_name: template.template_name } }"
  239. >
  240. 编辑
  241. </div>
  242. <div
  243. class="template-view template-view-delete"
  244. @click.stop="deleteTemplate(template)"
  245. v-log="{ describe: { action: '点击删除自定义模板', template_name: template.template_name } }"
  246. >
  247. 删除
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. <div class="template-tips c-333 fs-14 line-20 te-l mar-top-20 flex left" >
  254. <el-icon><Warning /></el-icon>
  255. <span class="mar-left-10" v-if="!isDetailServiceSelected">请先选中详情页生成,后在选择模板详情</span>
  256. <span class="mar-left-10" v-else>该模版需提供{{form.selectTemplate?.template_image_order?.split(',').length || 5}}张标准视角的商品图:{{form.selectTemplate?.template_image_order || '俯视,侧视,后跟,鞋底,内里'}}。请确保图片清晰度高,背景干净。</span>
  257. </div>
  258. </div>
  259. </div>
  260. <!-- 右侧:LOGO、详情资料准备、一键上架 -->
  261. <div class="right-panel">
  262. <!-- 主图LOGO -->
  263. <div class="right-section">
  264. <div class="section-title">
  265. <div class="section-title-line"></div>
  266. 主图LOGO
  267. </div>
  268. <div class="logo-upload-area">
  269. <div
  270. v-if="!form.logo_path"
  271. class="logo-upload-placeholder"
  272. :class="{ 'is-error': logoLoadError }"
  273. @click="openLogoUpload"
  274. >
  275. <div class="logo-upload-icon">
  276. <img src="@/assets/images/detail/sctp.png" />
  277. </div>
  278. <div class="logo-upload-text">点击或拖拽上传</div>
  279. <div class="logo-upload-hint" v-if="logoLoadError">LOGO指向的文件不存在或加载失败,请重新上传</div>
  280. <div class="logo-upload-hint" v-else>支持PNG、JPG格式</div>
  281. </div>
  282. <div v-else class="logo-upload-preview">
  283. <img :src="'file:///' + form.logo_path" alt="LOGO预览" class="logo-preview-image" @error="handleLogoLoadError" />
  284. <div class="logo-upload-actions">
  285. <span class="logo-action-btn" @click.stop="previewLogo">
  286. <el-icon><ZoomIn /></el-icon>
  287. </span>
  288. <span class="logo-action-btn" @click.stop="removeLogo">
  289. <el-icon><Delete /></el-icon>
  290. </span>
  291. </div>
  292. <div class="logo-upload-footer">
  293. <el-button type="primary" link @click.stop="openLogoUpload">重新上传</el-button>
  294. <el-button type="danger" link @click.stop="removeLogo">删除</el-button>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. <!-- 详情资料准备 -->
  300. <div class="right-section data-prep-section">
  301. <div class="section-title">
  302. <div class="section-title-line"></div>
  303. 详情资料准备
  304. </div>
  305. <div class="data-prep-content">
  306. <el-radio-group v-model="form.dataType" class="data-type-radio">
  307. <el-radio-button label="1" size="large">
  308. <img v-if="form.dataType == 1" src="@/assets/images/detail/excel_h.png" />
  309. <img v-else src="@/assets/images/detail/excel.png" />
  310. Excel上传</el-radio-button>
  311. <el-radio-button label="2" size="large">
  312. <img v-if="form.dataType == 2" src="@/assets/images/detail/xtdj_h.png" />
  313. <img v-else src="@/assets/images/detail/xtdj.png" />
  314. 系统对接</el-radio-button>
  315. </el-radio-group>
  316. <div v-if="form.dataType == '1'" class="excel-upload-section">
  317. <div
  318. v-if="!form.excel_path"
  319. class="excel-upload-area"
  320. @click="selectExcel"
  321. v-log="{ describe: { action: '点击选择Excel文件' } }"
  322. >
  323. <div class="excel-icon">
  324. <img src="@/assets/images/detail/file-excel.png" class="tab-icon" />
  325. </div>
  326. <div class="excel-upload-text">点击选择文件</div>
  327. </div>
  328. <div v-else class="excel-selected-info">
  329. <div class="excel-file-info">
  330. <div class="excel-icon">
  331. <img src="@/assets/images/detail/file-excel.png" class="tab-icon" />
  332. </div>
  333. <div class="excel-file-text">
  334. <div class="excel-file-label">已选择文件</div>
  335. <div class="excel-file-name" :title="excelFileName">{{ excelFileName }}</div>
  336. </div>
  337. </div>
  338. <el-button
  339. type="primary"
  340. link
  341. class="reupload-btn"
  342. @click="selectExcel"
  343. v-log="{ describe: { action: '重新上传Excel文件' } }"
  344. >
  345. 重新上传
  346. </el-button>
  347. </div>
  348. <el-button
  349. type="text"
  350. class="download-link"
  351. @click="downloadExcel"
  352. v-log="{ describe: { action: '点击下载Excel模板' } }"
  353. >
  354. 下载商品基础资料模版
  355. </el-button>
  356. </div>
  357. </div>
  358. </div>
  359. <!-- 一键上架平台 -->
  360. <div
  361. class="right-section publish-section"
  362. :class="{ 'publish-section--disabled': !canUsePublishSection }"
  363. v-if="onlineStoreTempList.length || onlineStoreTempListForeign.length"
  364. >
  365. <div class="section-title">
  366. <div class="section-title-line"></div>
  367. 一键上架平台
  368. </div>
  369. <div class="publish-content">
  370. <div class="publish-form-item" v-if="onlineStoreTempList.length">
  371. <div class="publish-label">国内电商平台:</div>
  372. <el-select
  373. v-model="domesticPlatforms"
  374. multiple
  375. placeholder="请选择"
  376. class="publish-select"
  377. :disabled="!canUsePublishSection"
  378. >
  379. <el-option
  380. v-for="store in onlineStoreTempList"
  381. :key="store.show_name"
  382. :label="store.show_name"
  383. :value="store.online_store_name"
  384. :disabled="!store.channel_status"
  385. />
  386. </el-select>
  387. </div>
  388. <div class="publish-form-item" v-if="onlineStoreTempListForeign.length">
  389. <div class="publish-label">跨境电商平台:</div>
  390. <el-select
  391. v-model="foreignPlatforms"
  392. multiple
  393. placeholder="请选择"
  394. class="publish-select"
  395. :disabled="!canUsePublishSection"
  396. >
  397. <el-option
  398. v-for="store in onlineStoreTempListForeign"
  399. :key="store.show_name"
  400. :label="store.show_name"
  401. :value="store.online_store_name"
  402. :disabled="!store.channel_status"
  403. />
  404. </el-select>
  405. </div>
  406. </div>
  407. </div>
  408. <!-- 底部按钮 -->
  409. <div class="footer">
  410. <el-button
  411. v-loading="requesting"
  412. class="button--primary1 footer-button"
  413. type="primary"
  414. @click="generate"
  415. v-log="{ describe: { action: '点击开始生成详情页' } }"
  416. >
  417. <img src="@/assets/images/processImage.vue/sc.png" />
  418. 开始生成
  419. <img src="@/assets/images/processImage.vue/go.png" class="go"/>
  420. </el-button>
  421. </div>
  422. </div>
  423. </div>
  424. <!-- 详情高级配置 -->
  425. <!-- <div class="section">
  426. <div class="section-title">
  427. <img src="@/assets/images/Photography/zhuangshi.png" style="width: 32px; height: 32px;" />
  428. 详情高级配置
  429. </div>
  430. <div class="section-content">
  431. &lt;!&ndash; 图片顺序 &ndash;&gt;
  432. <div class="form-item">
  433. <div class="label">图片顺序:</div>
  434. <el-input v-model="imageOrder" placeholder="请输入图片顺序" class="specific-page-input">
  435. <template #append>
  436. <el-button class="explain-btn" link type="primary">说明</el-button>
  437. </template>
  438. </el-input>
  439. </div>
  440. &lt;!&ndash; 同款检验 &ndash;&gt;
  441. &lt;!&ndash; <div class="form-item">
  442. <div class="label">同款检验:</div>
  443. <el-checkbox v-model="checkSimilar">同款下货号必须齐全</el-checkbox>
  444. </div>
  445. &ndash;&gt;
  446. &lt;!&ndash; 可指定页面独修改 &ndash;&gt;
  447. &lt;!&ndash; <div class="form-item">
  448. <div class="label">可指定页面独修改:</div>
  449. <el-input v-model="specificPage" placeholder="请输入入需要单独修改的页面,示例:4:1 (需修改模版的编号:第一张)"
  450. class="specific-page-input">
  451. <template #append>
  452. <el-button class="explain-btn" link type="primary">说明</el-button>
  453. </template>
  454. </el-input>
  455. </div>
  456. &ndash;&gt;
  457. </div>
  458. </div>
  459. <el-divider />-->
  460. </div>
  461. </div>
  462. </div>
  463. </div>
  464. <loading-dialog v-if="loadingDialogVisible" v-model="loadingDialogVisible" :requesting="requesting" :progress="progress" :message="message"
  465. :disabled-button="disabledButton" :use-new-progress="useNewProgress" :progress-steps="progressSteps" @button-click="handleComplete" :on-open-folder="openOutputDir">
  466. <template v-if="partErrList && partErrList.length > 0" #errList>
  467. <div v-for="(item, idx) in partErrList" :key="idx">
  468. <span v-if="item.goods_art_no">{{ item.goods_art_no }}:</span><span>{{ item.info }}</span>
  469. </div>
  470. </template>
  471. <template #progressMessages>
  472. <div class="progress-messages" v-if="progressMessages.length">
  473. <div class="message-header">
  474. <span>处理进度</span>
  475. <div class="flex right" style="gap:8px; align-items:center;">
  476. <el-button type="text" @click="openOutputDir" v-log="{ describe: { action: '点击打开输出目录' } }">打开目录</el-button>
  477. <el-button type="text" @click="showMessageHistory = !showMessageHistory" v-log="{ describe: { action: '点击查看进度详情' } }">
  478. {{ showMessageHistory ? '收起' : '查看详情' }}
  479. </el-button>
  480. </div>
  481. </div>
  482. <div class="message-list" v-if="showMessageHistory" ref="messageListRef">
  483. <div v-for="(msg, index) in progressMessages" :key="index" class="message-item flex left">
  484. <div class="message-time">{{ formatTime(msg.timestamp) }}</div>
  485. <div class="message-content mar-left-10" v-if="msg">
  486. <span class="goods-no" v-if="msg.goods_art_nos && msg.goods_art_nos.length > 0">货号{{ msg.goods_art_nos.join(', ') }}:</span>
  487. <span class="message-text">{{ msg.msg }}</span>
  488. </div>
  489. </div>
  490. </div>
  491. </div>
  492. </template>
  493. </loading-dialog>
  494. <el-dialog v-model="dialogVisible">
  495. <img style="width: 100%;" :src="dialogImageUrl" alt="Preview Image" />
  496. </el-dialog>
  497. <!-- LOGO预览弹窗 -->
  498. <el-dialog v-model="logoPreviewVisible" title="LOGO预览">
  499. <img style="width: 100%;" :src="logoPreviewUrl" alt="LOGO Preview" />
  500. </el-dialog>
  501. <!-- 模特生成弹窗 -->
  502. <ModelGenerationDialog
  503. v-model="modelDialogVisible"
  504. :initial-models="selectedModels"
  505. @confirm="handleModelSelection"
  506. @cancel="modelDialogVisible = false"
  507. />
  508. <!-- 场景提示词弹窗 -->
  509. <ScenePromptDialog
  510. v-model="scenePromptDialogVisible"
  511. :initial-prompt="scenePrompt"
  512. @confirm="handleScenePromptConfirm"
  513. @cancel="scenePromptDialogVisible = false"
  514. />
  515. <!-- 货号选择弹窗 -->
  516. <el-dialog
  517. v-model="goodsSelectDialogVisible"
  518. title="请选择一个货号作为自定义商品的模板"
  519. width="60%"
  520. :close-on-click-modal="false"
  521. :close-on-press-escape="false"
  522. custom-class="goods-select-dialog"
  523. >
  524. <div class="goods-select-content">
  525. <el-radio-group v-model="selectedGoodsArtNo" class="goods-radio-group">
  526. <div
  527. v-for="item in filteredGoodsList"
  528. :key="item.goods_art_no"
  529. class="goods-item"
  530. :class="{ 'selected': selectedGoodsArtNo === item.goods_art_no }"
  531. @click="selectedGoodsArtNo = item.goods_art_no"
  532. >
  533. <div class="goods-item-header">
  534. <div class="goods-item-left">
  535. <el-radio
  536. :label="item.goods_art_no"
  537. class="goods-radio"
  538. @click.stop
  539. > </el-radio>
  540. </div>
  541. </div>
  542. <div class="goods-item-images">
  543. <div
  544. v-for="(image, index) in item.items"
  545. :key="image.action_id || image.action_name"
  546. class="goods-item_image"
  547. >
  548. <span class="tag" v-if="!image.PhotoRecord?.image_path">{{ image.action_name }}</span>
  549. <el-image
  550. v-if="image.PhotoRecord?.image_path"
  551. :src="getFilePath(image.PhotoRecord.image_path)"
  552. :preview-src-list="getPreviewImageList(item)"
  553. :initial-index="getPreviewIndex(item, index)"
  554. class="preview-image"
  555. fit="contain"
  556. :preview-teleported="true"
  557. lazy
  558. >
  559. <template #error>
  560. <div class="image-slot">
  561. <span class="tag">{{ image.action_name }}</span>
  562. </div>
  563. </template>
  564. </el-image>
  565. <div v-else class="image-placeholder">
  566. <span class="tag">{{ image.action_name }}</span>
  567. </div>
  568. </div>
  569. </div>
  570. </div>
  571. </el-radio-group>
  572. </div>
  573. <template #footer>
  574. <div class="dialog-footer">
  575. <el-button @click="cancelGoodsSelection">取消</el-button>
  576. <el-button
  577. type="primary"
  578. :loading="goodsGenerateLoading"
  579. :disabled="goodsGenerateLoading"
  580. @click="confirmGoodsSelection"
  581. >
  582. {{ goodsGenerateLoading ? '正在生成自定义商品模版' : '确定' }}
  583. </el-button>
  584. </div>
  585. </template>
  586. </el-dialog>
  587. </template>
  588. <script lang="ts" setup>
  589. import { getCompanyTemplatesApi } from '@/apis/other'
  590. import tokenInfo from '@/stores/modules/token';
  591. import useUserInfo from "@/stores/modules/user";
  592. import { useRoute, useRouter } from 'vue-router'
  593. import { clickLog, setLogInfo } from '@/utils/log'
  594. import { ElMessage, ElMessageBox } from 'element-plus'
  595. import BlueHeaderBar from '@/components/header-bar/blue-header.vue'
  596. import { ref, computed, reactive, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
  597. import { Select, EditPen, ZoomIn, Delete, Picture, Document } from '@element-plus/icons-vue'
  598. // import upload from '@/components/upload' // 不再需要,改为单LOGO上传
  599. import client from "@/stores/modules/client";
  600. import icpList from '@/utils/ipc'
  601. const clientStore = client();
  602. import { getRouterUrl } from '@/utils/appfun'
  603. import { useUuidStore } from '@/stores/modules/uuid'
  604. import socket from "@/stores/modules/socket";
  605. const socketStore = socket();
  606. import ModelGenerationDialog from '@/components/ModelGeneration/index.vue'
  607. import ScenePromptDialog from '@/components/ScenePromptDialog/index.vue'
  608. import { Close, Warning } from '@element-plus/icons-vue'
  609. import LoadingDialog from '@/views/Photography/components/LoadingDialog.vue'
  610. import configInfo from "@/stores/modules/config";
  611. import { deleteCustomerTemplate } from '@/apis/other'
  612. const useConfigInfoStore = configInfo();
  613. const EXTERNAL_TOOL_EXECUTABLE = '智慧映拍照机辅助工具箱.exe'
  614. import usePhotography from './mixin/usePhotography'
  615. const {
  616. loading,
  617. goodsList,
  618. getPhotoRecords,
  619. getTime,
  620. getFilePath,
  621. } = usePhotography()
  622. const launchExternalTool = async (pagePath: string, successMessage: string) => {
  623. if (!clientStore?.ipc || !clientStore.isClient) {
  624. ElMessage.error('当前环境暂不支持外部工具');
  625. return;
  626. }
  627. if (!pagePath) return;
  628. const tokenStore = tokenInfo();
  629. const token = tokenStore?.getToken || '';
  630. const env = (useConfigInfoStore?.appConfig as any)?.env || 'prod';
  631. const argString = `token=${token}&page=${pagePath}&env=${env}`;
  632. try {
  633. const result = await clientStore.ipc.invoke(icpList.utils.runExternalTool, {
  634. exeName: EXTERNAL_TOOL_EXECUTABLE,
  635. args: [argString]
  636. });
  637. if (result?.code === 0) {
  638. ElMessage.success(successMessage);
  639. } else {
  640. throw new Error(result?.msg || '启动外部工具失败');
  641. }
  642. } catch (error: any) {
  643. console.error('launchExternalTool error:', error);
  644. ElMessage.error(error?.message || '打开外部工具失败');
  645. }
  646. }
  647. const handleWhiteBgExportClick = () => launchExternalTool('/copy_800_tool', '白底图批量导出工具已启动')
  648. const handleProductAlbumClick = () => launchExternalTool('/product_list', '产品图册生成工具已启动')
  649. // 货号选择弹窗相关状态
  650. const goodsSelectDialogVisible = ref(false)
  651. const filteredGoodsList = ref<any[]>([])
  652. const selectedGoodsArtNo = ref<string>('')
  653. const goodsGenerateLoading = ref(false)
  654. const addCustomTemplate = async() => {
  655. // 调用获取数据
  656. getPhotoRecords()
  657. // 处理数据的函数
  658. const processData = () => {
  659. // 从 goodsList 中筛选出 goods_art_no 在 goods_art_nos.value 中的对象
  660. const filteredGoods = goodsList.value.filter((item: any) =>
  661. goods_art_nos.value.includes(item.goods_art_no)
  662. )
  663. console.log('goods_art_nos', goods_art_nos.value)
  664. console.log('filteredGoods', filteredGoods)
  665. if (filteredGoods.length > 0) {
  666. // 若有匹配项,则只展示匹配到的货号
  667. filteredGoodsList.value = filteredGoods
  668. selectedGoodsArtNo.value = filteredGoods[0].goods_art_no
  669. goodsSelectDialogVisible.value = true
  670. } else if (goodsList.value.length > 0) {
  671. // 若没有匹配到货号,则展示全部货号列表
  672. filteredGoodsList.value = goodsList.value
  673. selectedGoodsArtNo.value = goodsList.value[0].goods_art_no
  674. goodsSelectDialogVisible.value = true
  675. } else {
  676. // 列表本身为空时再提示
  677. ElMessage.warning('未找到匹配的货号数据')
  678. }
  679. }
  680. // 使用 watch 监听 loading 状态,当从 true 变为 false 时,说明数据加载完成
  681. const stopWatcher = watch(
  682. () => loading.value,
  683. (isLoading, wasLoading) => {
  684. // 当 loading 从 true 变为 false 时,说明数据已经加载完成
  685. if (wasLoading && !isLoading) {
  686. processData()
  687. // 停止监听,避免重复执行
  688. stopWatcher()
  689. }
  690. }
  691. )
  692. // 如果当前 loading 已经是 false,可能数据已经存在或加载很快完成
  693. // 使用 nextTick 等待一个 tick,如果 loading 仍然是 false,直接处理
  694. if (!loading.value) {
  695. await nextTick()
  696. // 如果 loading 仍然是 false,可能数据已经存在,直接处理
  697. if (!loading.value) {
  698. processData()
  699. stopWatcher() // 停止监听
  700. }
  701. }
  702. }
  703. // 根据选中的货号调用后端生成商品模板
  704. const generateGoodsTemplate = (goodsArtNo: string) => {
  705. return new Promise<void>((resolve, reject) => {
  706. try {
  707. console.log('调用 get_goods_image_json, goods_art_no:', goodsArtNo)
  708. // 按后端要求带上 token(参考其他生成类接口)
  709. const tokenStore = tokenInfo();
  710. const token = (tokenStore as any)?.getToken || '';
  711. // 先清理监听,避免重复回调
  712. clientStore.ipc.removeAllListeners(icpList.generate.getGoodsImageJson)
  713. clientStore.ipc.send(icpList.generate.getGoodsImageJson, {
  714. goods_art_no: goodsArtNo,
  715. token,
  716. })
  717. clientStore.ipc.on(icpList.generate.getGoodsImageJson, (event, result) => {
  718. clientStore.ipc.removeAllListeners(icpList.generate.getGoodsImageJson)
  719. console.log('get_goods_image_json result:', result)
  720. if (result && result.code === 0) {
  721. resolve(result.data)
  722. } else {
  723. const msg = result?.msg || '商品模板生成失败'
  724. ElMessage.error(msg)
  725. reject(new Error(msg))
  726. }
  727. })
  728. } catch (error: any) {
  729. ElMessage.error(error?.message || '商品模板生成异常')
  730. reject(error)
  731. }
  732. })
  733. }
  734. // 确认选择货号
  735. const confirmGoodsSelection = async () => {
  736. if (!selectedGoodsArtNo.value) {
  737. ElMessage.warning('请选择一个货号')
  738. return
  739. }
  740. console.log('选中的货号:', selectedGoodsArtNo.value)
  741. goodsGenerateLoading.value = true
  742. try {
  743. const data = await generateGoodsTemplate(selectedGoodsArtNo.value)
  744. console.log('商品模版数据', data)
  745. // 组装 goods_images 数组:[{ key: 模板顺序项, value: 对应图片地址 }, ...]
  746. const goodsImages: Array<{ key: string; value: string }> = []
  747. const orderArr = (data?.template_image_order || '')
  748. .split(',')
  749. .map((s: string) => s.trim())
  750. .filter((s: string) => s)
  751. const imagesArr = Array.isArray(data?.customer_template_images)
  752. ? data.customer_template_images
  753. : []
  754. const len = Math.min(orderArr.length, imagesArr.length)
  755. for (let i = 0; i < len; i++) {
  756. goodsImages.push({
  757. key: orderArr[i],
  758. value: imagesArr[i],
  759. })
  760. }
  761. // 生成商品模板成功后,跳转到新增模板页,并携带当前选中的货号
  762. router.push({
  763. name: 'addTpl',
  764. query: {
  765. // 统一用 JSON 字符串传递图片与顺序信息
  766. customer_template_images: encodeURIComponent(JSON.stringify(goodsImages)),
  767. template_image_order: data?.template_image_order || '',
  768. },
  769. })
  770. } finally {
  771. // 无论成功或失败,都关闭弹窗,保留当前选择
  772. goodsSelectDialogVisible.value = false
  773. goodsGenerateLoading.value = false
  774. }
  775. }
  776. // 取消选择
  777. const cancelGoodsSelection = () => {
  778. goodsSelectDialogVisible.value = false
  779. selectedGoodsArtNo.value = ''
  780. filteredGoodsList.value = []
  781. }
  782. // 获取预览图片列表(只包含有图片路径的,保持原始顺序)
  783. const getPreviewImageList = (item: any) => {
  784. if (!item || !item.items) return []
  785. return item.items
  786. .filter((img: any) => img.PhotoRecord?.image_path)
  787. .map((img: any) => getFilePath(img.PhotoRecord.image_path))
  788. }
  789. // 获取当前图片在预览列表中的索引
  790. const getPreviewIndex = (item: any, currentIndex: number) => {
  791. if (!item || !item.items) return 0
  792. // 计算当前图片在过滤后的预览列表中的索引
  793. let previewIndex = 0
  794. for (let i = 0; i <= currentIndex; i++) {
  795. if (item.items[i]?.PhotoRecord?.image_path) {
  796. if (i === currentIndex) break
  797. previewIndex++
  798. }
  799. }
  800. return previewIndex
  801. }
  802. import { useCheckInfo } from '@/composables/userCheck';
  803. useCheckInfo();
  804. const showTips = ref(true)
  805. const folderPath = ref('') //货号文件夹
  806. // const reportMode = ref('normal') // 抠图模式
  807. const imageOrder = ref('俯视、侧视、后跟、鞋底、内里、组合、组合2、组合3') // 图片顺序
  808. const checkSimilar = ref(false) // 同款检验
  809. const specificPage = ref('') // 可指定页面独修改
  810. // 路由和状态管理初始化
  811. const route = useRoute();
  812. const router = useRouter();
  813. const uuidStore = useUuidStore();
  814. // 完成目录
  815. const completeDirectory = ref('')
  816. const loadingDialogVisible = ref(false)
  817. const progress = ref(0)
  818. const message = ref('正在为您处理,请稍后')
  819. const disabledButton = ref(true)
  820. // 新的进度条相关数据
  821. const useNewProgress = ref(false)
  822. const progressSteps = ref<Array<{
  823. msg_type: string
  824. goods_art_no: string
  825. name: string
  826. status: '等待处理' | '正在处理' | '处理完成' | '处理失败'
  827. current: number
  828. total: number
  829. error: number
  830. }>>([])
  831. // 删除自定义模板
  832. const deleteTemplate = async (template: any) => {
  833. if (!template?.id) return
  834. try {
  835. await ElMessageBox.confirm(
  836. `确定要删除自定义模板「${template.template_name || ''}」吗?`,
  837. '提示',
  838. {
  839. confirmButtonText: '确定',
  840. cancelButtonText: '取消',
  841. type: 'warning',
  842. },
  843. )
  844. const res = await deleteCustomerTemplate({ id: template.id })
  845. const data = res?.data
  846. if (data?.code === 0) {
  847. ElMessage.success('删除成功')
  848. // 从当前模板列表中移除
  849. const idx = templates.value.findIndex((item: any) => item.id === template.id)
  850. if (idx !== -1) {
  851. templates.value.splice(idx, 1)
  852. }
  853. } else {
  854. ElMessage.error(data?.msg || '删除失败')
  855. }
  856. } catch (e: any) {
  857. if (e !== 'cancel' && e !== 'close') {
  858. console.error('删除模板失败:', e)
  859. ElMessage.error(e?.message || '删除失败')
  860. }
  861. }
  862. }
  863. // 更新进度步骤
  864. const updateProgressStep = (msgType: string, stepData: any) => {
  865. console.log('updateProgressStep called:', msgType, stepData)
  866. const stepIndex = progressSteps.value.findIndex(step => step.msg_type === msgType)
  867. if (stepIndex !== -1) {
  868. // 更新现有步骤 - 使用新数组来确保响应式更新
  869. const newSteps = [...progressSteps.value]
  870. newSteps[stepIndex] = {
  871. ...newSteps[stepIndex],
  872. name: stepData.name, // 保持原有名称或使用新名称
  873. goods_art_no: stepData.goods_art_no,
  874. status: stepData.status,
  875. current: stepData.current || 0,
  876. total: stepData.total || 0,
  877. error: stepData.error || 0,
  878. folder: newSteps[stepIndex].folder || stepData.folder // 保持已有的folder或使用新的
  879. }
  880. progressSteps.value = newSteps
  881. console.log('Updated step:', newSteps[stepIndex])
  882. } else {
  883. // 添加新步骤
  884. progressSteps.value = [...progressSteps.value, {
  885. msg_type: msgType,
  886. name: stepData.name,
  887. goods_art_no: stepData.goods_art_no,
  888. status: stepData.status,
  889. current: stepData.current || 0,
  890. total: stepData.total || 0,
  891. error: stepData.error || 0,
  892. folder: stepData.folder // 添加folder字段
  893. }]
  894. console.log('Added new step:', progressSteps.value[progressSteps.value.length - 1])
  895. }
  896. }
  897. // 获取步骤名称
  898. // 初始化进度步骤 - 从后端数据动态获取
  899. const initProgressSteps = (backendSteps?: any[]) => {
  900. if (backendSteps && backendSteps.length > 0) {
  901. // 使用后端返回的步骤数据
  902. progressSteps.value = backendSteps.map(step => ({
  903. msg_type: step.msg_type,
  904. goods_art_no: step.goods_art_no,
  905. name: step.name,
  906. status: '等待处理',
  907. current: 0,
  908. total: step.total || 0,
  909. error: 0
  910. }))
  911. } else {
  912. // 默认步骤(当后端没有返回步骤数据时使用)
  913. progressSteps.value = []
  914. }
  915. }
  916. // 进度消息队列
  917. const progressMessages = ref<Array<{
  918. goods_no: string
  919. temp_name: string
  920. status: string
  921. goods_art_nos: string[]
  922. msg: string
  923. timestamp: number
  924. }>>([])
  925. const showMessageHistory = ref(true)
  926. const messageListRef = ref<HTMLElement | null>(null)
  927. // 新消息时自动滚动到底部
  928. const scrollMessageListToBottom = () => {
  929. nextTick(() => {
  930. const el = messageListRef.value
  931. if (el) {
  932. el.scrollTop = el.scrollHeight
  933. }
  934. })
  935. }
  936. let templates = ref([])
  937. // let goods_art_nos = ref([])
  938. let partErrList = ref([])
  939. const excel_template_url = ref('')
  940. // 是否正在请求接口
  941. const requesting = ref(false)
  942. const goods_art_nos = computed(() => {
  943. const goods_art_data = route.query.goods_art_nos
  944. return Array.isArray(goods_art_data) ? goods_art_data : [goods_art_data]
  945. })
  946. // 定义一个定时器变量
  947. const INTERVAL = ref<number | NodeJS.Timeout | null>(null);
  948. // 状态变量
  949. const totalPage = ref(0);
  950. const itemsPerPage = 3; // 每页显示的模板数量
  951. const dialogVisible = ref(false);
  952. const dialogImageUrl = ref('');
  953. const queryParams = reactive({ // 分页查询参数
  954. size: 1,
  955. current: 1,
  956. })
  957. const form = reactive({
  958. selectTemplate: {}, //选中的模板
  959. dataType: '1', // 1: 选择excel文件 2: 系统对接
  960. logo_path: '', // 主图LOGO
  961. excel_path: '', // 商品基础资料EXCEL文件选择
  962. services: ['is_detail'], // 勾选服务内容(多选)默认包含详情页生成
  963. })
  964. const excelFileName = computed(() => {
  965. if (!form.excel_path) return ''
  966. const segments = form.excel_path.split(/[/\\]/)
  967. return segments[segments.length - 1] || ''
  968. })
  969. const templatesLoaded = ref(false)
  970. const lastSelectedTemplateId = ref<string | number | null>(null)
  971. const isDetailServiceSelected = computed(() => form.services.includes('is_detail'))
  972. const hasTemplates = computed(() => templates.value.length > 0)
  973. const canUsePublishSection = computed(() => isDetailServiceSelected.value && hasTemplates.value)
  974. onMounted(() => {
  975. // 页面访问埋点
  976. const goods_art_data = route.query.goods_art_nos
  977. goods_art_nos.value = Array.isArray(goods_art_data) ? goods_art_data : [goods_art_data]
  978. getCompanyTemplates()
  979. getLogolist()
  980. loadDetailCache()
  981. // 初始化目录打开状态标记
  982. window.segmentFolderOpened = false;
  983. window.modelOrSceneFolderOpened = false;
  984. // 监听子组件发出的打开目录事件
  985. window.addEventListener('openFolder', handleOpenFolder);
  986. })
  987. // 页面卸载时清理监听器
  988. onBeforeUnmount(() => {
  989. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  990. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  991. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  992. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  993. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  994. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  995. clearInterval(INTERVAL.value);
  996. // 移除事件监听器
  997. window.removeEventListener('openFolder', handleOpenFolder);
  998. })
  999. // 计算属性,获取当前页可见的模板
  1000. const visibleTemplates = computed(() => {
  1001. const startIndex = (queryParams.current - 1) * itemsPerPage;
  1002. const data = templates.value.slice(startIndex, startIndex + itemsPerPage);
  1003. return data
  1004. });
  1005. const selectTemplate = (template: any, options: { saveCache?: boolean; ensureVisible?: boolean } = {}) => {
  1006. if (!isDetailServiceSelected.value) return
  1007. if (!template || !template.id) return
  1008. form.selectTemplate = template
  1009. lastSelectedTemplateId.value = template.id
  1010. if (options.ensureVisible) {
  1011. jumpToTemplatePageById(template.id)
  1012. }
  1013. const shouldSaveCache = options.saveCache !== undefined ? options.saveCache : true
  1014. if (shouldSaveCache) {
  1015. try {
  1016. localStorage.setItem(DETAIL_TEMPLATE_CACHE_KEY, JSON.stringify(template))
  1017. console.log('selectTemplate - saved to cache:', template);
  1018. } catch {}
  1019. }
  1020. };
  1021. const handleTemplateItemClick = (template: any) => {
  1022. if (!isDetailServiceSelected.value) return
  1023. selectTemplate(template)
  1024. };
  1025. const clearTemplateSelection = () => {
  1026. form.selectTemplate = {}
  1027. };
  1028. const findTemplateById = (templateId: string | number | null) => {
  1029. if (templateId === null || templateId === undefined) return null
  1030. return templates.value.find(template => String(template.id) === String(templateId)) || null
  1031. };
  1032. const jumpToTemplatePageById = (templateId: string | number | null) => {
  1033. if (templateId === null || templateId === undefined) return
  1034. const index = templates.value.findIndex(template => String(template.id) === String(templateId))
  1035. if (index === -1) return
  1036. const targetPage = Math.floor(index / itemsPerPage) + 1
  1037. if (queryParams.current !== targetPage) {
  1038. queryParams.current = targetPage
  1039. }
  1040. };
  1041. const ensureDefaultTemplateSelection = (options: { ensureVisible?: boolean } = {}) => {
  1042. if (!templatesLoaded.value || !isDetailServiceSelected.value || !templates.value.length) {
  1043. return
  1044. }
  1045. if (form.selectTemplate && (form.selectTemplate as any).id) {
  1046. if (options.ensureVisible) {
  1047. jumpToTemplatePageById((form.selectTemplate as any).id)
  1048. }
  1049. return
  1050. }
  1051. const cachedTemplate = findTemplateById(lastSelectedTemplateId.value)
  1052. const templateToSelect = cachedTemplate || templates.value[0]
  1053. if (templateToSelect) {
  1054. selectTemplate(templateToSelect, {
  1055. ensureVisible: options.ensureVisible,
  1056. saveCache: !cachedTemplate
  1057. })
  1058. }
  1059. };
  1060. watch(isDetailServiceSelected, (selected) => {
  1061. if (selected) {
  1062. ensureDefaultTemplateSelection({ ensureVisible: true })
  1063. } else {
  1064. clearTemplateSelection()
  1065. }
  1066. });
  1067. // 查看模板详情
  1068. const viewTemplate = (template) => {
  1069. // 展示大图
  1070. dialogVisible.value = true
  1071. dialogImageUrl.value = template.template_preview_image
  1072. };
  1073. // 编辑自定义模版
  1074. const editTemplate = (template: any) => {
  1075. if (!template) return
  1076. // 将画布 JSON、名称、商品图片等信息通过 query 传给编辑页
  1077. const customerTemplateJson = template.customer_template_json || []
  1078. const customerTemplateImages = template.customer_template_images || []
  1079. const templateImageOrder = template.template_image_order || ''
  1080. const templateName = template.template_name || ''
  1081. router.push({
  1082. name: 'editTpl',
  1083. params: { id: template.id },
  1084. query: {
  1085. customer_template_json: encodeURIComponent(JSON.stringify(customerTemplateJson)),
  1086. template_name: templateName,
  1087. customer_template_images: encodeURIComponent(JSON.stringify(customerTemplateImages)),
  1088. template_image_order: templateImageOrder,
  1089. },
  1090. })
  1091. };
  1092. // 获取模版列表
  1093. const getCompanyTemplates = async () => {
  1094. const { data } = await getCompanyTemplatesApi()
  1095. console.log('getCompanyTemplatesApi' ,data);
  1096. templates.value = data.list || []
  1097. // 获取电商平台列表 - 支持新的数据结构
  1098. if (data.online_store_temp_list) {
  1099. onlineStoreTempList.value = data.online_store_temp_list
  1100. }
  1101. if (data.online_store_temp_list_foreign) {
  1102. onlineStoreTempListForeign.value = data.online_store_temp_list_foreign
  1103. }
  1104. templatesLoaded.value = true
  1105. // 获取模板列表后,尝试从缓存恢复模板选择
  1106. loadTemplateFromCache()
  1107. excel_template_url.value = data.excel_template_url
  1108. // 计算总页数
  1109. totalPage.value = Math.ceil(templates.value.length / itemsPerPage);
  1110. }
  1111. const downloadExcel = () => {
  1112. const a = document.createElement('a')
  1113. a.href = excel_template_url.value,
  1114. a.download = '商品基础资料模版'
  1115. document.body.appendChild(a)
  1116. a.click()
  1117. setTimeout(() => {
  1118. document.body.removeChild(a);
  1119. }, 1000);
  1120. }
  1121. // 服务内容切换
  1122. const toggleService = (key: string) => {
  1123. const idx = form.services.indexOf(key)
  1124. if (idx > -1) form.services.splice(idx, 1)
  1125. else form.services.push(key)
  1126. // 保存服务选择状态到缓存
  1127. saveServicesToCache(form.services)
  1128. }
  1129. // 电商平台多选与一键上架
  1130. const domesticPlatforms = ref<string[]>([])
  1131. const foreignPlatforms = ref<string[]>([])
  1132. const onlineStoreTempList = ref<any[]>([]) // 国内电商平台列表
  1133. const onlineStoreTempListForeign = ref<any[]>([]) // 国外电商平台列表
  1134. // 模特与场景弹窗
  1135. const modelDialogVisible = ref(false)
  1136. const scenePromptDialogVisible = ref(false)
  1137. const selectedModels = ref<{ female: any; male: any } | null>(null)
  1138. const scenePrompt = ref('')
  1139. // 本地缓存键(与弹窗组件保持一致)
  1140. const DETAIL_MODEL_CACHE_KEY = 'model_selection_cache'
  1141. const DETAIL_SCENE_PROMPT_CACHE_KEY = 'scene_prompt_cache'
  1142. const detail_logo_cache_1_KEY = 'detail_logo_cache_1'
  1143. const DETAIL_DATA_TYPE_CACHE_KEY = 'detail_data_type_cache'
  1144. const DETAIL_SERVICES_CACHE_KEY = 'detail_services_cache'
  1145. const DETAIL_TEMPLATE_CACHE_KEY = 'detail_template_cache'
  1146. // 读取本地缓存
  1147. const loadDetailCache = () => {
  1148. console.log('loadDetailCache');
  1149. try {
  1150. const m = localStorage.getItem(DETAIL_MODEL_CACHE_KEY)
  1151. if (m) {
  1152. const parsed = JSON.parse(m)
  1153. if (parsed && (parsed.female || parsed.male)) {
  1154. selectedModels.value = parsed
  1155. console.log('loadDetailCache');
  1156. console.log(selectedModels.value);
  1157. }
  1158. }
  1159. } catch {}
  1160. try {
  1161. const p = localStorage.getItem(DETAIL_SCENE_PROMPT_CACHE_KEY)
  1162. if (p) {
  1163. console.log('scenePrompt');
  1164. scenePrompt.value = p
  1165. console.log(scenePrompt.value);
  1166. }
  1167. } catch {}
  1168. // 加载LOGO缓存
  1169. try {
  1170. const logo = localStorage.getItem(detail_logo_cache_1_KEY)
  1171. if (logo) {
  1172. form.logo_path = logo || ''
  1173. console.log(form.logo_path);
  1174. console.log('loadDetailCache - logo:', logo);
  1175. }
  1176. } catch {}
  1177. // 加载数据类型缓存
  1178. try {
  1179. const dataType = localStorage.getItem(DETAIL_DATA_TYPE_CACHE_KEY)
  1180. if (dataType) {
  1181. form.dataType = dataType
  1182. console.log('loadDetailCache - dataType:', dataType);
  1183. }
  1184. } catch {}
  1185. // 模板缓存加载将在获取模板列表后执行
  1186. // 加载服务选择状态缓存
  1187. try {
  1188. const services = localStorage.getItem(DETAIL_SERVICES_CACHE_KEY)
  1189. if (services) {
  1190. const parsed = JSON.parse(services)
  1191. if (Array.isArray(parsed)) {
  1192. form.services = parsed
  1193. console.log('loadDetailCache - services:', parsed);
  1194. }
  1195. }
  1196. } catch {}
  1197. }
  1198. // 保存到本地缓存(仅保存必要字段)
  1199. const saveModelsToCache = (models: { female: any; male: any }) => {
  1200. try {
  1201. const payload = {
  1202. female: models?.female ? {
  1203. id: models.female.id,
  1204. name: models.female.name,
  1205. image_url: models.female.image_url,
  1206. gender: models.female.gender,
  1207. keywords: models.female.keywords,
  1208. status: models.female.status
  1209. } : null,
  1210. male: models?.male ? {
  1211. id: models.male.id,
  1212. name: models.male.name,
  1213. image_url: models.male.image_url,
  1214. gender: models.male.gender,
  1215. keywords: models.male.keywords,
  1216. status: models.male.status
  1217. } : null
  1218. }
  1219. localStorage.setItem(DETAIL_MODEL_CACHE_KEY, JSON.stringify(payload))
  1220. } catch {}
  1221. }
  1222. const saveScenePromptToCache = (prompt: string) => {
  1223. try {
  1224. const v = (prompt || '').trim()
  1225. if (v) localStorage.setItem(DETAIL_SCENE_PROMPT_CACHE_KEY, v)
  1226. } catch {}
  1227. }
  1228. // 保存LOGO到缓存
  1229. const saveLogoToCache = (logoPath: string) => {
  1230. try {
  1231. localStorage.setItem(detail_logo_cache_1_KEY, logoPath)
  1232. } catch {}
  1233. }
  1234. // 保存数据类型到缓存
  1235. const saveDataTypeToCache = (dataType: string) => {
  1236. try {
  1237. if (dataType) {
  1238. localStorage.setItem(DETAIL_DATA_TYPE_CACHE_KEY, dataType)
  1239. console.log('saveDataTypeToCache:', dataType);
  1240. }
  1241. } catch {}
  1242. }
  1243. const saveServicesToCache = (services: string[]) => {
  1244. try {
  1245. localStorage.setItem(DETAIL_SERVICES_CACHE_KEY, JSON.stringify(services))
  1246. console.log('saveServicesToCache:', services);
  1247. } catch {}
  1248. }
  1249. // 从缓存加载模板选择
  1250. const loadTemplateFromCache = () => {
  1251. lastSelectedTemplateId.value = null
  1252. try {
  1253. const template = localStorage.getItem(DETAIL_TEMPLATE_CACHE_KEY)
  1254. if (template) {
  1255. const parsed = JSON.parse(template)
  1256. if (parsed && parsed.id) {
  1257. lastSelectedTemplateId.value = parsed.id
  1258. console.log('loadTemplateFromCache - template id:', parsed.id);
  1259. }
  1260. }
  1261. } catch (error) {
  1262. console.error('加载模板缓存失败:', error);
  1263. }
  1264. ensureDefaultTemplateSelection({ ensureVisible: true })
  1265. }
  1266. const openModelDialog = () => {
  1267. modelDialogVisible.value = true
  1268. }
  1269. const openScenePromptDialog = () => {
  1270. scenePromptDialogVisible.value = true
  1271. }
  1272. // 选择LOGO
  1273. // selectLogo 函数已移除,现在只支持单个LOGO上传
  1274. const handleModelSelection = (models: { female: any; male: any }) => {
  1275. selectedModels.value = models
  1276. saveModelsToCache(models)
  1277. modelDialogVisible.value = false
  1278. ElMessage.success('模特选择完成!')
  1279. }
  1280. const handleScenePromptConfirm = (prompt: string) => {
  1281. scenePrompt.value = prompt
  1282. saveScenePromptToCache(prompt)
  1283. }
  1284. const onCurrentChange = (page) => {
  1285. queryParams.current = page;
  1286. };
  1287. const onSizeChange = (data) => {
  1288. };
  1289. // 格式化时间
  1290. const formatTime = (timestamp: number) => {
  1291. const date = new Date(timestamp)
  1292. return `${date.getHours().toString().padStart(2, '0')}:${date.getMinutes().toString().padStart(2, '0')}:${date.getSeconds().toString().padStart(2, '0')}`
  1293. }
  1294. // 处理进度消息
  1295. const handleProgressMessage = (data: any) => {
  1296. console.log("detail_progress", data);
  1297. if (data.code === 0 && data.msg_type === 'detail_progress') {
  1298. const messageData = {
  1299. goods_no: data.data.goods_no,
  1300. temp_name: data.data.temp_name,
  1301. status: data.data.status,
  1302. goods_art_nos: data.data.goods_art_nos,
  1303. msg: data.msg,
  1304. timestamp: Date.now()
  1305. }
  1306. progressMessages.value.push(messageData)
  1307. // 更新当前显示的消息
  1308. message.value = data.data.goods_art_nos ? `货号${data.data.goods_art_nos.join(', ')}:${data.msg}` : `${data.msg}`
  1309. scrollMessageListToBottom()
  1310. // 更新新的进度条
  1311. if (data.progress) {
  1312. updateProgressStep('detail_progress', data.progress)
  1313. }
  1314. }
  1315. }
  1316. // 处理抠图进度消息
  1317. const handleSegmentProgressMessage = (data: any) => {
  1318. console.log("segment_progress", data);
  1319. if (data.code === 0 && data.msg_type === 'segment_progress') {
  1320. const messageData = {
  1321. goods_no: '',
  1322. temp_name: '',
  1323. status: data.data?.status || '',
  1324. goods_art_nos: data.data?.goods_art_nos || [],
  1325. msg: data.msg,
  1326. timestamp: Date.now()
  1327. }
  1328. progressMessages.value.push(messageData)
  1329. // 更新当前显示的消息
  1330. message.value = data.data.goods_art_nos ? `货号${data.data.goods_art_nos.join(', ')}:${data.msg}` : `${data.msg}`
  1331. scrollMessageListToBottom()
  1332. // 更新新的进度条
  1333. if (data.progress) {
  1334. if(['处理完成','处理失败'].includes( progressSteps.value[0]?.status)){
  1335. return;
  1336. }
  1337. updateProgressStep('segment_progress', data.progress)
  1338. if(data.progress?.folder && !window.segmentFolderOpened){
  1339. window.segmentFolderOpened = true;
  1340. openOutputDir(data.progress?.folder)
  1341. }
  1342. }
  1343. }
  1344. }
  1345. // 处理上脚图进度
  1346. const handleUpperFooterProgressMessage = (data: any) => {
  1347. console.log("upper_footer_progress", data);
  1348. if (data.code === 0 && data.msg_type === 'upper_footer_progress') {
  1349. const messageData = {
  1350. goods_no: '',
  1351. temp_name: '',
  1352. status: data.data?.status || '',
  1353. goods_art_nos: data.data?.goods_art_nos || [],
  1354. msg: data.msg,
  1355. timestamp: Date.now()
  1356. }
  1357. progressMessages.value.push(messageData)
  1358. message.value = data.data.goods_art_nos ? `货号${data.data.goods_art_nos.join(', ')}:${data.msg}` : `${data.msg}`
  1359. scrollMessageListToBottom()
  1360. // 更新新的进度条
  1361. if (data.progress) {
  1362. updateProgressStep('upper_footer_progress', data.progress)
  1363. // 如果是处理完成状态且目录还未打开,则打开目录
  1364. if(data.progress?.folder && !window.modelOrSceneFolderOpened){
  1365. window.modelOrSceneFolderOpened = true;
  1366. openOutputDir(data.progress?.folder)
  1367. }
  1368. }
  1369. }
  1370. }
  1371. // 处理场景图进度
  1372. const handleSceneProgressMessage = (data: any) => {
  1373. console.log("scene_progress", data);
  1374. if (data.code === 0 && data.msg_type === 'scene_progress') {
  1375. const messageData = {
  1376. goods_no: '',
  1377. temp_name: '',
  1378. status: data.data?.status || '',
  1379. goods_art_nos: data.data?.goods_art_nos || [],
  1380. msg: data.msg,
  1381. timestamp: Date.now()
  1382. }
  1383. progressMessages.value.push(messageData)
  1384. message.value = data.data.goods_art_nos ? `货号${data.data.goods_art_nos.join(', ')}:${data.msg}` : `${data.msg}`
  1385. scrollMessageListToBottom()
  1386. // 更新新的进度条
  1387. if (data.progress) {
  1388. updateProgressStep('scene_progress', data.progress)
  1389. // 如果是处理完成状态且目录还未打开,则打开目录
  1390. if(data.progress?.folder && !window.modelOrSceneFolderOpened){
  1391. window.modelOrSceneFolderOpened = true;
  1392. openOutputDir(data.progress?.folder)
  1393. }
  1394. }
  1395. }
  1396. }
  1397. // 处理商品上传进度
  1398. const handleUploadGoodsProgressMessage = (data: any) => {
  1399. console.log("upload_goods_progress", data);
  1400. if (data.code === 0 && data.msg_type === 'upload_goods_progress') {
  1401. const messageData = {
  1402. goods_no: '',
  1403. temp_name: '',
  1404. status: data.data?.status || '',
  1405. goods_art_nos: data.data?.goods_art_nos || [],
  1406. msg: data.msg,
  1407. timestamp: Date.now()
  1408. }
  1409. progressMessages.value.push(messageData)
  1410. message.value = data.data.goods_art_nos ? `货号${data.data.goods_art_nos.join(', ')}:${data.msg}` : `${data.msg}`
  1411. scrollMessageListToBottom()
  1412. // 更新新的进度条
  1413. if (data.progress) {
  1414. updateProgressStep('upload_goods_progress', data.progress)
  1415. }
  1416. }
  1417. }
  1418. // 打开输出目录:appConfig.appPath + '/build/extraResources/py/output'
  1419. const openOutputDir = (path) => {
  1420. try {
  1421. let fullPath = ''
  1422. if(path){
  1423. fullPath = path
  1424. }else{
  1425. const appPath = useConfigInfoStore?.appConfig?.appPath || ''
  1426. if (!appPath) {
  1427. ElMessage.error('未获取到应用目录 appPath')
  1428. return
  1429. }
  1430. fullPath = `${pyPath}\\output`
  1431. }
  1432. clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
  1433. clientStore.ipc.send(icpList.utils.shellFun, {
  1434. action: 'openPath',
  1435. params: fullPath.replace(/\//g, '\\')
  1436. });
  1437. } catch (e) {
  1438. console.error(e)
  1439. ElMessage.error('打开目录失败')
  1440. }
  1441. }
  1442. // 检测参数是否有效
  1443. const checkParams = async function () {
  1444. const useConfigInfoStore = configInfo();
  1445. const tokenInfoStore = tokenInfo();
  1446. const token = tokenInfoStore.getToken;
  1447. let temp_list = []
  1448. templates.value.map(item => {
  1449. temp_list.push({
  1450. template_id: item.template_id,
  1451. template_local_classes: item.template_local_classes,
  1452. })
  1453. })
  1454. // 根据选择的服务内容设置参数
  1455. const isDetail = form.services.includes('is_detail') ? 1 : 0
  1456. const isProductScene = form.services.includes('is_product_scene') ? 1 : 0
  1457. const isUpperFooter = form.services.includes('is_upper_footer') ? 1 : 0
  1458. const params = {
  1459. goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
  1460. logo_path: form.logo_path || '',
  1461. temp_name: form.selectTemplate?.template_id || '',
  1462. excel_path: form.dataType == '1' ? form.excel_path : '',
  1463. template_image_order: form.selectTemplate?.template_image_order,
  1464. temp_list,
  1465. token,
  1466. uuid: uuidStore.getUuid || '',
  1467. // 新增服务参数 - 合并国内和国外平台
  1468. online_stores: [...(domesticPlatforms.value || []), ...(foreignPlatforms.value || [])],
  1469. is_detail: isDetail,
  1470. is_product_scene: isProductScene,
  1471. is_upper_footer: isUpperFooter,
  1472. upper_footer_params: selectedModels.value ? {
  1473. man_id: selectedModels.value.male?.id || "",
  1474. women_id: selectedModels.value.female?.id || ""
  1475. } : {},
  1476. product_scene_prompt: scenePrompt.value || '',
  1477. is_check: 1 // 仅检测,不生成
  1478. }
  1479. try {
  1480. // 直接调用API进行检测,因为检测模式会直接返回结果
  1481. const response = await clientStore.ipc.invoke(icpList.generate.generatePhotoDetail, params);
  1482. console.log('=======checkParamscheckParamscheckParamscheckParams===========');
  1483. console.log(params);
  1484. console.log(response);
  1485. if (response.code === 0) {
  1486. return response;
  1487. } else {
  1488. throw new Error(response.msg || '检测失败');
  1489. }
  1490. } catch (error) {
  1491. throw new Error(error.message || '检测失败');
  1492. }
  1493. }
  1494. // 开始生成操作
  1495. const generate = async function () {
  1496. if (requesting.value) {
  1497. return
  1498. }
  1499. // 重置目录打开状态
  1500. window.segmentFolderOpened = false;
  1501. window.modelOrSceneFolderOpened = false;
  1502. if(form.services.length == 0){
  1503. ElMessage.error('请选择服务内容')
  1504. return
  1505. }
  1506. // 必填验证
  1507. if (form.services.includes('is_upper_footer') && !( selectedModels.value && selectedModels.value.male?.id && selectedModels.value.female?.id)) {
  1508. openModelDialog();
  1509. setTimeout(()=>{
  1510. ElMessage.error('请选择模特')
  1511. },200)
  1512. return
  1513. }
  1514. if (form.services.includes('is_product_scene') && !scenePrompt.value) {
  1515. openScenePromptDialog();
  1516. setTimeout(()=>{
  1517. ElMessage.error('请设置场景提示词')
  1518. },200)
  1519. return
  1520. }
  1521. if(form.services.includes('is_detail') || form.services.includes('is_upper_footer')){
  1522. if ( form.dataType == '1' && !form.excel_path) {
  1523. ElMessage.error('请上传商品基础资料')
  1524. return
  1525. }
  1526. }
  1527. // 埋点:开始生成详情页
  1528. clickLog({
  1529. describe: {
  1530. action: '点击开始生成详情页',
  1531. services: form.services,
  1532. dataType: form.dataType,
  1533. template_name: form.selectTemplate?.template_name,
  1534. goods_count: goods_art_nos.value.length,
  1535. goods_art_nos: goods_art_nos.value
  1536. }
  1537. }, route);
  1538. // 先进行检测
  1539. let checkResult;
  1540. try {
  1541. requesting.value = true
  1542. // ElMessage.info('正在检测参数,请稍候...');
  1543. checkResult = await checkParams();
  1544. // ElMessage.success('检测通过,开始生成...');
  1545. } catch (error) {
  1546. ElMessage.error(error.message || '检测失败,请检查参数');
  1547. requesting.value = false
  1548. return;
  1549. }
  1550. const useConfigInfoStore = configInfo();
  1551. console.log(useConfigInfoStore.appConfig);
  1552. const tokenInfoStore = tokenInfo();
  1553. const token = tokenInfoStore.getToken; // 使用 getToken() 获取 token
  1554. let temp_list = []
  1555. templates.value.map(item => {
  1556. temp_list.push({
  1557. template_id: item.template_id,
  1558. template_local_classes: item.template_local_classes,
  1559. })
  1560. })
  1561. // 根据选择的服务内容设置参数
  1562. const isDetail = form.services.includes('is_detail') ? 1 : 0
  1563. const isProductScene = form.services.includes('is_product_scene') ? 1 : 0
  1564. const isUpperFooter = form.services.includes('is_upper_footer') ? 1 : 0
  1565. const params = {
  1566. goods_art_no: JSON.parse(JSON.stringify(goods_art_nos.value)),
  1567. logo_path: form.logo_path || '',
  1568. temp_name: form.selectTemplate?.template_id || '',
  1569. excel_path: form.dataType == '1' ? form.excel_path : '',
  1570. template_image_order: form.selectTemplate?.template_image_order,
  1571. temp_list,
  1572. token,
  1573. uuid: uuidStore.getUuid || '',
  1574. // 新增服务参数 - 合并国内和国外平台
  1575. online_stores: [...(domesticPlatforms.value || []), ...(foreignPlatforms.value || [])],
  1576. is_detail: isDetail,
  1577. is_product_scene: isProductScene,
  1578. is_upper_footer: isUpperFooter,
  1579. upper_footer_params: selectedModels.value ? {
  1580. man_id: selectedModels.value.male?.id || "",
  1581. women_id: selectedModels.value.female?.id || ""
  1582. } : {},
  1583. product_scene_prompt: scenePrompt.value || '',
  1584. is_check: 0 // 正式生成
  1585. }
  1586. console.log(params)
  1587. // 开启进度弹窗
  1588. requesting.value = true
  1589. partErrList.value = []
  1590. message.value = '正在为您处理,请稍后'
  1591. progress.value = 0
  1592. // 清空之前的进度消息
  1593. progressMessages.value = []
  1594. showMessageHistory.value = true
  1595. // 启用新的进度条并初始化步骤
  1596. useNewProgress.value = true
  1597. // 清空之前的进度步骤
  1598. progressSteps.value = []
  1599. // 从检测结果中获取步骤信息
  1600. const backendSteps = checkResult?.data?.progress || []
  1601. initProgressSteps(backendSteps)
  1602. openLoadingDialog(goods_art_nos.value.length * 10)
  1603. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  1604. clientStore.ipc.send(icpList.generate.generatePhotoDetail, params);
  1605. /*
  1606. * detail_result_progress
  1607. *
  1608. * */
  1609. // 监听进度消息
  1610. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  1611. clientStore.ipc.on(icpList.socket.message + '_detail_progress', (event, data) => {
  1612. console.log('_detail_progress',data);
  1613. handleProgressMessage(data)
  1614. });
  1615. // 监听抠图进度消息
  1616. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  1617. clientStore.ipc.on(icpList.socket.message + '_segment_progress', (event, data) => {
  1618. console.log('_segment_progress',data);
  1619. handleSegmentProgressMessage(data)
  1620. });
  1621. // 监听上脚图进度消息
  1622. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  1623. clientStore.ipc.on(icpList.socket.message + '_upper_footer_progress', (event, data) => {
  1624. console.log('_upper_footer_progress',data);
  1625. handleUpperFooterProgressMessage(data)
  1626. });
  1627. // 监听场景图进度消息
  1628. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  1629. clientStore.ipc.on(icpList.socket.message + '_scene_progress', (event, data) => {
  1630. console.log('_scene_progress',data);
  1631. handleSceneProgressMessage(data)
  1632. });
  1633. // 监听商品上传进度消息
  1634. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  1635. clientStore.ipc.on(icpList.socket.message + '_upload_goods_progress', (event, data) => {
  1636. console.log('_upload_goods_progress',data);
  1637. handleUploadGoodsProgressMessage(data)
  1638. });
  1639. clientStore.ipc.on(icpList.socket.message + '_detail_result_progress', (event, result) => {
  1640. if(result.code !== 0 ){
  1641. if(result.msg){
  1642. handleFail(result.msg)
  1643. message.value = 'result.msg'
  1644. }
  1645. progress.value = 0
  1646. loadingDialogVisible.value = false
  1647. requesting.value = false
  1648. return;
  1649. }
  1650. console.log('result', result)
  1651. requesting.value = true
  1652. setTimeout(() => {
  1653. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_result_progress');
  1654. clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  1655. clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  1656. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upper_footer_progress');
  1657. clientStore.ipc.removeAllListeners(icpList.socket.message + '_scene_progress');
  1658. clientStore.ipc.removeAllListeners(icpList.socket.message + '_upload_goods_progress');
  1659. }, 100)
  1660. clearInterval(INTERVAL.value)
  1661. if (result.code === 0) {
  1662. const { output_folder, list } = result.data
  1663. const allSuccess = list.every(item => item.success);
  1664. const allFailure = list.every(item => !item.success);
  1665. if (allSuccess) {
  1666. console.log("全部成功")
  1667. handleSuccess(output_folder, '全部生成成功')
  1668. } else if (allFailure) {
  1669. console.log("全部失败");
  1670. handleFailure(list)
  1671. } else {
  1672. console.log("部分成功,部分失败");
  1673. handlePartSuccess(output_folder, list)
  1674. }
  1675. } else {
  1676. console.log('code全部生成失败')
  1677. handleFail(result.msg)
  1678. }
  1679. //生成失败 (接口请求失败)
  1680. function handleFail(errorMsg: string) {
  1681. // loadingDialogVisible.value = false
  1682. // disabledButton.value = false
  1683. if (errorMsg) {
  1684. ElMessage.error(errorMsg)
  1685. }
  1686. requesting.value = false // 重置请求状态,允许再次生成
  1687. // 处理完成后停止监听进度消息
  1688. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_detail_progress');
  1689. // clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
  1690. }
  1691. // 全部生成成功
  1692. function handleSuccess(href, loadingMsg) {
  1693. // 埋点:生成完成
  1694. setLogInfo(route, { action: '生成完成', output_folder: href, message: loadingMsg });
  1695. completeDirectory.value = href
  1696. progress.value = 100
  1697. disabledButton.value = false
  1698. message.value = loadingMsg
  1699. requesting.value = false // 重置请求状态,允许再次生成
  1700. // handleComplete()
  1701. }
  1702. // 部分成功
  1703. function handlePartSuccess(output_folder: string, partSuccessList) {
  1704. let errorList = []
  1705. partSuccessList.map(item => {
  1706. if (!item.success) {
  1707. errorList.push(item)
  1708. }
  1709. })
  1710. partErrList.value = errorList
  1711. handleSuccess(output_folder, '部分货号生成失败')
  1712. }
  1713. // 全部生成失败
  1714. function handleFailure(partSuccessList) {
  1715. // 埋点:生成失败(携带货号)
  1716. const failedGoods = (partSuccessList || []).map(item => item.goods_art_no).filter(Boolean)
  1717. setLogInfo(route, { action: '生成失败', error_count: partSuccessList.length, goods_art_nos: goods_art_nos.value, failed_goods_art_nos: failedGoods });
  1718. let errorList = []
  1719. partSuccessList.map(item => {
  1720. if (!item.success) {
  1721. errorList.push(item)
  1722. }
  1723. })
  1724. partErrList.value = errorList
  1725. completeDirectory.value = ''
  1726. progress.value = 100
  1727. disabledButton.value = true
  1728. message.value = '全部货号生成失败'
  1729. requesting.value = false // 重置请求状态,允许再次生成
  1730. }
  1731. requesting.value = false
  1732. });
  1733. }
  1734. const openLoadingDialog = (timer: number) => {
  1735. loadingDialogVisible.value = true
  1736. disabledButton.value = true
  1737. // 根据传入的秒数计算每次增加的进度值
  1738. const step = 100 / timer
  1739. INTERVAL.value = setInterval(() => {
  1740. if (progress.value < 50) {
  1741. progress.value = Math.min(progress.value + step, 100)
  1742. } else if (progress.value < 70) {
  1743. progress.value = Math.min(progress.value + step / 2, 100)
  1744. } if (progress.value < 85) {
  1745. progress.value = Math.min(progress.value + step / 5, 100)
  1746. } else if (progress.value < 90) {
  1747. progress.value = Math.min(progress.value + step / 10, 100)
  1748. } else if (progress.value < 95) {
  1749. progress.value = Math.min(progress.value + step / 50, 100)// 新增中间阶段
  1750. } else {
  1751. progress.value = Math.min(progress.value + step / 100, 100)
  1752. }
  1753. }, 1000)
  1754. }
  1755. //logo
  1756. const logoList = ref([])
  1757. const logoLoadError = ref(false)
  1758. const logoPreviewVisible = ref(false)
  1759. const logoPreviewUrl = ref('')
  1760. // 打开LOGO上传
  1761. const handleLogoSelected = (path?: string) => {
  1762. if (!path) return
  1763. form.logo_path = path
  1764. logoLoadError.value = false
  1765. saveLogoToCache(form.logo_path)
  1766. }
  1767. const openLogoUpload = () => {
  1768. clientStore.ipc.removeAllListeners(icpList.utils.openImage);
  1769. clientStore.ipc.send(icpList.utils.openImage);
  1770. clientStore.ipc.on(icpList.utils.openImage, async (event, result) => {
  1771. if (result && result.filePath) {
  1772. handleLogoSelected(result.filePath)
  1773. }
  1774. clientStore.ipc.removeAllListeners(icpList.utils.openImage);
  1775. })
  1776. }
  1777. // 预览LOGO
  1778. const previewLogo = () => {
  1779. if (form.logo_path) {
  1780. logoPreviewUrl.value = 'file:///' + form.logo_path
  1781. logoPreviewVisible.value = true
  1782. }
  1783. }
  1784. // 删除LOGO
  1785. const removeLogo = () => {
  1786. if (form.logo_path) {
  1787. saveLogoToCache('')
  1788. form.logo_path = ''
  1789. /* const currentLogoPath = form.logo_path
  1790. clientStore.ipc.send(icpList.generate.deleteLogo, {
  1791. path: currentLogoPath
  1792. });
  1793. clientStore.ipc.on(icpList.generate.deleteLogo, async (event, result) => {
  1794. console.log('deleteLogo', result);
  1795. form.logo_path = ''
  1796. saveLogoToCache('')
  1797. logoLoadError.value = false
  1798. // 从列表中移除
  1799. const index = logoList.value.indexOf(currentLogoPath)
  1800. if (index > -1) {
  1801. logoList.value.splice(index, 1)
  1802. }
  1803. clientStore.ipc.removeAllListeners(icpList.generate.deleteLogo);
  1804. })*/
  1805. }
  1806. }
  1807. const handleLogoLoadError = () => {
  1808. if (!form.logo_path) return
  1809. if (!logoLoadError.value) {
  1810. logoLoadError.value = true
  1811. form.logo_path = ''
  1812. saveLogoToCache('')
  1813. ElMessage.warning('LOGO加载出错或文件已被删除,请重新上传')
  1814. }
  1815. }
  1816. const getLogolist = async () => {
  1817. clientStore.ipc.send(icpList.generate.getLogoList);
  1818. clientStore.ipc.on(icpList.generate.getLogoList, async (event, result) => {
  1819. // 保持数组格式,兼容老的格式
  1820. logoList.value = result.data || []
  1821. console.log('getLogoList', result.data)
  1822. // 只使用第一个LOGO(如果存在且当前没有选择)
  1823. if(logoList.value.length && !form.logo_path){
  1824. form.logo_path = logoList.value[0]
  1825. logoLoadError.value = false
  1826. // 保存默认LOGO到缓存
  1827. saveLogoToCache(form.logo_path)
  1828. }
  1829. clientStore.ipc.removeAllListeners(icpList.generate.getLogoList);
  1830. })
  1831. }
  1832. function selectExcel() {
  1833. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1834. clientStore.ipc.send(icpList.utils.openFile, {
  1835. filters: [
  1836. { name: '支持xls,xlsx', extensions: ['xlsx', 'xls'] }
  1837. ],
  1838. title: "选择基础文件资料"
  1839. });
  1840. clientStore.ipc.on(icpList.utils.openFile, async (event, result) => {
  1841. form.excel_path = result
  1842. clientStore.ipc.removeAllListeners(icpList.utils.openFile);
  1843. })
  1844. }
  1845. const Router = useRouter()
  1846. //打开主图详情
  1847. function openPhotographySeniorDetail() {
  1848. const { href } = Router.resolve({
  1849. name: 'PhotographySeniorDetail'
  1850. })
  1851. clientStore.ipc.removeAllListeners(icpList.utils.openMain);
  1852. let params = {
  1853. title: '详情高级配置',
  1854. width: 1000,
  1855. height: 630,
  1856. frame: true,
  1857. id: "PhotographySeniorDetail",
  1858. url: getRouterUrl(href)
  1859. }
  1860. clientStore.ipc.send(icpList.utils.openMain, params);
  1861. }
  1862. // 处理打开目录事件
  1863. const handleOpenFolder = (event) => {
  1864. const { folder } = event.detail;
  1865. if (folder) {
  1866. openOutputDir(folder);
  1867. }
  1868. }
  1869. const handleComplete = () => {
  1870. // loadingDialogVisible.value = false
  1871. // 这里可以添加打开目录的逻辑
  1872. if(!completeDirectory.value){
  1873. openOutputDir()
  1874. return
  1875. }
  1876. clientStore.ipc.removeAllListeners(icpList.utils.shellFun);
  1877. let params = {
  1878. action: 'openPath',
  1879. params: completeDirectory.value?.replace(/\//g, '\\')
  1880. }
  1881. clientStore.ipc.send(icpList.utils.shellFun, params);
  1882. }
  1883. const selectFolder = () => {
  1884. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1885. clientStore.ipc.send(icpList.utils.openDirectory);
  1886. clientStore.ipc.on(icpList.utils.openDirectory, async (event, result) => {
  1887. folderPath.value = result
  1888. clientStore.ipc.removeAllListeners(icpList.utils.openDirectory);
  1889. })
  1890. }
  1891. </script>
  1892. <style lang="scss" scoped>
  1893. // 服务标签页样式
  1894. .detail-page {
  1895. height: calc(100vh - 50px);
  1896. }
  1897. .service-tabs {
  1898. display: flex;
  1899. gap: 10px;
  1900. padding: 20px;
  1901. .service-tab {
  1902. display: flex;
  1903. flex: 1;
  1904. align-items: center;
  1905. justify-content: center;
  1906. gap: 10px;
  1907. padding: 10px 20px;
  1908. border: 1px solid #e8e8e8;
  1909. border-radius: 8px;
  1910. cursor: pointer;
  1911. transition: all 0.3s;
  1912. position: relative;
  1913. background: #fff;
  1914. height: 140px;
  1915. .tab-checkbox {
  1916. margin-right: 0;
  1917. position: absolute;
  1918. left: 10px;
  1919. top:10px;
  1920. ::v-deep {
  1921. .is-checked .el-checkbox__inner {
  1922. background: #2957FF;
  1923. border-color: #2957FF;
  1924. }
  1925. .el-checkbox__inner {
  1926. border-radius: 18px;
  1927. transform: scale(1.2);
  1928. }
  1929. }
  1930. }
  1931. .tab-img {
  1932. width: 48px;
  1933. height: 48px;
  1934. background: #EFF6FF;
  1935. border-radius: 10px;
  1936. margin: 0 auto 5px;
  1937. }
  1938. .tab-icon {
  1939. width: 24px;
  1940. height: 24px;
  1941. }
  1942. .tab-name {
  1943. font-size: 14px;
  1944. color: #333;
  1945. font-weight: 500;
  1946. }
  1947. &.external-tool {
  1948. cursor: pointer;
  1949. opacity: 1;
  1950. background: #fff;
  1951. }
  1952. .tab-edit-btn {
  1953. position: absolute;
  1954. right: 10px;
  1955. top:10px;
  1956. width: 24px;
  1957. height: 24px;
  1958. display: flex;
  1959. align-items: center;
  1960. justify-content: center;
  1961. background: rgba(41, 87, 255, 0.1);
  1962. border-radius: 4px;
  1963. opacity: 0;
  1964. transition: opacity 0.3s;
  1965. cursor: pointer;
  1966. .el-icon {
  1967. color: #2957FF;
  1968. font-size: 16px;
  1969. }
  1970. }
  1971. &:hover {
  1972. border-color: #2957FF;
  1973. .tab-edit-btn {
  1974. opacity: 1;
  1975. }
  1976. }
  1977. &.active {
  1978. border-color: #2957FF;
  1979. border-bottom: 4px solid #2957FF;
  1980. .tab-img {
  1981. background: #2957FF;
  1982. }
  1983. }
  1984. &.disabled {
  1985. opacity: 0.8;
  1986. cursor: not-allowed;
  1987. background: #f5f5f5;
  1988. }
  1989. }
  1990. }
  1991. .detail-container {
  1992. background: #F5F6F7;
  1993. padding: 0 20px 20px 20px; // 底部留出空间给固定按钮
  1994. .detail-content {
  1995. max-width: 100%;
  1996. }
  1997. width: 100%;
  1998. min-width: 600px;
  1999. overflow: hidden;
  2000. }
  2001. .service-section {
  2002. margin-bottom: 20px;
  2003. .service-cards {
  2004. display: flex;
  2005. gap: 60px;
  2006. margin-top: 16px;
  2007. }
  2008. .service-card {
  2009. width: 240px;
  2010. height: 140px;
  2011. border-radius: 8px;
  2012. background: #fff;
  2013. border: 1px solid #e0e0e0;
  2014. display: flex;
  2015. align-items: flex-start;
  2016. padding: 12px;
  2017. cursor: pointer;
  2018. transition: all 0.3s ease;
  2019. position: relative;
  2020. &:hover {
  2021. border-color: #2957FF;
  2022. box-shadow: 0 2px 8px rgba(41, 87, 255, 0.1);
  2023. }
  2024. &.active {
  2025. border: 3px solid #2957FF;
  2026. background: #f8f9ff;
  2027. box-shadow: 0 4px 12px rgba(41, 87, 255, 0.25);
  2028. }
  2029. .service-checkbox {
  2030. position: absolute;
  2031. left: -40px;
  2032. top: 10px;
  2033. width: 30px;
  2034. transform: scale(1.5);
  2035. z-index: 10;
  2036. ::v-deep{
  2037. .el-checkbox {
  2038. display: block;
  2039. margin-right: 0;
  2040. }
  2041. .el-checkbox__input {
  2042. cursor: pointer;
  2043. }
  2044. }
  2045. }
  2046. .service-content {
  2047. flex: 1;
  2048. display: flex;
  2049. flex-direction: column;
  2050. align-items: center;
  2051. position: absolute;
  2052. left: 0;
  2053. top: 0;
  2054. right: 0;
  2055. bottom: 0;;
  2056. }
  2057. .service-image {
  2058. position: absolute;
  2059. width: 100%;
  2060. height: 100%;
  2061. img {
  2062. width: 100%;
  2063. height: 100%;
  2064. object-fit: cover;
  2065. border-radius: 4px;
  2066. }
  2067. .service-icon {
  2068. position: absolute;
  2069. top: 10px;
  2070. right: 10px;
  2071. width: 30px;
  2072. height: 30px;
  2073. background: #2957FF;
  2074. border-radius: 50%;
  2075. display: flex;
  2076. align-items: center;
  2077. justify-content: center;
  2078. color: white;
  2079. font-size: 18px;
  2080. }
  2081. }
  2082. .service-name {
  2083. font-size: 14px;
  2084. font-weight: 500;
  2085. text-align: center;
  2086. position: absolute;
  2087. background: rgba(0,0,0,.5);
  2088. height: 30px;
  2089. line-height: 30px;
  2090. color: #fff;
  2091. left: 0;
  2092. right: 0;
  2093. bottom:0px
  2094. }
  2095. }
  2096. }
  2097. .logo-section,
  2098. .template-section,
  2099. .data-prep-section {
  2100. }
  2101. .template-section {
  2102. background: #fff;
  2103. padding: 10px 20px 20px;
  2104. border-radius: 8px;
  2105. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  2106. .section-header {
  2107. display: flex;
  2108. justify-content: space-between;
  2109. align-items: center;
  2110. }
  2111. .template-tips {
  2112. height: 40px;
  2113. line-height: 40px;
  2114. padding: 0 10px;
  2115. background: #FFFBEA;
  2116. border-radius: 10px;
  2117. border: 1px solid #FEEEB0;
  2118. color: #9B4D26;
  2119. }
  2120. }
  2121. .template-section--disabled {
  2122. opacity: 0.8;
  2123. .template-list,
  2124. .template-pagination {
  2125. pointer-events: none;
  2126. }
  2127. }
  2128. .publish-section--disabled {
  2129. opacity: 0.6;
  2130. }
  2131. // 主布局:左右分栏
  2132. .main-layout {
  2133. display: flex;
  2134. gap: 20px;
  2135. align-items: flex-start;
  2136. .left-panel {
  2137. flex: 1;
  2138. min-width: 0;
  2139. }
  2140. .right-panel {
  2141. width: 400px;
  2142. flex-shrink: 0;
  2143. display: flex;
  2144. flex-direction: column;
  2145. gap: 20px;
  2146. }
  2147. }
  2148. .right-section {
  2149. background: #fff;
  2150. padding: 20px;
  2151. border-radius: 8px;
  2152. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  2153. &.data-prep-section {
  2154. height: 225px;
  2155. display: flex;
  2156. flex-direction: column;
  2157. box-sizing: border-box;
  2158. }
  2159. .section-title {
  2160. display: flex;
  2161. align-items: center;
  2162. gap: 10px;
  2163. font-weight: 600;
  2164. font-size: 16px;
  2165. color: #333333;
  2166. margin-bottom: 16px;
  2167. .section-title-line {
  2168. width: 3px;
  2169. height: 16px;
  2170. background: linear-gradient(135deg, #7C3AED 0%, #2957FF 100%);
  2171. border-radius: 2px;
  2172. }
  2173. .section-title-hint {
  2174. font-weight: normal;
  2175. font-size: 14px;
  2176. color: #999;
  2177. }
  2178. }
  2179. .data-prep-content {
  2180. display: flex;
  2181. flex-direction: column;
  2182. gap: 12px;
  2183. flex: 1;
  2184. .data-type-radio {
  2185. padding:5px;
  2186. background:#F3F5F6;
  2187. border-radius:10px;
  2188. ::v-deep {
  2189. .el-radio {
  2190. margin-right: 20px;
  2191. }
  2192. .el-radio-button {
  2193. flex:1;
  2194. box-shadow:none !important;
  2195. .el-radio-button__inner {
  2196. width: 100%;
  2197. background: none !important;
  2198. border: none !important;
  2199. display: flex;
  2200. align-items: center;
  2201. border-radius:10px !important;
  2202. justify-content: center;
  2203. img {
  2204. height: 14px;
  2205. margin: 0 5px;
  2206. position: relative;
  2207. top:-1px;
  2208. }
  2209. }
  2210. &.is-active {
  2211. background: #F8F9FF;
  2212. .el-radio-button__inner {
  2213. background: #fff !important;
  2214. color: #2957FF !important;
  2215. border-radius: 10px !important;
  2216. box-shadow: none !important;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. }
  2222. .excel-upload-section {
  2223. display: flex;
  2224. flex-direction: column;
  2225. gap: 8px;
  2226. flex: 1;
  2227. .excel-upload-area {
  2228. width: 100%;
  2229. height: 64px;
  2230. border: 1px dashed #D9D9D9;
  2231. border-radius: 8px;
  2232. display: flex;
  2233. align-items: center;
  2234. padding: 0 16px;
  2235. cursor: pointer;
  2236. transition: all 0.3s;
  2237. background: #fff;
  2238. &:hover {
  2239. border-color: #2957FF;
  2240. background: #F8F9FF;
  2241. }
  2242. .excel-icon {
  2243. width: 32px;
  2244. height:32px;
  2245. margin-right: 10px;
  2246. img {
  2247. width: 32px;
  2248. height:32px;
  2249. display: block;
  2250. }
  2251. }
  2252. .excel-upload-text {
  2253. font-size: 14px;
  2254. color: #333;
  2255. font-weight: 500;
  2256. }
  2257. }
  2258. .excel-selected-info {
  2259. width: 100%;
  2260. height: 64px;
  2261. border: 1px solid #E5E6EB;
  2262. border-radius: 8px;
  2263. padding: 12px 16px;
  2264. background: #fff;
  2265. display: flex;
  2266. align-items: center;
  2267. justify-content: space-between;
  2268. gap: 16px;
  2269. box-sizing: border-box;
  2270. .excel-file-info {
  2271. display: flex;
  2272. align-items: center;
  2273. flex: 1;
  2274. min-width: 0;
  2275. .excel-icon {
  2276. width: 32px;
  2277. height: 32px;
  2278. margin-right: 10px;
  2279. img {
  2280. width: 32px;
  2281. height: 32px;
  2282. display: block;
  2283. }
  2284. }
  2285. .excel-file-text {
  2286. display: flex;
  2287. flex-direction: column;
  2288. min-width: 0;
  2289. max-width: 100%;
  2290. .excel-file-label {
  2291. font-size: 12px;
  2292. text-align: left;
  2293. color: #888;
  2294. margin-bottom: 4px;
  2295. }
  2296. .excel-file-name {
  2297. font-size: 14px;
  2298. color: #1D2129;
  2299. font-weight: 500;
  2300. white-space: nowrap;
  2301. overflow: hidden;
  2302. text-overflow: ellipsis;
  2303. max-width: 100%;
  2304. }
  2305. }
  2306. }
  2307. .reupload-btn {
  2308. flex-shrink: 0;
  2309. }
  2310. }
  2311. .download-link {
  2312. color: #2957FF;
  2313. text-decoration: underline;
  2314. padding: 0;
  2315. font-size: 14px;
  2316. margin-top: 0;
  2317. justify-content: flex-start;
  2318. }
  2319. }
  2320. }
  2321. .publish-content {
  2322. display: flex;
  2323. flex-direction: column;
  2324. gap: 15px;
  2325. .publish-form-item {
  2326. display: flex;
  2327. flex-direction: column;
  2328. gap: 8px;
  2329. .publish-label {
  2330. font-size: 14px;
  2331. color: #333;
  2332. margin-bottom: 4px;
  2333. text-align: left;
  2334. }
  2335. .publish-select {
  2336. width: 100%;
  2337. ::v-deep {
  2338. .el-input.is-disabled .el-input__inner {
  2339. background-color: #F5F6F7;
  2340. border-color: #E8E8E8;
  2341. color: #999;
  2342. }
  2343. }
  2344. }
  2345. }
  2346. }
  2347. }
  2348. .logo-template-row {
  2349. display: flex;
  2350. gap: 24px;
  2351. align-items: flex-start;
  2352. .logo-col { flex: 2; min-width: 300px; }
  2353. .template-col { flex: 3; }
  2354. }
  2355. .logo-section {
  2356. .upload-item {
  2357. border: 2px solid rgba(0,0,0,0);
  2358. }
  2359. .active {
  2360. border: 2px solid #2957FF;
  2361. border-radius: 6px;
  2362. overflow: hidden;;
  2363. }
  2364. &.multi-line {
  2365. flex-direction: row; // 默认横向排列
  2366. flex-wrap: wrap; // 允许换行
  2367. align-items: flex-start; // 对齐方式调整为顶部对齐
  2368. .upload-item {
  2369. margin-bottom: 10px; // 每行之间增加间距
  2370. width: 90px; // 每行显示 4 个元素,减去外边距
  2371. box-sizing: border-box; // 确保宽度计算包含 padding 和 border
  2372. }
  2373. }
  2374. }
  2375. // LOGO上传区域样式
  2376. .logo-upload-area {
  2377. width: 100%;
  2378. }
  2379. .logo-upload-placeholder {
  2380. width: 100%;
  2381. height: 160px;
  2382. border: 1px dashed #D9D9D9;
  2383. border-radius: 10px;
  2384. display: flex;
  2385. flex-direction: column;
  2386. align-items: center;
  2387. justify-content: center;
  2388. cursor: pointer;
  2389. transition: all 0.3s;
  2390. background: #fff;
  2391. &:hover {
  2392. border-color: #2957FF;
  2393. background: #F8F9FF;
  2394. }
  2395. .logo-upload-icon {
  2396. width: 42px;
  2397. height: 42px;
  2398. margin-bottom: 12px;
  2399. display: flex;
  2400. align-items: center;
  2401. justify-content: center;
  2402. background: linear-gradient(135deg, #EFF6FF 0%, #F3E8FF 100%);
  2403. border-radius: 8px;
  2404. color: #2957FF;
  2405. img {
  2406. width: 42px;
  2407. height: 42px;
  2408. }
  2409. }
  2410. .logo-upload-text {
  2411. font-size: 14px;
  2412. color: #333;
  2413. margin-bottom: 8px;
  2414. font-weight: 500;
  2415. }
  2416. .logo-upload-hint {
  2417. font-size: 12px;
  2418. color: #999;
  2419. }
  2420. &.is-error {
  2421. border-color: #FF4D4F;
  2422. background: #FFF2F0;
  2423. .logo-upload-text,
  2424. .logo-upload-hint {
  2425. color: #FF4D4F;
  2426. }
  2427. }
  2428. }
  2429. .logo-upload-preview {
  2430. width: 100%;
  2431. height: 160px;
  2432. border: 1px solid #E8E8E8;
  2433. border-radius: 8px;
  2434. position: relative;
  2435. overflow: hidden;
  2436. background: #F5F5F5;
  2437. cursor: pointer;
  2438. .logo-preview-image {
  2439. width: 100%;
  2440. height: 100%;
  2441. object-fit: contain;
  2442. }
  2443. .logo-upload-actions {
  2444. position: absolute;
  2445. bottom: 0;
  2446. left: 0;
  2447. right: 0;
  2448. height: 40px;
  2449. background: rgba(0, 0, 0, 0.5);
  2450. display: flex;
  2451. align-items: center;
  2452. justify-content: center;
  2453. gap: 20px;
  2454. opacity: 0;
  2455. transition: opacity 0.3s;
  2456. .logo-action-btn {
  2457. width: 32px;
  2458. height: 32px;
  2459. display: flex;
  2460. align-items: center;
  2461. justify-content: center;
  2462. background: rgba(255, 255, 255, 0.2);
  2463. border-radius: 4px;
  2464. cursor: pointer;
  2465. color: #fff;
  2466. transition: background 0.3s;
  2467. &:hover {
  2468. background: rgba(255, 255, 255, 0.3);
  2469. }
  2470. .el-icon {
  2471. font-size: 18px;
  2472. }
  2473. }
  2474. }
  2475. &:hover .logo-upload-actions {
  2476. opacity: 1;
  2477. }
  2478. .logo-upload-footer {
  2479. display: flex;
  2480. justify-content: flex-end;
  2481. gap: 12px;
  2482. padding: 8px 4px 0;
  2483. }
  2484. }
  2485. .logo-upload {
  2486. border: 1px dashed #ccc;
  2487. border-radius: 5px;
  2488. padding: 50px 0;
  2489. text-align: center;
  2490. cursor: pointer;
  2491. }
  2492. .template-pagination {
  2493. background: #EFF3F6;
  2494. padding:2px 0;
  2495. border-radius:5px;
  2496. ::v-deep {
  2497. .is-active {
  2498. background: #fff !important;
  2499. color: #2957FF !important;
  2500. font-size: 14px !important;
  2501. font-weight: normal !important;
  2502. border-radius: 2px !important;
  2503. }
  2504. .number {
  2505. margin: 0px !important;
  2506. }
  2507. .btn-prev {
  2508. display: none;
  2509. }
  2510. .btn-next {
  2511. display: none;
  2512. }
  2513. }
  2514. }
  2515. .template-pagination button {
  2516. margin-right: 5px;
  2517. }
  2518. .template-pagination span {
  2519. display: inline-block;
  2520. width: 20px;
  2521. height: 20px;
  2522. line-height: 20px;
  2523. text-align: center;
  2524. border: 1px solid #ccc;
  2525. border-radius: 5px;
  2526. margin-right: 5px;
  2527. cursor: pointer;
  2528. }
  2529. .template-list {
  2530. display: flex;
  2531. flex-wrap: wrap;
  2532. gap: 20px;
  2533. margin-top: 10px;
  2534. .template-item {
  2535. flex:1;
  2536. max-width: 33%;
  2537. border: 1px solid #ccc;
  2538. border-radius: 10px;
  2539. cursor: pointer;
  2540. background: #f0f0f0;
  2541. position: relative;
  2542. height: 660px;
  2543. overflow: hidden;
  2544. &.active {
  2545. border-color: #1677FF;
  2546. }
  2547. .template-info {
  2548. position: absolute;
  2549. bottom: 0;
  2550. left: 0;
  2551. background: #fff;
  2552. width: 100%;
  2553. height: 40px;
  2554. line-height: 40px;
  2555. color: #333;
  2556. display: flex;
  2557. align-items: center;
  2558. justify-content: space-between;
  2559. .template-view {
  2560. color: #3366FF;
  2561. height: 30px;
  2562. line-height: 30px;
  2563. padding: 0 10px;
  2564. border-radius: 4px;
  2565. margin-right: 10px;
  2566. font-size: 14px;
  2567. }
  2568. }
  2569. }
  2570. }
  2571. .publish-section {
  2572. .label {
  2573. min-width: 120px;
  2574. margin-right: 12px;
  2575. }
  2576. }
  2577. .excel-upload {
  2578. width: 100%;
  2579. background: #F7F7F7;
  2580. padding: 20px 0;
  2581. }
  2582. .generate-button {
  2583. padding: 10px 20px;
  2584. color: white;
  2585. border: none;
  2586. border-radius: 5px;
  2587. cursor: pointer;
  2588. }
  2589. .select-button {
  2590. background: #DFE2E3 !important;
  2591. color: #3366FF !important;
  2592. height: 30px;
  2593. line-height: 30px;
  2594. padding: 0 10px;
  2595. border-radius: 4px;
  2596. margin-right: 10px;
  2597. font-size: 14px;
  2598. font-weight: 550;
  2599. }
  2600. .select-warp {
  2601. width: 18px;
  2602. height: 18px;
  2603. border-radius: 18px;
  2604. background-color: #fff;
  2605. position: absolute;
  2606. font-size: 12px;
  2607. line-height: 18px;
  2608. display: flex;
  2609. justify-content: center;
  2610. align-items: center;
  2611. top: 10px;
  2612. left: 10px;
  2613. &.active {
  2614. background-color: #1677FF;
  2615. }
  2616. }
  2617. .section-title {
  2618. display: flex;
  2619. align-items: center;
  2620. gap: 8px;
  2621. font-weight: bold;
  2622. color: #474747;
  2623. }
  2624. .section {
  2625. margin-bottom: 24px;
  2626. .section-title {
  2627. display: flex;
  2628. align-items: center;
  2629. gap: 8px;
  2630. font-weight: bold;
  2631. margin-bottom: 16px;
  2632. color: #474747;
  2633. }
  2634. .section-content {
  2635. padding-left: 16px;
  2636. }
  2637. }
  2638. .instruction-out {
  2639. background: #EAF3FF;
  2640. border-radius: 4px;
  2641. border: 1px solid #CBE1FF;
  2642. padding: 10px 20px;
  2643. width: 80%;
  2644. position: relative;
  2645. .instruction-list {
  2646. margin: 0px 0 0 10px;
  2647. padding-left: 20px;
  2648. padding-right: 40px;
  2649. width: 100%;
  2650. li {
  2651. margin-bottom: 4px;
  2652. text-align: left;
  2653. font-size: 14px;
  2654. }
  2655. }
  2656. .close-icon {
  2657. position: absolute;
  2658. top: 12px;
  2659. right: 19px;
  2660. }
  2661. }
  2662. .form-item {
  2663. margin: 16px 0;
  2664. display: flex;
  2665. .label {
  2666. min-width: 120px;
  2667. margin-right: 12px;
  2668. }
  2669. .folder-warp {
  2670. width: 100%;
  2671. display: flex;
  2672. flex-direction: column;
  2673. .folder-input {
  2674. flex: 1;
  2675. display: flex;
  2676. align-items: center;
  2677. .check-button {
  2678. background: #DFE2E3;
  2679. border-radius: 6px;
  2680. padding: 6px 12px;
  2681. color: #2957FF;
  2682. margin-left: 20px;
  2683. }
  2684. }
  2685. }
  2686. .hint {
  2687. text-align: left;
  2688. color: #999;
  2689. margin-top: 6px;
  2690. font-size: 14px;
  2691. color: #FF4C00;
  2692. font-style: normal;
  2693. }
  2694. .specific-page-input {
  2695. flex: 1;
  2696. }
  2697. }
  2698. .image-order {
  2699. flex: 1;
  2700. display: flex;
  2701. justify-content: space-between;
  2702. align-items: center;
  2703. }
  2704. .footer {
  2705. display: flex;
  2706. z-index: 100;
  2707. .footer-button {
  2708. padding: 12px 40px;
  2709. font-size: 16px;
  2710. border-radius: 8px;
  2711. display: block;
  2712. width: 100%;
  2713. height: 50px;
  2714. img {
  2715. height: 16px;;
  2716. margin: 0 10px;
  2717. }
  2718. .go {
  2719. opacity: .5;
  2720. }
  2721. }
  2722. }
  2723. .explain-btn {
  2724. padding-left: 20px;
  2725. padding-right: 20px;
  2726. color: #2957FF !important;
  2727. }
  2728. .progress-messages {
  2729. margin-top: 20px;
  2730. border-top: 1px solid #e4e7ed;
  2731. padding-top: 20px;
  2732. width: 100%;
  2733. display: none;
  2734. .message-header {
  2735. display: flex;
  2736. justify-content: space-between;
  2737. align-items: center;
  2738. margin-bottom: 15px;
  2739. font-weight: 500;
  2740. color: #606266;
  2741. }
  2742. .message-list {
  2743. max-height: 200px;
  2744. overflow-y: auto;
  2745. border: 1px solid #e4e7ed;
  2746. border-radius: 4px;
  2747. padding: 10px;
  2748. background: #fafafa;
  2749. .message-item {
  2750. margin-bottom: 12px;
  2751. padding-bottom: 12px;
  2752. border-bottom: 1px solid #f0f0f0;
  2753. &:last-child {
  2754. margin-bottom: 0;
  2755. padding-bottom: 0;
  2756. border-bottom: none;
  2757. }
  2758. .message-time {
  2759. font-size: 12px;
  2760. color: #909399;
  2761. margin-bottom: 4px;
  2762. }
  2763. .message-content {
  2764. font-size: 14px;
  2765. line-height: 1.4;
  2766. .goods-no {
  2767. color: #2957FF;
  2768. font-weight: 500;
  2769. }
  2770. .message-text {
  2771. color: #606266;
  2772. }
  2773. }
  2774. }
  2775. }
  2776. }
  2777. </style>
  2778. <style lang="scss" scoped>
  2779. // 货号选择弹窗样式(非 scoped,因为弹窗挂载在 body 上)
  2780. .goods-select-dialog {
  2781. max-width: 60vw;
  2782. .el-dialog__body {
  2783. padding: 20px;
  2784. max-height: 70vh;
  2785. overflow-y: auto;
  2786. height: 60vh;
  2787. }
  2788. .goods-select-content {
  2789. .goods-radio-group {
  2790. width: 100%;
  2791. display: flex;
  2792. flex-direction: column;
  2793. gap: 20px;
  2794. }
  2795. .goods-item {
  2796. background: #FFFFFF;
  2797. box-shadow: 0px 2px 4px 0px rgba(23,33,71,0.1);
  2798. border-radius: 10px;
  2799. border: 1px solid #D9DEE6;
  2800. margin-bottom: 20px;
  2801. cursor: pointer;
  2802. transition: all 0.3s;
  2803. .goods-radio {
  2804. width: 100%;
  2805. margin: 0;
  2806. padding: 0;
  2807. position: relative;
  2808. .el-radio__input {
  2809. position: absolute;
  2810. top: 14px;
  2811. left: 18px;
  2812. z-index: 10;
  2813. transform: scale(1);
  2814. }
  2815. .el-radio__inner {
  2816. border-width: 2px;
  2817. }
  2818. &.is-checked {
  2819. .el-radio__inner {
  2820. background-color: #409eff;
  2821. border-color: #409eff;
  2822. }
  2823. }
  2824. .el-radio__label {
  2825. width: 100%;
  2826. padding-left: 40px;
  2827. display: none;
  2828. }
  2829. }
  2830. .goods-item-header {
  2831. display: flex;
  2832. justify-content: flex-start;
  2833. align-items: center;
  2834. height: 40px;
  2835. padding: 0 16px;
  2836. background: linear-gradient(90deg, #F4ECFF 0%, #DFEDFF 100%);
  2837. border-radius: 10px 10px 0px 0px;
  2838. .goods-item-left {
  2839. display: flex;
  2840. align-items: center;
  2841. gap: 16px;
  2842. .goods-art-no {
  2843. font-size: 16px;
  2844. font-weight: 500;
  2845. color: #333;
  2846. }
  2847. .goods-item-meta {
  2848. display: flex;
  2849. justify-content: space-between;
  2850. align-items: center;
  2851. font-size: 12px;
  2852. color: #666;
  2853. img {
  2854. height: 14px;
  2855. margin-right: 2px;
  2856. }
  2857. .action-time {
  2858. color: #666;
  2859. }
  2860. .image-count {
  2861. color: #666;
  2862. }
  2863. }
  2864. }
  2865. }
  2866. .goods-item-images {
  2867. display: grid;
  2868. grid-template-columns: repeat(5, 1fr);
  2869. gap: 10px;
  2870. padding: 15px;
  2871. border-top: 1px solid #f0f0f0;
  2872. overflow-x: auto;
  2873. @media (min-width: 1200px) {
  2874. grid-template-columns: repeat(5, 1fr);
  2875. }
  2876. @media (max-width: 768px) {
  2877. grid-template-columns: repeat(3, 1fr);
  2878. }
  2879. }
  2880. .goods-item_image {
  2881. position: relative;
  2882. width: 100%;
  2883. aspect-ratio: 1;
  2884. background: #F7F7F7;
  2885. border-radius: 10px;
  2886. overflow: hidden;
  2887. cursor: pointer;
  2888. border: 1px solid #D9DEE6;
  2889. transition: all 0.3s;
  2890. .tag {
  2891. color: #bbb;
  2892. position: absolute;
  2893. left: 0;
  2894. right: 0;
  2895. top: 50%;
  2896. margin-top: -10px;
  2897. line-height: 20px;
  2898. text-align: center;
  2899. font-size: 12px;
  2900. z-index: 1;
  2901. pointer-events: none;
  2902. }
  2903. .preview-image {
  2904. width: 100%;
  2905. height: 100%;
  2906. .el-image__inner {
  2907. width: 100%;
  2908. height: 100%;
  2909. object-fit: cover;
  2910. }
  2911. }
  2912. .image-placeholder {
  2913. width: 100%;
  2914. height: 100%;
  2915. display: flex;
  2916. align-items: center;
  2917. justify-content: center;
  2918. background: #F7F7F7;
  2919. }
  2920. .image-slot {
  2921. width: 100%;
  2922. height: 100%;
  2923. display: flex;
  2924. align-items: center;
  2925. justify-content: center;
  2926. background: #F7F7F7;
  2927. }
  2928. &:hover {
  2929. border-color: #409eff;
  2930. transform: scale(1.02);
  2931. box-shadow: 0 2px 8px rgba(64, 158, 255, 0.2);
  2932. }
  2933. }
  2934. }
  2935. }
  2936. .dialog-footer {
  2937. display: flex;
  2938. justify-content: flex-end;
  2939. gap: 10px;
  2940. }
  2941. }
  2942. </style>