PageMain.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <div>
  3. <div class="add-page-box">
  4. <div class="add-config">
  5. <div class="add-box" @click="handleAddPage">
  6. <div>
  7. <el-icon class="add-icon" size="24px"><Plus /></el-icon>
  8. </div>
  9. <div class="add-content">新建主页</div>
  10. </div>
  11. </div>
  12. <div
  13. v-for="item in companyLayoutList"
  14. :key="item.id"
  15. class="content-show"
  16. @mouseover="showDeleteIcon(item)"
  17. @mouseleave="hideDeleteIcon(item)"
  18. @click="handleClick(item)"
  19. >
  20. <div class="pic-box">
  21. <!-- <img
  22. :src="globSetting.imgUrl! +(item.layout as any).bgInfo.img"
  23. alt="图片"
  24. class="content-pic"
  25. /> -->
  26. <MapContainerSmall
  27. ref="mapContainerRef"
  28. :bg-image-url="(item.layout as any).bgInfo.img"
  29. :show-shops="(item.layout as any).shopList"
  30. class="content-pic"
  31. />
  32. </div>
  33. <div class="pic-word">
  34. <img src="~@/assets/icons/file.png" alt="" />
  35. <div class="pic-name">{{ item.name }}</div>
  36. <img
  37. v-show="item.id === IconId"
  38. src="~@/assets/icons/del.png"
  39. alt=""
  40. @click.stop="deleteItem(item)"
  41. class="del-icon"
  42. />
  43. </div>
  44. </div> </div
  45. ></div>
  46. </template>
  47. <script lang="ts" setup>
  48. import { ref, onMounted } from 'vue';
  49. import { useRouter } from 'vue-router';
  50. import { useGlobSetting } from '@/hooks/setting';
  51. import { Plus } from '@element-plus/icons-vue';
  52. import { getCompanyLayoutList, delCompanyLayout } from '@/api/scene/scene';
  53. import MapContainerSmall from './mapContainer/MapContainerSmall.vue';
  54. const globSetting = useGlobSetting();
  55. interface companyLayoutType {
  56. createdAt: string;
  57. id: number;
  58. isDelete: number;
  59. labelId: number;
  60. layout: string;
  61. name: string;
  62. status: number;
  63. targetId: number;
  64. updatedAt: string;
  65. version: string;
  66. viewType: number;
  67. }
  68. const companyLayoutList = ref<companyLayoutType[]>([]);
  69. onMounted(() => {
  70. getCompanyLayoutList().then((res) => {
  71. companyLayoutList.value = res;
  72. companyLayoutList.value = companyLayoutList.value.map((item) => {
  73. item.layout = JSON.parse(item.layout);
  74. return item;
  75. });
  76. });
  77. });
  78. const router = useRouter();
  79. const handleAddPage = () => {
  80. router.push('/page-config/config');
  81. };
  82. const IconId = ref<number>();
  83. const showDeleteIcon = (item) => {
  84. IconId.value = item.id;
  85. };
  86. const hideDeleteIcon = (_item) => {
  87. IconId.value = undefined;
  88. };
  89. const handleClick = (item) => {
  90. router.push({
  91. path: '/page-config/config',
  92. query: { companyId: item.targetId, labelId: item.labelId },
  93. });
  94. };
  95. const deleteItem = (item) => {
  96. // 处理删除逻辑
  97. delCompanyLayout(item.id).then(() => {
  98. getCompanyLayoutList().then((res) => {
  99. companyLayoutList.value = res;
  100. companyLayoutList.value = companyLayoutList.value.map((item) => {
  101. item.layout = JSON.parse(item.layout);
  102. return item;
  103. });
  104. });
  105. });
  106. };
  107. // const label = ref('');
  108. </script>
  109. <style lang="scss" sctep>
  110. .search-btn {
  111. width: 340px;
  112. height: 32px;
  113. background: #f0f2f5;
  114. border-radius: 6px;
  115. }
  116. .add-page-box {
  117. display: flex;
  118. flex-wrap: wrap;
  119. margin-top: 10px;
  120. margin-bottom: 24px;
  121. align-content: flex-start;
  122. }
  123. .add-config {
  124. width: 216px;
  125. height: 191px;
  126. margin-right: 26px;
  127. }
  128. .add-box {
  129. width: 104px;
  130. height: 104px;
  131. background: rgba(255, 255, 255, 0.04);
  132. border-radius: 5px;
  133. border: 1px solid rgba(0, 0, 0, 0.15);
  134. // text-align: center;
  135. margin-left: 56px;
  136. margin-top: 43px;
  137. }
  138. .add-icon {
  139. margin-left: 40px;
  140. margin-top: 24px;
  141. }
  142. .add-content {
  143. font-size: 14px;
  144. margin-top: 10px;
  145. text-align: center;
  146. }
  147. .config-box {
  148. height: 700px;
  149. }
  150. .label-select {
  151. margin-right: 17px;
  152. border-radius: 4px;
  153. // border: 1px solid rgba(0, 0, 0, 0.15);
  154. }
  155. .content-show {
  156. // display: flex;
  157. width: 216px;
  158. height: 191px;
  159. margin-left: 26px;
  160. border: 1px solid #e8ecf2;
  161. margin-bottom: 24px;
  162. cursor: pointer;
  163. }
  164. .pic-box {
  165. height: 146px;
  166. width: 216px;
  167. background: #e8ecf2;
  168. padding-left: 17px;
  169. padding-top: 17px;
  170. }
  171. .content-pic {
  172. // margin-left: 17px;
  173. // margin-top: 17px;
  174. width: 182px;
  175. height: 114px;
  176. }
  177. .pic-word {
  178. position: relative;
  179. display: flex;
  180. padding-left: 16px;
  181. padding-top: 13px;
  182. }
  183. .pic-name {
  184. margin-left: 8px;
  185. margin-top: 2px;
  186. font-size: 12px;
  187. }
  188. .del-icon {
  189. position: absolute;
  190. right: 17px;
  191. bottom: 3px;
  192. }
  193. </style>