Leave.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 { 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: '姓名', name: 'T_user_name' }]
  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. </script>
  72. <template>
  73. <div class="Leave">
  74. <div style="width: 290px">
  75. <TableBase
  76. ref="TableRef"
  77. :columns="columns"
  78. :requestApi="Leave_List"
  79. :initParam="initParam"
  80. layout="prev, pager, next"
  81. :rowClick="getSalaryParams"
  82. >
  83. <template #table-header>
  84. <h3 class="title">待处理</h3>
  85. </template>
  86. <template #T_user_name="{ row }">
  87. <el-button type="primary" text @click="getSalaryParams(row)">{{ row.T_user_name }}</el-button>
  88. </template>
  89. </TableBase>
  90. </div>
  91. <transition
  92. leave-active-class="animate__animated animate__bounceOutRight"
  93. enter-active-class="animate__animated animate__bounceInDown"
  94. >
  95. <el-row class="h-100 f-1 margin-left-3" v-if="userInfo.Id">
  96. <el-col :span="24" class="h-100" style="overflow: hidden">
  97. <el-card class="m-b-3 b-show-0">
  98. <h3 class="title-user m-b-5">员工基本信息</h3>
  99. <div class="info-content">
  100. <el-avatar shape="square" size="large" :icon="UserFilled" />
  101. <div class="info-name">
  102. <h4 class="m-b-3">名字:{{ userInfo.T_user_name }}</h4>
  103. </div>
  104. </div>
  105. </el-card>
  106. <el-card class="m-b-3 b-show-0" :style="{ height: cardHeight + 'px' }">
  107. <el-descriptions title="请假申请" :column="1" size="large" border>
  108. <el-descriptions-item label="请假类型:"
  109. ><el-text class="mx-1" type="primary">{{
  110. userInfo.T_type_name ? userInfo.T_type_name : '-'
  111. }}</el-text></el-descriptions-item
  112. >
  113. <el-descriptions-item label="开始时间:"
  114. ><el-text class="mx-1" type="primary">{{
  115. userInfo.T_start_time ? userInfo.T_type_name : '-'
  116. }}</el-text></el-descriptions-item
  117. >
  118. <el-descriptions-item label="结束时间:" :span="2"
  119. ><el-text class="mx-1" type="primary">{{
  120. userInfo.T_end_time ? userInfo.T_end_time : '-'
  121. }}</el-text></el-descriptions-item
  122. >
  123. <el-descriptions-item label="请假时长:">
  124. <el-text class="mx-1" type="primary">{{
  125. userInfo.T_duration ? getFormatDuration(userInfo.T_duration) : '-'
  126. }}</el-text>
  127. </el-descriptions-item>
  128. <el-descriptions-item label="内容:">
  129. <el-text class="mx-1" type="primary">{{ userInfo.T_text ? userInfo.T_text : '-' }}</el-text>
  130. </el-descriptions-item>
  131. </el-descriptions>
  132. <div class="btn">
  133. <el-button type="primary" @click="LeaveUser(1)">通过</el-button>
  134. <el-button type="danger" @click="LeaveUser(0)">不通过</el-button>
  135. </div>
  136. </el-card>
  137. </el-col>
  138. </el-row>
  139. </transition>
  140. </div>
  141. </template>
  142. <style scoped lang="scss">
  143. .Leave {
  144. display: flex;
  145. overflow: hidden;
  146. .b-show-0 {
  147. box-shadow: none;
  148. }
  149. .title {
  150. width: 100%;
  151. text-align: center;
  152. }
  153. .title-user {
  154. text-align: left;
  155. }
  156. .btn {
  157. margin-top: 2rem;
  158. display: flex;
  159. justify-content: end;
  160. }
  161. .info-content {
  162. display: flex;
  163. color: #303133;
  164. .info-name {
  165. display: flex;
  166. align-items: center;
  167. padding-left: 0.75rem;
  168. }
  169. }
  170. }
  171. </style>