index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <template>
  2. <div>
  3. <setting @select="handleShow"></setting>
  4. <toolbar @addVR="handleAddvr" @rename="onRename"></toolbar>
  5. <div class="dialog" v-if="show">
  6. <Select
  7. @updateList="updateScene"
  8. :panos="list"
  9. :current="activeItem"
  10. @cancle="show = false"
  11. :title="'选择场景'"
  12. :name="'scene'"
  13. @submit="handelSelect"
  14. >
  15. <template slot="list" slot-scope="{ data }">
  16. <div class="pano-con">
  17. <div class="ui-remark">{{ data.name }}</div>
  18. <ul>
  19. <li
  20. v-for="(item, i) in data.arr"
  21. @click="activeItem = item"
  22. :class="{ 'li-active': item.id == activeItem.id }"
  23. :key="i"
  24. >
  25. <div class="typeli">
  26. <i
  27. class="iconfont iconscene_map_3d"
  28. :class="{ iconjump: item.type !== 'house' }"
  29. ></i>
  30. </div>
  31. <div class="img">
  32. <img :src="item.icon" alt="">
  33. </div>
  34. <div class="ui-title">
  35. <span>{{item.type=='house'?item.roomName:item.sceneTitle}}</span>
  36. </div>
  37. </li>
  38. </ul>
  39. </div>
  40. </template>
  41. </Select>
  42. </div>
  43. <div class="dialog" style="z-index:2000" v-if="huxingshow">
  44. <Select
  45. :houseList="houseList"
  46. @updateList="updateHX"
  47. @cancle="huxingshow = false"
  48. :title="'选择VR模型'"
  49. :name="'table'"
  50. @changeCurrent="changeCurrent"
  51. :paging="paging"
  52. @submit="selectHX"
  53. >
  54. </Select>
  55. </div>
  56. <popup v-show="showRename" :can-close="false">
  57. <div class="ui-message ui-message-confirm dark" style="width: 400px">
  58. <div class="ui-message-header">
  59. <span>重命名</span>
  60. <span @click="showRename = false">
  61. <i class="iconfont icon_close"></i>
  62. </span>
  63. </div>
  64. <div class="ui-message-main re-name">
  65. <div>
  66. <input
  67. class="ui-input"
  68. type="text"
  69. maxlength="15"
  70. placeholder="输入名字"
  71. v-model="reNameItem.reName"
  72. />
  73. </div>
  74. </div>
  75. <div class="ui-message-footer">
  76. <button class="ui-button cancel" @click="showRename = false">
  77. 取消
  78. </button>
  79. <button :class="`ui-button submit`" @click="handleRename()">
  80. 确定
  81. </button>
  82. </div>
  83. </div>
  84. </popup>
  85. <popup v-show="showAddHouse" :can-close="false">
  86. <div class="ui-message ui-message-confirm dark" style="width: 400px">
  87. <div class="ui-message-header">
  88. <span>样板间户型</span>
  89. <span @click="showAddHouse = false">
  90. <i class="iconfont icon_close"></i>
  91. </span>
  92. </div>
  93. <div class="ui-message-main re-name add-vr">
  94. <div>
  95. <p class="ui-remark">样板间名称</p>
  96. <combox
  97. :data="houseNameList"
  98. :selected-index="houseActive"
  99. @change="onHouseChange"
  100. ></combox>
  101. </div>
  102. <div>
  103. <p class="ui-remark">VR模型</p>
  104. <div @click="huxingshow = true">
  105. <input
  106. class="ui-input"
  107. type="text"
  108. placeholder="请选择VR模型"
  109. v-model="huxing.sceneName"
  110. disabled
  111. />
  112. </div>
  113. </div>
  114. </div>
  115. <div class="ui-message-footer">
  116. <button class="ui-button cancel" @click="showAddHouse = false">
  117. 取消
  118. </button>
  119. <button :class="`ui-button submit`" @click="handleHouse()">
  120. 确定
  121. </button>
  122. </div>
  123. </div>
  124. </popup>
  125. </div>
  126. </template>
  127. <script>
  128. import Setting from "./Setting";
  129. import Toolbar from "./Toolbar";
  130. import Select from "@/components/select";
  131. import Popup from "@/components/shared/popup";
  132. import Combox from "@/components/shared/Combox";
  133. import {
  134. saveSomeData,
  135. getPanoList,
  136. getHouseNameList,
  137. getHouseList,
  138. saveHouse,
  139. } from "@/api";
  140. export default {
  141. name: "home",
  142. components: {
  143. Setting,
  144. Select,
  145. Toolbar,
  146. Popup,
  147. Combox,
  148. },
  149. data() {
  150. return {
  151. showRename: false,
  152. showAddHouse: false,
  153. activeItem: "",
  154. show: false,
  155. activeId: "",
  156. huxingshow: false,
  157. searchKey: "",
  158. hxsearchKey: "",
  159. house: "",
  160. houseNameList: [],
  161. houseActive: 0,
  162. houseDataActive: "",
  163. houseList: [],
  164. hasChange:false,
  165. huxing: {
  166. sceneName: "",
  167. roomId: "",
  168. },
  169. reNameItem: {
  170. id: "",
  171. reName: "",
  172. },
  173. currentId: "",
  174. list: [],
  175. paging: {
  176. pageSize: 8,
  177. pageNum: 1,
  178. total: 0,
  179. showSize: 8,
  180. current: 1,
  181. },
  182. };
  183. },
  184. mounted() {
  185. this.getPanoList();
  186. },
  187. watch: {
  188. activeId(newVal) {
  189. if (!newVal) {
  190. return;
  191. }
  192. let tmp = "";
  193. this.list.forEach((item) => {
  194. if (!tmp) {
  195. tmp = item.arr.find((i) => {
  196. return newVal == i.id;
  197. });
  198. }
  199. });
  200. this.activeItem = tmp;
  201. },
  202. "paging.pageNum": function() {
  203. this.getHouseList();
  204. },
  205. showAddHouse(newVal) {
  206. if (newVal) {
  207. getHouseNameList(
  208. {
  209. current: 1,
  210. size: 1000,
  211. },
  212. (res) => {
  213. this.houseNameList = res.data
  214. ? res.data.records
  215. : [];
  216. if (this.huxing.roomId) {
  217. this.houseActive = this.houseNameList.findIndex(
  218. (item) => this.huxing.roomId == item.id
  219. );
  220. }
  221. this.houseDataActive = this.houseNameList[this.houseActive];
  222. }
  223. );
  224. }
  225. },
  226. show(newVal) {
  227. if (newVal) {
  228. this.searchKey = "";
  229. this.getPanoList();
  230. }
  231. },
  232. huxingshow(newVal) {
  233. if (newVal) {
  234. this.hxsearchKey = "";
  235. this.paging.pageNum = 1;
  236. this.getHouseList();
  237. }
  238. },
  239. },
  240. methods: {
  241. updateHX(data){
  242. this.hxsearchKey = data
  243. this.getHouseList();
  244. },
  245. updateScene(data){
  246. this.searchKey = data
  247. this.getPanoList();
  248. },
  249. handleShow(data) {
  250. this.show = true;
  251. this.activeId = data;
  252. },
  253. changeCurrent(data) {
  254. this.paging.pageNum = data;
  255. },
  256. handleAddvr(data) {
  257. this.showAddHouse = true;
  258. this.currentId = "";
  259. this.huxing = {
  260. sceneName: "",
  261. roomId: "",
  262. };
  263. if (data) {
  264. this.huxing.roomId = data.roomId;
  265. this.huxing.sceneName = data.sceneTitle;
  266. this.huxing.id = data.vrModelId;
  267. this.huxing.webSite = data.webSite;
  268. this.huxing.num = data.sceneCode;
  269. this.currentId = data.id;
  270. }
  271. },
  272. getHouseList() {
  273. getHouseList(
  274. {
  275. pageNum: this.paging.pageNum,
  276. pageSize: this.paging.pageSize,
  277. searchKey: this.hxsearchKey,
  278. },
  279. (res) => {
  280. this.paging.pageNum = res.data.pageNum;
  281. this.paging.pageSize = res.data.pageSize;
  282. this.paging.total = res.data.total;
  283. this.houseList = res.data.list;
  284. }
  285. );
  286. },
  287. onHouseChange(data, index) {
  288. this.houseActive = index;
  289. this.houseDataActive = data;
  290. this.hasChange = true
  291. },
  292. onRename(data) {
  293. this.reNameItem.id = data.id;
  294. this.reNameItem.reName = data.sceneTitle;
  295. this.showRename = true;
  296. },
  297. handleRename() {
  298. if (!this.reNameItem) {
  299. return this.$alert({ content: "请输入名字" });
  300. }
  301. saveSomeData(
  302. {
  303. id: this.reNameItem.id,
  304. sceneTitle: this.reNameItem.reName,
  305. },
  306. () => {
  307. this.$tips({ content: "重命名成功", icon: "ok" });
  308. this.showRename = false;
  309. this.$bus.emit("refresh");
  310. }
  311. );
  312. },
  313. handleHouse() {
  314. if (!this.huxing.id||!(this.houseDataActive&&this.houseDataActive.id)) {
  315. return this.$alert({ content: "请选择样板间名称和VR模型" });
  316. }
  317. if (!this.hasChange) {
  318. return this.showAddHouse = false;
  319. }
  320. saveHouse(
  321. {
  322. icon: this.huxing.thumb,
  323. roomId: (this.houseDataActive&&this.houseDataActive.id),
  324. roomName: (this.houseDataActive&&this.houseDataActive.name),
  325. id: this.currentId || null,
  326. sceneTitle: this.huxing.sceneName,
  327. vrModelId: this.huxing.id,
  328. webSite: this.huxing.webSite,
  329. sceneCode: this.huxing.num,
  330. },
  331. (res) => {
  332. if (res.code == 0) {
  333. this.$tips({
  334. content: this.currentId ? "修改成功" : "添加成功",
  335. icon: "ok",
  336. });
  337. this.hasChange = false
  338. this.huxingshow = false;
  339. this.showAddHouse = false;
  340. this.$bus.emit("refresh");
  341. } else {
  342. return this.$alert({ content: res.msg });
  343. }
  344. }
  345. );
  346. },
  347. selectHX(data) {
  348. this.hasChange = true
  349. this.huxing = data;
  350. this.huxingshow = false;
  351. },
  352. handelSelect() {
  353. this.$bus.emit("updateParams", {
  354. id: this.activeItem.id,
  355. isIndex: 1,
  356. });
  357. this.$bus.emit('initScene',this.activeItem)
  358. this.$bus.emit("getInitScene", this.activeItem);
  359. this.show = false;
  360. },
  361. getPanoList() {
  362. getPanoList(
  363. {
  364. pageNum: 1,
  365. pageSize: 1000,
  366. searchKey: this.searchKey,
  367. status: 3,
  368. },
  369. (data) => {
  370. let tmp = {};
  371. data.data.list.forEach((item) => {
  372. if (!tmp[item.type]) {
  373. tmp[item.type] = [item];
  374. } else {
  375. tmp[item.type].push(item);
  376. }
  377. });
  378. let tt = [];
  379. Object.keys(tmp).forEach((item) => {
  380. tt.push({
  381. id: item,
  382. sort: this.$nameSort[item],
  383. name: this.$nameStr[item],
  384. arr: tmp[item],
  385. });
  386. });
  387. tt.sort((a, b) => {
  388. return a.sort - b.sort;
  389. });
  390. this.list = [...tt];
  391. }
  392. );
  393. },
  394. },
  395. };
  396. </script>
  397. <style lang="less" scoped>
  398. .dialog {
  399. position: fixed;
  400. z-index: 30;
  401. left: 0;
  402. top: 0;
  403. width: 100%;
  404. height: 100%;
  405. background-color: rgba(0, 0, 0, 0.5);
  406. }
  407. .pano-con {
  408. height: auto;
  409. background: none;
  410. padding: 10px 0;
  411. .ui-remark {
  412. padding-left: 10px;
  413. }
  414. > ul {
  415. > li {
  416. cursor: pointer;
  417. }
  418. }
  419. }
  420. .re-name {
  421. width: 80%;
  422. margin: 40px auto;
  423. }
  424. .add-vr {
  425. text-align: left;
  426. .ui-remark {
  427. margin: 10px 0;
  428. }
  429. }
  430. </style>