index.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918
  1. <template>
  2. <div>
  3. <!-- <div v-if="isRenaming">
  4. <input ref="rename" type="text" @blur="onInputNewNameComplete" v-model="inputData.name" />
  5. </div> -->
  6. <!-- <button @click="addNode(null)">Add Node</button> -->
  7. <el-tree
  8. :highlight-current="true"
  9. ref="sceneTree"
  10. :data="this.info.navigationTrees"
  11. :expand-on-click-node="false"
  12. node-key="id"
  13. class="custom-tree"
  14. :default-expand-all="false"
  15. @node-drag-start="handleDragStart"
  16. @node-drag-enter="handleDragEnter"
  17. @node-drag-leave="handleDragLeave"
  18. @node-drag-over="handleDragOver"
  19. @node-drag-end="handleDragEnd"
  20. @node-drop="handleDrop"
  21. @node-click="handlerGroup"
  22. @node-expand="handleNodeExpand"
  23. @node-collapse="handleNodeCollapse"
  24. draggable
  25. :allow-drop="allowDrop"
  26. :allow-drag="allowDrag"
  27. >
  28. <template slot-scope="{ node, data }">
  29. <div class="tree-msg" :class="data.type == 'group' ? 'group-item' : 'image-item'">
  30. <!-- <div class="line"></div> -->
  31. <div class="tree-info">
  32. <div v-if="data.type == 'group'" class="group-info">
  33. <i v-if="data.type == 'group' && !expandedNodes.includes(data.id)" class="iconfont icon-editor_folder_off folder_collapsed"></i>
  34. <!-- 拖拽图标 -->
  35. <i ref="drag-group" class="drag-icon iconfont icon-editor_folder_off folder_collapsed"></i>
  36. <i v-if="data.type == 'group' && expandedNodes.includes(data.id)" class="iconfont icon-editor_folder_on folder_expanded"></i>
  37. <span v-if="reNameId != data.id"> {{ data.name }}</span>
  38. <input
  39. ref="reNameInput"
  40. v-model.trim="data.name"
  41. @blur="onInputNewNameComplete(data)"
  42. v-if="reNameId == data.id"
  43. maxlength="50"
  44. :placeholder="$i18n.t('navigation.enter_name')"
  45. class="group-title-input"
  46. />
  47. <div v-if="reNameId != data.id && deleteId == null" class="controls-btn">
  48. <i v-if="data.type == 'group' && data.level == 0" class="iconfont icon-editor_list_add icon-add" @click.stop="addNode(data)" v-tooltip="$i18n.t('navigation.add_two_group')"> </i>
  49. <i
  50. v-if="(data.type == 'group' && data.children.length && data.children[0].type != 'group') || (data.type == 'group' && !data.children.length)"
  51. class="iconfont icon-editor_list_image icon-image"
  52. @click.stop="onRequestForAddScene(data)"
  53. v-tooltip="$i18n.t('navigation.add_pano_or_scene')"
  54. >
  55. </i>
  56. <i @click="onClickForRename(data)" class="iconfont icon-editor_list_edit icon-edit" v-tooltip="$i18n.t('navigation.rename')"> </i>
  57. <i class="iconfont icon-editor_list_delete icon-delete" v-tooltip="$i18n.t('navigation.delete')" @click.stop="onDel(node, data)"> </i>
  58. </div>
  59. </div>
  60. <div class="image-info" v-else>
  61. <div class="cover-image">
  62. <img ref="drag-image" :src="data.icon + ossImagePreviewUrlSuffix()" alt="" />
  63. </div>
  64. <div class="image-name">
  65. <div class="name-top">
  66. <span v-if="reNameId != data.id">{{ data.name }}</span>
  67. <input
  68. ref="reNameInput"
  69. v-if="reNameId == data.id"
  70. v-model.trim="inputData.name"
  71. @blur="onInputNewNameComplete(data)"
  72. maxlength="50"
  73. :placeholder="$i18n.t('navigation.enter_name')"
  74. class="group-title-input"
  75. />
  76. </div>
  77. <span class="name-bottom">
  78. {{ data.type === "pano" ? $i18n.t("navigation.pano") : $i18n.t("navigation.scene") }}
  79. </span>
  80. </div>
  81. <div v-if="reNameId != data.id && deleteId == null" class="controls-btn">
  82. <i @click="onClickForRename(data)" class="iconfont icon-editor_list_edit icon-edit" v-tooltip="$i18n.t('navigation.rename')"> </i>
  83. <i class="iconfont icon-editor_list_delete icon-delete" v-tooltip="$i18n.t('navigation.delete')" @click.stop="onDel(node, data)"> </i>
  84. </div>
  85. </div>
  86. </div>
  87. <div class="deletion-confirm-wrap">
  88. <div class="deletion-confirm" :class="deleteId == data.id ? 'show' : 'hide'" v-clickoutside="onRequestForCancelDelete" @click.stop="onConfirmDelete(node, data)">
  89. {{ $i18n.t("navigation.delete") }}
  90. </div>
  91. </div>
  92. <!-- <div class="controls-btn">
  93. <i v-if="data.type == 'group' && data.level == 0" class="iconfont icon-editor_list_add icon-add" @click.stop="addNode(data)" v-tooltip="$i18n.t('navigation.add_two_group')"> </i>
  94. <i
  95. v-if="(data.type == 'group' && data.children.length && data.children[0].type != 'group') || (data.type == 'group' && !data.children.length)"
  96. class="iconfont icon-editor_list_image icon-image"
  97. @click.stop="onRequestForAddScene(data)"
  98. v-tooltip="$i18n.t('navigation.add_pano_or_scene')"
  99. >
  100. </i>
  101. <i @click="onClickForRename(data)" class="iconfont icon-editor_list_edit icon-edit" v-tooltip="$i18n.t('navigation.rename')"> </i>
  102. <i class="iconfont icon-editor_list_delete icon-delete" v-tooltip="$i18n.t('navigation.delete')" @click.stop="() => remove(node, data)"> </i>
  103. </div> -->
  104. </div>
  105. </template>
  106. </el-tree>
  107. <!-- 选择全景图 or 场景 组件 -->
  108. <div class="dialog" style="z-index: 2000" v-if="isShowSelectionWindow">
  109. <MaterialSelector
  110. :title="$i18n.t('gather.select_material')"
  111. @cancel="isShowSelectionWindow = false"
  112. @submit="onSubmitFromMaterialSelector"
  113. :selectableType="['pano', '3D']"
  114. :initialMaterialType="'pano'"
  115. :isMultiSelection="true"
  116. />
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. // import { VueTreeList, Tree, TreeNode } from "vue-tree-list";
  122. import { mapGetters, mapMutations } from "vuex";
  123. import SceneInGroup from "@/components/sceneInGroupInEditor.vue";
  124. import MaterialSelector from "@/components/materialSelector.vue";
  125. import { isUpgradeAdapter } from "@/utils/fixVersion";
  126. import { ossImagePreviewUrlSuffix } from "@/utils/other.js";
  127. export default {
  128. components: {
  129. // VueTreeList,
  130. MaterialSelector,
  131. },
  132. computed: {
  133. ...mapGetters({
  134. info: "base/baseInfo",
  135. sceneList: "base/sceneList",
  136. currentScene: "scene/currentScene",
  137. currentSecondId: "navigation/currentSecondId",
  138. currentRootId: "navigation/currentRootId",
  139. }),
  140. },
  141. watch: {
  142. "info.navigationTrees": {
  143. // immediate: true,
  144. handler: function (newVal, oldVal) {
  145. if (newVal) {
  146. //赋值新数据后保存展开状态
  147. this.$nextTick(() => {
  148. this.newNodesMap = [];
  149. for (let key in this.$refs.sceneTree.store.nodesMap) {
  150. this.newNodesMap.push(this.$refs.sceneTree.store.nodesMap[key]);
  151. }
  152. this.nodesMap.forEach((item, index) => {
  153. this.newNodesMap.forEach((new_item, new_index) => {
  154. if (index == new_index) {
  155. new_item.expanded = item.expanded;
  156. }
  157. });
  158. });
  159. this.nodesMap = this.newNodesMap;
  160. });
  161. }
  162. },
  163. deep: true,
  164. },
  165. sceneList: {
  166. // immediate: true,
  167. handler: function (newVal, oldVal) {
  168. if (newVal) {
  169. if (this.info.firstScene) {
  170. if (!newVal.some((item) => item.id == this.info.firstScene.id)) {
  171. this.$store.commit("base/setData", { firstScene: null });
  172. }
  173. if (!newVal.some((item) => item.id == this.currentScene.id)) {
  174. this.$store.commit("scene/setCurrentScene", null);
  175. }
  176. }
  177. }
  178. },
  179. deep: true,
  180. },
  181. },
  182. data() {
  183. return {
  184. inputData: null,
  185. insertTag: null,
  186. isShowSelectionWindow: false,
  187. expandedNodes: [], // 用于存储已展开节点的数组
  188. nodesMap: [],
  189. newNodesMap: [],
  190. reNameId: null,
  191. backUpName: "",
  192. deleteId: null,
  193. timer: null,
  194. };
  195. },
  196. methods: {
  197. ossImagePreviewUrlSuffix,
  198. handleNodeExpand(data, node, instance) {
  199. console.log("节点展开", data);
  200. // 当节点展开时,将其id添加到数组中
  201. this.expandedNodes.push(data.id);
  202. console.error(this.expandedNodes);
  203. },
  204. handleNodeCollapse(data, node, instance) {
  205. console.log("节点折叠", data);
  206. // 当节点折叠时,从数组中移除其id
  207. const index = this.expandedNodes.indexOf(data.id);
  208. if (index !== -1) {
  209. this.expandedNodes.splice(index, 1);
  210. }
  211. console.error(this.expandedNodes);
  212. },
  213. handleDragStart(node, ev) {
  214. console.log("drag start", node);
  215. if (node.data.type == "group") {
  216. ev.dataTransfer.setDragImage(this.$refs["drag-group"], -10, -18);
  217. } else {
  218. ev.dataTransfer.setDragImage(this.$refs["drag-image"], -10, -18);
  219. }
  220. },
  221. handleDragEnter(draggingNode, dropNode, ev) {
  222. console.log("tree drag enter: ", dropNode);
  223. if (!this.timer) {
  224. if (dropNode.data.type == "group" && dropNode.data.children.length && !dropNode.expanded) {
  225. this.timer = setTimeout(() => {
  226. console.error("可以展开");
  227. dropNode.expanded = true;
  228. this.clearTimer();
  229. }, 1000);
  230. }
  231. }
  232. },
  233. clearTimer() {
  234. clearTimeout(this.timer);
  235. this.timer = null;
  236. },
  237. handleDragLeave(draggingNode, dropNode, ev) {
  238. this.clearTimer();
  239. // if (dropNode.expanded) {
  240. // dropNode.expanded = false;
  241. // }
  242. // console.log("tree drag leave: ", dropNode.data.type);
  243. },
  244. handleDragOver(draggingNode, dropNode, ev) {
  245. // console.log("tree drag over: ", dropNode.data.type);
  246. },
  247. handleDragEnd(draggingNode, dropNode, dropType, ev) {
  248. // console.log("tree drag end: ", dropNode && dropNode.data.type, dropType);
  249. this.clearTimer();
  250. this.processTreeData("drag");
  251. },
  252. handleDrop(draggingNode, dropNode, dropType, ev) {
  253. // console.log("tree drop: ", dropNode.data.type, dropType);
  254. return false;
  255. },
  256. allowDrop(draggingNode, dropNode, type) {
  257. if (draggingNode.data.type != "group") {
  258. //拖拽场景
  259. if (dropNode.level == 1) {
  260. //不允许拖拽到第一层级
  261. if (!dropNode.data.children.length || (dropNode.data.children.length && dropNode.data.children[0].type != "group")) {
  262. return type == "inner";
  263. } else {
  264. return false;
  265. }
  266. } else if (dropNode.level == 2) {
  267. //不允许拖拽到和目录同级
  268. if (dropNode.data.type == "group") {
  269. return type == "inner";
  270. }
  271. }
  272. return type == "prev" || type == "next";
  273. } else {
  274. //拖拽组
  275. if (draggingNode.level == 2 || draggingNode.level == 1) {
  276. //当拖拽的是第一第二级目录的时候,只能拖拽到第二级目录的前后,不能拖拽到2级目录的里面
  277. if (dropNode.level == 3) {
  278. return false;
  279. }
  280. if (dropNode.level == 2) {
  281. if (dropNode.data.type != "group") {
  282. if (dropNode.parent.data.children.length && dropNode.parent.data.children[0].type != "group") {
  283. return type == "prev" || type == "next";
  284. } else {
  285. return false;
  286. }
  287. } else {
  288. return type == "prev" || type == "next";
  289. }
  290. } else if (dropNode.level == 1) {
  291. return type == "prev" || type == "next" || type == "inner";
  292. }
  293. }
  294. }
  295. },
  296. allowDrag(draggingNode) {
  297. // console.error(draggingNode.data.name)
  298. // return draggingNode.data.name.indexOf("三级 3-2-2") === -1;
  299. return true;
  300. },
  301. handlerGroup(data, note, e) {
  302. if (data.type == "group") {
  303. // if (data.children.length) {
  304. this.$refs.sceneTree.store.nodesMap[data.id].expanded = !this.$refs.sceneTree.store.nodesMap[data.id].expanded;
  305. if (this.$refs.sceneTree.store.nodesMap[data.id].expanded) {
  306. this.handleNodeExpand(data);
  307. } else {
  308. this.handleNodeCollapse(data);
  309. }
  310. // }
  311. }
  312. },
  313. onRequestForAddScene(item) {
  314. this.insertTag = item;
  315. this.isShowSelectionWindow = true;
  316. },
  317. onSubmitFromMaterialSelector(selected) {
  318. console.error(this.insertTag);
  319. let changeListLength = this.insertTag.children.length || 0;
  320. let newScenes = [];
  321. let roundId = new Date().getTime();
  322. for (const item of selected) {
  323. roundId += 1;
  324. if (item.materialType === "pano") {
  325. newScenes.push({
  326. children: [],
  327. fodderId: item.id,
  328. icon: item.icon,
  329. sceneCode: item.sceneCode,
  330. name: item.name,
  331. // category: this.level === 1 ? this.groupNode.children[0].id : this.groupNode.id,
  332. type: "pano",
  333. sort: changeListLength,
  334. parentId: null,
  335. level: this.insertTag.level + 1,
  336. id: "add_" + roundId,
  337. // id: "s_" + this.$randomWord(true, 8, 8),
  338. });
  339. } else if (item.materialType === "3D") {
  340. console.log("item.num", item.num);
  341. newScenes.push({
  342. children: [],
  343. icon: item.thumb,
  344. sceneCode: item.num,
  345. name: item.sceneName,
  346. sort: changeListLength,
  347. // category: this.level === 1 ? this.groupNode.children[0].id : this.groupNode.id,
  348. type: "4dkk",
  349. level: this.insertTag.level + 1,
  350. version: isUpgradeAdapter(item.isUpgrade), // 'V3' OR 'V4'. 全景看看v1.3新增
  351. id: "add_" + roundId,
  352. // id: "s_" + this.$randomWord(true, 8, 8),
  353. // fodderId: item.id,
  354. });
  355. }
  356. changeListLength++;
  357. }
  358. console.error(newScenes);
  359. console.error(this.sceneList);
  360. let allSuccess = true;
  361. newScenes.forEach((item, i) => {
  362. // let temp = this.info.scenes.find((eachScene) => {
  363. let temp = this.sceneList.find((eachScene) => {
  364. return eachScene.sceneCode === item.sceneCode;
  365. });
  366. if (temp) {
  367. setTimeout(() => {
  368. this.$msg.message(
  369. `${item.type == "4dkk" ? this.$i18n.t("navigation.scene_name") : this.$i18n.t("navigation.pano")}${this.$i18n.t("navigation.already_exists", {
  370. msg: item.sceneTitle,
  371. })}`
  372. );
  373. }, i * 100);
  374. allSuccess = false;
  375. return;
  376. }
  377. // this.info.scenes.push(item);
  378. this.insertTag.children.push(item);
  379. });
  380. this.isShowSelectionWindow = false;
  381. if (allSuccess) {
  382. this.handlerGroup(this.insertTag);
  383. this.$msg.success(this.$i18n.t("gather.success"));
  384. }
  385. },
  386. onClickForRename(data) {
  387. // this.isRenaming = true;
  388. this.inputData = data;
  389. this.backUpName = data.name;
  390. this.reNameId = data.id;
  391. if (this.inputData.name == "默认二级分组") {
  392. this.inputData.name = this.$i18n.t("navigation.default_group_two");
  393. } else if (this.inputData.name == "一级分组") {
  394. this.inputData.name = this.$i18n.t("navigation.group_one");
  395. } else {
  396. // this.inputData .name = data.name;
  397. }
  398. this.$nextTick(() => {
  399. this.$refs.reNameInput.focus();
  400. });
  401. // this.$nextTick(() => {
  402. // // this.$refs['input-for-rename'].focus()
  403. // this.$refs["input-for-rename"].select();
  404. // this.$refs["input-for-rename"].scrollIntoView({
  405. // behavior: "smooth",
  406. // });
  407. // });
  408. },
  409. onInputNewNameComplete(data) {
  410. console.error(data.name);
  411. if (this.inputData.name.trim() == "") {
  412. // data.name = this.backUpName;
  413. // data.name = data.name;
  414. this.reNameId = null;
  415. return;
  416. }
  417. data.name = this.inputData.name;
  418. this.reNameId = null;
  419. // this.isRenaming = false;
  420. // if (!this.inputData.name.trim()) {
  421. // return;
  422. // }
  423. // if (this.inputData.name !== this.groupNode.name) {
  424. // // this.$emit("renameGroup", this.groupNode.id, this.level, this.newName);
  425. // }
  426. // this.inputData = null;
  427. },
  428. onDel(node, data) {
  429. this.deleteId = data.id;
  430. },
  431. onRequestForCancelDelete() {
  432. this.deleteId = null;
  433. },
  434. onConfirmDelete(node, data) {
  435. // this.$emit("delete", this.sceneInfo.id);
  436. // this.isConfirmingDeletion = false;
  437. this.onRequestForCancelDelete();
  438. if (this.sceneList.length == 1 && data.type != "group") {
  439. this.$alert({
  440. title: this.$i18n.t("navigation.delete_init_scene"),
  441. content: this.$i18n.t("navigation.keep_one_scene"),
  442. });
  443. return;
  444. }
  445. console.error(node, data);
  446. if (this.info.navigationTrees.length == 1 && node.level == 1) {
  447. this.$alert({
  448. content: this.$i18n.t("navigation.keep_one_group"),
  449. });
  450. return;
  451. }
  452. if ((node.level == 1 || node.level == 2) && data.type == "group") {
  453. let delScenes = [];
  454. this.info.navigationTrees.forEach((item) => {
  455. item.children.forEach((s_item) => {
  456. if (s_item.type != "group" && (item.id == node.data.id || s_item.id == node.data.id)) {
  457. delScenes.push(s_item);
  458. }
  459. s_item.children.forEach((t_item) => {
  460. if (t_item.type != "group" && (item.id == node.data.id || s_item.id == node.data.id)) {
  461. delScenes.push(t_item);
  462. }
  463. });
  464. });
  465. });
  466. if (delScenes.length >= this.sceneList.length) {
  467. //如果要删除的场景大于等于 当前场景数量,则弹出提示 至少保留一个
  468. this.$alert({
  469. title: this.$i18n.t("navigation.delete_init_scene"),
  470. content: this.$i18n.t("navigation.keep_one_scene"),
  471. });
  472. return;
  473. }
  474. }
  475. const parent = node.parent;
  476. const children = parent.data.children || parent.data;
  477. const index = children.findIndex((d) => d.id === data.id);
  478. children.splice(index, 1);
  479. this.processTreeData("del");
  480. // if (parent.data.children.length == 1 && parent.data.children[0].type == "group") {
  481. // let newChild = children[0].children;
  482. // parent.data.children = newChild;
  483. // }
  484. // console.error(this.info.navigationTrees);
  485. },
  486. addNode(data) {
  487. let roundId = new Date().getTime();
  488. let group = {
  489. id: "add_" + roundId,
  490. name: data ? this.$i18n.t("navigation.group_two") : this.$i18n.t("navigation.group_one"),
  491. type: "group",
  492. level: data ? 1 : 0,
  493. children: [],
  494. };
  495. if (data) {
  496. // if (data.children.length && data.children[0].type != "group") {
  497. // //新增子目录的时候,如果目录里面没有子目录,新增一个默认目录包含旧数据
  498. // let list = JSON.parse(JSON.stringify(data.children));
  499. // data.children = [];
  500. // let defaultDir = {
  501. // id: "add_" + (roundId + 1),
  502. // sort: 0,
  503. // name: this.$i18n.t("navigation.default_group_two"),
  504. // type: "group",
  505. // children: list,
  506. // };
  507. // data.children.push(defaultDir);
  508. // }
  509. data.children.push(group);
  510. this.$refs.sceneTree.store.nodesMap[data.id].expanded = true;
  511. } else {
  512. this.info.navigationTrees.push(group);
  513. }
  514. this.processTreeData("add");
  515. this.$nextTick(() => {
  516. this.onClickForRename(group);
  517. });
  518. },
  519. getRoundId() {
  520. return new Date().getTime();
  521. },
  522. processTreeData(type) {
  523. this.info.navigationTrees.forEach((item) => {
  524. //一级目录
  525. let panoList = item.children.filter((pano) => pano.type != "group");
  526. let groupList = item.children.filter((pano) => pano.type == "group");
  527. switch (type) {
  528. case "add":
  529. if (panoList.length && groupList.length) {
  530. //新增目录到二级目录。且二级目录只有场景的时候
  531. console.error("add");
  532. let list = [];
  533. let defaultDir = {
  534. id: "add_" + (this.getRoundId() + 1),
  535. sort: 0,
  536. name: this.$i18n.t("navigation.default_group_two"),
  537. type: "group",
  538. children: panoList,
  539. };
  540. list.push(defaultDir);
  541. list = list.concat(groupList);
  542. item.children = list;
  543. }
  544. if (item.children.length == 1 && item.type == "group" && !item.children[0].children.length) {
  545. //新增二级目录的时候,如果新增完只有一个二级目录,且二级目录为空,创建多一个目录,且第一个为默认二级目录
  546. let list = [];
  547. let defaultDir = {
  548. id: "add_" + (this.getRoundId() + 1),
  549. sort: 0,
  550. name: this.$i18n.t("navigation.default_group_two"),
  551. type: "group",
  552. children: [],
  553. };
  554. list.push(defaultDir);
  555. list = list.concat(groupList);
  556. item.children = list;
  557. }
  558. break;
  559. case "del":
  560. if (groupList.length == 1 && !panoList.length && groupList[0].children.length) {
  561. //当只有一个二级目录,二级目录有场景
  562. item.children = groupList[0].children;
  563. }
  564. if (groupList.length == 1 && !groupList[0].children.length) {
  565. //当只有一个二级目录,二级目录没有场景
  566. item.children = [];
  567. }
  568. break;
  569. case "drag":
  570. if (panoList.length && groupList.length) {
  571. //新增目录到二级目录。且二级目录只有场景的时候
  572. console.error("drag");
  573. let list = [];
  574. let defaultDir = {
  575. id: "add_" + (this.getRoundId() + 1),
  576. sort: 0,
  577. name: this.$i18n.t("navigation.default_group_two"),
  578. type: "group",
  579. children: panoList,
  580. };
  581. list.push(defaultDir);
  582. list = list.concat(groupList);
  583. item.children = list;
  584. console.error(item.children);
  585. break;
  586. }
  587. }
  588. // if (item.id == this.currentRootId) {
  589. // console.error(groupList);
  590. // if (groupList.length) {
  591. // let index = groupList.findIndex((pano) => pano.children.length);
  592. // this.$store.commit("navigation/setData", { currentSecondId: groupList[index].id });
  593. // } else {
  594. // this.$store.commit("navigation/setData", { currentSecondId: null });
  595. // }
  596. // // let currentSecondId = item.children.find((group) => group.id == this.currentSecondId);
  597. // // console.error("currentSecondId", currentSecondId);
  598. // }
  599. });
  600. },
  601. },
  602. created() {},
  603. };
  604. </script>
  605. <style lang="less" rel="stylesheet/less" scoped>
  606. .vtl {
  607. // .vtl-drag-disabled {
  608. // background-color: #d0cfcf;
  609. // &:hover {
  610. // background-color: #d0cfcf;
  611. // }
  612. // }
  613. // .vtl-disabled {
  614. // background-color: #d0cfcf;
  615. // }
  616. }
  617. </style>
  618. <style lang="less" rel="stylesheet/less" scoped>
  619. .icon {
  620. &:hover {
  621. cursor: pointer;
  622. }
  623. }
  624. .el-tree {
  625. background: none !important;
  626. color: hsla(0, 0%, 100%, 0.6);
  627. // .folder_expanded {
  628. // display: none;
  629. // }
  630. // .is-expanded {
  631. // .folder_collapsed {
  632. // display: none;
  633. // }
  634. // .folder_expanded {
  635. // display: inline-block;
  636. // }
  637. // }
  638. .tree-msg {
  639. width: calc(100% - 24px);
  640. // min-height: 40px;
  641. color: hsla(0, 0%, 100%, 0.6);
  642. // display: flex;
  643. // align-items: center;
  644. // justify-content: space-between;
  645. padding-right: 10px;
  646. .tree-info {
  647. // display: flex;
  648. // align-items: center;
  649. // justify-content: flex-start;
  650. height: 100%;
  651. // height: 40px;
  652. // flex: 1;
  653. .group-info {
  654. display: flex;
  655. align-items: center;
  656. justify-content: flex-start;
  657. flex: 1;
  658. height: 100%;
  659. position: relative;
  660. .drag-icon {
  661. position: absolute;
  662. width: 40px;
  663. height: 40px;
  664. background: #313131;
  665. box-shadow: 0 0 4px 0 rgb(0 0 0 / 50%);
  666. border-radius: 4px;
  667. display: flex;
  668. justify-content: center;
  669. align-items: center;
  670. z-index: -1;
  671. }
  672. span {
  673. margin-left: 6px;
  674. display: inline-block;
  675. text-overflow: ellipsis;
  676. overflow: hidden;
  677. white-space: nowrap;
  678. flex: 1 1 auto;
  679. }
  680. }
  681. }
  682. .image-info {
  683. display: flex;
  684. align-items: center;
  685. // padding: 10px 0;
  686. height: 64px;
  687. // flex: 1;
  688. width: 100%;
  689. .cover-image {
  690. flex: 0 0 auto;
  691. width: 64px;
  692. height: 64px;
  693. background: #b0b0b0;
  694. border-radius: 2px;
  695. background-size: cover;
  696. img {
  697. width: 100%;
  698. height: 100%;
  699. pointer-events: none;
  700. object-fit: cover;
  701. }
  702. }
  703. .image-name {
  704. margin-left: 10px;
  705. width: calc(100% - 74px);
  706. flex: 1 1 auto;
  707. display: flex;
  708. flex-direction: column;
  709. justify-content: space-between;
  710. height: 100%;
  711. flex: 1;
  712. .name-top {
  713. width: 100%;
  714. span {
  715. width: 100%;
  716. word-break: break-all;
  717. display: -webkit-box;
  718. -webkit-box-orient: vertical;
  719. -webkit-line-clamp: 2;
  720. overflow: hidden;
  721. font-size: 14px;
  722. color: hsla(0, 0%, 100%, 0.6);
  723. white-space: normal;
  724. }
  725. }
  726. .name-bottom {
  727. color: #0076f6;
  728. }
  729. }
  730. .group-title-input {
  731. width: 100%;
  732. margin-left: 0;
  733. }
  734. }
  735. .group-title-input {
  736. margin-left: 6px;
  737. flex: 1 1 auto;
  738. width: 1px;
  739. height: 30px;
  740. background: #1a1b1d;
  741. border-radius: 2px;
  742. border: 1px solid #404040;
  743. color: #fff;
  744. font-size: 14px;
  745. padding: 0 10px 0 16px;
  746. &:focus {
  747. border-color: #0076f6;
  748. }
  749. }
  750. .deletion-confirm-wrap {
  751. position: absolute;
  752. top: 0;
  753. bottom: 0;
  754. right: 0;
  755. width: 44px;
  756. overflow: hidden;
  757. pointer-events: none;
  758. border-top-right-radius: 4px;
  759. border-bottom-right-radius: 4px;
  760. > .deletion-confirm {
  761. position: absolute;
  762. top: 0;
  763. bottom: 0;
  764. width: 100%;
  765. background: #fa5555;
  766. transition: right 0.3s;
  767. cursor: pointer;
  768. text-align: center;
  769. font-size: 12px;
  770. color: #fff;
  771. pointer-events: auto;
  772. &::after {
  773. content: "";
  774. height: 100%;
  775. vertical-align: middle;
  776. display: inline-block;
  777. }
  778. &.show {
  779. right: 0;
  780. }
  781. &.hide {
  782. right: -44px;
  783. }
  784. }
  785. }
  786. .controls-btn {
  787. display: none;
  788. > i {
  789. margin-left: 12px;
  790. &.iconfont {
  791. &:hover {
  792. color: #0076f6;
  793. }
  794. }
  795. }
  796. }
  797. &.image-item {
  798. .controls-btn {
  799. position: absolute;
  800. right: 10px;
  801. bottom: 8px;
  802. }
  803. .tree-info {
  804. display: flex;
  805. align-items: center;
  806. justify-content: flex-start;
  807. width: 100%;
  808. }
  809. }
  810. }
  811. }
  812. </style>
  813. <style lang="less">
  814. .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  815. background: none !important;
  816. }
  817. .el-tree-node:focus > .el-tree-node__content {
  818. background: none !important;
  819. }
  820. .el-tree-node:focus > .el-tree-node__content:hover {
  821. background: #313131 !important;
  822. }
  823. .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content:hover {
  824. background: #313131 !important;
  825. }
  826. .el-tree-node__content:hover,
  827. .el-upload-list__item:hover {
  828. background: #313131;
  829. }
  830. .el-tree-node > .el-tree-node__children {
  831. overflow: inherit;
  832. }
  833. .el-tree-node__content {
  834. // height: 60px;
  835. height: auto;
  836. // padding: 10px 0;
  837. border-radius: 4px;
  838. }
  839. .el-tree-node__content {
  840. // padding-left: 30px !important;
  841. position: relative;
  842. &::before {
  843. content: "";
  844. width: 24px;
  845. height: 24px;
  846. display: inline-block;
  847. }
  848. &:hover {
  849. .controls-btn {
  850. display: block !important;
  851. }
  852. }
  853. }
  854. .custom-tree .el-tree__drop-indicator {
  855. // display: none
  856. // margin-top: -25px; /* 修改间距为10px */
  857. // margin-bottom: 10px; /* 修改间距为10px */
  858. }
  859. .el-tree-node__expand-icon {
  860. // height: 44px;
  861. display: flex;
  862. align-items: center;
  863. margin-right: 5px;
  864. }
  865. // .el-tree-node__expand-icon:hover {
  866. // background: red;
  867. // }
  868. // .el-tree-node__content{
  869. // background: red;
  870. // }
  871. .el-tree-node__content .el-tree-node__expand-icon {
  872. position: absolute;
  873. height: 100%;
  874. // left: 6px;
  875. }
  876. .el-tree-node__content .el-tree-node__expand-icon:first-child + .group-item {
  877. height: 44px;
  878. }
  879. .el-tree-node__content .el-tree-node__expand-icon:first-child + .image-item {
  880. height: 80px;
  881. }
  882. </style>