admin.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <hc-card id-ref="hc-certificate-management" div-p="12px">
  3. <template #header>
  4. <div class="w-100">
  5. <el-select v-model="searchForm.projectId" filterable clearable block placeholder="选择项目" @change="searchClick">
  6. <el-option v-for="item in projectData" :key="item.id" :label="item.projectName" :value="item.id" />
  7. </el-select>
  8. </div>
  9. </template>
  10. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :is-index="false" >
  11. <template #action="{ row }">
  12. <el-link type="primary" @click="rowClick(row)">查看</el-link>
  13. </template>
  14. </hc-table>
  15. <template #action>
  16. <hc-pages :pages="searchForm" @change="pageChange" />
  17. </template>
  18. <!-- 查看 -->
  19. <hc-drawer v-model="isRowDrawer" is-close to-id="hc-certificate-management">
  20. <HcAdminSee v-if="isRowDrawer" :cid="tableRowItem.contractId" />
  21. </hc-drawer>
  22. </hc-card>
  23. </template>
  24. <script setup>
  25. import { nextTick, onActivated, ref } from 'vue'
  26. import { getArrValue } from 'js-fast-way'
  27. import HcAdminSee from './modules/admin/see.vue'
  28. import mainApi from '~api/certificate/admin'
  29. defineOptions({
  30. name: 'CertificateAdmin',
  31. })
  32. //激活
  33. onActivated(() => {
  34. getDataApi()
  35. })
  36. const getDataApi = async () => {
  37. await getProjectData()
  38. searchClick()
  39. }
  40. //项目列表
  41. const projectData = ref([])
  42. const getProjectData = async () => {
  43. const { data } = await mainApi.queryProjectList()
  44. projectData.value = getArrValue(data)
  45. }
  46. //搜索条件
  47. const searchForm = ref({ projectId: '', current: 1, size: 20, total: 0 })
  48. //搜索
  49. const searchClick = () => {
  50. searchForm.value.current = 1
  51. getTableData()
  52. }
  53. //分页
  54. const pageChange = ({ current, size }) => {
  55. searchForm.value.current = current
  56. searchForm.value.size = size
  57. getTableData()
  58. }
  59. //表格数据
  60. const tableColumn = ref([
  61. { key: 'projectName', name: '项目名称' },
  62. { key: 'personalCount', name: '个人证书(个)', align: 'center' },
  63. { key: 'enterpriseCount', name: '企业证书(个)', align: 'center' },
  64. { key: 'action', name: '操作', width: 80, align: 'center' },
  65. ])
  66. const tableData = ref([])
  67. //获取表格数据
  68. const tableLoading = ref(true)
  69. const getTableData = async () => {
  70. tableData.value = []
  71. tableLoading.value = true
  72. const { error, code, data } = await mainApi.page({
  73. ...searchForm.value,
  74. total: null,
  75. })
  76. tableLoading.value = false
  77. if (!error && code === 200) {
  78. tableData.value = getArrValue(data['records'])
  79. searchForm.value.total = data['total']
  80. } else {
  81. tableData.value = []
  82. searchForm.value.total = 0
  83. }
  84. }
  85. //点击查看
  86. const isRowDrawer = ref(false)
  87. const tableRowItem = ref({})
  88. const rowClick = (row) => {
  89. tableRowItem.value = row
  90. nextTick(() => {
  91. isRowDrawer.value = true
  92. })
  93. }
  94. </script>