index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. <template>
  2. <div class="booth-page">
  3. <div class="booth-container">
  4. <!-- 操作栏(独立卡片) -->
  5. <div class="action-card">
  6. <el-button type="primary" icon="View" @click="handleViewProducts">查看推荐商品</el-button>
  7. </div>
  8. <!-- 商品展示区域(独立卡片) -->
  9. <div class="content-card" @mouseenter="stopAutoPlay" @mouseleave="startAutoPlay">
  10. <div class="product-display-area">
  11. <div class="carousel-viewport">
  12. <transition name="slide-fade" mode="out-in">
  13. <div class="product-grid" :key="currentPage">
  14. <div
  15. v-for="product in displayProducts"
  16. :key="product.id"
  17. class="product-card"
  18. >
  19. <el-icon class="delete-icon" @click="handleRemoveProduct(product.id)">
  20. <Close />
  21. </el-icon>
  22. <div class="product-image">
  23. <el-image
  24. :src="product.imageUrl"
  25. fit="cover"
  26. lazy
  27. class="image"
  28. >
  29. <template #error>
  30. <div class="image-slot">
  31. <el-icon><Picture /></el-icon>
  32. </div>
  33. </template>
  34. </el-image>
  35. </div>
  36. <div class="product-info">
  37. <p class="product-name">{{ product.name }}</p>
  38. <p class="product-price">¥{{ product.price }}</p>
  39. </div>
  40. </div>
  41. </div>
  42. </transition>
  43. </div>
  44. <!-- 导航箭头 -->
  45. <el-icon
  46. v-if="hasPrev"
  47. class="nav-arrow nav-arrow-left"
  48. @click="handlePrev"
  49. >
  50. <ArrowLeft />
  51. </el-icon>
  52. <el-icon
  53. v-if="hasNext"
  54. class="nav-arrow nav-arrow-right"
  55. @click="handleNext"
  56. >
  57. <ArrowRight />
  58. </el-icon>
  59. </div>
  60. <!-- 空状态 -->
  61. <el-empty v-if="displayProducts.length === 0" description="暂无商品,请点击查看推荐商品添加" />
  62. </div>
  63. </div>
  64. <!-- 已选商品对话框 -->
  65. <el-dialog
  66. v-model="dialog.visible"
  67. title="已选商品"
  68. width="900px"
  69. append-to-body
  70. destroy-on-close
  71. @close="handleDialogClose"
  72. >
  73. <!-- 操作按钮 -->
  74. <div class="dialog-actions mb-[10px]">
  75. <el-button type="primary" plain icon="Plus" @click="handleAddProduct">新增商品</el-button>
  76. <el-button type="primary" plain icon="Upload" @click="handleImportProduct">导入商品</el-button>
  77. </div>
  78. <!-- 商品表格 -->
  79. <el-table :data="selectedProducts" border max-height="450" style="width: 100%">
  80. <el-table-column label="商品编号" align="center" prop="id" width="100" />
  81. <el-table-column label="商品图片" align="center" width="80">
  82. <template #default="scope">
  83. <el-image
  84. :src="scope.row.imageUrl"
  85. fit="cover"
  86. style="width: 50px; height: 50px; border-radius: 4px"
  87. lazy
  88. >
  89. <template #error>
  90. <div class="image-slot-small">
  91. <el-icon><Picture /></el-icon>
  92. </div>
  93. </template>
  94. </el-image>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="商品名称" align="center" prop="name" :show-overflow-tooltip="true" min-width="180" />
  98. <el-table-column label="价格" align="center" width="90">
  99. <template #default="scope">
  100. <span class="price-text">¥{{ scope.row.price }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column label="排序" align="center" width="100">
  104. <template #default="scope">
  105. <el-input-number
  106. v-model="scope.row.sort"
  107. :min="0"
  108. :max="999"
  109. controls-position="right"
  110. size="small"
  111. style="width: 80px"
  112. @change="handleSortChange(scope.row)"
  113. />
  114. </template>
  115. </el-table-column>
  116. <el-table-column label="操作" align="center" width="70">
  117. <template #default="scope">
  118. <span class="action-link danger" @click="handleDeleteProduct(scope.row.id)">删除</span>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <template #footer>
  123. <div class="dialog-footer">
  124. <el-button type="primary" @click="handleConfirm">确认</el-button>
  125. <el-button @click="handleDialogClose">取消</el-button>
  126. </div>
  127. </template>
  128. </el-dialog>
  129. <!-- 选择轮播商品对话框 -->
  130. <el-dialog
  131. v-model="selectDialog.visible"
  132. title="选择轮播商品"
  133. width="1200px"
  134. append-to-body
  135. @close="handleSelectDialogClose"
  136. >
  137. <!-- 搜索栏 -->
  138. <div class="search-bar mb-[10px]">
  139. <el-input
  140. v-model="searchKeyword"
  141. placeholder="请输入商品编号名称输入搜索"
  142. clearable
  143. style="width: 400px"
  144. @keyup.enter="handleSearchProducts"
  145. >
  146. <template #append>
  147. <el-button icon="Search" @click="handleSearchProducts">搜索</el-button>
  148. </template>
  149. </el-input>
  150. </div>
  151. <!-- 商品表格 -->
  152. <el-table
  153. ref="newProductTableRef"
  154. :data="filteredAvailableProducts"
  155. border
  156. max-height="500"
  157. @selection-change="handleSelectionChange"
  158. >
  159. <el-table-column type="selection" width="55" align="center" />
  160. <el-table-column label="轮播商品编号" align="center" prop="id" width="150" />
  161. <el-table-column label="轮播商品图片" align="center" width="120">
  162. <template #default="scope">
  163. <el-image
  164. :src="scope.row.imageUrl"
  165. fit="cover"
  166. style="width: 80px; height: 80px; border-radius: 4px"
  167. lazy
  168. >
  169. <template #error>
  170. <div class="image-slot-small">
  171. <el-icon><Picture /></el-icon>
  172. </div>
  173. </template>
  174. </el-image>
  175. </template>
  176. </el-table-column>
  177. <el-table-column label="轮播商品名称" align="center" prop="name" :show-overflow-tooltip="true" min-width="300" />
  178. <el-table-column label="价格" align="center" prop="price" width="120">
  179. <template #default="scope">
  180. <span class="price-text">¥{{ scope.row.price }}</span>
  181. </template>
  182. </el-table-column>
  183. </el-table>
  184. <!-- 分页 -->
  185. <pagination
  186. v-show="newProductPagination.total > 0"
  187. v-model:page="newProductPagination.pageNum"
  188. v-model:limit="newProductPagination.pageSize"
  189. :total="newProductPagination.total"
  190. @pagination="loadAvailableProducts"
  191. />
  192. <template #footer>
  193. <div class="dialog-footer">
  194. <el-button type="primary" @click="handleConfirmSelect">确认</el-button>
  195. <el-button @click="handleSelectDialogClose">取消</el-button>
  196. </div>
  197. </template>
  198. </el-dialog>
  199. <!-- 导入商品对话框 -->
  200. <el-dialog
  201. v-model="importDialog.visible"
  202. title="导入商品(商品编号逗号隔开)"
  203. width="600px"
  204. append-to-body
  205. destroy-on-close
  206. @close="handleImportDialogClose"
  207. >
  208. <el-form label-width="80px">
  209. <el-form-item label="商品编号:">
  210. <el-input
  211. v-model="importProductIds"
  212. type="textarea"
  213. :rows="6"
  214. placeholder="请输入内容"
  215. />
  216. </el-form-item>
  217. </el-form>
  218. <template #footer>
  219. <div class="dialog-footer">
  220. <el-button type="primary" @click="handleConfirmImport">确 认</el-button>
  221. <el-button @click="handleImportDialogClose">取 消</el-button>
  222. </div>
  223. </template>
  224. </el-dialog>
  225. </div>
  226. </template>
  227. <script setup name="IndustrialBooth" lang="ts">
  228. import { ref, reactive, computed, watch, nextTick, onMounted, onUnmounted } from 'vue';
  229. import { ElMessage, ElMessageBox } from 'element-plus';
  230. import { Close, Picture, ArrowLeft, ArrowRight } from '@element-plus/icons-vue';
  231. import { listProduct } from '@/api/product/base';
  232. import { listRecommend, listRecommendLink, addRecommendLink, delRecommendLink } from '@/api/product/recommend';
  233. // 推荐位编号(工业装修-轮播展位商品)
  234. const recommendNo = 'industrial_booth';
  235. const recommendId = ref<number | null>(null);
  236. const loading = ref(false);
  237. // 对话框
  238. const dialog = reactive({
  239. visible: false
  240. });
  241. // 选择商品对话框
  242. const selectDialog = reactive({
  243. visible: false
  244. });
  245. // 导入商品对话框
  246. const importDialog = reactive({
  247. visible: false
  248. });
  249. // 导入商品编号
  250. const importProductIds = ref('');
  251. // 搜索关键词
  252. const searchKeyword = ref('');
  253. // 可选商品列表(从接口获取)
  254. const availableProducts = ref<any[]>([]);
  255. // 选中的商品ID列表(用于新增商品标签页)
  256. const selectedProductIds = ref<string[]>([]);
  257. // 新增商品分页
  258. const newProductPagination = reactive({
  259. pageNum: 1,
  260. pageSize: 20,
  261. total: 0
  262. });
  263. // 当前页码(从0开始)
  264. const currentPage = ref(0);
  265. const pageSize = 5; // 每页显示5个商品
  266. // 自动轮播定时器
  267. let autoPlayTimer: ReturnType<typeof setInterval> | null = null;
  268. const autoPlayInterval = 3000; // 3秒切换一次
  269. // 已选商品列表(从接口获取)
  270. const selectedProducts = ref<any[]>([]);
  271. // 获取可选商品列表
  272. const loadAvailableProducts = async () => {
  273. try {
  274. const params: any = {
  275. pageNum: newProductPagination.pageNum,
  276. pageSize: newProductPagination.pageSize
  277. };
  278. if (searchKeyword.value) {
  279. params.itemName = searchKeyword.value;
  280. }
  281. const res: any = await listProduct(params);
  282. // 字段映射
  283. availableProducts.value = (res.rows || []).map((item: any) => ({
  284. id: item.id,
  285. productNo: item.productNo,
  286. name: item.itemName,
  287. imageUrl: item.productImageUrl || item.productImage,
  288. price: item.minSellingPrice || item.memberPrice || '0.00'
  289. }));
  290. newProductPagination.total = res.total || 0;
  291. } catch (error) {
  292. console.error('获取商品列表失败', error);
  293. availableProducts.value = [];
  294. }
  295. };
  296. // 获取推荐位ID
  297. const loadRecommendId = async () => {
  298. try {
  299. const res: any = await listRecommend({ recommendNo, pageSize: 1 });
  300. if (res.rows && res.rows.length > 0) {
  301. recommendId.value = res.rows[0].id;
  302. }
  303. } catch (error) {
  304. console.error('获取推荐位失败', error);
  305. }
  306. };
  307. // 获取已选商品列表(通过推荐关联)
  308. const loadSelectedProducts = async () => {
  309. loading.value = true;
  310. try {
  311. if (!recommendId.value) {
  312. await loadRecommendId();
  313. }
  314. if (!recommendId.value) {
  315. selectedProducts.value = [];
  316. return;
  317. }
  318. // 先获取推荐关联的商品ID列表
  319. const linkRes: any = await listRecommendLink({ recommendId: recommendId.value, pageSize: 100 });
  320. const links = linkRes.rows || [];
  321. if (links.length === 0) {
  322. selectedProducts.value = [];
  323. return;
  324. }
  325. // 获取商品详情
  326. const productIds = links.map((link: any) => link.productId);
  327. const productRes: any = await listProduct({ ids: productIds.join(','), pageSize: 100 });
  328. const productMap = new Map((productRes.rows || []).map((p: any) => [p.id, p]));
  329. // 组装数据
  330. selectedProducts.value = links.map((link: any, index: number) => {
  331. const product: any = productMap.get(link.productId) || {};
  332. return {
  333. id: product.id || link.productId,
  334. linkId: link.id, // 关联ID,用于删除
  335. productNo: product.productNo,
  336. name: product.itemName || `商品${link.productId}`,
  337. imageUrl: product.productImageUrl || product.productImage,
  338. price: product.minSellingPrice || product.memberPrice || '0.00',
  339. sort: links.length - index // 默认排序
  340. };
  341. });
  342. } catch (error) {
  343. console.error('获取已选商品失败', error);
  344. selectedProducts.value = [];
  345. } finally {
  346. loading.value = false;
  347. }
  348. };
  349. // 计算当前显示的商品(按排序值降序排列)
  350. const sortedProducts = computed(() => {
  351. return [...selectedProducts.value].sort((a, b) => b.sort - a.sort);
  352. });
  353. // 总页数
  354. const totalPages = computed(() => {
  355. return Math.ceil(sortedProducts.value.length / pageSize);
  356. });
  357. // 当前页显示的商品
  358. const displayProducts = computed(() => {
  359. const start = currentPage.value * pageSize;
  360. const end = start + pageSize;
  361. return sortedProducts.value.slice(start, end);
  362. });
  363. // 是否有上一页
  364. const hasPrev = computed(() => {
  365. return currentPage.value > 0;
  366. });
  367. // 是否有下一页
  368. const hasNext = computed(() => {
  369. return currentPage.value < totalPages.value - 1;
  370. });
  371. // 查看推荐商品
  372. const handleViewProducts = async () => {
  373. dialog.visible = true;
  374. // 每次打开都重新加载数据
  375. await loadSelectedProducts();
  376. };
  377. // 对话框关闭
  378. const handleDialogClose = () => {
  379. dialog.visible = false;
  380. };
  381. // 新增商品
  382. const handleAddProduct = () => {
  383. selectDialog.visible = true;
  384. selectedProductIds.value = [];
  385. searchKeyword.value = '';
  386. newProductPagination.pageNum = 1;
  387. // 加载可选商品列表
  388. loadAvailableProducts();
  389. // 等待DOM更新后,清除表格选中状态
  390. nextTick(() => {
  391. if (newProductTableRef.value) {
  392. newProductTableRef.value.clearSelection();
  393. }
  394. });
  395. };
  396. // 选择商品对话框关闭
  397. const handleSelectDialogClose = () => {
  398. selectDialog.visible = false;
  399. selectedProductIds.value = [];
  400. searchKeyword.value = '';
  401. // 清除表格选中状态
  402. if (newProductTableRef.value) {
  403. newProductTableRef.value.clearSelection();
  404. }
  405. };
  406. // 搜索商品
  407. const handleSearchProducts = () => {
  408. newProductPagination.pageNum = 1;
  409. loadAvailableProducts();
  410. };
  411. // 表格选择变化
  412. const newProductTableRef = ref();
  413. const handleSelectionChange = (selection: any[]) => {
  414. selectedProductIds.value = selection.map((item) => item.id);
  415. };
  416. // 确认选择商品
  417. const handleConfirmSelect = async () => {
  418. if (selectedProductIds.value.length === 0) {
  419. ElMessage.warning('请至少选择一个商品');
  420. return;
  421. }
  422. try {
  423. if (!recommendId.value) {
  424. await loadRecommendId();
  425. }
  426. if (!recommendId.value) {
  427. ElMessage.error('推荐位不存在,请先创建');
  428. return;
  429. }
  430. // 批量添加推荐关联,统计实际添加数量
  431. let addedCount = 0;
  432. let skippedCount = 0;
  433. for (const productId of selectedProductIds.value) {
  434. // 检查是否已存在
  435. if (selectedProducts.value.find((p) => String(p.id) === String(productId))) {
  436. skippedCount++;
  437. } else {
  438. await addRecommendLink({ recommendId: recommendId.value, productId });
  439. addedCount++;
  440. }
  441. }
  442. if (addedCount > 0) {
  443. ElMessage.success(`成功添加 ${addedCount} 个商品${skippedCount > 0 ? `,${skippedCount} 个已存在被跳过` : ''}`);
  444. } else {
  445. ElMessage.warning('所选商品均已存在');
  446. }
  447. handleSelectDialogClose();
  448. // 刷新已选列表
  449. await loadSelectedProducts();
  450. } catch (error) {
  451. ElMessage.error('添加失败');
  452. }
  453. };
  454. // 分页后的可选商品列表(过滤掉已选的商品)
  455. const filteredAvailableProducts = computed(() => {
  456. const selectedIds = selectedProducts.value.map((p) => String(p.id));
  457. return availableProducts.value.filter((item) => !selectedIds.includes(String(item.id)));
  458. });
  459. // 分页变化
  460. watch(
  461. () => [newProductPagination.pageNum, newProductPagination.pageSize],
  462. () => {
  463. if (selectDialog.visible) {
  464. loadAvailableProducts();
  465. }
  466. }
  467. );
  468. // 导入商品
  469. const handleImportProduct = () => {
  470. importDialog.visible = true;
  471. importProductIds.value = '';
  472. };
  473. // 导入对话框关闭
  474. const handleImportDialogClose = () => {
  475. importDialog.visible = false;
  476. importProductIds.value = '';
  477. };
  478. // 确认导入商品
  479. const handleConfirmImport = () => {
  480. if (!importProductIds.value.trim()) {
  481. ElMessage.warning('请输入商品编号');
  482. return;
  483. }
  484. // 解析商品编号(逗号隔开)
  485. const ids = importProductIds.value
  486. .split(/[,,]/)
  487. .map((id) => id.trim())
  488. .filter((id) => id);
  489. if (ids.length === 0) {
  490. ElMessage.warning('请输入有效的商品编号');
  491. return;
  492. }
  493. // 模拟导入逻辑(实际应调用接口查询商品信息)
  494. let addedCount = 0;
  495. ids.forEach((id) => {
  496. // 检查是否已存在
  497. if (!selectedProducts.value.find((p) => p.id === id)) {
  498. // 模拟添加商品(实际应从接口获取商品信息)
  499. selectedProducts.value.push({
  500. id: id,
  501. name: `商品${id}`,
  502. imageUrl: `https://via.placeholder.com/200x200/409EFF/FFFFFF?text=${id}`,
  503. price: '0.00',
  504. sort: Math.max(...selectedProducts.value.map((p) => p.sort), 0) + 1
  505. });
  506. addedCount++;
  507. }
  508. });
  509. if (addedCount > 0) {
  510. ElMessage.success(`成功导入 ${addedCount} 个商品`);
  511. } else {
  512. ElMessage.warning('所有商品编号已存在');
  513. }
  514. handleImportDialogClose();
  515. };
  516. // 删除商品
  517. const handleDeleteProduct = (id: string) => {
  518. const product = selectedProducts.value.find((item) => String(item.id) === String(id));
  519. ElMessageBox.confirm('是否确认删除该商品?', '提示', {
  520. confirmButtonText: '确定',
  521. cancelButtonText: '取消',
  522. type: 'warning'
  523. })
  524. .then(async () => {
  525. try {
  526. if (product?.linkId) {
  527. await delRecommendLink(product.linkId);
  528. }
  529. const index = selectedProducts.value.findIndex((item) => String(item.id) === String(id));
  530. if (index !== -1) {
  531. selectedProducts.value.splice(index, 1);
  532. }
  533. ElMessage.success('删除成功');
  534. // 调整页码确保不越界
  535. if (currentPage.value >= totalPages.value && currentPage.value > 0) {
  536. currentPage.value = totalPages.value - 1;
  537. }
  538. } catch (error) {
  539. ElMessage.error('删除失败');
  540. }
  541. })
  542. .catch(() => {});
  543. };
  544. // 排序改变
  545. const handleSortChange = (row: any) => {
  546. // 排序值改变后,重新计算显示的商品
  547. console.log('排序值改变:', row);
  548. };
  549. // 确认
  550. const handleConfirm = () => {
  551. ElMessage.success('保存成功');
  552. dialog.visible = false;
  553. };
  554. // 上一页
  555. const handlePrev = () => {
  556. if (hasPrev.value) {
  557. currentPage.value--;
  558. }
  559. };
  560. // 下一页
  561. const handleNext = () => {
  562. if (hasNext.value) {
  563. currentPage.value++;
  564. }
  565. };
  566. // 移除商品(从展示区域移除)
  567. const handleRemoveProduct = (id: string) => {
  568. const product = selectedProducts.value.find((item) => String(item.id) === String(id));
  569. ElMessageBox.confirm('是否确认从展示区域移除该商品?', '提示', {
  570. confirmButtonText: '确定',
  571. cancelButtonText: '取消',
  572. type: 'warning'
  573. })
  574. .then(async () => {
  575. try {
  576. if (product?.linkId) {
  577. await delRecommendLink(product.linkId);
  578. }
  579. const index = selectedProducts.value.findIndex((item) => String(item.id) === String(id));
  580. if (index !== -1) {
  581. selectedProducts.value.splice(index, 1);
  582. }
  583. ElMessage.success('移除成功');
  584. // 调整页码确保不越界
  585. if (currentPage.value >= totalPages.value && currentPage.value > 0) {
  586. currentPage.value = totalPages.value - 1;
  587. }
  588. } catch (error) {
  589. ElMessage.error('移除失败');
  590. }
  591. })
  592. .catch(() => {});
  593. };
  594. // 开始自动轮播
  595. const startAutoPlay = () => {
  596. stopAutoPlay();
  597. if (totalPages.value <= 1) return;
  598. autoPlayTimer = setInterval(() => {
  599. if (totalPages.value <= 1) {
  600. stopAutoPlay();
  601. return;
  602. }
  603. // 循环播放:1 -> 2 -> 1 -> 2
  604. if (currentPage.value >= totalPages.value - 1) {
  605. currentPage.value = 0;
  606. } else {
  607. currentPage.value++;
  608. }
  609. }, autoPlayInterval);
  610. };
  611. // 停止自动轮播
  612. const stopAutoPlay = () => {
  613. if (autoPlayTimer) {
  614. clearInterval(autoPlayTimer);
  615. autoPlayTimer = null;
  616. }
  617. };
  618. onMounted(() => {
  619. // 加载已选商品
  620. loadSelectedProducts();
  621. // 启动自动轮播
  622. startAutoPlay();
  623. });
  624. onUnmounted(() => {
  625. // 清理定时器
  626. stopAutoPlay();
  627. });
  628. </script>
  629. <style scoped lang="scss">
  630. .booth-page {
  631. min-height: 100vh;
  632. background: #f5f5f5;
  633. padding: 20px;
  634. }
  635. .booth-container {
  636. max-width: 1200px;
  637. margin: 0 auto;
  638. }
  639. .action-card {
  640. background: #fff;
  641. border-radius: 4px;
  642. padding: 15px 20px;
  643. margin-bottom: 12px;
  644. }
  645. .content-card {
  646. background: #fff;
  647. border-radius: 4px;
  648. padding: 20px;
  649. }
  650. .product-display-area {
  651. position: relative;
  652. min-height: 400px;
  653. padding: 20px 0;
  654. }
  655. .carousel-viewport {
  656. margin: 0 40px;
  657. }
  658. .product-grid {
  659. display: grid;
  660. grid-template-columns: repeat(5, 1fr);
  661. gap: 20px;
  662. }
  663. // 滑动过渡动画
  664. .slide-fade-enter-active {
  665. transition: all 0.4s ease-out;
  666. }
  667. .slide-fade-leave-active {
  668. transition: all 0.3s ease-in;
  669. }
  670. .slide-fade-enter-from {
  671. transform: translateX(30px);
  672. opacity: 0;
  673. }
  674. .slide-fade-leave-to {
  675. transform: translateX(-30px);
  676. opacity: 0;
  677. }
  678. .product-card {
  679. position: relative;
  680. background: #fff;
  681. border: 1px solid #ebeef5;
  682. border-radius: 8px;
  683. padding: 12px;
  684. cursor: pointer;
  685. transition: all 0.3s;
  686. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  687. &:hover {
  688. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  689. transform: translateY(-2px);
  690. }
  691. .delete-icon {
  692. position: absolute;
  693. top: 8px;
  694. right: 8px;
  695. font-size: 18px;
  696. color: #909399;
  697. cursor: pointer;
  698. z-index: 10;
  699. background: rgba(255, 255, 255, 0.8);
  700. border-radius: 50%;
  701. padding: 4px;
  702. transition: all 0.3s;
  703. &:hover {
  704. color: #f56c6c;
  705. background: rgba(255, 255, 255, 1);
  706. }
  707. }
  708. .product-image {
  709. width: 100%;
  710. height: 180px;
  711. margin-bottom: 12px;
  712. background: #f5f7fa;
  713. border-radius: 4px;
  714. overflow: hidden;
  715. .image {
  716. width: 100%;
  717. height: 100%;
  718. }
  719. .image-slot {
  720. display: flex;
  721. justify-content: center;
  722. align-items: center;
  723. width: 100%;
  724. height: 100%;
  725. background: #f5f7fa;
  726. color: #909399;
  727. font-size: 40px;
  728. }
  729. }
  730. .product-info {
  731. .product-name {
  732. margin: 0 0 8px 0;
  733. font-size: 13px;
  734. color: #303133;
  735. line-height: 1.5;
  736. overflow: hidden;
  737. text-overflow: ellipsis;
  738. display: -webkit-box;
  739. -webkit-line-clamp: 2;
  740. -webkit-box-orient: vertical;
  741. min-height: 39px;
  742. }
  743. .product-price {
  744. margin: 0;
  745. font-size: 18px;
  746. font-weight: 600;
  747. color: #f56c6c;
  748. }
  749. }
  750. }
  751. .nav-arrow {
  752. position: absolute;
  753. top: 50%;
  754. transform: translateY(-50%);
  755. font-size: 32px;
  756. color: #909399;
  757. cursor: pointer;
  758. background: rgba(255, 255, 255, 0.9);
  759. border-radius: 50%;
  760. padding: 8px;
  761. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  762. transition: all 0.3s;
  763. z-index: 10;
  764. &:hover {
  765. color: #409eff;
  766. background: #fff;
  767. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  768. }
  769. &.nav-arrow-left {
  770. left: 10px;
  771. }
  772. &.nav-arrow-right {
  773. right: 10px;
  774. }
  775. }
  776. .dialog-actions {
  777. display: flex;
  778. gap: 10px;
  779. }
  780. .image-slot-small {
  781. display: flex;
  782. justify-content: center;
  783. align-items: center;
  784. width: 100%;
  785. height: 100%;
  786. background: #f5f7fa;
  787. color: #909399;
  788. font-size: 20px;
  789. }
  790. .price-text {
  791. color: #f56c6c;
  792. font-weight: 600;
  793. }
  794. .search-bar {
  795. display: flex;
  796. align-items: center;
  797. }
  798. :deep(.el-dialog__body) {
  799. padding: 20px;
  800. }
  801. .action-link {
  802. cursor: pointer;
  803. font-size: 14px;
  804. &.danger {
  805. color: #f56c6c;
  806. &:hover {
  807. color: #f78989;
  808. }
  809. }
  810. }
  811. </style>