search.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <!-- 搜索工作栏 -->
  3. <ContentWrap>
  4. <el-form
  5. class="-mb-15px"
  6. :model="queryParams"
  7. ref="queryFormRef"
  8. :inline="true"
  9. label-width="68px"
  10. >
  11. <el-form-item label="姓名" prop="name">
  12. <el-input v-model="queryParams.name" placeholder="请输入" clearable @keyup.enter="handleQuery" class="!w-160px" />
  13. </el-form-item>
  14. <el-form-item label="联系电话" prop="phone">
  15. <el-input v-model="queryParams.phone" placeholder="请输入" clearable @keyup.enter="handleQuery" class="!w-160px" />
  16. </el-form-item>
  17. <el-form-item label="酒店品牌" prop="brand">
  18. <el-input v-model="queryParams.brand" placeholder="请输入" clearable @keyup.enter="handleQuery" class="!w-160px" />
  19. </el-form-item>
  20. <el-form-item label="最高学历" prop="eduType">
  21. <el-select
  22. v-model="queryParams.eduType"
  23. placeholder="请选择"
  24. clearable
  25. class="!w-160px"
  26. >
  27. <el-option
  28. v-for="dict in getIntDictOptions(DICT_TYPE.MENDUNER_EDUCATION_TYPE)"
  29. :key="dict.value"
  30. :label="dict.label"
  31. :value="dict.value"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="工作经验" prop="expType">
  36. <el-select
  37. v-model="queryParams.expType"
  38. placeholder="请选择"
  39. clearable
  40. class="!w-160px"
  41. >
  42. <el-option
  43. v-for="dict in getIntDictOptions(DICT_TYPE.MENDUNER_EXP_TYPE)"
  44. :key="dict.value"
  45. :label="dict.label"
  46. :value="dict.value"
  47. />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item label="所在城市" prop="areaIds">
  51. <el-cascader
  52. v-model="queryParams.areaIds"
  53. :options="areaTreeData"
  54. :props="{ label: 'name', value: 'id', multiple: true, emitPath: false }"
  55. collapse-tags
  56. collapse-tags-tooltip
  57. class="!w-160px"
  58. />
  59. </el-form-item>
  60. <el-form-item label="意向城市" prop="workAreaIds">
  61. <el-cascader
  62. v-model="queryParams.workAreaIds"
  63. :options="areaTreeData"
  64. :props="{ label: 'name', value: 'id', multiple: true, emitPath: false }"
  65. collapse-tags
  66. collapse-tags-tooltip
  67. class="!w-160px"
  68. />
  69. </el-form-item>
  70. <el-form-item label="意向职位" prop="positionIds">
  71. <el-cascader
  72. v-model="queryParams.positionIds"
  73. :options="positionTreeData"
  74. :props="{ label: 'nameCn', value: 'id', emitPath: false }"
  75. class="!w-160px"
  76. />
  77. </el-form-item>
  78. <el-form-item>
  79. <el-button @click="handleQuery" :loading="loading" type="primary"><Icon icon="ep:search" /> 搜索</el-button>
  80. <el-button @click="resetQuery" :loading="loading"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
  81. </el-form-item>
  82. </el-form>
  83. </ContentWrap>
  84. <ContentWrap v-if="addList?.length">
  85. <span style="color: #666;">已选择: </span>
  86. <el-tag v-for="(i, index) in addList" :key="i.id" closable type="success" style="margin: 5px 10px 5px 0;" @close="delAddTag(index)">
  87. {{ i.name_zh }}
  88. </el-tag>
  89. </ContentWrap>
  90. <!-- 列表 -->
  91. <ContentWrap v-loading="loading">
  92. <div class="listBox">
  93. <div v-if="!loading && !list?.length" class="tip" style="line-height: 200px;">
  94. <div v-if="paramsBool">未查到任何数据,请更换查询条件后再试!</div>
  95. <div v-else>请输入查询条件!</div>
  96. </div>
  97. <personCard
  98. v-for="item of list"
  99. :key="item.id"
  100. :data="item"
  101. class="item"
  102. detailButTxt="+ 添加"
  103. @detail="detail"
  104. />
  105. </div>
  106. <div v-if="total">
  107. <Pagination
  108. :total="total"
  109. layout="total, prev, pager, next"
  110. v-model:page="queryParams.pageNo"
  111. v-model:limit="queryParams.pageSize"
  112. @pagination="getList"
  113. />
  114. </div>
  115. </ContentWrap>
  116. </template>
  117. <script setup>
  118. defineOptions({ name: 'TalentMapSearch' })
  119. import { TalentMap } from '@/api/menduner/system/talentMap'
  120. import { PersonInfoApi } from '@/api/menduner/system/person'
  121. import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
  122. import personCard from './personCard.vue'
  123. import { getDict } from '@/hooks/web/useDictionaries'
  124. import { timesTampChange, timestampToAge } from '@/utils/transform/date'
  125. const props = defineProps({
  126. paramsVerify: Boolean, // 查询条件必传
  127. searchName: String
  128. })
  129. const message = useMessage() // 消息弹窗
  130. const { t } = useI18n() // 国际化
  131. const loading = ref(false) // 列表的加载中
  132. const list = ref([]) // 列表的数据
  133. const total = ref(0) // 列表的总页数
  134. const queryParams = reactive({
  135. pageNo: 1,
  136. pageSize: 5,
  137. name: '',
  138. phone: undefined,
  139. brand: '',
  140. eduType: undefined,
  141. expType: undefined,
  142. areaIds: [],
  143. workAreaIds: [],
  144. positionIds: [],
  145. })
  146. const queryFormRef = ref() // 搜索的表单
  147. // 地区列表
  148. const areaTreeData = ref([])
  149. const getDictData = async () => {
  150. const { data } = await getDict('areaTreeData', {}, 'areaTreeData')
  151. const obj = data.find(e => e.name === '中国')
  152. const list = obj?.children ? obj.children.map(e =>{
  153. // 市辖区直接显示区
  154. const municipality = e.children && e.children.length && e.children[0].name === '市辖区'
  155. if (municipality && e.children[0].children?.length) e.children = e.children[0].children
  156. return e
  157. }) : []
  158. areaTreeData.value = list.length ? list : []
  159. }
  160. getDictData()
  161. const positionTreeData = ref([])
  162. const getPositionTreeData = async () => {
  163. const { data } = await getDict('positionTreeData', {}, 'positionTreeData')
  164. positionTreeData.value = data || []
  165. }
  166. getPositionTreeData()
  167. /** 查询列表 */
  168. const getList = async () => {
  169. // if (loading.value) return message.warning('请勿频繁操作 !')
  170. loading.value = true
  171. try {
  172. const data = await PersonInfoApi.getPersonInfoPage(queryParams)
  173. list.value = data?.list.map(e => {
  174. return {
  175. ...e.person,
  176. workExpList: e.work ? [e.work] : []
  177. }
  178. }) || []
  179. total.value = data?.total || 0
  180. } catch (error) {
  181. console.log('打印->error', error)
  182. list.value = []
  183. total.value = 0
  184. } finally {
  185. loading.value = false
  186. }
  187. }
  188. const paramsBool = ref(false) // 是否存在筛选条件
  189. /** 搜索按钮操作 */
  190. const handleQuery = () => {
  191. const obj = { pageNo: null, pageSize: null, ...queryParams }
  192. paramsBool.value = Object.values(obj).some(value => value !== undefined && value !== null && value !== '' && value.length)
  193. if (props.paramsVerify && !paramsBool.value) return message.warning('请输入查询条件后再查询 !')
  194. queryParams.pageNo = 1
  195. getList()
  196. }
  197. /** 重置按钮操作 */
  198. const resetQuery = () => {
  199. queryFormRef.value.resetFields()
  200. handleQuery()
  201. }
  202. const getTypicalData = (row, expData) => {
  203. return {
  204. id: row.id,
  205. userId: row.userId,
  206. name_zh: row?.name || '',
  207. email: row?.email || '',
  208. mobile: row?.phone || '',
  209. birthday: row?.birthday ? timesTampChange(row.birthday, 'Y-M-D') : '',
  210. age: row?.birthday ? timestampToAge(row.birthday) : null,
  211. created_at: row?.createTime ? timesTampChange(row.createTime, 'Y-M-D') : null,
  212. updated_at: row?.updateTime ? timesTampChange(row.updateTime, 'Y-M-D') : null,
  213. career_path: expData ? expData.map(e => {
  214. return {
  215. hotel_zh: e?.enterpriseName || null,
  216. title_zh: e?.positionName || null,
  217. date: e?.startTime ? timesTampChange(e.startTime, 'Y-M-D') : null
  218. }
  219. }) : null
  220. }
  221. }
  222. const addList = ref([])
  223. const detail = (row, expData) => {
  224. if (!row?.id || !row?.userId) {
  225. message.warning('添加失败 !')
  226. return
  227. }
  228. if (addList.value.some(e => e.userId === row.userId)) {
  229. message.warning('已经被添加,请勿重复添加 !')
  230. return
  231. }
  232. addList.value.push(getTypicalData(row, expData))
  233. message.success('已添加到选择列表!')
  234. }
  235. const delAddTag = (index) => {
  236. addList.value.splice(index, 1)
  237. }
  238. /** 初始化 **/
  239. // onMounted(async () => {
  240. // if (props.paramsVerify) return
  241. // setTimeout(() => {
  242. // if (props.searchName) {
  243. // queryParams.name = props.searchName
  244. // }
  245. // }, 1000)
  246. // getList()
  247. // })
  248. if (!props.paramsVerify) getList()
  249. defineExpose({
  250. addList
  251. })
  252. </script>
  253. <style lang="scss" scoped>
  254. .tip {
  255. text-align: center;
  256. margin-bottom: 10px;
  257. color: #e6a23c;
  258. }
  259. .listBox {
  260. min-height: 200px;
  261. max-height: calc(100vh - 400px);
  262. overflow-y: auto;
  263. padding: 10px;
  264. .item {
  265. margin-bottom: 10px;
  266. }
  267. }
  268. </style>