index.vue 15 KB

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