PageMain.vue 4.9 KB

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