5
0

tree.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <hc-card>
  3. <template #header>
  4. <el-alert title="可独立修改私有项目的归档规则,不会影响其他项目归档规则" type="warning" :closable="false" />
  5. </template>
  6. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
  7. <template #action="{ row }">
  8. <el-link type="primary" @click="tableRowClick(row)">配置规则</el-link>
  9. </template>
  10. </hc-table>
  11. <template #action>
  12. <hc-pages :pages="searchForm" @change="pageChange" />
  13. </template>
  14. <!-- 配置规则 -->
  15. <HcDrawerTemp v-model="isDrawerTempShow" :data="tableInfo" @close="getTableData" />
  16. </hc-card>
  17. </template>
  18. <script setup>
  19. import { onActivated, onDeactivated, ref } from 'vue'
  20. import { getArrValue } from 'js-fast-way'
  21. import HcDrawerTemp from './tree/drawer-temp.vue'
  22. import mainApi from '~api/project/tree'
  23. defineOptions({
  24. name: 'ProjectTree',
  25. })
  26. //激活
  27. onActivated(() => {
  28. searchForm.value.current = 1
  29. getTableData()
  30. })
  31. //搜索条件
  32. const searchForm = ref({ projectId: '', current: 1, size: 20, total: 0 })
  33. //分页
  34. const pageChange = ({ current, size }) => {
  35. searchForm.value.current = current
  36. searchForm.value.size = size
  37. getTableData()
  38. }
  39. //表格数据
  40. const tableColumn = ref([
  41. { key: 'projectName', name: '项目名称' },
  42. { key: 'action', name: '操作', width: 100, align: 'center' },
  43. ])
  44. const tableData = ref([])
  45. //获取表格数据
  46. const tableLoading = ref(false)
  47. const getTableData = async () => {
  48. tableData.value = []
  49. tableLoading.value = true
  50. const { data } = await mainApi.page({
  51. ...searchForm.value,
  52. total: null,
  53. })
  54. tableLoading.value = false
  55. tableData.value = getArrValue(data?.records)
  56. searchForm.value.total = data?.total ?? 0
  57. }
  58. //配置规则
  59. const tableInfo = ref({})
  60. const isDrawerTempShow = ref(false)
  61. const tableRowClick = (row) => {
  62. tableInfo.value = row
  63. isDrawerTempShow.value = true
  64. }
  65. //离开了当前页面
  66. onDeactivated(() => {
  67. isDrawerTempShow.value = false
  68. })
  69. </script>