index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="weeklyStatisticBox">
  3. <div class="title">部门周报统计</div>
  4. <div class="searchBox">
  5. <el-form :inline="true" class="demo-form-inline">
  6. <!-- <DeptAndUserSelect
  7. :defaultDept="deptId"
  8. :isHideDept="true"
  9. :deptOnChange="deptOnChange"
  10. :userOnChange="userOnChange"
  11. /> -->
  12. <el-form-item label="月份:">
  13. <el-date-picker
  14. v-model="reportYearAndMonth"
  15. type="month"
  16. placeholder="请选择月份"
  17. :clearable="false"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" :icon="Search" @click="onSearchHandle">查询</el-button>
  22. <!-- <el-button type="primary" :icon="UploadFilled" @click="onExportHandle">导出</el-button> -->
  23. </el-form-item>
  24. </el-form>
  25. </div>
  26. <div class="tableBox">
  27. <el-table
  28. :data="dataSource"
  29. style="width: 100%"
  30. :height="calculateTableHeight(400)"
  31. v-loading="loading"
  32. >
  33. <el-table-column type="index" label="序号" width="80" align="center" />
  34. <el-table-column label="月份" width="100">
  35. <template #default="scope">
  36. <div>{{ getChineseMonth(scope.row.reportMonth) }}</div>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="deptName" label="部门" width="280" />
  40. <el-table-column prop="nickName" label="姓名" />
  41. <el-table-column prop="shouldFilledCount" label="应填(周)" />
  42. <el-table-column prop="notFilledCount" label="未填(周)" />
  43. <el-table-column prop="filledCount" label="已填(周)" />
  44. <el-table-column label="填写率">
  45. <template #default="scope">
  46. <div>{{ getPercent(scope.row.fillRate) }}%</div>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="操作">
  50. <template #default="scope">
  51. <el-button link type="primary" size="small" @click="jumpToMyLog(scope.row)"
  52. >查看</el-button
  53. >
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </div>
  58. <div class="pageBox">
  59. <el-pagination
  60. v-model:current-page="pageNo"
  61. v-model:page-size="pageSize"
  62. :total="pageTotal"
  63. layout="total, prev, pager, next, sizes, jumper"
  64. @current-change="handleCurrentChange"
  65. @size-change="handleSizeChange"
  66. />
  67. </div>
  68. </div>
  69. </template>
  70. <script setup lang="ts">
  71. import request from '@/config/axios'
  72. import { Search } from '@element-plus/icons-vue'
  73. import moment from 'moment'
  74. import { getUserInfo, calculateTableHeight } from '@/utils/tool'
  75. import DeptAndUserSelect from '@/components/DeptAndUserSelect/index.vue'
  76. defineOptions({
  77. name: 'WeeklyStatistic'
  78. })
  79. const loading = ref(false)
  80. // 获取用户部门id
  81. const getDefaultDept = () => {
  82. const userInfo = getUserInfo()
  83. // 如果有,从url中获取部门id
  84. const urlDeptId = currentRoute.value.query.deptId
  85. return urlDeptId ?? userInfo.deptId
  86. }
  87. // 获取查询日期
  88. const getDefaultDate = () => {
  89. // 如果有,从url中获取查询日期
  90. const date: any = currentRoute.value.query.date
  91. return date ? moment(date) : moment()
  92. }
  93. // 条件查询
  94. const onSearchHandle = (): void => {
  95. getWeeklyStatisticData()
  96. }
  97. const handleCurrentChange = (current): void => {
  98. pageNo.value = current
  99. getWeeklyStatisticData()
  100. }
  101. const handleSizeChange = (size): void => {
  102. pageSize.value = size
  103. getWeeklyStatisticData()
  104. }
  105. // 点击查看
  106. const { push } = useRouter()
  107. const jumpToMyLog = (row: any): void => {
  108. const { userId, nickName, reportYear, reportMonth } = row
  109. // 查看本月填报详情
  110. push(`/weeklyLogDetail?userId=${userId}&userName=${nickName}&date=${reportYear}-${reportMonth}`)
  111. // 查看本月填报列表
  112. // push(
  113. // `/mySendLog?type=weekly&userId=${userId}&userName=${nickName}&date=${reportYear}-${reportMonth}`
  114. // )
  115. }
  116. const { currentRoute } = useRouter()
  117. onMounted(() => {
  118. // 获取周报数据
  119. getWeeklyStatisticData()
  120. })
  121. // const userInfo = getUserInfo()
  122. const reportYearAndMonth = ref(getDefaultDate())
  123. // const userId = ref(userInfo.id ?? '')
  124. const userId = ref('')
  125. // const deptId = ref(userInfo.deptId ?? '')
  126. const deptId = ref(getDefaultDept())
  127. const dataSource = ref('')
  128. const pageSize = ref(20)
  129. const pageNo = ref(1)
  130. const pageTotal = ref(0)
  131. // 获取周报统计数据
  132. const getWeeklyStatisticData = async (): Promise<void> => {
  133. loading.value = true
  134. const params: any = {
  135. reportType: 'weekly',
  136. year: moment(reportYearAndMonth.value).format('YYYY'),
  137. month: moment(reportYearAndMonth.value).format('M'),
  138. // deptId: deptId.value,
  139. userId: userId.value,
  140. pageSize: pageSize.value,
  141. pageNo: pageNo.value
  142. }
  143. if (currentRoute.value?.query?.deptId) {
  144. params.deptId = currentRoute.value.query.deptId
  145. }
  146. const { list = [], total = 0 } = await request.get({
  147. url: '/adm/reportStatistics/query-report-statistics',
  148. params
  149. })
  150. dataSource.value = list
  151. pageTotal.value = total
  152. loading.value = false
  153. }
  154. // 部门切换时
  155. const deptOnChange = (id) => {
  156. deptId.value = id
  157. }
  158. // 人员切换时
  159. const userOnChange = (id) => {
  160. userId.value = id
  161. }
  162. // 获取中文月份
  163. const monthList = [
  164. '一月',
  165. '二月',
  166. '三月',
  167. '四月',
  168. '五月',
  169. '六月',
  170. '七月',
  171. '八月',
  172. '九月',
  173. '十月',
  174. '十一月',
  175. '十二月'
  176. ]
  177. const getChineseMonth = (month = 0) => {
  178. return monthList[month - 1]
  179. }
  180. // 获取百分比
  181. const getPercent = (value = 0) => {
  182. return (value * 100).toFixed(1)
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .weeklyStatisticBox {
  187. margin-top: 20px;
  188. height: calc(100% - 20px);
  189. background-color: #fff;
  190. border-radius: 20px;
  191. padding: 20px;
  192. .title {
  193. height: 32px;
  194. font-weight: bold;
  195. font-size: 24px;
  196. color: #121518;
  197. margin-bottom: 20px;
  198. }
  199. .tableBox {
  200. height: auto;
  201. }
  202. :deep {
  203. .el-table th.el-table__cell {
  204. background-color: #edf2fc;
  205. color: #4c525b;
  206. }
  207. }
  208. .pageBox {
  209. padding: 20px;
  210. display: flex;
  211. justify-content: right;
  212. }
  213. }
  214. </style>