index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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="180" />
  58. <el-table-column label="操作" align="center">
  59. <template #default="scope">
  60. <el-button
  61. link
  62. type="primary"
  63. @click="openForm(scope.row)"
  64. >
  65. 标注
  66. </el-button>
  67. <el-button
  68. v-if="scope.row.status === 'active'"
  69. link
  70. type="danger"
  71. @click="handleAction(scope.row.id, 'inactive')"
  72. >
  73. 禁用
  74. </el-button>
  75. <el-button
  76. v-if="scope.row.status === 'inactive'"
  77. link
  78. type="success"
  79. @click="handleAction(scope.row.id, 'active')"
  80. >
  81. 启用
  82. </el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. </ContentWrap>
  87. <!-- 表单弹窗:添加/修改 -->
  88. <LabelingForm ref="formRef" @success="getList" />
  89. </template>
  90. <script setup lang="ts" name="Tag">
  91. import { talentLabelingApi } from '@/api/menduner/system/talentMap/labeling'
  92. import LabelingForm from './LabelingForm.vue'
  93. const loading = ref(false)
  94. const list = ref([])
  95. const queryParams = reactive({
  96. hotel_zh: undefined,
  97. name_zh: undefined,
  98. title_zh: undefined
  99. })
  100. const queryFormRef = ref() // 搜索的表单
  101. const message = useMessage() // 消息弹窗
  102. /** 查询列表 */
  103. const getList = async () => {
  104. loading.value = true
  105. try {
  106. const data = await talentLabelingApi.getCardList()
  107. list.value = data
  108. } finally {
  109. loading.value = false
  110. }
  111. }
  112. /** 添加/修改操作 */
  113. const formRef = ref()
  114. const openForm = (data: any) => {
  115. formRef.value.open(data)
  116. }
  117. /** 搜索按钮操作 */
  118. const handleQuery = () => {
  119. getList()
  120. }
  121. /** 重置按钮操作 */
  122. const resetQuery = () => {
  123. queryFormRef.value.resetFields()
  124. handleQuery()
  125. }
  126. /** 禁用、启用按钮操作 */
  127. const handleAction = async (id: number, status: string) => {
  128. try {
  129. // 二次确认
  130. await message.confirm(`是否确定${status === 'active' ? '启用' : '禁用'}?`)
  131. // 发起删除
  132. await talentLabelingApi.updateTalentStatus(id, { status })
  133. message.success('操作成功')
  134. // 刷新列表
  135. setTimeout(async () => {
  136. await getList()
  137. }, 0)
  138. } catch {}
  139. }
  140. /** 初始化 **/
  141. onMounted(() => {
  142. getList()
  143. })
  144. </script>