serverDetail.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <!--
  2. * @Author: vera_min vera_min@163.com
  3. * @Date: 2022-09-05 08:41:57
  4. * @LastEditors: vera_min vera_min@163.com
  5. * @LastEditTime: 2022-09-06 17:18:19
  6. * @FilePath: /sagoo-admin-ui/src/views/network/tunnel/component/serverDetail.vue
  7. * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. -->
  9. <!-- 服务器详情页 -->
  10. <template>
  11. <el-descriptions :column="2" border>
  12. <el-descriptions-item>
  13. <template #label>
  14. <div class="cell-item">名称</div>
  15. </template>
  16. {{detail.name}}
  17. </el-descriptions-item>
  18. <el-descriptions-item>
  19. <template #label>
  20. <div class="cell-item">类型</div>
  21. </template>
  22. {{detail.types}}
  23. </el-descriptions-item>
  24. <el-descriptions-item>
  25. <template #label>
  26. <div class="cell-item">地址</div>
  27. </template>
  28. {{detail.addr}}
  29. </el-descriptions-item>
  30. <el-descriptions-item>
  31. <template #label>
  32. <div class="cell-item">状态</div>
  33. </template>
  34. {{ detail.status ? '启动' : '未启动' }}
  35. </el-descriptions-item>
  36. <el-descriptions-item>
  37. <template #label>
  38. <div class="cell-item">禁用</div>
  39. </template>
  40. <el-switch :loading="loading" :before-change="onChangeStatus" :disabled="!detail.status" :active-value="0" :inactive-value="1" size="small" v-model="detail.status" />
  41. </el-descriptions-item>
  42. <el-descriptions-item>
  43. <template #label>
  44. <div class="cell-item">创建时间</div>
  45. </template>
  46. {{ detail.createdAt }}
  47. </el-descriptions-item>
  48. </el-descriptions>
  49. </template>
  50. <script lang="ts">
  51. import { toRefs, reactive, onMounted, defineComponent } from 'vue';
  52. import { ElMessage } from 'element-plus';
  53. import api from '/@/api/network';
  54. interface TableDataState {
  55. loading: boolean
  56. }
  57. export default defineComponent({
  58. name: 'serverDetail',
  59. props: {
  60. detail: {
  61. type: Object,
  62. default: () => {}
  63. }
  64. },
  65. setup(props) {
  66. const state = reactive<TableDataState>({
  67. loading: false
  68. });
  69. onMounted(() => {
  70. });
  71. // 禁用状态
  72. const onChangeStatus = () => {
  73. state.loading = true
  74. return new Promise(() => {
  75. api.server.changeServerStatus({ id: props.detail.id, status: 0 }).then(() => {
  76. state.loading = false
  77. ElMessage.success('已关闭');
  78. props.detail.status = 0
  79. })
  80. })
  81. };
  82. return {
  83. onChangeStatus,
  84. ...toRefs(props),
  85. ...toRefs(state),
  86. };
  87. }
  88. });
  89. </script>