index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div class="p-4">
  3. <div class="resoure-center resouresList">
  4. <div class="datacenter-left">
  5. <div class="page-name">
  6. <p>数据目录</p>
  7. </div>
  8. <div class="ztree-container">
  9. <a-directory-tree :tree-data="treeData" v-model:expandedKeys="expandedKeys" v-model:selectedKeys="selectedKeys"
  10. v-if="treeData.length" v-model:checkedKeys="checkedKeys" :defaultExpandedKeys="expandedKeys"
  11. :replaceFields="replaceFields" @select="nodeSelect">
  12. <template #title="item">{{ `${item.name}(${item.count})` }}</template>
  13. </a-directory-tree>
  14. </div>
  15. </div>
  16. <Tabs :animated="false" v-model:activeKey="activeKey">
  17. <template v-for="item in achieveList " :key="item.type">
  18. <TabPane :tab="[`${item.typeName == '数据' ? '文件' : item.typeName}资源(${item.count})`]">
  19. <component :is="item.type == 'MR'?'MapData':item.type == 'ER'?'SceneData':'FileData'" :listData="item"
  20. @resAddToCar="resAddToCar" />
  21. </TabPane>
  22. </template>
  23. </Tabs>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. import { Tabs } from 'ant-design-vue';
  29. import { defineComponent, ref, watch } from 'vue';
  30. import MapData from './item/MapData.vue';
  31. import FileData from './item/FileData.vue';
  32. import SceneData from './item/SceneData.vue';
  33. import { onMounted } from 'vue';
  34. import { directoryTree, platList, platListByMenuId } from '/@/api/resource/plat';
  35. import eventBus from '/@/utils/eventBus';
  36. import { is } from '/@/utils/is';
  37. import { useAdminStoreOut } from '/@/store/modules/admin';
  38. export default defineComponent({
  39. components: {
  40. Tabs,
  41. TabPane: Tabs.TabPane,
  42. MapData,
  43. FileData,
  44. SceneData,
  45. },
  46. setup() {
  47. const replaceFields = ref({
  48. children: 'child',
  49. key: 'id',
  50. title: 'name'
  51. })
  52. const treeData = ref([]);
  53. const expandedKeys = ref([]);
  54. const selectedKeys = ref([]);
  55. const currentTreeNodeKeys = ref([]);
  56. const checkedKeys = ref([]);
  57. const achieveList = ref([]);
  58. const adminStore = useAdminStoreOut();
  59. const activeKey = ref('MR');
  60. const nodeSelect = (selectedKey, { selectedNode, node }) => {
  61. if (currentTreeNodeKeys.value.length && currentTreeNodeKeys.value[0] === selectedKey[0]) {
  62. selectedKeys.value = [];
  63. currentTreeNodeKeys.value = [];
  64. paramsObj.keywords = null;
  65. activeKey.value = 'MR';
  66. // eventBus.emit("tagChangeTag");
  67. eventBus.emit('platListCenter', paramsObj, true)
  68. return;
  69. } else {
  70. currentTreeNodeKeys.value[0] = selectedKey[0]
  71. if (selectedKey.length) {
  72. paramsObj.keywords = null;
  73. activeKey.value = 'MR';
  74. // eventBus.emit("tagChangeTag");
  75. eventBus.emit('platListCenter', paramsObj, true)
  76. }
  77. }
  78. }
  79. onMounted(() => {
  80. directoryTree().then((r) => {
  81. if (r) {
  82. treeData.value = r[0].child[0].child
  83. treeData.value.forEach(item => {
  84. expandedKeys.value.push(item.id)
  85. })
  86. }
  87. });
  88. platList().then((r) => {
  89. if (r) {
  90. achieveList.value = r;
  91. updateAction()
  92. console.log(achieveList.value)
  93. }
  94. });
  95. });
  96. var paramsObj = {};
  97. eventBus.one('platListCenter', (o, idTyep) => {
  98. var type = null;
  99. if (o && o.type) type = o.type == 'MAP' ? 'MR' : o.type == 'SCENE' ? 'ER' : 'DR';
  100. let params = o ? JSON.parse(JSON.stringify(o)) : {};
  101. paramsObj = params;
  102. params.id = currentTreeNodeKeys.value.length ? currentTreeNodeKeys.value[0] : null
  103. platList(params).then((r) => {
  104. if (r) {
  105. if (type && !idTyep) {
  106. var list = JSON.parse(JSON.stringify(achieveList.value))
  107. if (r?.length) {
  108. achieveList.value = list.map(i => {
  109. if (i && i.type == type) {
  110. i = r.find(j => j && j.type == type) || { ...i, items: [], count: 0 };
  111. }
  112. return i;
  113. })
  114. if (!o.isPage) updateAction()
  115. } else {
  116. achieveList.value = list.map(i => {
  117. if (i && i.type == type) {
  118. i.items = r, i.count = 0;
  119. }
  120. return i;
  121. });
  122. updateAction()
  123. }
  124. } else {
  125. if (o.isPage) {
  126. var c = r.find(j => j.type == activeKey.value)
  127. achieveList.value.forEach(i => {
  128. if (i.type == activeKey.value) {
  129. i.items = c.items;
  130. }
  131. })
  132. } else {
  133. achieveList.value = r;
  134. updateAction()
  135. }
  136. }
  137. }
  138. });
  139. });
  140. const resAddToCar = () => {
  141. let params = {
  142. id: currentTreeNodeKeys.value.length ? currentTreeNodeKeys.value[0] : null
  143. }
  144. platList(params).then((r) => { if (r) { achieveList.value = r } });
  145. }
  146. function updateAction() {
  147. var type = true;
  148. var r = achieveList.value;
  149. r.forEach((i) => { if (i.type == 'MR' && i.count) { type = false; activeKey.value = 'MR' } });
  150. if (type) r.forEach((i) => { if (i.type == 'ER' && i.count) { type = false; activeKey.value = 'ER' } });
  151. if (type) r.forEach((i) => { if (i.type == 'DR' && i.count) { type = false; activeKey.value = 'DR' } });
  152. }
  153. return {
  154. activeKey,
  155. replaceFields,
  156. treeData,
  157. expandedKeys,
  158. selectedKeys,
  159. checkedKeys,
  160. achieveList,
  161. nodeSelect,
  162. resAddToCar
  163. };
  164. },
  165. });
  166. </script>
  167. <style>
  168. .resouresList .ant-tabs-nav .ant-tabs-tab {
  169. font-weight: bold;
  170. font-size: 16px;
  171. }
  172. .resouresList .ant-tabs .ant-tabs-top-content {
  173. width: 100%;
  174. height: 100vh;
  175. overflow: auto;
  176. &::-webkit-scrollbar {
  177. width: 3px;
  178. }
  179. }
  180. .datacenter-right .resource_list {
  181. margin-bottom: 160px;
  182. }
  183. </style>
  184. <style lang="less" scoped>
  185. .p-4 {
  186. height: 100%;
  187. .resoure-center {
  188. padding: 20px;
  189. width: 100%;
  190. height: 100%;
  191. background-color: #fff;
  192. border-radius: 6px;
  193. overflow: hidden;
  194. height: calc(100vh - 70px);
  195. .datacenter-left {
  196. float: left;
  197. width: 250px;
  198. height: 100%;
  199. margin-right: 16px;
  200. border-top: none;
  201. background: #F8F8F8;
  202. .page-name {
  203. height: 40px;
  204. border-bottom: solid 1px #DEDEDE;
  205. box-sizing: border-box;
  206. p {
  207. height: 40px;
  208. line-height: 40px;
  209. font-size: 16px;
  210. font-family: PingFang SC;
  211. font-weight: bold;
  212. color: #333333;
  213. text-align: center;
  214. margin-bottom: 0px;
  215. }
  216. }
  217. .ztree-container {
  218. float: left;
  219. overflow: auto;
  220. width: 100%;
  221. max-height: 800px;
  222. height: calc(100% - 43px);
  223. padding: 10px;
  224. &::-webkit-scrollbar {
  225. width: 3px;
  226. }
  227. &::-webkit-scrollbar-thumb {
  228. border-radius: 2px;
  229. background: #ccd5df;
  230. }
  231. &::-webkit-scrollbar-track {
  232. display: none;
  233. }
  234. ::v-deep .ant-tree-treenode-selected {
  235. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-normal.ant-tree-node-selected::before {
  236. background: #e0eaf5 !important;
  237. }
  238. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-open.ant-tree-node-selected::before {
  239. background: #e0eaf5 !important;
  240. }
  241. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-close.ant-tree-node-selected::before {
  242. background: #e0eaf5 !important;
  243. }
  244. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-normal.ant-tree-node-selected {
  245. color: #0671DD;
  246. }
  247. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-open.ant-tree-node-selected {
  248. color: #0671DD;
  249. }
  250. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-close.ant-tree-node-selected {
  251. color: #0671DD;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. ::v-deep .ztree-container span.ant-tree-switcher span.anticon>svg {
  259. width: 20px;
  260. height: 20px;
  261. color: #888888;
  262. }
  263. .account-center-bottom {
  264. background: #fff;
  265. height: calc(100vh - 80px);
  266. overflow: hidden;
  267. }
  268. .account-center {
  269. &-bottom {
  270. padding: 10px;
  271. margin: 16px;
  272. // background-color: @component-background;
  273. border-radius: 3px;
  274. }
  275. }
  276. </style>