Leave.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <script setup lang="ts">
  2. import { ElMessage } from 'element-plus'
  3. import { GlobalStore } from '@/stores/index'
  4. import { ref, onMounted, onUnmounted } from 'vue'
  5. import { getFormatDuration } from '@/utils/common'
  6. import { UserFilled } from '@element-plus/icons-vue'
  7. import TableBase from '@/components/TableBase/index.vue'
  8. import { ColumnProps } from '@/components/TableBase/interface/index'
  9. import { Leave_List, Leave_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_user_name: string
  15. T_dept: string
  16. T_post: string
  17. T_type_name: string
  18. T_start_time: string
  19. T_end_time: string
  20. T_text: string
  21. Id: string
  22. T_duration: number
  23. }
  24. const userInfo = ref<UserInfoIn>({
  25. T_user_name: '',
  26. T_dept: '',
  27. T_post: '',
  28. T_type_name: '',
  29. T_start_time: '',
  30. T_end_time: '',
  31. T_text: '',
  32. Id: '',
  33. T_duration: 0
  34. })
  35. const initParam = {
  36. User_tokey: globalStore.GET_User_tokey
  37. }
  38. const getSalaryParams = (row: any) => {
  39. userInfo.value = { ...row }
  40. }
  41. const LeaveUser = async (T_State: number) => {
  42. if (!userInfo.value.Id) return
  43. const params = {
  44. User_tokey: globalStore.GET_User_tokey,
  45. T_id: userInfo.value.Id,
  46. T_State
  47. }
  48. const res: any = await Leave_Approval(params)
  49. if (res.Code === 200) {
  50. if (T_State) {
  51. ElMessage.success('审核通过!')
  52. } else {
  53. ElMessage.warning('审核不通过!')
  54. }
  55. TableRef.value.getTableList()
  56. userInfo.value = {} as UserInfoIn
  57. }
  58. }
  59. let cardHeight = ref(0)
  60. const resize = () => {
  61. const height = document.documentElement.clientHeight
  62. cardHeight.value = height - 3 * 12 - 140 - 60
  63. }
  64. onMounted(() => {
  65. resize()
  66. window.onresize = resize
  67. })
  68. onUnmounted(() => {
  69. window.onresize = null
  70. })
  71. const tableRowClassName = (data: any): any => {
  72. //判断是否相等,相同时改变背景颜色
  73. let user: any = undefined
  74. if (data.row.Id === userInfo.value.Id) {
  75. user = data.row
  76. }
  77. if (user !== undefined) {
  78. let rowBackground = {
  79. background: '#f0f9eb',
  80. color: '#67c23a'
  81. }
  82. return rowBackground
  83. } else {
  84. return ''
  85. }
  86. }
  87. </script>
  88. <template>
  89. <div class="Leave">
  90. <div style="width: 290px">
  91. <TableBase
  92. ref="TableRef"
  93. :columns="columns"
  94. :requestApi="Leave_List"
  95. :initParam="initParam"
  96. layout="prev, pager, next"
  97. :rowClick="getSalaryParams"
  98. :tableRowClassName="tableRowClassName"
  99. >
  100. <template #table-header>
  101. <h3 class="title">待处理</h3>
  102. </template>
  103. </TableBase>
  104. </div>
  105. <transition
  106. leave-active-class="animate__animated animate__bounceOutRight"
  107. enter-active-class="animate__animated animate__bounceInDown"
  108. >
  109. <el-row class="h-100 f-1 margin-left-3" v-if="userInfo.Id">
  110. <el-col :span="24" class="h-100" style="overflow: hidden">
  111. <el-card class="m-b-3 b-show-0">
  112. <h3 class="title-user m-b-5">员工基本信息</h3>
  113. <div class="info-content">
  114. <el-avatar shape="square" size="large" :icon="UserFilled" />
  115. <div class="info-name">
  116. <h4 class="m-b-3">名字:{{ userInfo.T_user_name }}</h4>
  117. </div>
  118. </div>
  119. </el-card>
  120. <el-card class="m-b-3 b-show-0" :style="{ height: cardHeight + 'px' }">
  121. <el-descriptions title="请假申请" :column="1" size="large" border>
  122. <el-descriptions-item label="请假类型:"
  123. ><el-text class="mx-1" type="primary">{{
  124. userInfo.T_type_name ? userInfo.T_type_name : '-'
  125. }}</el-text></el-descriptions-item
  126. >
  127. <el-descriptions-item label="开始时间:"
  128. ><el-text class="mx-1" type="primary">{{
  129. userInfo.T_start_time ? userInfo.T_type_name : '-'
  130. }}</el-text></el-descriptions-item
  131. >
  132. <el-descriptions-item label="结束时间:" :span="2"
  133. ><el-text class="mx-1" type="primary">{{
  134. userInfo.T_end_time ? userInfo.T_end_time : '-'
  135. }}</el-text></el-descriptions-item
  136. >
  137. <el-descriptions-item label="请假时长:">
  138. <el-text class="mx-1" type="primary">{{
  139. userInfo.T_duration ? getFormatDuration(userInfo.T_duration) : '-'
  140. }}</el-text>
  141. </el-descriptions-item>
  142. <el-descriptions-item label="内容:">
  143. <el-text class="mx-1" type="primary">{{ userInfo.T_text ? userInfo.T_text : '-' }}</el-text>
  144. </el-descriptions-item>
  145. </el-descriptions>
  146. <div class="btn">
  147. <el-button type="primary" @click="LeaveUser(1)">通过</el-button>
  148. <el-button type="danger" @click="LeaveUser(0)">不通过</el-button>
  149. </div>
  150. </el-card>
  151. </el-col>
  152. </el-row>
  153. </transition>
  154. </div>
  155. </template>
  156. <style scoped lang="scss">
  157. .Leave {
  158. display: flex;
  159. overflow: hidden;
  160. .b-show-0 {
  161. box-shadow: none;
  162. }
  163. .title {
  164. width: 100%;
  165. text-align: center;
  166. }
  167. .title-user {
  168. text-align: left;
  169. }
  170. .btn {
  171. margin-top: 2rem;
  172. display: flex;
  173. justify-content: end;
  174. }
  175. .info-content {
  176. display: flex;
  177. color: #303133;
  178. .info-name {
  179. display: flex;
  180. align-items: center;
  181. padding-left: 0.75rem;
  182. }
  183. }
  184. }
  185. </style>