index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="40px"
  10. >
  11. <el-form-item label="职位" prop="title_zh">
  12. <el-input
  13. v-model="queryParams.title_zh"
  14. placeholder="请输入职位名称"
  15. clearable
  16. @keyup.enter="handleQuery"
  17. class="!w-240px"
  18. />
  19. </el-form-item>
  20. <el-form-item label="酒店" prop="hotel_zh">
  21. <el-input
  22. v-model="queryParams.hotel_zh"
  23. placeholder="请输入酒店名称"
  24. clearable
  25. @keyup.enter="handleQuery"
  26. class="!w-240px"
  27. />
  28. </el-form-item>
  29. <el-form-item label="姓名" prop="name_zh">
  30. <el-input
  31. v-model="queryParams.name_zh"
  32. placeholder="请输入姓名"
  33. clearable
  34. @keyup.enter="handleQuery"
  35. class="!w-240px"
  36. />
  37. </el-form-item>
  38. <el-form-item>
  39. <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
  40. <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  41. </el-form-item>
  42. </el-form>
  43. </ContentWrap>
  44. <!-- 列表 -->
  45. <ContentWrap>
  46. <el-table v-loading="loading" :data="list" :stripe="true" row-key="id">
  47. <el-table-column label="姓名" align="center" prop="name_zh" />
  48. <el-table-column label="职位" align="center" prop="title_zh" :show-overflow-tooltip="true" />
  49. <el-table-column label="酒店" align="center" prop="hotel_zh" :show-overflow-tooltip="true" />
  50. <el-table-column label="人才状态" align="center" prop="status">
  51. <template #default="scope">
  52. <el-tag :type="scope.row.status === 'active' ? 'success' : 'danger'">
  53. {{ scope.row.status === 'active' ? '已启用' : '已禁用' }}
  54. </el-tag>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="创建时间" align="center" prop="created_at" width="160" />
  58. <el-table-column label="更新时间" align="center" prop="updated_at" width="160" />
  59. <el-table-column label="操作" align="center">
  60. <template #default="scope">
  61. <el-button link type="primary" @click="openForm(scope.row)">标注</el-button>
  62. <el-button v-if="scope.row.status === 'active'" link type="danger" @click="handleAction(scope.row.id, 'inactive')">禁用</el-button>
  63. <el-button v-if="scope.row.status === 'inactive'" link type="success" @click="handleAction(scope.row.id, 'active')">启用</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. </ContentWrap>
  68. <!-- 表单弹窗:添加/修改 -->
  69. <LabelingForm ref="formRef" @success="getList" />
  70. </template>
  71. <script setup lang="ts" name="Tag">
  72. import { talentLabelingApi } from '@/api/menduner/system/talentMap/labeling'
  73. import LabelingForm from './LabelingForm.vue'
  74. const loading = ref(false)
  75. const list = ref([])
  76. const queryParams = reactive({
  77. hotel_zh: undefined,
  78. name_zh: undefined,
  79. title_zh: undefined
  80. })
  81. const queryFormRef = ref() // 搜索的表单
  82. const message = useMessage() // 消息弹窗
  83. /** 查询列表 */
  84. const getList = async () => {
  85. loading.value = true
  86. try {
  87. const data = await talentLabelingApi.getCardList()
  88. list.value = data ? data.reverse() : []
  89. } finally {
  90. loading.value = false
  91. }
  92. }
  93. /** 添加/修改操作 */
  94. const formRef = ref()
  95. const openForm = (data: any) => {
  96. formRef.value.open(data)
  97. }
  98. /** 搜索按钮操作 */
  99. const handleQuery = () => {
  100. // message.warning('建设中...')
  101. getList()
  102. }
  103. /** 重置按钮操作 */
  104. const resetQuery = () => {
  105. message.warning('建设中...')
  106. // queryFormRef.value.resetFields()
  107. // handleQuery()
  108. }
  109. /** 禁用、启用按钮操作 */
  110. const handleAction = async (id: number, status: string) => {
  111. try {
  112. // 二次确认
  113. await message.confirm(`是否确定${status === 'active' ? '启用' : '禁用'}?`)
  114. // 发起删除
  115. await talentLabelingApi.updateTalentStatus(id, { status })
  116. message.success('操作成功')
  117. // 刷新列表
  118. setTimeout(async () => {
  119. await getList()
  120. }, 0)
  121. } catch {}
  122. }
  123. /** 初始化 **/
  124. onMounted(() => {
  125. getList()
  126. })
  127. </script>