PageMain.vue 5.0 KB

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