AppHomeView.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script setup lang="ts">
  2. // @ts-ignore
  3. import API from "@/api/index.js"
  4. import { ref } from "vue"
  5. import { PriceTag } from "@element-plus/icons-vue"
  6. import { ElMessage } from "element-plus"
  7. const Api = API
  8. const appList = ref([])
  9. const init = () => {
  10. Api.appList({ type: "APP" }).then((res) => {
  11. appList.value = res
  12. })
  13. }
  14. const appCreate = () => {
  15. ElMessage.success("新建应用成功")
  16. Api.appCreate({ type: "APP", appName: name.value }).then(() => {
  17. init()
  18. showDialog.value = false
  19. })
  20. }
  21. const name = ref(undefined)
  22. const showDialog = ref(false)
  23. const detail = ref(undefined)
  24. const showDetailsDialog = ref(false)
  25. const addApp = () => {
  26. name.value = undefined
  27. showDialog.value = true
  28. }
  29. const showApp = (scope) => {
  30. detail.value = undefined
  31. // showDetailsDialog.value = true
  32. }
  33. init()
  34. </script>
  35. <template>
  36. <el-card style="margin-top: 20px">
  37. <template #header>
  38. <el-button @click="addApp">新建应用</el-button>
  39. </template>
  40. <el-table :data="appList" style="width: 100%">
  41. <el-table-column type="index" width="150" label="序号" />
  42. <el-table-column prop="appName" label="应用名称" />
  43. <el-table-column prop="createTime" label="创建时间" />
  44. <el-table-column fixed="right" label="操作" min-width="120">
  45. <template #default="scope">
  46. <el-button link type="primary" size="small" @click="showApp(scope.row)"> 详情 </el-button>
  47. <el-button link type="primary" size="small">删除</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. </el-card>
  52. <el-dialog v-model="showDialog" title="新建应用" width="500">
  53. <el-input
  54. class="text item"
  55. v-model="name"
  56. style="width: 440px"
  57. placeholder="请输入应用名称"
  58. :prefix-icon="PriceTag"
  59. :clearable="true"
  60. />
  61. <template #footer>
  62. <div class="dialog-footer">
  63. <el-button @click="showDialog = false">Cancel</el-button>
  64. <el-button type="primary" @click="appCreate"> Confirm</el-button>
  65. </div>
  66. </template>
  67. </el-dialog>
  68. <el-dialog v-model="showDetailsDialog" title="应用信息" width="500">
  69. <el-input
  70. class="text item"
  71. v-model="name"
  72. style="width: 440px"
  73. placeholder="请输入应用名称"
  74. :prefix-icon="PriceTag"
  75. :clearable="true"
  76. />
  77. <template #footer>
  78. <div class="dialog-footer">
  79. <el-button type="primary" @click="showDetailsDialog = false"> 关闭</el-button>
  80. </div>
  81. </template>
  82. </el-dialog>
  83. </template>
  84. <style scoped></style>