index.vue 6.0 KB

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