actions.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <div class="table-actions">
  3. <template v-if="bimDone">
  4. <a @click="updateBimName">修改</a>
  5. <a v-if="!store.current!.panos" @click="syncScene">同步</a>
  6. </template>
  7. <template v-if="done">
  8. <a @click="queryScene">查看</a>
  9. <!-- <a>分享</a> -->
  10. </template>
  11. <a v-if="lastStep" class="warn" @click="deleteScene"> 删除 </a>
  12. </div>
  13. </template>
  14. <script setup lang="ts">
  15. import { useProject, BinType, BimStatus, SceneStatus } from '@/store'
  16. import { Modal } from 'ant-design-vue'
  17. import { computed } from 'vue'
  18. import { renderModal } from '@/helper'
  19. import { projectManage } from '@/env'
  20. import UploadBim from './update.vue'
  21. import type { ProjectScene } from '@/store'
  22. const props = defineProps<{ scene: ProjectScene }>()
  23. const store = useProject()
  24. const bimDone = computed(
  25. () => props.scene.type === BinType && props.scene.status === BimStatus.done
  26. )
  27. const sceneDone = computed(
  28. () =>
  29. props.scene.type !== BinType && props.scene.status === SceneStatus.SUCCESS
  30. )
  31. const done = computed(() => sceneDone.value || bimDone.value)
  32. const lastStep = computed(
  33. () =>
  34. props.scene.type !== BinType ||
  35. [BimStatus.done, BimStatus.error].includes(props.scene.status)
  36. )
  37. const deleteScene = () => {
  38. Modal.confirm({
  39. content: '确定要删除此场景?',
  40. title: '系统提示',
  41. width: '400px',
  42. okText: '删除',
  43. icon: null,
  44. cancelText: '取消',
  45. onOk: async () => {
  46. if (props.scene.type === BinType) {
  47. await store.deleteBim()
  48. } else {
  49. await store.deleteScene(props.scene.num)
  50. }
  51. }
  52. })
  53. }
  54. const queryScene = () => {
  55. const base = `${projectManage}?projectId=${store.current!.projectId}`
  56. if ('num' in props.scene) {
  57. window.open(`${base}&m=${props.scene.num}`)
  58. } else {
  59. window.open(`${base}&bim`)
  60. }
  61. }
  62. const syncScene = () => {
  63. window.open(`${projectManage}?projectId=${store.current!.projectId}&adjust`)
  64. }
  65. const updateBimName = () => {
  66. const bim = store.current!.bimData!
  67. renderModal(UploadBim, {
  68. bim: {
  69. bimName: bim.bimName,
  70. bimPath: bim.bimOssFilePath || bim.bimLocalFilePath
  71. },
  72. async onSave(data) {
  73. await store.updateBimName(data.bimName)
  74. }
  75. })
  76. }
  77. </script>