IdleAssetsStoreMap.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <a-card>
  3. <a-tabs :default-active-key="defaultActive" @change="handleClick">
  4. <a-tab-pane v-for="(item, index) in positionsList" :tab="item.name" :key="index">
  5. <div style="position: relative;">
  6. <div class="point" v-for="store in storeList" :key="store.id" :style="computPosition(store.positionX, store.positionY)" />
  7. <img v-if="item.opcImg" :src="item.opcImg" width="100%" alt="">
  8. <a-empty v-else description="暂无底图,请上传" />
  9. </div>
  10. </a-tab-pane>
  11. </a-tabs>
  12. </a-card>
  13. </template>
  14. <script>
  15. import { querySbPosition } from '@/api/sb/position'
  16. import { fetchStorePosition, fetchStoreStore } from '@/api/store/store'
  17. export default {
  18. data () {
  19. return {
  20. positionsList: [],
  21. defaultActive: 0,
  22. storeList: []
  23. }
  24. },
  25. created () {
  26. this.getInfo()
  27. },
  28. methods: {
  29. getInfo () {
  30. querySbPosition({ type: 1 }).then(res => {
  31. this.positionsList = res.data
  32. this.handleClick(this.defaultActive)
  33. })
  34. },
  35. computPosition (x, y) {
  36. const left = x + '%'
  37. const top = y + '%'
  38. return {
  39. left, top
  40. }
  41. },
  42. handleClick (i) {
  43. this.defaultActive = i
  44. fetchStorePosition({ id: this.positionsList[i].id }).then(res => {
  45. this.storeList = res.data
  46. })
  47. },
  48. handleClickImg (e) {
  49. console.log(e.offsetX, e.offsetY)
  50. console.log(e.target.width, e.target.height)
  51. // console.log(e.offsetX, e.offsetY)
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="less" scoped>
  57. .point {
  58. position: absolute;
  59. width: 10px;
  60. height: 10px;
  61. background: red;
  62. border-radius: 50%;
  63. }
  64. </style>