index.vue 4.3 KB

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