detail.vue 11 KB

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