index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="table-default">
  3. <div class="pt-5 pl-2" v-action="'operation.FirstPage.add'">
  4. <el-button type="primary" size="default" @click="openForm(null)">新增</el-button>
  5. </div>
  6. <el-table :data="tableData" class="mt-3" v-loading="loading">
  7. <el-table-column label="ID" prop="id"></el-table-column>
  8. <el-table-column label="列表名称" prop="type_str">
  9. </el-table-column>
  10. <el-table-column label="添加时间" prop="created_at">
  11. </el-table-column>
  12. <el-table-column label="状态" v-action="'operation.FirstPage.enableStatus'">
  13. <template #default="scope">
  14. <div>
  15. <el-switch v-model="scope.row.status" :disabled="Boolean(scope.row.status)" @change="switchStatus(scope.row)"
  16. :active-value="1" :inactive-value="0">
  17. </el-switch>
  18. </div>
  19. </template>
  20. </el-table-column>
  21. <el-table-column label="操作">
  22. <template #default="scope">
  23. <el-button link type="primary" size="default" @click="handleConfigure(scope.row)"
  24. v-action="'operation.FirstPage.setConfig'">配置</el-button>
  25. </template>
  26. </el-table-column>
  27. </el-table>
  28. <Paginate />
  29. </div>
  30. <Dialog v-model="configVisible" title="配置" width="50%" destroy-on-close>
  31. <config @close="closeType('configVisible')" :primary="currentConfig"></config>
  32. </Dialog>
  33. <Dialog v-model="addVisible" title="新增" width="30%" destroy-on-close>
  34. <create @close="closeType('addVisible')"></create>
  35. </Dialog>
  36. </template>
  37. <script lang="ts" setup>
  38. import { InfoFilled } from '@element-plus/icons-vue';
  39. import { computed, onMounted, ref } from 'vue';
  40. import create from './form/create.vue';
  41. import config from './form/config.vue';
  42. import { useGetList } from '@/hook/curd/useGetList';
  43. import { operationManageFirstPageEnableStatus } from '@/api/pageLayout/homePage/index'
  44. const api = 'operationManage/firstPage/list';
  45. const { data, query, search, reset, loading } = useGetList(api, true);
  46. const tableData = computed(() => data.value?.data);
  47. const addVisible = ref(false)
  48. const currentConfig = ref({})
  49. const configVisible = ref(false) //设置回传弹窗
  50. const closeType = (type: string) => {
  51. switch (type) {
  52. case 'configVisible':
  53. configVisible.value = false
  54. break;
  55. case 'addVisible':
  56. addVisible.value = false
  57. break;
  58. }
  59. search()
  60. }
  61. const switchStatus = (data: object) => {
  62. operationManageFirstPageEnableStatus({ id: data.id }).then(res => {
  63. ElMessage.success(res.message)
  64. search()
  65. })
  66. }
  67. const openForm = (data: any) => {
  68. addVisible.value = true
  69. };
  70. const handleConfigure = (data: object) => {
  71. currentConfig.value = data
  72. configVisible.value = true
  73. };
  74. onMounted(() => {
  75. search();
  76. });
  77. </script>
  78. <style lang='scss' scoped></style>