index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="con" v-loading.fullscreen.lock="loading">
  3. <el-dialog title="场景获取" :close-on-click-modal="false" :visible.sync="downloadingVisible" width="400px">
  4. <el-form :model="downloading" :label-position="'right'" label-width="100px">
  5. <div style="padding: 0 30px">
  6. <div class="add-l">
  7. <el-form-item label="场景名称:">
  8. <span>{{downloading.sceneName}}</span>
  9. </el-form-item>
  10. <el-form-item label="下载进度:" prop="percent" v-if="downloading.status != 1003">
  11. <!-- <span style="color:#0175dc">100%</span> -->
  12. <span style="color:#0175dc">{{downloading.percent}}%</span>
  13. </el-form-item>
  14. <el-form-item label="状态:" prop="status">
  15. <span v-if="downloading.status == 1002" style="color:#0175dc">获取成功</span>
  16. <span v-if="downloading.status == 1000 || downloading.status == 1001" style="color:#0175dc">获取中</span>
  17. <span v-if="downloading.status == 1003" style="color:red">获取失败</span>
  18. <!-- <span style="color:#0175dc">下载成功</span> -->
  19. </el-form-item>
  20. </div>
  21. </div>
  22. </el-form>
  23. <div style="text-align: center" class="dialog-footer">
  24. <div>
  25. <el-button v-if="downloading.status == 1002 || downloading.status == 1003" size="small" type="primary" @click="downloadingVisible = false">确 定</el-button>
  26. </div>
  27. </div>
  28. </el-dialog>
  29. <div class="h-header">
  30. <vcenter>
  31. <div class="h-input">
  32. <el-input v-model="CompanyName" placeholder="请输入公司名称"></el-input>
  33. </div>
  34. <div class="h-input">
  35. <el-input v-model="SceneName" placeholder="请输入场景名称"></el-input>
  36. </div>
  37. <div class="h-input">
  38. <el-input v-model="ShebeiID" placeholder="请输入设备ID"></el-input>
  39. </div>
  40. <div>
  41. <el-button type="primary" @click="search">搜索</el-button>
  42. </div>
  43. </vcenter>
  44. </div>
  45. <div class="h-body">
  46. <div style="padding-left:20px;">
  47. <vcenter>
  48. <!--<el-tabs>
  49. <el-tab-pane @click="" label="新场景"></el-tab-pane>
  50. <el-tab-pane @click="" label="旧场景"></el-tab-pane>
  51. </el-tabs>-->
  52. </vcenter>
  53. </div>
  54. <el-table height="520" :data="tableData" style="width: 100%;padding:0 20px;" :default-sort="{prop:'createTime',order:'descending'}">
  55. <el-table-column
  56. v-for="(item,i) in tableHeader"
  57. :key="i"
  58. :prop="item.name"
  59. :label="item.label"
  60. >
  61. </el-table-column>
  62. <el-table-column label="操作">
  63. <template slot-scope="scope">
  64. <span @click="_S_download(scope.row)" style="cursor:pointer;color:#0175dc;">下载场景</span>
  65. </template>
  66. </el-table-column>
  67. </el-table>
  68. <div class="p-con">
  69. <el-pagination
  70. @size-change="handleSizeChange"
  71. @current-change="handleCurrentChange"
  72. :current-page.sync="currentPage"
  73. :page-size="size"
  74. layout="total, prev, pager, next, jumper"
  75. :total="total"
  76. ></el-pagination>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script>
  82. import vcenter from '@/components/vcenter'
  83. import Vue from 'vue'
  84. export default {
  85. components:{vcenter},
  86. data(){
  87. return{
  88. CompanyName:'',
  89. SceneName:'',
  90. ShebeiID:'',
  91. currentPage:1,
  92. size:10,
  93. total:0,
  94. tableHeader:[
  95. {name:'sceneName',label:'场景名称'},{name:'webSite',label:'场景链接'},
  96. {name:'companyName',label:'企业名称'},{name:'childName',label:'拍摄设备ID'},
  97. {name:'createTime',label:'拍摄时间'},{name:'viewCount',label:'场景访问量'},
  98. {name:'num',label:'场景码'}
  99. ],
  100. tableData:[],
  101. loading: false,
  102. type:'',
  103. downloading:{
  104. sceneName:'',
  105. status:'',
  106. percent:''
  107. },
  108. downloadingVisible: false
  109. }
  110. },
  111. methods:{
  112. // S_download(row){
  113. // let webSite = row.num
  114. // /*let i = webSite.indexOf('=')
  115. // let sceneCode = webSite.slice(i+1)*/
  116. // this.loading = true
  117. // this.$http({
  118. // method: 'get',
  119. // url:`/scene/downloadSceneData?sceneNum=${webSite}`,
  120. // headers:{
  121. // token: window.localStorage.getItem('zfb_token')
  122. // }
  123. // }).then(res =>{
  124. // this.loading = false
  125. // if (res.code === 200){
  126. // window.open(`/${res.message}`, '_blank')
  127. // } else {
  128. // return this.$alert(res.message, '提示', {
  129. // confirmButtonText: '确定'
  130. // })
  131. // }
  132. // })
  133. // },
  134. // sleep(millisecond){
  135. // return new Promise(resolve => {
  136. // setTimeout(()=>{
  137. // resolve()
  138. // },millisecond)
  139. // })
  140. // },
  141. _S_download(row){
  142. let webSite = row.num
  143. this.downloading.sceneName = row.sceneName
  144. this.loading = true
  145. this.$http({
  146. method: 'get',
  147. url: `/scene/downloadSceneData?sceneNum=${webSite}`,
  148. headers:{
  149. token: window.localStorage.getItem('zfb_token')
  150. }
  151. }).then(res => {
  152. this.loading = false
  153. if(res.code === 200){
  154. //链接存在时直接下载
  155. if(res.message.indexOf('zip') != -1 && res.message.indexOf('http') == -1){
  156. window.open(`/zfb/${res.message}`,'_blank')
  157. }
  158. //如果是完整的链接则直接下载
  159. else if(res.message.indexOf('http') != -1){
  160. window.open(res.message , '_blank')
  161. }
  162. //设置定时器实时获取下载链接的status和percent
  163. else if(res.message == 'success'){
  164. // setTimeout(()=>{
  165. // var get_process = setInterval(()=>{
  166. // this.getProcess(row , get_process)
  167. // },2000)
  168. // },3000)
  169. var get_process = setInterval(()=>{
  170. this.getProcess(row , get_process)
  171. },2000)
  172. }
  173. else{
  174. return this.$alert(res.error, '提示', {
  175. confirmButtonText: '确定'
  176. })
  177. }
  178. }
  179. else if(res.code === 400){
  180. return this.$alert(res.message, '提示', {
  181. confirmButtonText: '确定'
  182. })
  183. }
  184. else{
  185. return this.$alert(res.error, '提示', {
  186. confirmButtonText: '确定'
  187. })
  188. }
  189. })
  190. },
  191. getProcess(row , get_process){
  192. // let params = {
  193. // sceneNum: row.num
  194. // }
  195. this.$http({
  196. method: 'get',
  197. url: `/scene/getDownloadProcess?sceneNum=${row.num}`,
  198. // data: params,
  199. headers: {
  200. token: window.localStorage.getItem('zfb_token')
  201. }
  202. }).then(res => {
  203. if(res.code === 200){
  204. this.downloadingVisible = true
  205. this.downloading.status = res.message.status
  206. this.downloading.percent = res.message.percent
  207. if(this.downloading.status == 1002 || this.downloading.status == 1003){
  208. clearInterval(get_process)
  209. if(res.message.url && this.downloading.status == 1002){
  210. window.open(res.message.url,'_blank')
  211. }
  212. }
  213. }
  214. else{
  215. return this.$alert(res.error, '提示', {
  216. confirmButtonText: '确定'
  217. })
  218. }
  219. })
  220. },
  221. handleSizeChange(val){
  222. console.log(`每页 ${val} 条`)
  223. },
  224. handleCurrentChange(val){
  225. // this.loading = true
  226. console.log(`当前页: ${val}`)
  227. },
  228. async getData () {
  229. this.loading = true
  230. let params = {
  231. companyName: this.CompanyName || '',
  232. childName: this.ShebeiID || '',
  233. sceneName: this.SceneName || '',
  234. //startTime: this.value5 ? this.value5[0] : '',
  235. //endTime: this.value5 ? this.value5[1] : '',
  236. //state: this.dropdown_active.id !== '' ? this.dropdown_active.id : '',
  237. type: this.type
  238. }
  239. let result = await this.$http({
  240. method: 'post',
  241. data: params,
  242. url: '/scene/pageList',
  243. headers: {
  244. token: window.localStorage.getItem('zfb_token'),
  245. pageNum: this.currentPage,
  246. pageSize: this.size
  247. }
  248. })
  249. //发布日期和状态格式规范
  250. /*for (let i = 0; i < result.message.list.length; i++) {
  251. result.message.list[i].createTime = this.$base.dateFormat('yyyy-MM-dd hh:mm', new Date(result.message.list[i].createTime))
  252. result.message.list[i].state = this.fixState(result.message.list[i].state)
  253. }*/
  254. if (result.code === 200){
  255. this.tableData = result.message.list
  256. }else{
  257. return this.$alert(result.error, '提示', {
  258. confirmButtonText: '确定'
  259. })
  260. }
  261. this.total = result.message.total
  262. this.currentPage = result.message.pageNum
  263. this.loading = false
  264. },
  265. refresh () {
  266. // this.loading = true
  267. this.getData()
  268. // this.loading = false
  269. },
  270. search(){
  271. this.currentPage === 1 ? this.refresh() : this.currentPage = 1
  272. }
  273. },
  274. mounted(){
  275. this.refresh()
  276. },
  277. watch:{
  278. currentPage(){
  279. this.refresh()
  280. },
  281. // size(){
  282. // this.refresh()
  283. // },
  284. num (newVal, oldVal) {
  285. if (newVal > oldVal) {
  286. this.addDevies.push({
  287. value: '',
  288. isAvailable: false,
  289. hasCheck: false
  290. })
  291. } else {
  292. this.addDevies.pop()
  293. }
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. .con {
  300. .time-data{
  301. position: relative;
  302. .select-data{
  303. position: absolute;
  304. left: 0;
  305. top: 0;
  306. opacity: 0;
  307. cursor: pointer;
  308. }
  309. >span{
  310. color: #0175dc;
  311. }
  312. }
  313. .ei-num {
  314. .el-input-number {
  315. width: 90%;
  316. }
  317. }
  318. .clear-music {
  319. position: relative;
  320. text-align: right;
  321. top: -30px;
  322. color: #999;
  323. cursor: pointer;
  324. }
  325. .musicIcon {
  326. width: 100%;
  327. height: 100%;
  328. line-height: 1;
  329. margin-top: 35px;
  330. img {
  331. width: 50px;
  332. height: auto;
  333. }
  334. p {
  335. font-weight: bold;
  336. font-size: 14px;
  337. color: #000;
  338. line-height: 20px;
  339. height: 20px;
  340. margin-top: 20px;
  341. }
  342. }
  343. .icon-plus {
  344. margin-left: 15px;
  345. width: 40px;
  346. height: 38px;
  347. line-height: 38px;
  348. text-align: center;
  349. background: #f5f7fa;
  350. color: #999;
  351. cursor: pointer;
  352. font-size: 13px;
  353. display: inline-block;
  354. border: 1px solid #dcdfe6;
  355. border-radius: 4px;
  356. &:hover {
  357. border: 1px solid #c0c4cc;
  358. }
  359. }
  360. .add-num {
  361. margin-left: 15px;
  362. width: 250px;
  363. .icon-close,
  364. .icon-correct {
  365. line-height: 1;
  366. color: #999;
  367. }
  368. input[type="number"]::-webkit-inner-spin-button,
  369. input[type="number"]::-webkit-outer-spin-button {
  370. -webkit-appearance: none;
  371. margin: 0;
  372. }
  373. }
  374. .ei-input {
  375. width: 100%;
  376. max-height: 200px;
  377. overflow-y: auto;
  378. .input-con {
  379. display: inline-block;
  380. width: 45%;
  381. margin: 2px 5px 2px 0;
  382. height: 60px;
  383. position: relative;
  384. .el-input_err {
  385. & /deep/ .el-input__inner {
  386. border: 1px solid #f56c6c;
  387. }
  388. }
  389. .el-input_success {
  390. & /deep/ .el-input__inner {
  391. border: 1px solid #67c23a;
  392. }
  393. }
  394. span {
  395. color: #f56c6c;
  396. font-size: 12px;
  397. line-height: 1;
  398. padding-top: 4px;
  399. position: absolute;
  400. left: 0;
  401. }
  402. }
  403. }
  404. .h-header {
  405. height: 80px;
  406. background-color: #fff;
  407. padding-left: 20px;
  408. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  409. border-radius: 3px;
  410. div {
  411. display: inline-block;
  412. }
  413. .h-input {
  414. width: 220px;
  415. }
  416. }
  417. .h-body {
  418. width: 100%;
  419. margin: 30px 0 0;
  420. padding-top: 20px;
  421. box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.1);
  422. border-radius: 3px;
  423. background-color: #fff;
  424. .tabs{
  425. padding-left: 100px;
  426. }
  427. .logo-add {
  428. div {
  429. cursor: pointer;
  430. line-height: 40px;
  431. border: 1px dotted #dcdfe6;
  432. border-radius: 4px;
  433. font-weight: bold;
  434. font-size: 18px;
  435. display: inline-block;
  436. width: 40px;
  437. height: 40px;
  438. background: #f5f7fa;
  439. position: relative;
  440. img {
  441. width: 100%;
  442. height: 100%;
  443. position: absolute;
  444. top: 0;
  445. left: 0;
  446. }
  447. span {
  448. position: absolute;
  449. z-index: 100;
  450. left: 0;
  451. top: 0;
  452. width: 100%;
  453. height: 100%;
  454. }
  455. }
  456. }
  457. .o-span {
  458. color: #0175dc;
  459. cursor: pointer;
  460. }
  461. .p-con {
  462. width: 100%;
  463. text-align: right;
  464. padding: 25px 20px 30px;
  465. }
  466. }
  467. .d-table {
  468. border: 1px solid #ccc;
  469. .d-con {
  470. max-height: 200px;
  471. overflow-y: scroll;
  472. }
  473. .d-header {
  474. font-weight: bold;
  475. }
  476. .d-header,
  477. .d-body {
  478. height: 40px;
  479. line-height: 40px;
  480. width: 100%;
  481. border-bottom: 1px solid #ccc;
  482. &:last-child {
  483. border: none;
  484. }
  485. span {
  486. text-align: center;
  487. display: inline-block;
  488. width: 24%;
  489. }
  490. .unbind{
  491. cursor: pointer;
  492. }
  493. }
  494. }
  495. }
  496. </style>