husq
2023-09-27 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<template>
  <div class="project-box flex-common">
    <a-spin :spinning="model" style="width: 100%;">
      <div class="project-card" :class="{active: index == selectIndex}" v-for="(item, index) in cardList" :key="item.id">
        <div class="project-left" @click="goCenter(item, index)">
          <div class="head mb10 flex-display flex-align-center flex-justify-between">
            <div class="head-left flex-display flex-align-center">
              <a-tag color="#87d068">{{ status[item.projectStatus] || '进行中' }}</a-tag>
              <span class="head-text">{{ item.workspace_name }}</span>
            </div>
            <div class="head-right">
              <a-dropdown>
                <dash-outlined />
                <template #overlay>
                  <a-menu>
                    <a-menu-item>
                      <a @click="goEdit(item)">编辑</a>
                    </a-menu-item>
                    <!-- <a-menu-item>
                      <a @click="editStatus(item)">归档</a>
                    </a-menu-item> -->
                    <a-menu-item>
                      <a @click="deleteItem(item)">删除</a>
                    </a-menu-item>
                  </a-menu>
                </template>
              </a-dropdown>
            </div>
          </div>
          <div class="wrapper">
            <div class="introduction mb10">{{ item.workspace_desc || '暂无简介' }}</div>
            <div class="time mb5">创建时间: {{ item.createTime }}</div>
            <div class="manager mb5 flex-display flex-align-center">
              <user-outlined />
              <!-- {{item.memberList[0].userId}} -->
              <div class="user_name ml10">测试角色</div>
            </div>
          </div>
        </div>
        <div>
          <div class="enter" @click="goDetail(item)">
            <export-outlined />
          </div>
        </div>
      </div>
    </a-spin>
  </div>
</template>
 
<script setup lang="ts">
import { DashOutlined, UserOutlined, ExportOutlined, ExclamationCircleOutlined } from '@ant-design/icons-vue'
import { defineEmits, defineProps, createVNode } from 'vue'
import { ELocalStorageKey, ERouterName } from '/@/types/index'
import { status, projectCard } from './data'
import { del, edit } from '/@/api/project-page'
import { delPlatformInfo } from '/@/api/manage'
import { Modal, message } from 'ant-design-vue'
import { useMyStore } from '/@/store'
import { flyTo, isEntityExist } from '/@/hooks/use-center-point'
const { appContext } = getCurrentInstance()
const global = appContext.config.globalProperties
const store = useMyStore()
const router = useRouter()
const emit = defineEmits(['refreshList', 'update:modelValue'])
const props = defineProps({
  cardList: {
    type: Array as () => projectCard[],
    required: true,
  },
  modelValue: [String, Number, Boolean]
})
const model = computed({
  get () {
    return props.modelValue
  },
  set (val) {
    emit('update:modelValue', val)
  }
})
const spinning = ref<boolean>(true)
const selectIndex = ref(-1)
// 删除方法
const deleteItem = (item: projectCard) => {
  Modal.confirm({
    title: () => '确认删除?',
    icon: () => createVNode(ExclamationCircleOutlined),
    content: () => '删除后项目内容将不可恢复,您确定要删除该项目吗?',
    okText: () => '确定',
    okType: 'danger',
    cancelText: () => '取消',
    onOk () {
      delPlatformInfo(item.id).then(res => {
        if (res.code === 0) {
          message.success('删除成功')
          emit('refreshList')
        }
      })
    },
  })
}
 
const editStatus = (item: projectCard) => {
  Modal.confirm({
    title: () => '确认归档?',
    icon: () => createVNode(ExclamationCircleOutlined),
    content: () => '项目完成后可归档,归档后 Pilot 将无法加入该项目,您确定要归档该项目吗?',
    okText: () => '确定',
    okType: 'danger',
    cancelText: () => '取消',
    onOk () {
      const obj = { id: item.id, projectStatus: 2 }
      edit(obj).then(res => {
        if (res.code === 5000) {
          message.success('归档成功')
          emit('refreshList')
        }
      })
    },
  })
}
 
const goEdit = (item: any) => {
  router.push({
    name: ERouterName.EDIT_PROJECT,
    query: { id: item.id }
  })
  store.commit('SET_POINT_LIST', [])
}
 
const goDetail = (item: any) => {
  store.commit('SET_PROJECT_ID', item.workspace_id)
  localStorage.setItem(ELocalStorageKey.WorkspaceId, item.workspace_id)
  store.commit('SET_POINT_LIST', [])
  store.commit('SET_PROJECT_NAME', item.workspace_name)
  router.push({
    name: ERouterName.WORKSPACE,
    query: { id: item.id, workSpaceId: item.workspace_id },
  })
}
const goCenter = (item:any, index:number) => {
  selectIndex.value === index ? selectIndex.value = -1 : selectIndex.value = index
  flyTo(global.$viewer, item.longitude, item.latitude)
  const flag = isEntityExist(global.$viewer, item.longitude, item.latitude)
}
</script>
 
<style scoped lang="scss">
.project-box {
  width: 100%;
  height: 100%;
 
  :deep(.ant-spin-nested-loading) {
    width: 100%;
    height: 100%;
  }
 
  .project-card {
    cursor: pointer;
    width: 100%;
    min-height: 120px;
    background: #232323;
    user-select: none;
    border-bottom: 1px solid #4f4f4f;
    display: flex;
  }
  .active {
    cursor: pointer;
    background-color: #101010;
  }
  .project-left {
    padding: 16px;
    flex: 1;
    width: calc(100% - 48px);
    box-sizing: border-box;
 
    .head {
      .head-left {
        font-size: 16px;
      }
    }
  }
 
  .enter {
    background: #303030;
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    height: 100%;
    cursor: pointer;
  }
}
</style>