Users.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <script setup lang="ts">
  2. import TableBase from '@/components/TableBase/index.vue'
  3. import { ColumnProps } from '@/components/TableBase/interface/index'
  4. import { Edit, Delete } from '@element-plus/icons-vue'
  5. import { ref, nextTick } from 'vue'
  6. import { GlobalStore } from '@/stores/index'
  7. import { User_List, User_Del } from '@/api/user/index'
  8. import DrawerFrom from './components/DrawerFrom.vue'
  9. import { ElMessage, ElMessageBox } from 'element-plus'
  10. const globalStore = GlobalStore()
  11. const action = ref(true)
  12. const drawerFromRef = ref()
  13. const TableRef = ref()
  14. const columns: ColumnProps[] = [
  15. { type: 'index', label: '#', width: 80 },
  16. { prop: 'T_name', label: '姓名', search: { el: 'input' } },
  17. { prop: 'T_post_name', label: '职位' },
  18. { prop: 'T_dept_name', label: '部门' },
  19. { prop: 'T_phone', label: '联系电话' },
  20. { prop: 'T_nation', label: '民族' },
  21. { prop: 'T_sex', label: '性别', name: 'T_sex' },
  22. { prop: 'T_school', label: '毕业院校' },
  23. { prop: 'T_major', label: '专业' },
  24. { prop: 'T_education', label: '学历' },
  25. { prop: 'T_entry_time', label: '入职时间' },
  26. { prop: 'T_positive_time', label: '转正时间' },
  27. { prop: 'T_entry_type', label: '入职类型', name: 'T_entry_type' },
  28. { prop: 'T_contract_start_time', label: '劳动合同开始时间' },
  29. { prop: 'T_contract_end_time', label: '劳动合同结束时间' },
  30. { prop: 'T_expire', label: '是否到期', name: 'T_expire' },
  31. { prop: 'T_marry', label: '婚否', name: 'T_marry' },
  32. { prop: 'operation', label: '操作', width: 200, fixed: 'right' }
  33. ]
  34. const openDrawerFrom = () => {
  35. drawerFromRef.value.openDrawer()
  36. }
  37. const UpdateTableList = () => {
  38. TableRef.value.getTableList()
  39. }
  40. const UpdateAction = (val: boolean) => {
  41. action.value = val
  42. }
  43. const EditUserInfo = (row: any) => {
  44. action.value = false
  45. drawerFromRef.value.openDrawer()
  46. drawerFromRef.value.DataEcho(row)
  47. }
  48. const DeleteUserInfo = (row: any) => {
  49. ElMessageBox.confirm('您确定要删除吗?', '警告', {
  50. confirmButtonText: '确定',
  51. cancelButtonText: '取消',
  52. type: 'warning'
  53. })
  54. .then(async () => {
  55. const res: any = await User_Del({ User_tokey: globalStore.GET_User_tokey, T_uuid: row.T_uuid })
  56. if (res.Code === 200) {
  57. ElMessage({
  58. type: 'success',
  59. message: '删除成功!'
  60. })
  61. nextTick(() => {
  62. TableRef.value.getTableList()
  63. })
  64. }
  65. })
  66. .catch(() => {
  67. ElMessage({
  68. type: 'warning',
  69. message: '取消成功!'
  70. })
  71. })
  72. }
  73. // search
  74. const search = ref<string>('')
  75. const SearchInfo = () => {
  76. initParam.T_name = search.value
  77. TableRef.value.searchTable()
  78. }
  79. const initParam = {
  80. User_tokey: globalStore.GET_User_tokey,
  81. T_name: ''
  82. }
  83. </script>
  84. <template>
  85. <TableBase ref="TableRef" :columns="columns" :requestApi="User_List" :initParam="initParam">
  86. <template #table-header>
  87. <div class="input-suffix">
  88. <el-row :gutter="20">
  89. <el-col :span="12">
  90. <span class="ml-3 w-35 text-gray-600 inline-flex items-center">账户查询:</span>
  91. <el-input type="text" class="w-50 m-2" v-model="search" />
  92. <el-button type="primary" @click="SearchInfo">搜索</el-button>
  93. </el-col>
  94. <el-col :span="6" :offset="6"><el-button type="primary" @click="openDrawerFrom">添加</el-button></el-col>
  95. </el-row>
  96. </div>
  97. </template>
  98. <template #T_sex="{ row }">
  99. <el-tag class="ml-2" type="success" v-if="row.T_sex === 1">男</el-tag>
  100. <el-tag class="ml-2" type="danger" v-else>女</el-tag>
  101. </template>
  102. <template #T_expire="{ row }">
  103. <el-tag class="ml-2" type="success" v-if="row.T_expire === 0">否</el-tag>
  104. <el-tag class="ml-2" type="danger" v-else>是</el-tag>
  105. </template>
  106. <template #T_marry="{ row }">
  107. <el-tag class="ml-2" type="success" v-if="row.T_marry === 0">未婚</el-tag>
  108. <el-tag class="ml-2" type="danger" v-else>已婚</el-tag>
  109. </template>
  110. <template #T_entry_type="{ row }">
  111. <el-tag class="ml-2" type="success" v-if="+row.T_entry_type === 1">全职</el-tag>
  112. <el-tag class="ml-2" type="warning" v-else-if="+row.T_entry_type === 2">兼职</el-tag>
  113. <el-tag class="ml-2" type="danger" v-else>实习生</el-tag>
  114. </template>
  115. <template #right="{ row }">
  116. <el-button link type="primary" size="small" :icon="Edit" @click="EditUserInfo(row)">编辑</el-button>
  117. <el-button link type="danger" size="small" :icon="Delete" @click="DeleteUserInfo(row)">删除</el-button>
  118. </template>
  119. </TableBase>
  120. <DrawerFrom ref="drawerFromRef" :action="action" @onTableList="UpdateTableList" @onaction="UpdateAction" />
  121. </template>
  122. <style scoped lang="scss">
  123. .input-suffix {
  124. width: 100%;
  125. .w-50 {
  126. width: 12.5rem;
  127. }
  128. }
  129. .form {
  130. margin-top: 3rem;
  131. }
  132. </style>