index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="my-layout">
  3. <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
  4. <el-form :inline="true" @submit.stop.prevent>
  5. <el-form-item label="应用名称">
  6. <el-input v-model="state.filter.name" placeholder="请输入应用名称" @keyup.enter="onQuery" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
  10. </el-form-item>
  11. </el-form>
  12. </el-card>
  13. <el-card class="my-fill mt8" shadow="never">
  14. <el-row>
  15. <el-col :span="6">
  16. <div class="flex app appDdd" @click="onAdd">
  17. <div class="flex appDdd" style="width: 100px;height: 100px;background-color: #EFEFEF;border-radius: 50%;font-size: 20px;">+</div>
  18. </div>
  19. </el-col>
  20. <el-col :span="6" v-for="(v, k) in state.applyData" :key="k">
  21. <div class="flex app">
  22. <div style="display: flex;justify-content: space-between;align-items: flex-start;align-self: flex-end;">
  23. <div class="flex delete" @click="onDelete(v)">X</div>
  24. </div>
  25. <div class="flex" style="flex: 1;">{{ v.name }}</div>
  26. <div class="flex" style="flex: 1;">最小可用版本:{{ v.minVersion }}</div>
  27. <div class="flex" style="height: 75px;width: 100%;">
  28. <el-row style="width: 100%">
  29. <el-col :span="8"><el-button style="width: 100%;height: 38px;border-radius: 0" type="primary" @click="toPermissPage(v)">权限</el-button></el-col>
  30. <el-col :span="8"><el-button style="width: 98%;height: 38px;border-radius: 0;" type="primary" @click="toRolePage(v)">角色</el-button></el-col>
  31. <el-col :span="8"><el-button style="width: 100%;height: 38px;border-radius: 0;" type="primary" @click="toViewPage(v)">视图</el-button></el-col>
  32. <el-col :span="8"><el-button style="width: 100%;height: 38px;border-radius: 0;margin-top: 1%;" type="primary" @click="toEquipmentPage(v)">设备管理</el-button></el-col>
  33. <el-col :span="8"><el-button style="width: 98%;height: 38px;border-radius: 0;margin-top: 1%;" type="primary" @click="onEdit(v)">修改</el-button></el-col>
  34. </el-row>
  35. </div>
  36. </div>
  37. </el-col>
  38. </el-row>
  39. </el-card>
  40. <org-form ref="orgFormRef" :title="state.orgFormTitle" :org-tree-data="state.orgTreeData"></org-form>
  41. </div>
  42. </template>
  43. <script lang="ts" setup name="admin/org">
  44. import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
  45. import { OauthApply,OauthApplyDto } from '/@/api/admin/data-contracts'
  46. import { PermissionApi } from '/@/api/admin/Permission'
  47. import router from "/@/router";
  48. import eventBus from '/@/utils/mitt'
  49. import { auth } from '/@/utils/authFunction'
  50. // 引入组件
  51. const OrgForm = defineAsyncComponent(() => import('./components/org-form.vue'))
  52. const { proxy } = getCurrentInstance() as any
  53. const orgFormRef = ref()
  54. const state = reactive({
  55. loading: false,
  56. orgFormTitle: '',
  57. filter: {
  58. name: '',
  59. }as OauthApplyDto,
  60. applyData: [] as Array<OauthApply>,
  61. })
  62. onMounted(() => {
  63. onQuery()
  64. eventBus.off('refreshOrg')
  65. eventBus.on('refreshOrg', () => {
  66. onQuery()
  67. })
  68. })
  69. onBeforeMount(() => {
  70. eventBus.off('refreshOrg')
  71. })
  72. const onQuery = async () => {
  73. state.loading = true
  74. const res = await new PermissionApi().getApplyInfo(state.filter).catch(() => {
  75. state.loading = false
  76. })
  77. state.applyData=res.data
  78. state.loading=false
  79. }
  80. const onAdd = () => {
  81. state.orgFormTitle = '新增应用'
  82. orgFormRef.value.open()
  83. }
  84. const onEdit = (row: OauthApply) => {
  85. state.orgFormTitle = '编辑应用'
  86. orgFormRef.value.open(row)
  87. }
  88. const onDelete = (row: OauthApply) => {
  89. proxy.$modal
  90. .confirmDelete(`确定要删除应用【${row.name}】?`)
  91. .then(async () => {
  92. await new PermissionApi().applyDelete({ id: row.id }, { loading: true })
  93. onQuery()
  94. })
  95. .catch(() => {})
  96. }
  97. const toRolePage = (row: OauthApply) => {
  98. router.push({path:`/application/roleManage/${row.name}`})
  99. }
  100. const toViewPage = (row: OauthApply) => {
  101. router.push({path:`/application/viewManage/${row.name}`})
  102. }
  103. const toPermissPage = (row: OauthApply) => {
  104. router.push({path:`/application/permissionManage/${row.name}`})
  105. }
  106. const toEquipmentPage = (row: OauthApply) => {
  107. router.push({path:`/application/equipment/${row.name}`})
  108. }
  109. </script>
  110. <style scoped lang="scss">
  111. .flex{
  112. display: flex;
  113. flex-direction: column;
  114. align-items: center;
  115. justify-content: center;
  116. text-align: center;
  117. }
  118. .app{
  119. margin-left: 10px;
  120. margin-bottom: 10px;
  121. height: 175px;
  122. border: #7728F5 solid 2px;
  123. }
  124. .appDdd{
  125. border: #7728F5 dashed 1px;
  126. cursor: default;
  127. }
  128. .delete{
  129. width: 25px;
  130. height: 25px;
  131. border: #BBBBBB solid 2px;
  132. border-radius: 50%;
  133. color: #BBBBBB;
  134. font-size: 25px;
  135. cursor: default;
  136. }
  137. </style>