dep.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <div class="attendanceCenterDep">
  3. <h1>考勤统计表</h1>
  4. <div class="depSearch">
  5. <div class="depSearchFlex">
  6. <div class="searBox">
  7. <span class="span">月份:</span>
  8. <el-date-picker v-model="fromParams.month" type="month" placeholder="请选择月份" />
  9. </div>
  10. <div class="searBox">
  11. <span class="span">部门:</span>
  12. <el-tree-select
  13. v-model="fromParams.deptId"
  14. :data="deptList"
  15. :props="defaultProps"
  16. check-strictly
  17. default-expand-all
  18. node-key="id"
  19. placeholder="请选择部门"
  20. />
  21. </div>
  22. <div class="searBox">
  23. <span class="span">人员:</span>
  24. <el-input v-model="fromParams.userName" placeholder="请输入人员名称" />
  25. </div>
  26. <div class="searBtns">
  27. <el-button @click="querysClick" type="primary" style="background: #3485ff">
  28. <img src="@/assets/imgs/OA/search.png" class="mr-8px" alt="" />
  29. 查询</el-button
  30. >
  31. <el-button type="primary">
  32. <img src="@/assets/imgs/OA/open.png" class="mr-8px" alt="" />
  33. 导出</el-button
  34. >
  35. <el-button type="success" style="background-color: #05ce9e" v-if="false">
  36. <img src="@/assets/imgs/OA/kq/kqqrIcon.png" class="mr-8px" alt="" />
  37. 考勤确认</el-button
  38. >
  39. </div>
  40. </div>
  41. <el-popover :width="50">
  42. <template #reference>
  43. <div class="depStateBox">
  44. <p>?</p>
  45. </div>
  46. </template>
  47. <template #default>
  48. <div class="depStateContent">
  49. <ul class="">
  50. <li class="flex" v-for="(l, i) in depStateContentList" :key="i">
  51. <div v-if="i == 0" class="flex">
  52. <img src="@/assets/imgs/OA/kq/gouzi.png" alt="" />:
  53. <p>{{ l.name }}</p>
  54. </div>
  55. <div v-else class="flex">
  56. <h4>{{ l.deps }}:</h4>
  57. <p>{{ l.name }}</p>
  58. </div>
  59. </li>
  60. </ul>
  61. </div>
  62. </template>
  63. </el-popover>
  64. </div>
  65. <div class="depTable">
  66. <el-table
  67. v-loading="tableLoading"
  68. :data="
  69. tableData.slice(
  70. (pagesList.pageNo - 1) * pagesList.pageSize,
  71. pagesList.pageSize * pagesList.pageNo
  72. )
  73. "
  74. style="width: 100%; height: 100%"
  75. stripe
  76. >
  77. <!-- <el-table-column type="index" width="50" /> -->
  78. <el-table-column prop="deptName" label="部门" />
  79. <el-table-column prop="nickName" label="姓名" width="80" />
  80. <el-table-column
  81. v-for="(item, index) in tableHeadList"
  82. :key="index"
  83. :label="item.dayOfWeek"
  84. width="30"
  85. :label-class-name="item.isworkday == 1 ? '' : 'workday'"
  86. >
  87. <el-table-column
  88. :label-class-name="item.isworkday == 1 ? '' : 'workday'"
  89. :label="item.day"
  90. width="30"
  91. >
  92. <template #default="scope">
  93. <div class="iconsFlex" v-if="item.isworkday == 1">
  94. <div class="sw" @click="swStateClick(scope.row, item, 1)">
  95. <img
  96. v-if="sco(scope.row, item, 1) == '1'"
  97. src="@/assets/imgs/OA/kq/gouzi.png"
  98. alt=""
  99. />
  100. <div class="spans" v-else-if="sco(scope.row, item, 1) == '2'"> 迟 </div>
  101. <div class="spans" v-else-if="sco(scope.row, item, 1) == '3'"> 早 </div>
  102. <div class="spans" v-else-if="sco(scope.row, item, 1) == '4'"> 旷 </div>
  103. <div class="spans" v-else-if="sco(scope.row, item, 1) == '5'"> 差 </div>
  104. <div class="spans" v-else-if="sco(scope.row, item, 1) == '11'"> 事 </div>
  105. <div class="spans" v-else-if="sco(scope.row, item, 1) == '12'"> 病 </div>
  106. <div class="spans" v-else-if="sco(scope.row, item, 1) == '13'"> 婚 </div>
  107. <div class="spans" v-else-if="sco(scope.row, item, 1) == '14'"> 产 </div>
  108. <div class="spans" v-else-if="sco(scope.row, item, 1) == '15'"> 陪 </div>
  109. <div class="spans" v-else-if="sco(scope.row, item, 1) == '19'"> 丧 </div>
  110. <div class="spans" v-else-if="sco(scope.row, item, 1) == '16'"> 伤 </div>
  111. <div class="spans" v-else-if="sco(scope.row, item, 1) == '17'"> 年 </div>
  112. <div class="spans" v-else-if="sco(scope.row, item, 1) == '18'"> 调 </div>
  113. <div class="spans" v-else-if="sco(scope.row, item, 1) == '20'"> 他 </div>
  114. <div class="spans" v-else> </div>
  115. </div>
  116. <div class="xw" @click="swStateClick(scope.row, item, 2)">
  117. <img
  118. v-if="sco(scope.row, item, 2) == '1'"
  119. src="@/assets/imgs/OA/kq/gouzi.png"
  120. alt=""
  121. />
  122. <div class="spans" v-else-if="sco(scope.row, item, 2) == '2'"> 迟 </div>
  123. <div class="spans" v-else-if="sco(scope.row, item, 2) == '3'"> 早 </div>
  124. <div class="spans" v-else-if="sco(scope.row, item, 2) == '4'"> 旷 </div>
  125. <div class="spans" v-else-if="sco(scope.row, item, 2) == '5'"> 差 </div>
  126. <div class="spans" v-else-if="sco(scope.row, item, 2) == '11'"> 事 </div>
  127. <div class="spans" v-else-if="sco(scope.row, item, 2) == '12'"> 病 </div>
  128. <div class="spans" v-else-if="sco(scope.row, item, 2) == '13'"> 婚 </div>
  129. <div class="spans" v-else-if="sco(scope.row, item, 2) == '14'"> 产 </div>
  130. <div class="spans" v-else-if="sco(scope.row, item, 2) == '15'"> 陪 </div>
  131. <div class="spans" v-else-if="sco(scope.row, item, 2) == '19'"> 丧 </div>
  132. <div class="spans" v-else-if="sco(scope.row, item, 2) == '16'"> 伤 </div>
  133. <div class="spans" v-else-if="sco(scope.row, item, 2) == '17'"> 年 </div>
  134. <div class="spans" v-else-if="sco(scope.row, item, 2) == '18'"> 调 </div>
  135. <div class="spans" v-else-if="sco(scope.row, item, 2) == '20'"> 他 </div>
  136. <div class="spans" v-else> </div>
  137. </div>
  138. </div>
  139. </template>
  140. </el-table-column>
  141. </el-table-column>
  142. <el-table-column prop="kg" width="40" label-class-name="labelModeRl">
  143. <template #header>
  144. <span>旷工</span>
  145. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  146. </template>
  147. </el-table-column>
  148. <el-table-column prop="cd" width="40" label-class-name="labelModeRl">
  149. <template #header>
  150. <span>迟到</span>
  151. <span class="c-#989FA8 font-size-14px m-t-8px">次</span>
  152. </template>
  153. </el-table-column>
  154. <el-table-column prop="zt" width="40" label-class-name="labelModeRl">
  155. <template #header>
  156. <span>早退</span>
  157. <span class="c-#989FA8 font-size-14px m-t-8px">次</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column prop="cc" width="40" label-class-name="labelModeRl">
  161. <template #header>
  162. <span>出差</span>
  163. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  164. </template>
  165. </el-table-column>
  166. <el-table-column prop="sj" width="40" label-class-name="labelModeRl">
  167. <template #header>
  168. <span>事假</span>
  169. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  170. </template>
  171. </el-table-column>
  172. <el-table-column prop="tx" width="40" label-class-name="labelModeRl">
  173. <template #header>
  174. <span>调休</span>
  175. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  176. </template>
  177. </el-table-column>
  178. <el-table-column prop="bj" width="40" label-class-name="labelModeRl">
  179. <template #header>
  180. <span>病假</span>
  181. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  182. </template>
  183. </el-table-column>
  184. <el-table-column prop="nj" width="40" label-class-name="labelModeRl">
  185. <template #header>
  186. <span>年假</span>
  187. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="cj" width="40" label-class-name="labelModeRl">
  191. <template #header>
  192. <span>产假</span>
  193. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  194. </template>
  195. </el-table-column>
  196. <el-table-column prop="qt" width="40" label-class-name="labelModeRl">
  197. <template #header>
  198. <span>其他</span>
  199. <span class="c-#989FA8 font-size-14px m-t-8px">天</span>
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. </div>
  204. <div class="depPages">
  205. <el-pagination
  206. :current-page="pagesList.pageNo"
  207. :page-size="pagesList.pageSize"
  208. background
  209. layout="total, prev, pager, next, jumper"
  210. :total="pagesList.total"
  211. @current-change="handleCurrentChange"
  212. />
  213. </div>
  214. <DepsUpdataDetail ref="depsDetailRef" @updataInit="updataInit" />
  215. </div>
  216. </template>
  217. <script setup lang="ts">
  218. defineOptions({ name: 'AttendanceDep' })
  219. import * as DeptApi from '@/api/system/dept'
  220. import DepsUpdataDetail from './components/depsUpdataDetail.vue'
  221. import { defaultProps, handleTree } from '@/utils/tree'
  222. import * as MineApi from '@/api/oa/attendanceCenter'
  223. import { arrFlatten, depSort, isArrayDelOrNickname, allDeptsArr, dayOfWeekCall } from './attendAuth'
  224. import moment from 'moment'
  225. import { depsState } from './depsState'
  226. const porps = defineProps(['deptsName'])
  227. const pagesList: any = ref({
  228. pageNo: 1,
  229. pageSize: 12,
  230. total: 0
  231. })
  232. const fromParams: any = ref({
  233. deptId: '0a168fe9-2ba8-4302-b6b6-a524c1aef967',
  234. month: '',
  235. userName: ''
  236. })
  237. if (porps.deptsName == '公司') {
  238. fromParams.value.deptId = '4e99393c-c0ea-4146-a7fb-56fb8019c477'
  239. }
  240. const deptSort: any = ref([])
  241. const deptList = ref<Tree[]>([]) // 树形结构
  242. const tableData = ref([])
  243. const initTreeDeps = async () => {
  244. DeptApi.getSimpleDeptList().then((res) => {
  245. deptList.value = handleTree(res)
  246. deptSort.value = arrFlatten(res, 'children')
  247. })
  248. }
  249. const depStateContentList = ref()
  250. depStateContentList.value = depsState
  251. const handleCurrentChange = async (page) => {
  252. pagesList.value.pageNo = page
  253. let toMoseMonths: any = []
  254. toMoseMonths[0] = moment().startOf('months').format('YYYY-MM-DD') + ' 00:00:00'
  255. toMoseMonths[1] = moment().endOf('months').format('YYYY-MM-DD') + ' 23:59:59'
  256. // initInsMouth(toMoseMonths)
  257. }
  258. const querysClick = async () => {
  259. // initInsMouth()
  260. pagesList.value.pageNo = 1
  261. let month = fromParams.value.month
  262. let toMoseMonths: any = []
  263. toMoseMonths[0] = moment(month).startOf('months').format('YYYY-MM-DD') + ' 00:00:00'
  264. toMoseMonths[1] = moment(month).endOf('months').format('YYYY-MM-DD') + ' 23:59:59'
  265. initInsMouth(toMoseMonths)
  266. }
  267. const tableLoading = ref(true)
  268. const updataInit = (date) => {
  269. initInsMouth(date)
  270. }
  271. const initInsMouth = async (date: any) => {
  272. tableLoading.value = true
  273. let params = {
  274. attendanceDate: date, // 考勤时间
  275. attendanceStatus: '', // 考勤状态,示例值(2)
  276. attendanceType: '', // 考勤类型(1:上午;2:下午),示例值(1)
  277. otherMinute: '', // 其他考勤状态分钟(除了出勤)
  278. nickname: fromParams.value.userName, //用户昵称
  279. deptId: fromParams.value.deptId //部门ID
  280. }
  281. initWorkDay(date).then((restall) => {
  282. MineApi.getWorkdaySheetList(params).then((res) => {
  283. let namesArr: any = isArrayDelOrNickname(JSON.parse(JSON.stringify(res)))
  284. let resArr: any = res
  285. resArr.forEach((item: any) => {
  286. if (item.attendanceTime) {
  287. item.date = moment(item.attendanceTime).format('YYYY-MM-DD')
  288. } else {
  289. item.date = moment(item.attendanceDate).format('YYYY-MM-DD')
  290. }
  291. })
  292. let arr = allDeptsArr(restall, resArr, namesArr)
  293. let sbArr = depSort(deptSort.value, arr)
  294. tableData.value = sbArr
  295. pagesList.value.total = arr.length
  296. tableLoading.value = false
  297. })
  298. })
  299. }
  300. const sco = (row, item, index) => {
  301. let kq = ''
  302. if (index == 1) {
  303. row.attendArray.forEach((k) => {
  304. if (k.date == item.date) {
  305. if (k.swAttendanceStatus) {
  306. kq = k.swAttendanceStatus
  307. }
  308. }
  309. })
  310. } else {
  311. row.attendArray.forEach((k) => {
  312. if (k.date == item.date) {
  313. if (k.xwAttendanceStatus) {
  314. kq = k.xwAttendanceStatus
  315. }
  316. }
  317. })
  318. }
  319. return kq
  320. }
  321. const tableHeadList: any = ref([])
  322. const initWorkDay = async (date: any) => {
  323. let params = {
  324. dateDay: date, // 日期(数组)
  325. dayOfWeek: '', // 星期几
  326. holidayRemark: '', // 节假备注,示例值(国庆节)
  327. isworkday: '', // 是否工作日
  328. year: '', // 年份
  329. month: '', // 月份
  330. week: '' // 周
  331. }
  332. const res = await MineApi.getWorkdayList(params)
  333. let arr = res
  334. arr.forEach((item: any) => {
  335. item.date = moment(item.dateDay).format('YYYY-MM-DD')
  336. item.prop = item.dayOfWeek
  337. item.dayOfWeek = dayOfWeekCall(item.dayOfWeek)
  338. item.day = moment(item.dateDay).format('DD')
  339. })
  340. tableHeadList.value = arr
  341. return await arr
  342. }
  343. const depsDetailRef = ref()
  344. const swStateClick = (row, item, index) => {
  345. //更改考勤
  346. if (porps.deptsName == '公司') {
  347. return
  348. }
  349. depsDetailRef.value.initShow(row, item, index, fromParams.value.month)
  350. }
  351. onMounted(() => {
  352. let toMonth = moment().format('YYYY-MM')
  353. fromParams.value.month = toMonth
  354. // 加载部门树
  355. initTreeDeps()
  356. let toMoseMonths: any = []
  357. toMoseMonths[0] = moment().startOf('months').format('YYYY-MM-DD') + ' 00:00:00'
  358. toMoseMonths[1] = moment().endOf('months').format('YYYY-MM-DD') + ' 23:59:59'
  359. initInsMouth(toMoseMonths)
  360. })
  361. </script>
  362. <style lang="scss" scoped>
  363. .attendanceCenterDep {
  364. position: relative;
  365. width: 100%;
  366. height: calc(100% - 15px);
  367. padding: 15px 30px;
  368. margin-top: 15px;
  369. background: #fff;
  370. border-radius: 10px;
  371. h1 {
  372. margin-bottom: 20px;
  373. font-size: 20px;
  374. font-weight: 600;
  375. color: #121518;
  376. }
  377. .depSearch {
  378. display: flex;
  379. width: 100%;
  380. margin-bottom: 20px;
  381. align-items: center;
  382. justify-content: space-between;
  383. .depSearchFlex {
  384. display: flex;
  385. align-items: center;
  386. .searBox {
  387. display: flex;
  388. align-items: center;
  389. margin-right: 25px;
  390. .span {
  391. font-size: 16px;
  392. white-space: nowrap;
  393. }
  394. }
  395. }
  396. .depStateBox {
  397. display: flex;
  398. width: 30px;
  399. height: 30px;
  400. cursor: pointer;
  401. border: 2px solid #e1e4ea;
  402. border-radius: 50%;
  403. align-items: center;
  404. justify-content: center;
  405. p {
  406. font-size: 16px;
  407. font-weight: 600;
  408. color: #e1e4ea;
  409. }
  410. }
  411. }
  412. .depTable {
  413. width: 100%;
  414. height: calc(100% - 140px);
  415. }
  416. .depPages {
  417. position: absolute;
  418. right: 30px;
  419. bottom: 10px;
  420. }
  421. }
  422. :deep(.depTable) {
  423. .el-table {
  424. .workDayClass {
  425. color: pink;
  426. }
  427. .is-group {
  428. height: 80px;
  429. tr {
  430. background-color: #e5f0fb;
  431. th {
  432. font-weight: 500;
  433. color: #233755;
  434. background-color: #e5f0fb;
  435. border-color: #fff;
  436. }
  437. }
  438. }
  439. .cell {
  440. width: 100%;
  441. height: 100%;
  442. padding: 0 !important;
  443. font-size: 16px !important;
  444. text-align: center;
  445. }
  446. .el-table__cell {
  447. // padding: 0;
  448. }
  449. .el-table__body-wrapper {
  450. tr {
  451. td {
  452. border: 0;
  453. }
  454. }
  455. .el-table__row--striped {
  456. td {
  457. background-color: #f7f7f7;
  458. }
  459. }
  460. }
  461. .iconsFlex {
  462. display: flex;
  463. width: 100%;
  464. height: 100%;
  465. align-items: center;
  466. flex-wrap: wrap;
  467. .spans {
  468. width: 100%;
  469. height: 100%;
  470. font-size: 14px !important;
  471. font-weight: 800;
  472. color: #f23c3c;
  473. cursor: pointer;
  474. user-select: none;
  475. }
  476. .sw {
  477. display: flex;
  478. width: 100%;
  479. height: 50%;
  480. user-select: none;
  481. align-items: center;
  482. justify-content: center;
  483. }
  484. .sw:hover {
  485. .spans {
  486. color: #989fa8;
  487. }
  488. }
  489. .xw:hover {
  490. .spans {
  491. color: #989fa8;
  492. }
  493. }
  494. .xw {
  495. display: flex;
  496. width: 100%;
  497. height: 50%;
  498. user-select: none;
  499. align-items: center;
  500. justify-content: center;
  501. }
  502. }
  503. }
  504. .labelModeRl {
  505. writing-mode: vertical-rl;
  506. }
  507. }
  508. :deep(.workday) {
  509. color: #989fa8 !important;
  510. }
  511. </style>