index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="p-4">
  3. <div class="resoure-center">
  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. updateAction()
  115. } else {
  116. achieveList.value = list.map(i => { if (i && i.type == type) { i.items = r, i.count = 0; } return i; });
  117. updateAction()
  118. }
  119. } else {
  120. achieveList.value = r;
  121. updateAction()
  122. }
  123. }
  124. });
  125. });
  126. const resAddToCar = () => {
  127. let params = {
  128. id: currentTreeNodeKeys.value.length ? currentTreeNodeKeys.value[0] : null
  129. }
  130. platList(params).then((r) => { if (r) { achieveList.value = r, updateAction() } });
  131. }
  132. function updateAction() {
  133. var type = true;
  134. var r = achieveList.value;
  135. r.forEach((i) => { if (i.type == 'MR' && i.count) { type = false; activeKey.value = 'MR' } });
  136. if (type) r.forEach((i) => { if (i.type == 'ER' && i.count) { type = false; activeKey.value = 'ER' } });
  137. if (type) r.forEach((i) => { if (i.type == 'DR' && i.count) { type = false; activeKey.value = 'DR' } });
  138. }
  139. return {
  140. activeKey,
  141. replaceFields,
  142. treeData,
  143. expandedKeys,
  144. selectedKeys,
  145. checkedKeys,
  146. achieveList,
  147. nodeSelect,
  148. resAddToCar
  149. };
  150. },
  151. });
  152. </script>
  153. <style lang="less" scoped>
  154. .p-4 {
  155. height: 100%;
  156. .resoure-center {
  157. padding: 20px;
  158. width: 100%;
  159. height: 100%;
  160. background-color: #fff;
  161. border-radius: 6px;
  162. .datacenter-left {
  163. float: left;
  164. width: 250px;
  165. height: 100%;
  166. margin-right: 16px;
  167. border-top: none;
  168. background: #F8F8F8;
  169. .page-name {
  170. height: 40px;
  171. border-bottom: solid 1px #DEDEDE;
  172. box-sizing: border-box;
  173. p {
  174. height: 40px;
  175. line-height: 40px;
  176. font-size: 16px;
  177. font-family: PingFang SC;
  178. font-weight: bold;
  179. color: #333333;
  180. text-align: center;
  181. margin-bottom: 0px;
  182. }
  183. }
  184. .ztree-container {
  185. float: left;
  186. overflow: auto;
  187. width: 100%;
  188. max-height: 800px;
  189. height: calc(100% - 43px);
  190. padding: 10px;
  191. &::-webkit-scrollbar {
  192. width: 3px;
  193. }
  194. &::-webkit-scrollbar-thumb {
  195. border-radius: 2px;
  196. background: #ccd5df;
  197. }
  198. &::-webkit-scrollbar-track {
  199. display: none;
  200. }
  201. ::v-deep .ant-tree-treenode-selected {
  202. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-normal.ant-tree-node-selected::before {
  203. background: #e0eaf5 !important;
  204. }
  205. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-open.ant-tree-node-selected::before {
  206. background: #e0eaf5 !important;
  207. }
  208. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-close.ant-tree-node-selected::before {
  209. background: #e0eaf5 !important;
  210. }
  211. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-normal.ant-tree-node-selected {
  212. color: #0671DD;
  213. }
  214. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-open.ant-tree-node-selected {
  215. color: #0671DD;
  216. }
  217. .ant-tree-node-content-wrapper.ant-tree-node-content-wrapper-close.ant-tree-node-selected {
  218. color: #0671DD;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. ::v-deep .ztree-container span.ant-tree-switcher span.anticon>svg {
  226. width: 20px;
  227. height: 20px;
  228. color: #888888;
  229. }
  230. .account-center-bottom {
  231. background: #fff;
  232. height: calc(100vh - 80px);
  233. overflow: hidden;
  234. }
  235. .account-center {
  236. &-bottom {
  237. padding: 10px;
  238. margin: 16px;
  239. // background-color: @component-background;
  240. border-radius: 3px;
  241. }
  242. }
  243. </style>