detail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="main animate__animated animate__backInRight" v-loading="loading">
  5. <div class="w_1200">
  6. <el-col :span="24" class="one">
  7. <el-col :span="24" class="oneText">
  8. <el-col :span="4" class="one_1">
  9. <el-image
  10. class="image"
  11. v-if="info && info.icon && info.icon.length > 0"
  12. :src="info.icon[0].url"
  13. fit="fill"
  14. />
  15. <el-image class="image" v-else :src="zj" fit="fill" />
  16. </el-col>
  17. <el-col :span="14" class="one_2">
  18. <el-col :span="24" class="name textOver">
  19. <el-tooltip effect="dark" :content="info.name" placement="top">
  20. {{ info.name || '暂无姓名' }}
  21. </el-tooltip>
  22. <div class="tags">
  23. <el-tag type="primary" v-if="info.title">{{
  24. getDict(info.title || '暂无', 'title')
  25. }}</el-tag>
  26. <el-tag type="success" v-if="info.education">{{
  27. getDict(info.education || '暂无', 'education')
  28. }}</el-tag>
  29. </div>
  30. </el-col>
  31. <div class="other"><span> 出生年月:</span>{{ info.birth || '暂无' }}</div>
  32. <div class="other"><span> 所在地区:</span>{{ getArea(info.area) }}</div>
  33. <div class="other"><span> 技术领域:</span>{{ getDict(info.field, 'field') }}</div>
  34. <div class="other"><span> 研究方向:</span>{{ info.direction || '暂无' }}</div>
  35. <div class="other"><span> 工作单位:</span>{{ info.work || '暂无' }}</div>
  36. </el-col>
  37. <el-col :span="6" class="one_3">
  38. <el-col :span="10" class="file" @click="toCollection(0)" v-if="info.is_collection">
  39. <el-icon :size="16"><StarFilled /></el-icon>
  40. <span>已收藏</span>
  41. </el-col>
  42. <el-col :span="10" class="file" @click="toCollection(1)" v-else>
  43. <el-icon :size="16"><Star /></el-icon>
  44. <span>收藏</span>
  45. </el-col>
  46. <el-col :span="14">
  47. <a-button type="primary" @click="toChat">
  48. <template #icon>
  49. <MessageOutlined />
  50. </template>
  51. 在线洽谈
  52. </a-button>
  53. </el-col>
  54. </el-col>
  55. </el-col>
  56. <el-col :span="24" class="twoText">
  57. <el-col :span="24" class="title">个人简介</el-col>
  58. <el-col :span="24" class="brief">{{ info.brief || '暂无相关简介' }}</el-col>
  59. </el-col>
  60. <el-col :span="24" class="twoText">
  61. <el-col :span="24" class="title">相关成果</el-col>
  62. <el-col :span="24" class="content">
  63. <a-list :loading="loading" :grid="{ gutter: 16, column: 4 }" :data-source="list">
  64. <template #renderItem="{ item }">
  65. <el-col :span="24" class="list">
  66. <el-col :span="24" class="name textOver">
  67. <el-tooltip effect="dark" :content="item.name" placement="top">
  68. {{ item.name || '暂无名称' }}
  69. </el-tooltip>
  70. </el-col>
  71. <el-col :span="24" class="two_1">
  72. <span>技术领域:</span>{{ getDict(item.field, 'field') }}
  73. </el-col>
  74. <el-col :span="24" class="two_1">
  75. <span>成果地区:</span>{{ getArea(item.area) }}
  76. </el-col>
  77. <el-col :span="24" class="two_1">
  78. <span>单位:</span>{{ item.userName || '暂无单位' }}
  79. </el-col>
  80. <el-col :span="24" class="bottom">
  81. <a-button size="small" type="primary" @click="toView(item)">
  82. 查看详情
  83. </a-button>
  84. </el-col>
  85. </el-col>
  86. </template>
  87. </a-list>
  88. <el-col :span="24" class="page">
  89. <el-pagination
  90. background
  91. layout="total, prev, pager, next"
  92. :page-sizes="[10, 20, 50, 100, 200]"
  93. :total="total"
  94. :page-size="limit"
  95. v-model:current-page="currentPage"
  96. @current-change="changePage"
  97. @size-change="sizeChange"
  98. >
  99. </el-pagination>
  100. </el-col>
  101. </el-col>
  102. </el-col>
  103. </el-col>
  104. </div>
  105. </el-col>
  106. </el-row>
  107. </div>
  108. </template>
  109. <script setup>
  110. import moment from 'moment'
  111. // 基础
  112. import { get } from 'lodash-es'
  113. const $checkRes = inject('$checkRes')
  114. import { MessageOutlined } from '@ant-design/icons-vue'
  115. // 接口
  116. import { ExpertStore } from '@/store/api/user/expert'
  117. import { AchievementStore } from '@/store/api/platform/achievement'
  118. import { CollectionStore } from '@/store/api/platform/collection'
  119. import { DictDataStore } from '@/store/api/system/dictData'
  120. const achievementStore = AchievementStore()
  121. const store = ExpertStore()
  122. const dictDataStore = DictDataStore()
  123. const collectionStore = CollectionStore()
  124. import { UserStore } from '@/store/user'
  125. const userStore = UserStore()
  126. const user = computed(() => userStore.user)
  127. // 图片引入
  128. import zj from '/images/zj.png'
  129. // 路由
  130. const route = useRoute()
  131. const router = useRouter()
  132. // 加载中
  133. const loading = ref(false)
  134. const info = ref({})
  135. // 字典表
  136. const educationList = ref([])
  137. const fieldList = ref([])
  138. const titleList = ref([])
  139. // 成果列表
  140. const list = ref([])
  141. let skip = 0
  142. let limit = inject('limit')
  143. const total = ref(0)
  144. // 请求
  145. onMounted(async () => {
  146. loading.value = true
  147. await searchOther()
  148. await search()
  149. await searchAchieve({ skip, limit })
  150. loading.value = false
  151. })
  152. const search = async () => {
  153. let id = route.query.id
  154. if (id) {
  155. let res = await store.detail(id)
  156. if (res.errcode == '0') info.value = res.data
  157. }
  158. }
  159. const searchAchieve = async (query = { skip: 0, limit }) => {
  160. const info = {
  161. skip: query.skip,
  162. limit: query.limit,
  163. is_use: '0',
  164. status: '1'
  165. }
  166. const res = await achievementStore.list(info)
  167. if (res.errcode == '0') {
  168. list.value = res.data
  169. total.value = res.total
  170. }
  171. }
  172. const searchOther = async () => {
  173. let result
  174. // 学历
  175. result = await dictDataStore.query({ code: 'education', is_use: '0' })
  176. if ($checkRes(result)) educationList.value = result.data
  177. // 技术领域
  178. result = await dictDataStore.query({ code: 'field', is_use: '0' })
  179. if ($checkRes(result)) fieldList.value = result.data
  180. // 职称
  181. result = await dictDataStore.query({ code: 'title', is_use: '0' })
  182. if ($checkRes(result)) titleList.value = result.data
  183. }
  184. // 字典数据转换
  185. const getDict = (data, model) => {
  186. let res
  187. if (model == 'education') res = educationList.value.find((f) => f.value == data)
  188. if (model == 'field') res = fieldList.value.find((f) => f.value == data)
  189. if (model == 'title') res = titleList.value.find((f) => f.value == data)
  190. return get(res, 'label')
  191. }
  192. // 地区
  193. const getArea = (data) => {
  194. if (data) return data.join(',')
  195. else return '暂无地区'
  196. }
  197. // 在线洽谈
  198. const toChat = () => {
  199. router.push({ path: '/chat', query: { id: info.value.user } })
  200. }
  201. // 收藏
  202. const toCollection = async (status) => {
  203. if (user.value.id) {
  204. let res
  205. let message
  206. const data = {
  207. user: user.value.id,
  208. source: info.value._id,
  209. type: 'expert',
  210. time: moment().format('YYYY-MM-DD')
  211. }
  212. if (status == '1') {
  213. message = '收藏成功'
  214. res = await collectionStore.create(data)
  215. } else {
  216. message = '取消收藏成功'
  217. res = await collectionStore.cancel(data)
  218. }
  219. if (res.errcode === 0) {
  220. ElMessage({
  221. message,
  222. type: 'success'
  223. })
  224. await search()
  225. }
  226. } else {
  227. ElMessage({
  228. message: '未登录无法进行收藏 请登录',
  229. type: 'warning'
  230. })
  231. }
  232. }
  233. // 查看
  234. const toView = (item) => {
  235. router.push({ path: '/achievement/detail', query: { id: item.id || item._id } })
  236. }
  237. const currentPage = ref(1)
  238. // 分页
  239. const changePage = (page = currentPage.value) => {
  240. searchAchieve({ skip: (page - 1) * limit, limit: limit })
  241. }
  242. const sizeChange = (limits) => {
  243. console.log(limits)
  244. limit = limits
  245. currentPage.value = 1
  246. searchAchieve({ skip: 0, limit: limit })
  247. }
  248. </script>
  249. <style scoped lang="scss">
  250. .main {
  251. background: #f7f7f7;
  252. .one {
  253. margin: 10px 0;
  254. background-color: #fff;
  255. padding: 24px;
  256. border-top: 6px solid #2374ff;
  257. overflow: hidden;
  258. border-radius: 0 0 5px 5px;
  259. .oneText {
  260. display: flex;
  261. padding: 20px;
  262. margin: 10px 0;
  263. border-radius: 10px;
  264. border: 1px solid #edeff2;
  265. .one_1 {
  266. .image {
  267. width: 150px;
  268. height: 150px;
  269. border-radius: 90px;
  270. }
  271. }
  272. .one_2 {
  273. .name {
  274. display: flex;
  275. align-items: center;
  276. font-size: $global-font-size-18;
  277. color: #121834;
  278. font-weight: 500;
  279. margin: 5px 0 0 0;
  280. .tags {
  281. grid-gap: 0.5rem;
  282. gap: 0.5rem;
  283. display: flex;
  284. margin: 0 0 0 10px;
  285. }
  286. }
  287. .name:hover {
  288. color: #2374ff;
  289. }
  290. .other {
  291. font-size: $global-font-size-14;
  292. text-align: justify;
  293. line-height: $global-font-size-14;
  294. font-weight: 400;
  295. letter-spacing: 0;
  296. color: #8f97a3;
  297. margin-top: 10px;
  298. span:last-child {
  299. color: #525a68;
  300. }
  301. }
  302. }
  303. .one_3 {
  304. display: flex;
  305. align-items: center;
  306. justify-content: center;
  307. .file {
  308. display: flex;
  309. align-items: center;
  310. justify-content: center;
  311. font-family: PingFangSC-Regular;
  312. font-size: $global-font-size-16;
  313. color: #2374ff;
  314. span {
  315. margin: 0 0 0 5px;
  316. }
  317. }
  318. }
  319. }
  320. .twoText {
  321. padding: 20px;
  322. border-radius: 10px;
  323. margin: 10px 0;
  324. border: 1px solid #edeff2;
  325. .title {
  326. font-size: $global-font-size-20;
  327. color: #383b40;
  328. letter-spacing: 0;
  329. line-height: $global-font-size-20;
  330. font-weight: 600;
  331. margin-bottom: 30px;
  332. }
  333. .content {
  334. margin-top: 20px;
  335. .list {
  336. border: 1px solid #edeff2;
  337. background: #fff;
  338. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.03);
  339. border-radius: 2px;
  340. width: 270px;
  341. height: 180px;
  342. margin-bottom: 15px;
  343. cursor: pointer;
  344. transition: all 0.3s;
  345. padding: 15px;
  346. .name {
  347. font-size: $global-font-size-18;
  348. color: #121834;
  349. height: 16px;
  350. line-height: 13px;
  351. font-weight: 500;
  352. margin: 10px 0;
  353. }
  354. .name:hover {
  355. color: #2374ff;
  356. }
  357. .two_1 {
  358. font-size: $global-font-size-14;
  359. text-align: justify;
  360. line-height: $global-font-size-14;
  361. font-weight: 400;
  362. letter-spacing: 0;
  363. color: #8f97a3;
  364. margin-top: 15px;
  365. span:last-child {
  366. color: #525a68;
  367. }
  368. }
  369. .bottom {
  370. margin: 10px 0 0 0;
  371. text-align: right;
  372. }
  373. }
  374. .list:hover {
  375. background: #f0f7ff;
  376. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  377. }
  378. .page {
  379. display: flex;
  380. flex-direction: row-reverse;
  381. padding: 20px;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. </style>