index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="container">
  3. <el-card shadow="hover">
  4. <div class="top-operate-wrap">
  5. <div class="left">
  6. <el-form :inline="true" label-width="82px">
  7. <el-form-item label="服务器名称">
  8. <el-input size="default" style="width: 200px;margin-left: 20px;" class="search-input" v-model="key" placeholder="请输入搜索关键字" clearable>
  9. </el-input>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button size="default" type="primary" class="ml10" @click="searchData">
  13. <el-icon>
  14. <ele-Search />
  15. </el-icon>
  16. 查询
  17. </el-button>
  18. <el-button @click="toPage" size="default" type="success" class="ml10">
  19. <el-icon>
  20. <ele-FolderAdd />
  21. </el-icon>
  22. 新建
  23. </el-button>
  24. </el-form-item>
  25. </el-form>
  26. <!-- <el-button @click="toPage" size="default" type="success" class="ml10">
  27. <el-icon>
  28. <ele-FolderAdd />
  29. </el-icon>
  30. 新建
  31. </el-button>
  32. <el-input size="default" style="width: 200px;margin-left: 20px;" class="search-input" v-model="key" placeholder="请输入搜索关键字" clearable>
  33. </el-input>
  34. <el-button type="primary" plain size="default" @click="searchData">搜索</el-button> -->
  35. </div>
  36. <!-- <div class="right">
  37. <el-button @click="index=1" :class="index==1?'active':''" size="default" class="fa fa-th"></el-button>
  38. <el-button @click="index=2" :class="index==2?'active':''" size="default" class="fa fa-list"></el-button>
  39. </div> -->
  40. </div>
  41. <!-- 页面主要内容 -->
  42. <tempalte v-if="index==1">
  43. <!-- table -->
  44. <tableTunnel :queryForm="queryParams" />
  45. </tempalte>
  46. <tempalte v-if="index==2">
  47. <!-- list -->
  48. <listTunnel :queryForm="queryParams" />
  49. </tempalte>
  50. </el-card>
  51. </div>
  52. </template>
  53. <script lang="ts">
  54. import { reactive, toRefs, onMounted, defineComponent, ref } from 'vue';
  55. import type { FormInstance, FormRules } from 'element-plus';
  56. import { useRouter } from 'vue-router';
  57. import { ElMessage } from 'element-plus';
  58. import listTunnel from './component/list.vue';
  59. import tableTunnel from './component/table.vue';
  60. // import api from '/@/api/assess';
  61. // 定义接口来定义对象的类型
  62. interface RuleFormRow {
  63. title: string;
  64. }
  65. interface ItemState {
  66. queryParams: RuleFormRow;
  67. index: number;
  68. key: string;
  69. }
  70. export default defineComponent({
  71. name: 'tunnalManage',
  72. components: { listTunnel, tableTunnel },
  73. setup() {
  74. const router = useRouter();
  75. const state = reactive<ItemState>({
  76. index: 2,
  77. queryParams: {
  78. title: ''
  79. },
  80. key: ''
  81. });
  82. const searchData = () => {
  83. console.log(state.key)
  84. state.queryParams.title = state.key
  85. };
  86. const toPage = () => {
  87. router.push('/network/server/create')
  88. };
  89. return {
  90. toPage,
  91. searchData,
  92. ...toRefs(state),
  93. };
  94. },
  95. });
  96. </script>
  97. <style lang="scss" scoped>
  98. .container {
  99. .top-operate-wrap {
  100. display: flex;
  101. justify-content: space-between;
  102. align-items: center;
  103. margin-bottom: 20px;
  104. .right {
  105. display: flex;
  106. .el-button:nth-child(2) {
  107. margin-left: 0;
  108. border-top-left-radius: 0;
  109. border-bottom-left-radius: 0;
  110. }
  111. .el-button:nth-child(1) {
  112. border-top-right-radius: 0;
  113. border-bottom-right-radius: 0;
  114. border-right: none;
  115. }
  116. .active {
  117. color: var(--el-button-hover-text-color);
  118. border-color: var(--el-button-hover-border-color);
  119. background-color: var(--el-button-hover-bg-color);
  120. outline: 0;
  121. }
  122. }
  123. }
  124. }
  125. </style>