3
0

AppDeployDeviceInfoView.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <el-dialog
  3. class="app-deploy-device-info-view"
  4. :visible.sync="modalIsShow"
  5. title="设备信息"
  6. top="10px"
  7. width="600px"
  8. :close-on-click-modal="false"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. @opened="visibleChange"
  12. >
  13. <div class="box-justify">
  14. <h4 class="info-title">{{ deviceId }}</h4>
  15. <el-button type="primary" @click="copy">复制信息</el-button>
  16. </div>
  17. <div class="info-body">
  18. <json-viewer v-if="info" :value="info" :expand-depth="9"></json-viewer>
  19. </div>
  20. <div slot="footer"></div>
  21. </el-dialog>
  22. </template>
  23. <script>
  24. import { appDeployDeviceInfo } from "../api";
  25. export default {
  26. name: "app-deploy-device-info-view",
  27. props: {
  28. deviceId: {
  29. type: String
  30. }
  31. },
  32. data() {
  33. return {
  34. modalIsShow: false,
  35. info: null
  36. };
  37. },
  38. methods: {
  39. async visibleChange() {
  40. this.info = null;
  41. const data = await appDeployDeviceInfo(this.deviceId);
  42. this.info = data || {};
  43. },
  44. cancel() {
  45. this.modalIsShow = false;
  46. },
  47. open() {
  48. this.modalIsShow = true;
  49. },
  50. copy() {
  51. const inputDom = document.createElement("textarea");
  52. inputDom.value = JSON.stringify(this.info);
  53. document.body.appendChild(inputDom);
  54. inputDom.select();
  55. document.execCommand("copy");
  56. inputDom.parentNode.removeChild(inputDom);
  57. this.$message.success("复制成功!");
  58. }
  59. }
  60. };
  61. </script>
  62. <style scoped>
  63. .info-title {
  64. font-size: 18px;
  65. }
  66. .info-body {
  67. margin-top: 10px;
  68. min-height: 200px;
  69. background-color: #f0f4f9;
  70. }
  71. .info-body >>> .jv-container.jv-light {
  72. background-color: transparent;
  73. border-radius: 10px;
  74. }
  75. .info-body >>> .jv-code {
  76. padding: 15px;
  77. line-height: 20px;
  78. }
  79. .info-body >>> .jv-toggle {
  80. margin-right: 5px;
  81. }
  82. </style>