PageCameraList.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="scene-layout">
  3. <header class="scene-layout__header">
  4. <div class="header__btn" @click="router.back">
  5. <img :src="rollback" />
  6. <span>返回</span>
  7. </div>
  8. </header>
  9. <main class="scene-layout__main">
  10. <section v-if="length > 0" class="main__layout">
  11. <el-card
  12. v-for="company in companyList"
  13. :key="company.id"
  14. shadow="hover"
  15. class="layout-cards"
  16. >
  17. <div class="layout-card" @click="handleClickCompany(company.id, company.name)">
  18. <div v-if="company.layout">
  19. <MapContainerSmall
  20. ref="mapContainerRef"
  21. :bg-image-url="(company.layout as any).bgInfo.img"
  22. :show-shops="(company.layout as any).shopList"
  23. class="content-pic"
  24. />
  25. </div>
  26. <div v-else>
  27. <img :src="noLayout" />
  28. <span>请添加场景布局</span>
  29. </div>
  30. </div>
  31. <template #footer>
  32. <span class="footer--default">{{ company.name }}</span>
  33. <div class="icons">
  34. <el-image
  35. v-if="company.layout"
  36. :src="preview"
  37. :preview-src-list="[company.layout]"
  38. hide-on-click-modal
  39. fit="cover"
  40. />
  41. <img :src="edit" @click="handleClickCompany(company.id, company.name)" />
  42. </div>
  43. </template>
  44. </el-card>
  45. </section>
  46. <section class="main__empty" v-else>
  47. <img :src="empty" />
  48. <span>
  49. 目前无内容,
  50. <router-link to="/scene/workshop">请先添加公司</router-link>
  51. </span>
  52. </section>
  53. </main>
  54. </div>
  55. </template>
  56. <script lang="ts" setup>
  57. import rollback from '@/assets/rollback.png';
  58. import empty from '@/assets/images/table/table-empty.png';
  59. import noLayout from '@/assets/images/page-config/no-layout.png';
  60. import preview from '@/assets/images/table/table-preview.png';
  61. import edit from '@/assets/images/table/table-edit.png';
  62. import router from '@/router';
  63. import { CompanyInfoList } from '@/types/scene-layout/type';
  64. import { ViewType } from '@/types/page-config/type';
  65. import {
  66. getCompanyListApi,
  67. getPcCompanyLayoutListApi,
  68. getMobileCompanyLayoutList,
  69. } from '@/api/scene/scene';
  70. import { computed, onMounted, ref } from 'vue';
  71. import MapContainerSmall from '@/views/page-config/component/mapContainer/MapContainerSmall.vue';
  72. const companyList = ref<CompanyInfoList[]>([]);
  73. const length = computed(() => {
  74. return companyList.value.length;
  75. });
  76. const viewType = ref<number>();
  77. const handleClickCompany = (companyId, companyName) => {
  78. router.push({
  79. path: '/layout/scene-config',
  80. query: { companyId, companyName, viewType: viewType.value },
  81. });
  82. };
  83. onMounted(async () => {
  84. viewType.value = Number(router.currentRoute.value.query.viewType);
  85. companyList.value = await getCompanyListApi();
  86. const companyIDList = companyList.value.map((x) => x.id);
  87. const platformApiMap = {
  88. [ViewType.companyHomepage_PC]: getPcCompanyLayoutListApi,
  89. [ViewType.companyHomepage_phone]: getMobileCompanyLayoutList,
  90. };
  91. platformApiMap[viewType.value]({ companyIds: companyIDList }).then((res) => {
  92. res.map((companyWithLayout) => {
  93. companyList.value.find((company) => company.id === companyWithLayout.id)!.layout =
  94. JSON.parse(companyWithLayout.layout);
  95. });
  96. });
  97. });
  98. </script>
  99. <style lang="scss" scoped>
  100. .footer--default {
  101. opacity: 0.45;
  102. }
  103. .scene-layout {
  104. position: absolute;
  105. top: 0;
  106. left: 0;
  107. width: 100%;
  108. height: calc(100vh - 64px);
  109. &__header {
  110. display: flex;
  111. align-items: center;
  112. width: inherit;
  113. height: 54px;
  114. padding-left: 23px;
  115. background: #ffffff;
  116. border-top: 1px solid rgba(0, 0, 0, 0.1);
  117. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.12);
  118. .header__btn {
  119. display: flex;
  120. gap: 10px;
  121. cursor: pointer;
  122. }
  123. img {
  124. width: 14px;
  125. height: 14px;
  126. }
  127. span {
  128. line-height: 14px;
  129. &:hover {
  130. text-shadow: 5px 5px 6px rgba(0, 0, 0, 0.12);
  131. }
  132. }
  133. }
  134. &__main {
  135. margin-top: 12px;
  136. width: inherit;
  137. height: calc(100vh - 64px - 54px - 12px);
  138. background: #ffffff;
  139. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.12);
  140. border-radius: 6px;
  141. }
  142. .main__layout {
  143. display: flex;
  144. gap: 25px;
  145. flex-wrap: wrap;
  146. align-content: flex-start;
  147. width: inherit;
  148. height: inherit;
  149. padding: 22px 24px 22px 24px;
  150. }
  151. .layout-cards {
  152. width: 216px;
  153. height: 190px;
  154. .layout-card div {
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: center;
  158. align-items: center;
  159. gap: 4px;
  160. }
  161. }
  162. :deep(.el-card__body) {
  163. width: inherit;
  164. height: 145px;
  165. display: flex;
  166. flex-direction: column;
  167. justify-content: center;
  168. align-items: center;
  169. padding: 0;
  170. background: #f5f5f5;
  171. cursor: pointer;
  172. }
  173. :deep(.el-card__footer) {
  174. display: flex;
  175. justify-content: space-between;
  176. align-items: center;
  177. width: inherit;
  178. height: 45px;
  179. padding: 0 12px 0 12px;
  180. .icons {
  181. display: flex;
  182. gap: 10px;
  183. img,
  184. el-image {
  185. cursor: pointer;
  186. opacity: 0.4;
  187. transition: opacity 0.5s ease-in-out;
  188. &:hover {
  189. opacity: 1;
  190. }
  191. }
  192. }
  193. }
  194. .main__empty {
  195. display: flex;
  196. flex-direction: column;
  197. gap: 2px;
  198. justify-content: center;
  199. align-items: center;
  200. width: inherit;
  201. height: inherit;
  202. }
  203. }
  204. </style>