index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight">
  5. <el-col :span="24" class="idemand">
  6. <el-image class="image" :src="demand" fit="fill" />
  7. <div class="select">
  8. <el-row class="select_1">
  9. <el-col class="over" :span="6" v-if="oneList.length > 0">
  10. <div class="list">
  11. <div class="left">技术领域:</div>
  12. <div class="right">
  13. <div class="label" v-for="(item, index) in oneList" :key="index">
  14. {{ item.label }}<el-icon @click="toDel(item, 'one')"><Close /></el-icon>
  15. </div>
  16. </div>
  17. </div>
  18. </el-col>
  19. <el-col class="over" :span="6" v-if="twoList.length > 0">
  20. <div class="list">
  21. <div class="left">职称:</div>
  22. <div class="right">
  23. <div class="label" v-for="(item, index) in twoList" :key="index">
  24. {{ item.label }}<el-icon @click="toDel(item, 'two')"><Close /></el-icon>
  25. </div>
  26. </div>
  27. </div>
  28. </el-col>
  29. <el-col class="over" :span="6" v-if="thrList.length > 0">
  30. <div class="list">
  31. <div class="left">所在地区:</div>
  32. <div class="right">
  33. <div class="label" v-for="(item, index) in thrList" :key="index">
  34. {{ item.label }}<el-icon @click="toDel(item, 'thr')"><Close /></el-icon>
  35. </div>
  36. </div>
  37. </div>
  38. </el-col>
  39. <el-col class="over" :span="6" v-if="fourList.length > 0">
  40. <div class="list">
  41. <div class="left">学历:</div>
  42. <div class="right">
  43. <div class="label" v-for="(item, index) in fourList" :key="index">
  44. {{ item.label }}<el-icon @click="toDel(item, 'four')"><Close /></el-icon>
  45. </div>
  46. </div>
  47. </div>
  48. </el-col>
  49. </el-row>
  50. </div>
  51. </el-col>
  52. <div class="w_1200">
  53. <el-col :span="24" class="one">
  54. <el-row class="one_1">
  55. <el-col :span="3" class="left">技术领域</el-col>
  56. <el-col :span="20" class="right" v-if="oneShow">
  57. <a-button
  58. class="title"
  59. v-for="(item, index) in fieldList"
  60. :key="index"
  61. type="link"
  62. size="samll"
  63. @click="toSelect(item, 'one')"
  64. :class="[item.is_active ? 'show' : '']"
  65. >
  66. {{ item.label }}
  67. </a-button>
  68. </el-col>
  69. <el-col :span="20" class="right" v-else>
  70. <a-button
  71. class="title"
  72. v-for="(item, index) in fieldList.slice(0, 8)"
  73. :key="index"
  74. type="link"
  75. size="samll"
  76. @click="toSelect(item, 'one')"
  77. :class="[item.is_active ? 'show' : '']"
  78. >
  79. {{ item.label }}
  80. </a-button>
  81. </el-col>
  82. <el-col :span="1" class="button">
  83. <span v-if="!oneShow" @click="oneShow = true">
  84. 更多
  85. <el-icon><ArrowDown /></el-icon>
  86. </span>
  87. <span v-else @click="oneShow = false">
  88. 收起
  89. <el-icon><ArrowUp /></el-icon>
  90. </span>
  91. </el-col>
  92. </el-row>
  93. <el-row class="one_1">
  94. <el-col :span="3" class="left">职称</el-col>
  95. <el-col :span="21" class="right">
  96. <a-button
  97. class="title"
  98. v-for="(item, index) in titleList"
  99. :key="index"
  100. type="link"
  101. size="samll"
  102. @click="toSelect(item, 'two')"
  103. :class="[item.is_active ? 'show' : '']"
  104. >
  105. {{ item.label }}
  106. </a-button>
  107. </el-col>
  108. </el-row>
  109. <el-row class="one_1">
  110. <el-col :span="3" class="left">所在地区</el-col>
  111. <el-col :span="20" class="right" v-if="twoShow">
  112. <a-button
  113. class="title"
  114. v-for="(item, index) in cityList"
  115. :key="index"
  116. type="link"
  117. size="samll"
  118. @click="toSelect(item, 'thr')"
  119. :class="[item.is_active ? 'show' : '']"
  120. >
  121. {{ item.label }}
  122. </a-button>
  123. </el-col>
  124. <el-col :span="20" class="right" v-else>
  125. <a-button
  126. class="title"
  127. v-for="(item, index) in cityList.slice(0, 10)"
  128. :key="index"
  129. type="link"
  130. size="samll"
  131. @click="toSelect(item, 'thr')"
  132. :class="[item.is_active ? 'show' : '']"
  133. >
  134. {{ item.label }}
  135. </a-button>
  136. </el-col>
  137. <el-col :span="1" class="button">
  138. <span v-if="!twoShow" @click="twoShow = true">
  139. 更多
  140. <el-icon><ArrowDown /></el-icon>
  141. </span>
  142. <span v-else @click="twoShow = false">
  143. 收起
  144. <el-icon><ArrowUp /></el-icon>
  145. </span>
  146. </el-col>
  147. </el-row>
  148. <el-row class="one_1">
  149. <el-col :span="3" class="left">学历</el-col>
  150. <el-col :span="21" class="right">
  151. <a-button
  152. class="title"
  153. v-for="(item, index) in educationList"
  154. :key="index"
  155. type="link"
  156. size="samll"
  157. @click="toSelect(item, 'four')"
  158. :class="[item.is_active ? 'show' : '']"
  159. >
  160. {{ item.label }}
  161. </a-button>
  162. </el-col>
  163. </el-row>
  164. </el-col>
  165. <el-col :span="24" class="two">
  166. <a-list :loading="loading" :grid="{ gutter: 14, column: 4 }" :data-source="list">
  167. <template #renderItem="{ item }">
  168. <el-col :span="24" class="list" @click="toView(item)">
  169. <el-col :span="24" class="name textOver">
  170. <el-tooltip effect="dark" :content="item.name" placement="top">
  171. {{ item.name || '暂无姓名' }}
  172. </el-tooltip>
  173. <div class="tags">
  174. <el-tag type="primary" v-if="item.title">{{
  175. getDict(item.title, 'title')
  176. }}</el-tag>
  177. <el-tag type="success" v-if="item.education">{{
  178. getDict(item.education, 'education')
  179. }}</el-tag>
  180. </div>
  181. </el-col>
  182. <el-col :span="24" class="two_1">
  183. <span>所在地区:</span>
  184. {{ getArea(item.area) }}
  185. </el-col>
  186. <el-col :span="24" class="two_1">
  187. <span>技术领域:</span>
  188. {{ getDict(item.field, 'field') }}
  189. </el-col>
  190. <el-col :span="24" class="two_1 textOver">
  191. <span>研究方向:</span>
  192. {{ item.direction || '暂无' }}
  193. </el-col>
  194. <el-col :span="24" class="two_1 textOver">
  195. <span>工作单位:</span>
  196. {{ item.work || '暂无' }}
  197. </el-col>
  198. <el-col :span="24" class="bottom">
  199. <el-button @click.stop="toChat(item)" type="primary" size="small">
  200. 联络专家
  201. </el-button>
  202. </el-col>
  203. </el-col>
  204. </template>
  205. </a-list>
  206. </el-col>
  207. <el-col :span="24" class="thr">
  208. <el-pagination
  209. background
  210. layout="total, prev, pager, next"
  211. :page-sizes="[10, 20, 50, 100, 200]"
  212. :total="total"
  213. :page-size="limit"
  214. v-model:current-page="currentPage"
  215. @current-change="changePage"
  216. @size-change="sizeChange"
  217. >
  218. </el-pagination>
  219. </el-col>
  220. </div>
  221. </el-col>
  222. </el-row>
  223. </div>
  224. </template>
  225. <script setup>
  226. import { getCity } from '@/utils/city'
  227. const $checkRes = inject('$checkRes')
  228. import { get } from 'lodash-es'
  229. // 接口
  230. import { ExpertStore } from '@/store/api/user/expert'
  231. import { DictDataStore } from '@/store/api/system/dictData'
  232. const store = ExpertStore()
  233. const dictDataStore = DictDataStore()
  234. // 图片引入
  235. import demand from '@/assets/innovation.png'
  236. // 路由
  237. const router = useRouter()
  238. // 加载中
  239. const loading = ref(false)
  240. const searchForm = ref({})
  241. // 列表
  242. const list = ref([])
  243. let skip = 0
  244. let limit = inject('limit')
  245. const total = ref(0)
  246. // 字典表
  247. const educationList = ref([])
  248. const fieldList = ref([])
  249. const titleList = ref([])
  250. const cityList = ref([])
  251. // 查询
  252. const oneList = ref([])
  253. const twoList = ref([])
  254. const thrList = ref([])
  255. const fourList = ref([])
  256. // 是否展开
  257. const oneShow = ref(false)
  258. const twoShow = ref(false)
  259. // 查看
  260. const toView = (item) => {
  261. router.push({ path: '/expert/detail', query: { id: item.id || item._id } })
  262. }
  263. // 请求
  264. onMounted(async () => {
  265. loading.value = true
  266. await searchOther()
  267. await search({ skip, limit })
  268. loading.value = false
  269. })
  270. const searchOther = async () => {
  271. let result
  272. // 学历
  273. result = await dictDataStore.query({ code: 'education', is_use: '0' })
  274. if ($checkRes(result)) educationList.value = result.data
  275. // 技术领域
  276. result = await dictDataStore.query({ code: 'field', is_use: '0' })
  277. if ($checkRes(result)) fieldList.value = result.data
  278. // 职称
  279. result = await dictDataStore.query({ code: 'title', is_use: '0' })
  280. if ($checkRes(result)) titleList.value = result.data
  281. // 城市
  282. getCity().then((response) => (cityList.value = response.address))
  283. }
  284. const search = async (query = { skip: 0, limit }) => {
  285. const info = {
  286. skip: query.skip,
  287. limit: query.limit,
  288. ...searchForm.value,
  289. is_show: '0',
  290. status: '1'
  291. }
  292. const res = await store.query(info)
  293. if (res.errcode == '0') {
  294. list.value = res.data
  295. total.value = res.total
  296. }
  297. }
  298. // 字典数据转换
  299. const getDict = (data, model) => {
  300. let res
  301. if (model == 'education') res = educationList.value.find((f) => f.value == data)
  302. if (model == 'field') res = fieldList.value.find((f) => f.value == data)
  303. if (model == 'title') res = titleList.value.find((f) => f.value == data)
  304. return get(res, 'label')
  305. }
  306. // 地区显示
  307. const getArea = (data) => {
  308. if (data) return data.join(',')
  309. else return '暂无地区'
  310. }
  311. // 联络专家
  312. const toChat = (item) => {
  313. router.push({ path: '/chat', query: { id: item.user } })
  314. }
  315. // 选择查询
  316. const toSelect = (item, num) => {
  317. if (item.is_active) return
  318. if (num == 'one') {
  319. for (const val of fieldList.value) {
  320. if (val.value == item.value) val.is_active = true
  321. }
  322. const one = oneList.value.find((f) => f.value == item.value)
  323. if (!one) oneList.value.push(item)
  324. else oneList.value = oneList.value.filter((f) => f.value == item.value)
  325. }
  326. if (num == 'two') {
  327. for (const val of titleList.value) {
  328. if (val.value == item.value) val.is_active = true
  329. }
  330. const two = twoList.value.find((f) => f.value == item.value)
  331. if (!two) twoList.value.push(item)
  332. else twoList.value = twoList.value.filter((f) => f.value == item.value)
  333. }
  334. if (num == 'thr') {
  335. for (const val of cityList.value) {
  336. if (val.value == item.value) val.is_active = true
  337. }
  338. const thr = thrList.value.find((f) => f.value == item.value)
  339. if (!thr) thrList.value.push(item)
  340. else thrList.value = thrList.value.filter((f) => f.value == item.value)
  341. }
  342. if (num == 'four') {
  343. for (const val of educationList.value) {
  344. if (val.value == item.value) val.is_active = true
  345. }
  346. const four = fourList.value.find((f) => f.value == item.value)
  347. if (!four) fourList.value.push(item)
  348. else fourList.value = fourList.value.filter((f) => f.value == item.value)
  349. }
  350. }
  351. // 删除标签
  352. const toDel = (item, type) => {
  353. if (type == 'one') {
  354. const one = oneList.value.filter((f) => f.value != item.value)
  355. oneList.value = one
  356. for (const i of fieldList.value) {
  357. if (i.value == item.value) i.is_active = !i.is_active
  358. }
  359. }
  360. if (type == 'two') {
  361. const two = twoList.value.filter((f) => f.value != item.value)
  362. twoList.value = two
  363. for (const i of titleList.value) {
  364. if (i.value == item.value) i.is_active = !i.is_active
  365. }
  366. }
  367. if (type == 'thr') {
  368. const thr = thrList.value.filter((f) => f.value != item.value)
  369. thrList.value = thr
  370. for (const i of cityList.value) {
  371. if (i.value == item.value) i.is_active = !i.is_active
  372. }
  373. }
  374. if (type == 'four') {
  375. const four = fourList.value.filter((f) => f.value != item.value)
  376. fourList.value = four
  377. for (const i of educationList.value) {
  378. if (i.value == item.value) i.is_active = !i.is_active
  379. }
  380. }
  381. }
  382. const currentPage = ref(1)
  383. // 分页
  384. const changePage = (page = currentPage.value) => {
  385. search({ skip: (page - 1) * limit, limit: limit })
  386. }
  387. const sizeChange = (limits) => {
  388. limit = limits
  389. currentPage.value = 1
  390. search({ skip: 0, limit: limit })
  391. }
  392. </script>
  393. <style lang="scss" scoped>
  394. .main {
  395. background: rgb(248, 248, 248);
  396. .idemand {
  397. position: relative;
  398. .image {
  399. width: 100%;
  400. height: 200px;
  401. }
  402. .select {
  403. width: 1200px;
  404. position: absolute;
  405. left: 18.5%;
  406. bottom: 10%;
  407. .select_1 {
  408. display: flex;
  409. align-items: flex-end;
  410. .over {
  411. max-height: 106px;
  412. overflow-y: auto;
  413. .list {
  414. border-radius: 5px;
  415. margin-right: 10px;
  416. background-color: #fff;
  417. padding: 5px;
  418. font-size: 14px;
  419. .left {
  420. padding: 10px;
  421. }
  422. .right {
  423. display: flex;
  424. flex-wrap: wrap;
  425. .label {
  426. display: flex;
  427. align-items: center;
  428. margin: 3px;
  429. padding: 5px;
  430. background: #f5f5f5;
  431. border: 1px solid #f0f0f0;
  432. border-radius: 2px;
  433. }
  434. }
  435. }
  436. }
  437. .over::-webkit-scrollbar {
  438. display: none;
  439. }
  440. }
  441. }
  442. }
  443. .one {
  444. background: #ffffff;
  445. border-radius: 10px;
  446. padding: 15px;
  447. margin: 10px 0 0 0;
  448. .one_1 {
  449. display: flex;
  450. align-items: center;
  451. padding: 10px 0;
  452. border-bottom: #9d9898 1px dashed;
  453. .left {
  454. background: #2280ff;
  455. border-radius: 15px;
  456. line-height: 26px;
  457. color: #fff;
  458. text-align: center;
  459. overflow: hidden;
  460. white-space: nowrap;
  461. text-overflow: ellipsis;
  462. font-family: PingFangSC-Medium;
  463. }
  464. .right {
  465. .show {
  466. color: #2374ff !important;
  467. }
  468. .title {
  469. color: #666;
  470. font-size: 14px;
  471. line-height: 15px;
  472. margin: 0 10px;
  473. display: inline-block;
  474. overflow: hidden;
  475. text-decoration: none;
  476. }
  477. .title:hover {
  478. color: #2374ff;
  479. }
  480. }
  481. .button {
  482. color: #2374ff;
  483. font-size: 12px;
  484. cursor: pointer;
  485. }
  486. }
  487. }
  488. .two {
  489. margin: 15px;
  490. .list {
  491. background: #fff;
  492. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.03);
  493. border-radius: 2px;
  494. width: 285px;
  495. height: 190px;
  496. margin-bottom: 15px;
  497. cursor: pointer;
  498. transition: all 0.3s;
  499. padding: 20px;
  500. .name {
  501. display: flex;
  502. align-items: center;
  503. font-size: 16px;
  504. color: #121834;
  505. font-weight: 500;
  506. margin: 5px 0 0 0;
  507. .tags {
  508. grid-gap: 0.5rem;
  509. gap: 0.5rem;
  510. display: flex;
  511. margin: 0 0 0 10px;
  512. }
  513. }
  514. .name:hover {
  515. color: #2374ff;
  516. }
  517. .two_1 {
  518. font-size: 12px;
  519. text-align: justify;
  520. line-height: 12px;
  521. font-weight: 400;
  522. letter-spacing: 0;
  523. color: #8f97a3;
  524. margin-top: 10px;
  525. span:last-child {
  526. color: #525a68;
  527. }
  528. }
  529. .bottom {
  530. margin: 10px;
  531. text-align: right;
  532. .button {
  533. font-size: 12px;
  534. color: #fff;
  535. text-align: center;
  536. line-height: 12px;
  537. font-weight: 500;
  538. padding: 5px 12px;
  539. background: #2374ff;
  540. box-shadow: 0 3px 6px 0 rgba(35, 116, 255, 0.1);
  541. border-radius: 2px;
  542. }
  543. }
  544. }
  545. .list:hover {
  546. background: #f0f7ff;
  547. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  548. }
  549. }
  550. .thr {
  551. display: flex;
  552. flex-direction: row-reverse;
  553. padding: 20px;
  554. }
  555. }
  556. </style>