Overtime.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <script setup lang="ts">
  2. import { ElMessage } from 'element-plus'
  3. import { GlobalStore } from '@/stores/index'
  4. import { getFormatDuration } from '@/utils/common'
  5. import { UserFilled } from '@element-plus/icons-vue'
  6. import TableBase from '@/components/TableBase/index.vue'
  7. import { ref, nextTick, onMounted, onUnmounted } from 'vue'
  8. import { ColumnProps } from '@/components/TableBase/interface/index'
  9. import { Overtime_List, Overtime_Approval } from '@/api/workAttendance/index'
  10. const TableRef = ref()
  11. const globalStore = GlobalStore()
  12. const columns: ColumnProps[] = [{ prop: 'T_user_name', label: '姓名' }]
  13. interface UserInfoIn {
  14. T_uid: string
  15. T_user_name: string
  16. T_dept: string
  17. T_post: string
  18. T_type_name: string
  19. T_start_time: string
  20. T_end_time: string
  21. T_text: string
  22. Id: string
  23. T_duration: string
  24. T_prove_img: string
  25. }
  26. const userInfo = ref<UserInfoIn>({
  27. T_uid: '',
  28. T_user_name: '',
  29. T_dept: '',
  30. T_post: '',
  31. T_type_name: '',
  32. T_start_time: '',
  33. T_end_time: '',
  34. T_text: '',
  35. Id: '',
  36. T_prove_img: '',
  37. T_duration: ''
  38. })
  39. const initParam = {
  40. User_tokey: globalStore.GET_User_tokey
  41. }
  42. const getSalaryParams = (row: any) => {
  43. userInfo.value = { ...row }
  44. }
  45. const LeaveUser = async (T_State: number) => {
  46. if (!userInfo.value.Id) return
  47. const params = {
  48. User_tokey: globalStore.GET_User_tokey,
  49. T_id: userInfo.value.Id,
  50. T_State
  51. }
  52. const res: any = await Overtime_Approval(params)
  53. if (res.Code === 200) {
  54. if (T_State) {
  55. ElMessage.success('审核通过!')
  56. } else {
  57. ElMessage.warning('审核不通过!')
  58. }
  59. nextTick(() => {
  60. TableRef.value.getTableList()
  61. userInfo.value = {} as UserInfoIn
  62. })
  63. }
  64. }
  65. let cardHeight = ref(0)
  66. const resize = () => {
  67. const height = document.documentElement.clientHeight
  68. cardHeight.value = height - 3 * 12 - 140 - 60 - 6
  69. }
  70. onMounted(() => {
  71. resize()
  72. window.onresize = resize
  73. })
  74. onUnmounted(() => {
  75. window.onresize = null
  76. })
  77. const tableRowClassName = (data: any): any => {
  78. //判断是否相等,相同时改变背景颜色
  79. let user: any = undefined
  80. if (data.row.Id === userInfo.value.Id) {
  81. user = data.row
  82. }
  83. if (user !== undefined) {
  84. let rowBackground = {
  85. background: '#f0f9eb',
  86. color: '#67c23a'
  87. }
  88. return rowBackground
  89. } else {
  90. return ''
  91. }
  92. }
  93. </script>
  94. <template>
  95. <div class="Leave">
  96. <div style="width: 290px">
  97. <TableBase
  98. ref="TableRef"
  99. :columns="columns"
  100. :requestApi="Overtime_List"
  101. :initParam="initParam"
  102. layout="prev, pager, next"
  103. :rowClick="getSalaryParams"
  104. :tableRowClassName="tableRowClassName"
  105. >
  106. <template #table-header>
  107. <h3 class="title">待处理</h3>
  108. </template>
  109. </TableBase>
  110. </div>
  111. <transition
  112. leave-active-class="animate__animated animate__bounceOutRight"
  113. enter-active-class="animate__animated animate__bounceInDown"
  114. >
  115. <el-row class="h-100 f-1 margin-left-3" v-if="userInfo.Id">
  116. <el-col :span="24" class="h-100" style="overflow: hidden">
  117. <el-card class="m-b-3 b-show-0">
  118. <h3 class="title-user m-b-5">员工基本信息</h3>
  119. <div class="info-content">
  120. <el-avatar shape="square" size="large" :icon="UserFilled" />
  121. <div class="info-name">
  122. <h4 class="m-b-3">名字:{{ userInfo.T_user_name }}</h4>
  123. </div>
  124. </div>
  125. </el-card>
  126. <el-card class="m-b-3 b-show-0" :style="{ height: cardHeight + 'px' }">
  127. <el-row>
  128. <el-col :span="12"
  129. ><div>
  130. 开始时间:<el-tag v-if="userInfo.T_start_time" type="success" effect="dark">
  131. {{ userInfo.T_start_time }}
  132. </el-tag>
  133. </div></el-col
  134. >
  135. <el-col :span="12"
  136. ><div>
  137. 结束时间:<el-tag v-if="userInfo.T_end_time" type="success" effect="dark">
  138. {{ userInfo.T_end_time }}
  139. </el-tag>
  140. </div></el-col
  141. >
  142. </el-row>
  143. <el-row>
  144. <el-col :span="12"
  145. ><div>
  146. 加班时长:<el-tag v-if="userInfo.T_duration" type="success" effect="dark">
  147. {{ getFormatDuration(userInfo.T_duration as any) }}
  148. </el-tag>
  149. </div></el-col
  150. >
  151. </el-row>
  152. <el-row>
  153. <el-col style="display: flex">
  154. 取证:
  155. <img v-if="userInfo.T_prove_img" :src="userInfo.T_prove_img" class="img" />
  156. <span v-else>无</span>
  157. </el-col>
  158. </el-row>
  159. <el-row>
  160. <el-col>
  161. <span class="ml-3 w-35 text-gray-600 inline-flex items-center">内容:</span>
  162. <el-input
  163. v-model="userInfo.T_text"
  164. :autosize="{ minRows: 4, maxRows: 6 }"
  165. type="textarea"
  166. placeholder="加班内容"
  167. />
  168. </el-col>
  169. </el-row>
  170. <div class="btn">
  171. <el-button type="primary" @click="LeaveUser(1)">通过</el-button>
  172. <el-button type="danger" @click="LeaveUser(0)">不通过</el-button>
  173. </div>
  174. </el-card>
  175. </el-col>
  176. </el-row>
  177. </transition>
  178. </div>
  179. </template>
  180. <style scoped lang="scss">
  181. .Leave {
  182. display: flex;
  183. overflow: hidden;
  184. .img {
  185. width: 200px;
  186. }
  187. .b-show-0 {
  188. box-shadow: none;
  189. font-size: 16px;
  190. font-weight: 500;
  191. .el-row {
  192. margin-bottom: 10px;
  193. .el-col {
  194. padding: 15px;
  195. }
  196. }
  197. }
  198. .title {
  199. width: 100%;
  200. text-align: center;
  201. }
  202. .title-user {
  203. text-align: left;
  204. }
  205. .btn {
  206. margin-top: 2rem;
  207. display: flex;
  208. justify-content: end;
  209. }
  210. .info-content {
  211. display: flex;
  212. color: #303133;
  213. .info-name {
  214. display: flex;
  215. // flex-direction: column;
  216. align-items: center;
  217. padding-left: 0.75rem;
  218. span:first-child {
  219. margin-right: 2rem;
  220. }
  221. }
  222. }
  223. }
  224. </style>