projectTable.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="tableBox">
  3. <div class="table" ref="tableRef">
  4. <el-table
  5. stripe
  6. :data="dataSource"
  7. style="width: 100%; height: 100%"
  8. :style="{ height: tableHeight + 'px' }"
  9. v-loading="loading"
  10. :header-cell-style="{
  11. background: '#E5F0FB',
  12. color: '#233755',
  13. height: '50px'
  14. }"
  15. >
  16. <el-table-column label="序号" width="60" align="center">
  17. <template #default="scope">{{ scope.$index + 1 }}</template>
  18. </el-table-column>
  19. <el-table-column prop="nickName" label="人员" width="120" />
  20. <el-table-column :show-overflow-tooltip="true" prop="deptName" label="部门" width="200" />
  21. <el-table-column :show-overflow-tooltip="true" prop="xmmc" label="项目名称" />
  22. <el-table-column prop="xmbh" label="项目编号" width="250" />
  23. <el-table-column prop="workTime" label="项目工时(小时)" width="180" align="center" />
  24. </el-table>
  25. </div>
  26. <div class="pageBox">
  27. <el-pagination
  28. :page-size="20"
  29. background
  30. layout="total, prev, pager, next"
  31. :total="pageTotal"
  32. :current-page="pageNo"
  33. @current-change="currentChange"
  34. />
  35. </div>
  36. </div>
  37. </template>
  38. <script lang="ts" setup>
  39. import moment from 'moment'
  40. import request from '@/config/axios'
  41. import PubsubService from '@/utils/PubsubService'
  42. const loading = ref(false)
  43. const dataSource = ref([])
  44. const pageNo = ref(1)
  45. const pageTotal = ref(0)
  46. const tableRef: any = ref(null)
  47. const tableHeight: any = ref(0)
  48. onMounted(() => {
  49. tableHeight.value = tableRef.value.clientHeight
  50. // 接收查询事件
  51. PubsubService.subscribe('xmgstj-form-onSearch', (params) => {
  52. getDataSource(params)
  53. })
  54. getDataSource()
  55. })
  56. const { push } = useRouter()
  57. // 查看详情
  58. const jumpToDetail = (row: any) => {
  59. push(`/customerDetail`)
  60. }
  61. // 获取数据
  62. const getDataSource = (params?) => {
  63. loading.value = true
  64. request
  65. .get({
  66. url: '/adm/reportWorkloadStatistics/query-workload-statistics',
  67. params: {
  68. year: params?.year ?? moment().format('YYYY'),
  69. month: params?.month ?? moment().format('M'),
  70. userId: params?.userId ?? '',
  71. deptId: params?.deptId ? [params.deptId] : [],
  72. projectName: params?.projectName ?? '',
  73. pageNo: pageNo.value,
  74. pageSize: 20
  75. }
  76. })
  77. .then((res) => {
  78. ElMessage.success(`数据查询成功`)
  79. loading.value = false
  80. const { list, total } = res
  81. dataSource.value = list
  82. pageTotal.value = total
  83. pageNo.value = 1
  84. })
  85. .catch(() => {
  86. ElMessage.error('查询失败,请稍后重试!')
  87. loading.value = false
  88. })
  89. }
  90. // 切换页面
  91. const currentChange = (page) => {
  92. pageNo.value = page
  93. getDataSource()
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .titleBox {
  98. display: flex;
  99. justify-content: space-between;
  100. line-height: 60px;
  101. }
  102. .tableBox {
  103. margin-top: 0;
  104. }
  105. </style>