index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <div class="warpper">
  3. <el-row type="flex" justify="space-between" class="toolbar">
  4. <!--工具条-->
  5. <el-row type="flex">
  6. <el-form :inline="true">
  7. <el-form-item>
  8. <el-input
  9. @keydown.enter.native="search"
  10. v-model="searchKey"
  11. placeholder="场景名称"
  12. ></el-input>
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" v-on:click="search">查询</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-button type="primary" @click="downloadSceneData"
  19. >下载MP场景数据</el-button
  20. >
  21. </el-row>
  22. <!-- 生成大场景someData -->
  23. <el-row type="flex" class="addScene">
  24. <el-button type="primary" @click="handModelDownload(mutiTargetObj,'age')"
  25. >下载四维看看场景数据</el-button
  26. >
  27. <el-button type="primary" @click="handModelDownload(mutiTargetObj,'bigScene')" >下载大场景数据</el-button>
  28. <el-button type="warning" style="margin-right: 20px" @click="logout"
  29. >登出</el-button
  30. >
  31. </el-row>
  32. </el-row>
  33. <!-- 表格 -->
  34. <el-table
  35. :data="scenes"
  36. style="width: 100%"
  37. @selection-change="handleSelectionChange"
  38. >
  39. <el-table-column type="selection" width="50"></el-table-column>
  40. <el-table-column type="index" width="50" label="序号"></el-table-column>
  41. <el-table-column prop="sceneTitle" width="200" label="场景名称">
  42. </el-table-column>
  43. <el-table-column prop="sceneCode" width="200" label="MP场景码">
  44. </el-table-column>
  45. <el-table-column label="状态" width="200">
  46. <template slot-scope="scope">
  47. <span>{{ manage_scene_status[scope.row.status] }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. prop="description"
  52. width="400"
  53. label="备注"
  54. ></el-table-column>
  55. <el-table-column
  56. prop="createTime"
  57. width="200"
  58. label="创建时间"
  59. ></el-table-column>
  60. <el-table-column
  61. prop="updateTime"
  62. width="200"
  63. label="更新时间"
  64. ></el-table-column>
  65. <el-table-column fixed="right" label="操作" width="200">
  66. <template slot-scope="scope">
  67. <a :href="scope.row.webSite" target="_blank">查看</a>
  68. <a @click="handModelDownload(scope.row, 'obj')">模型下载</a>
  69. <a @click="handModelUpload(scope.row, 'obj')">模型上传</a>
  70. <a @click="handModelDownload(scope.row, 'pano')">全景图下载</a>
  71. <a @click="handModelUpload(scope.row, 'pano')">全景图上传</a>
  72. </template>
  73. </el-table-column>
  74. </el-table>
  75. <div class="p-con">
  76. <el-pagination
  77. @current-change="handleCurrentChange"
  78. :current-page.sync="currentPage"
  79. :page-size="size"
  80. layout="prev, pager, next, jumper"
  81. :total="total"
  82. >
  83. </el-pagination>
  84. </div>
  85. <!-- 场景码下载 -->
  86. <el-dialog title="下载MP场景数据" :visible.sync="dialogFormVisible">
  87. <el-form :model="form" ref="ruleForm" :rules="rules">
  88. <el-form-item
  89. label="场景码"
  90. :label-width="formLabelWidth"
  91. prop="sceneCode"
  92. >
  93. <el-input
  94. type="sceneCode"
  95. v-model="form.sceneCode"
  96. autocomplete="off"
  97. placeholder="请输入场景码"
  98. ></el-input>
  99. </el-form-item>
  100. <br />
  101. <el-form-item
  102. label="场景名称"
  103. :label-width="formLabelWidth"
  104. prop="sceneTitle"
  105. >
  106. <el-input
  107. type="sceneTitle"
  108. v-model="form.sceneTitle"
  109. autocomplete="off"
  110. placeholder="请输入场景名称"
  111. ></el-input>
  112. </el-form-item>
  113. <br />
  114. <el-form-item label="备注" :label-width="formLabelWidth">
  115. <el-input
  116. type="textarea"
  117. :rows="2"
  118. placeholder="请输入备注"
  119. v-model="form.description"
  120. >
  121. </el-input>
  122. </el-form-item>
  123. </el-form>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button @click="dialogFormVisible = false">取 消</el-button>
  126. <el-button type="primary" @click="sceneCodeSubmit('ruleForm')"
  127. >确 定</el-button
  128. >
  129. </div>
  130. </el-dialog>
  131. <!-- 文件上传 -->
  132. <el-dialog title="上传模型" :visible.sync="dialogFilesVisible">
  133. <el-form ref="form1" label-width="100px" class="add-frome">
  134. <el-form-item label="全景图文件">
  135. <el-upload
  136. class="upload-demo"
  137. :action="uploadUrl"
  138. ref="upload"
  139. accept=".zip"
  140. :on-change="handleChange"
  141. :on-remove="handleRemove"
  142. :on-success="onSuccess"
  143. :on-error="onError"
  144. :file-list="fileList"
  145. :auto-upload="false"
  146. >
  147. <el-button slot="trigger" size="small" type="primary"
  148. >选取文件</el-button
  149. >
  150. <div slot="tip" class="el-upload__tip">只能上传zip文件</div>
  151. </el-upload>
  152. </el-form-item>
  153. </el-form>
  154. <div slot="footer" class="dialog-footer">
  155. <el-button @click="dialogFilesVisible = false">取 消</el-button>
  156. <el-button
  157. type="primary"
  158. v-loading.fullscreen.lock="fullscreenLoading"
  159. @click="submitUpload"
  160. >确 定</el-button
  161. >
  162. </div>
  163. </el-dialog>
  164. </div>
  165. </template>
  166. <script>
  167. import { MANAGE_SCENE_STATUS } from "@/config/data";
  168. export default {
  169. name: "list",
  170. data() {
  171. return {
  172. searchKey: "",
  173. scenes: [],
  174. url: "",
  175. currentPage: 1,
  176. total: 0,
  177. size: 15,
  178. fileList: [],
  179. uploadUrl: "",
  180. fullscreenLoading: false,
  181. targetObj: null,
  182. mutiTargetObj:[],
  183. manage_scene_status: MANAGE_SCENE_STATUS,
  184. dialogFormVisible: false,
  185. dialogFilesVisible: false,
  186. form: {
  187. sceneCode: "",
  188. sceneTitle: "",
  189. description: "",
  190. },
  191. rules: {
  192. sceneCode: [
  193. { required: true, message: "场景码不能为空", trigger: "blur" },
  194. ],
  195. sceneTitle: [
  196. { required: true, message: "场景名称不能为空", trigger: "blur" },
  197. ],
  198. description: [],
  199. },
  200. formLabelWidth: "120px",
  201. };
  202. },
  203. async created() {
  204. this.getScenes();
  205. },
  206. watch: {
  207. currentPage() {
  208. this.getScenes();
  209. },
  210. },
  211. methods: {
  212. // 处理勾选
  213. handleSelectionChange(val) {
  214. console.log("val", val);
  215. this.mutiTargetObj = val;
  216. },
  217. handleRemove(file) {
  218. let index = this.fileList.findIndex((item) => {
  219. return item.uid === file.uid;
  220. });
  221. this.fileList.splice(index, 1);
  222. },
  223. handleChange(file) {
  224. this.fileList = this.fileList.length === 0 ? this.fileList : [];
  225. this.fileList.push(file["raw"]);
  226. },
  227. onSuccess(res) {
  228. this.$alert("上传成功", "提示", {
  229. confirmButtonText: "确定",
  230. callback: (action) => {
  231. console.log("上传成功");
  232. this.dialogFilesVisible = false;
  233. },
  234. });
  235. },
  236. onError(res) {
  237. this.$alert("上传失败", "提示", {
  238. confirmButtonText: "确定",
  239. callback: (action) => {
  240. console.log("上传失败");
  241. },
  242. });
  243. },
  244. async submitUpload() {
  245. var that = this;
  246. if (this.fileList.length === 0) {
  247. this.$alert("请上传附件", "提示", {
  248. confirmButtonText: "确定",
  249. callback: (action) => {
  250. console.log("上传失败");
  251. },
  252. });
  253. return;
  254. }
  255. let formData = new FormData();
  256. this.fileList.forEach((file) => {
  257. formData.append("file", file);
  258. });
  259. this.fullscreenLoading = true;
  260. let res = await this.$http.post(
  261. `/manage/scene/upload/${this.targetObj.uploadType}/${this.targetObj.sceneCode}`,
  262. formData,
  263. {
  264. "Content-Type": "multipart/form-data",
  265. }
  266. );
  267. this.fullscreenLoading = false;
  268. if (res["code"] === 0) {
  269. that.onSuccess(res);
  270. } else {
  271. that.onError(res);
  272. }
  273. },
  274. search() {
  275. this.currentPage === 1 ? this.getScenes() : (this.currentPage = 1);
  276. },
  277. sceneCodeSubmit(formName) {
  278. this.$refs[formName].validate((valid) => {
  279. if (valid) {
  280. this.sceneCodeSendHttp();
  281. }
  282. });
  283. },
  284. sceneCodeSendHttp() {
  285. let { sceneCode, description,sceneTitle } = this.form;
  286. let body = {
  287. description,
  288. sceneCode,
  289. sceneTitle
  290. };
  291. this.$http.post("/manage/scene/download", body).then((res) => {
  292. this.$message(res["msg"]);
  293. if (res["code"] === 0) {
  294. console.log("下载成功");
  295. this.getScenes()
  296. this.dialogFormVisible = false;
  297. } else {
  298. }
  299. });
  300. },
  301. downloadSceneData() {
  302. this.dialogFormVisible = true;
  303. },
  304. handleSizeChange(val) {
  305. console.log(`每页 ${val} 条`);
  306. },
  307. handleCurrentChange(val) {
  308. console.log(`当前页: ${val}`);
  309. },
  310. async getScenes() {
  311. let params = {
  312. pageNum: this.currentPage,
  313. pageSize: this.size,
  314. searchKey: this.searchKey,
  315. };
  316. let res = await this.$http.post("/manage/scene/list", params);
  317. this.scenes = res.data.list;
  318. this.total = res.data.total;
  319. this.currentPage = res.data.pageNum;
  320. },
  321. //模型下载 全景下载 下载四维看看数据 下载大场景数据
  322. async handModelDownload(item,type) {
  323. console.log("item", item,'type',type);
  324. if(!Array.isArray(item)){
  325. this.fullscreenLoading = true;
  326. try{
  327. let res = await this.$http.get(`/manage/scene/download/${type}/${item.sceneCode}`,{ params: { code: item.sceneCode } });
  328. this.fullscreenLoading = false;
  329. if (res && res["code"] === 0) {
  330. let url = `/download${res["data"]}`
  331. window.open(url);
  332. } else {}
  333. }catch(e){
  334. this.fullscreenLoading = false;
  335. console.log('e',e)
  336. }
  337. }
  338. else {
  339. let target = item;
  340. if(target.length === 0) {
  341. this.$message('请勾选选项');
  342. return;
  343. }
  344. target.forEach(item=>{
  345. this.$http.get(`/manage/scene/download/${type}/${item.sceneCode}`,{ params: { code: item.sceneCode } }).then(res=>{
  346. if (res && res["code"] === 0) {
  347. let url = `/download${res["data"]}`
  348. window.open(url);
  349. } else {}
  350. })
  351. })
  352. }
  353. },
  354. handModelUpload(item,type) {
  355. this.dialogFilesVisible = true;
  356. this.targetObj = {...item,uploadType:type};
  357. this.fileList = [];
  358. },
  359. async delScene(name) {
  360. if (confirm("删除后将无法恢复!你确定要删除这个场景吗?")) {
  361. await this.$http.get(`/manage/scene/removes/${name}`);
  362. this.getScenes();
  363. }
  364. },
  365. logout() {
  366. console.log("登出");
  367. window.localStorage.setItem("cjt_token", "");
  368. this.$router.push("/login");
  369. // this.$http({
  370. // method: 'get',
  371. // url: '/admin/logout',
  372. // headers: {
  373. // Authorization: window.localStorage.getItem('token')
  374. // }
  375. // }).then(res => {
  376. // if (res.code === 5001 || res.code === 5002) return
  377. // if (res.code === 0) {
  378. // window.localStorage.setItem('cjt_token', '')
  379. // this.$token = ''
  380. // this.$alert('退出成功', '提示', {
  381. // confirmButtonText: '确定',
  382. // callback: action => {
  383. // window.localStorage.setItem('menu', '')
  384. // this.$router.push('/login')
  385. // }
  386. // })
  387. // }
  388. // })
  389. },
  390. },
  391. };
  392. </script>
  393. <style scoped>
  394. .warpper {
  395. border: 1px solid #dfe6ec;
  396. max-width: 1680px;
  397. margin: 0 auto;
  398. }
  399. .toolbar {
  400. background: #f2f2f2;
  401. padding: 10px;
  402. }
  403. .el-form-item {
  404. margin-bottom: 0;
  405. }
  406. .addScene {
  407. width: 450px;
  408. }
  409. .p-con {
  410. text-align: center;
  411. padding: 20px 0;
  412. }
  413. </style>