index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <template>
  2. <!-- todo: 哪里用到了? -->
  3. <div class="editor-navigation">
  4. <GroupSettings
  5. class="group-settings-area"
  6. @catalog="data=>activeCataLog = data"
  7. @addPano="onAddPano"
  8. @addGroup="onAddGroup"
  9. @addScene="onAddScene"
  10. @rename="onRename"
  11. />
  12. <div class="preview-area"></div>
  13. <InitialSceneSettings class="initial-scene-settings-area" @select="handleInitScene"></InitialSceneSettings>
  14. <popup v-show="showAddGroup" :can-close="false">
  15. <div class="ui-message ui-message-confirm dark" style="width: 400px">
  16. <div class="ui-message-header">
  17. <span>{{
  18. currentTabAtri.oper == "add"
  19. ? `新增${currentTabAtri.type == 1 ? "一" : "二"}级分组`
  20. : `重命名${currentTabAtri.type == 1 ? "一" : "二"}级分组`
  21. }}</span>
  22. <span @click="showAddGroup = false">
  23. <i class="iconfont icon_close"></i>
  24. </span>
  25. </div>
  26. <div class="ui-message-main re-name">
  27. <div>
  28. <input
  29. class="ui-input"
  30. type="text"
  31. maxlength="15"
  32. placeholder="请输入分组名,限15个字"
  33. v-model="currentTabAtri.name"
  34. />
  35. </div>
  36. </div>
  37. <div class="ui-message-footer">
  38. <button class="ui-button cancel" @click="showAddGroup = false">
  39. 取消
  40. </button>
  41. <button
  42. class="ui-button submit"
  43. :class="{ disable: !currentTabAtri.name }"
  44. @click="handleAddGroup()"
  45. >
  46. 确定
  47. </button>
  48. </div>
  49. </div>
  50. </popup>
  51. <popup v-show="showRename" :can-close="false">
  52. <div class="ui-message ui-message-confirm dark" style="width: 400px">
  53. <div class="ui-message-header">
  54. <span>重命名</span>
  55. <span @click="handleRenameClose">
  56. <i class="iconfont icon_close"></i>
  57. </span>
  58. </div>
  59. <div class="ui-message-main re-name">
  60. <div>
  61. <input
  62. class="ui-input"
  63. type="text"
  64. maxlength="50"
  65. placeholder="输入名字"
  66. v-model="reNameItem.sceneTitle"
  67. />
  68. </div>
  69. </div>
  70. <div class="ui-message-footer">
  71. <button class="ui-button cancel" @click="handleRenameClose">
  72. 取消
  73. </button>
  74. <button
  75. class="ui-button submit"
  76. :class="{ disable: !reNameItem.sceneTitle }"
  77. @click="handleRename()"
  78. >
  79. 确定
  80. </button>
  81. </div>
  82. </div>
  83. </popup>
  84. <div class="dialog" style="z-index: 2000" v-if="showList">
  85. <Table
  86. :list="type == 'scene' ? sceneList : panoList"
  87. :tabHeader="$MAPTABLEHEADER[type]"
  88. @updateList="update"
  89. @cancle="showList = false"
  90. :title="type == 'scene' ? '选择三维场景' : '选择全景图'"
  91. :primaryKey="type == 'scene' ? 'num' : 'id'"
  92. @changeCurrent="changeCurrent"
  93. :paging="paging"
  94. @submit="handleSelect"
  95. >
  96. </Table>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. import InitialSceneSettings from "./initialSceneSettings.vue";
  102. import GroupSettings from "./groupSettings";
  103. import Popup from "@/components/shared/popup/index.vue";
  104. import {
  105. getSceneList,
  106. getMaterialList,
  107. } from "@/api";
  108. import Table from "@/components/tableSelect.vue";
  109. import { mapGetters } from "vuex";
  110. import { savePanoToWorks } from "@/api";
  111. import { changeByteUnit } from '@/utils/file'
  112. export default {
  113. name: "EditorNavigation",
  114. components: {
  115. InitialSceneSettings,
  116. GroupSettings,
  117. Popup,
  118. Table,
  119. },
  120. computed: {
  121. ...mapGetters({
  122. sceneList: "sceneList",
  123. info: "info",
  124. backupInfo: "backupInfo"
  125. }),
  126. },
  127. data() {
  128. return {
  129. activeCataLog: "",
  130. type: "scene",
  131. currentTabAtri: "",
  132. showAddGroup: false,
  133. showRename: false,
  134. showList: false,
  135. showInitScene: true,
  136. reNameItem: {
  137. id: "",
  138. sceneTitle: "",
  139. },
  140. key: "",
  141. paging: {
  142. pageSize: 8,
  143. pageNum: 1,
  144. total: 0,
  145. showSize: 4,
  146. current: 1,
  147. },
  148. panoList: [],
  149. };
  150. },
  151. mounted() {},
  152. watch: {
  153. "paging.pageNum": function () {
  154. this.type == "scene" ? this.getSceneList() : this.getMaterialList();
  155. },
  156. showList(newVal) {
  157. if (!newVal) {
  158. this.paging = {
  159. pageSize: 8,
  160. pageNum: 1,
  161. total: 0,
  162. showSize: 4,
  163. current: 1,
  164. };
  165. }
  166. },
  167. },
  168. methods: {
  169. handleInitScene() {
  170. this.showInitScene = true;
  171. },
  172. update(data) {
  173. this.key = data;
  174. this.type == "scene" ? this.getSceneList() : this.getMaterialList();
  175. },
  176. handleSelect(data) {
  177. let params = ''
  178. if (this.type == "scene") {
  179. params = data.map((item) => {
  180. return {
  181. icon: item.thumb,
  182. sceneCode: item.num,
  183. sceneTitle: item.sceneName,
  184. type: "4dkk",
  185. category:this.activeCataLog.id,
  186. id:'s_'+this.$randomWord(true,8,8)
  187. };
  188. });
  189. } else {
  190. params = data.map((item) => {
  191. return {
  192. icon: item.icon,
  193. sceneCode: item.sceneCode,
  194. sceneTitle: item.name,
  195. category:this.activeCataLog.id,
  196. type: "pano",
  197. id:'s_'+this.$randomWord(true,8,8)
  198. };
  199. });
  200. }
  201. params.forEach((item,i) => {
  202. let temp = this.info.scenes.find(sub=>sub.sceneCode == item.sceneCode)
  203. if (temp) {
  204. console.log(this.$msg);
  205. setTimeout(() => {
  206. this.$msg.message(`${item.type=='4dkk'?'场景':'全景图'}${item.sceneTitle}已存在,不可重复添加`);
  207. }, i*100);
  208. return
  209. }
  210. !temp&&this.info.scenes.push(item)
  211. });
  212. this.$bus.emit('scenesChange')
  213. this.$store.commit("SetInfo", this.info);
  214. this.showList = false;
  215. },
  216. changeCurrent(data) {
  217. this.paging.pageNum = data;
  218. },
  219. savePanoToWorks(data) {
  220. savePanoToWorks(data, () => {
  221. this.$bus.emit("refresh");
  222. });
  223. },
  224. onRename(data) {
  225. this.reNameItem = data;
  226. this.showRename = true;
  227. },
  228. handleRenameClose(){
  229. this.showRename = false
  230. this.$bus.emit('scenesChange')
  231. this.$store.commit("SetInfo", this.backupInfo);
  232. },
  233. handleRename() {
  234. if (!this.reNameItem.sceneTitle.trim()) {
  235. return this.$alert({ content: "请输入名字" });
  236. }
  237. this.$msg.success("重命名成功")
  238. this.$store.commit("SetInfo", this.info);
  239. this.showRename = false;
  240. },
  241. onAddGroup(data) {
  242. this.showAddGroup = true;
  243. this.currentTabAtri = { ...data, name: data.item.name || "" };
  244. },
  245. handleAddGroup() {
  246. if (!this.currentTabAtri.name.trim()) {
  247. return this.$alert({ content: "请输入名字" });
  248. }
  249. let willActive = ''
  250. let tmp = this.currentTabAtri.item;
  251. if (this.currentTabAtri.oper == "edit") {
  252. tmp.name = this.currentTabAtri.name;
  253. } else {
  254. if (this.currentTabAtri.type == 1) {
  255. let id = 'c_'+this.$randomWord(true,8,8)
  256. willActive = {
  257. id: 'r_'+this.$randomWord(true,8,8),
  258. name: this.currentTabAtri.name,
  259. children: [id],
  260. }
  261. this.info.catalogRoot.push(willActive);
  262. this.info.catalogs.push({
  263. id,
  264. name: '默认二级分组',
  265. });
  266. console.log(this.info.catalogs);
  267. }
  268. if (this.currentTabAtri.type == 2) {
  269. let id = 'c_'+this.$randomWord(true,8,8)
  270. let item = this.info.catalogRoot.find(
  271. (item) => item.id == tmp.parentId
  272. );
  273. item.children.push(id);
  274. willActive = {
  275. id,
  276. name: this.currentTabAtri.name,
  277. }
  278. this.info.catalogs.push(willActive);
  279. }
  280. }
  281. this.$bus.emit('scenesChange')
  282. this.$store.commit("SetInfo", this.info);
  283. this.$msg.success("操作成功")
  284. this.showAddGroup = false;
  285. if (this.currentTabAtri.oper != "edit") {
  286. this.$bus.emit('getActive',{
  287. type:this.currentTabAtri.type,
  288. willActive
  289. })
  290. }
  291. },
  292. onAddScene() {
  293. this.type = "scene";
  294. this.getSceneList();
  295. this.showList = true;
  296. },
  297. onAddPano() {
  298. this.type = "pano";
  299. this.getMaterialList();
  300. this.showList = true;
  301. },
  302. getSceneList() {
  303. getSceneList(
  304. {
  305. pageNum: this.paging.pageNum,
  306. pageSize: this.paging.pageSize,
  307. searchKey: this.key,
  308. },
  309. (data) => {
  310. let { list, total } = data.data.data;
  311. this.paging.total = total;
  312. this.$store.commit("SetSceneList", list);
  313. }
  314. );
  315. },
  316. getMaterialList() {
  317. getMaterialList(
  318. {
  319. pageNum: this.paging.pageNum,
  320. pageSize: this.paging.pageSize,
  321. searchKey: this.key,
  322. type: this.type,
  323. urlSelect: true,
  324. },
  325. (data) => {
  326. this.paging.pageNum = data.data.pageNum;
  327. this.paging.pageSize = data.data.pageSize;
  328. this.paging.total = data.data.total;
  329. this.panoList = data.data.list.map(i=>{
  330. i.fileSize = changeByteUnit(Number(i.fileSize))
  331. i.createTime = i.createTime.substring(0,i.createTime.length-3)
  332. i.updateTime = i.updateTime.substring(0,i.updateTime.length-3)
  333. return i
  334. })
  335. }
  336. );
  337. },
  338. },
  339. };
  340. </script>
  341. <style lang="less" scoped>
  342. .editor-navigation {
  343. height: 100%;
  344. display: flex;
  345. .group-settings-area {
  346. width: 300px;
  347. flex: 0 0 auto;
  348. }
  349. .preview-area {
  350. background: red;
  351. flex: 1 0 auto;
  352. }
  353. .initial-scene-settings-area {
  354. width: 274px;
  355. flex: 0 0 auto;
  356. }
  357. .dialog {
  358. position: fixed;
  359. z-index: 30;
  360. left: 0;
  361. top: 0;
  362. width: 100%;
  363. height: 100%;
  364. background-color: rgba(0, 0, 0, 0.5);
  365. }
  366. .pano-con {
  367. height: auto;
  368. background: none;
  369. padding: 10px 0;
  370. .ui-remark {
  371. padding-left: 10px;
  372. }
  373. > ul {
  374. > li {
  375. cursor: pointer;
  376. }
  377. }
  378. }
  379. .re-name {
  380. width: 80%;
  381. margin: 40px auto;
  382. }
  383. .add-vr {
  384. text-align: left;
  385. .ui-remark {
  386. margin: 10px 0;
  387. }
  388. }
  389. }
  390. </style>