detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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-row :span="24" class="one_1">
  8. <el-col :span="20" class="title">{{ info.name || '暂无标题' }}</el-col>
  9. <el-col :span="4" class="file" @click="toCollection(0)" v-if="info.is_collection">
  10. <el-icon :size="16"><StarFilled /></el-icon>
  11. <span>已收藏</span>
  12. </el-col>
  13. <el-col :span="4" class="file" @click="toCollection(1)" v-else>
  14. <el-icon :size="16"><Star /></el-icon>
  15. <span>收藏</span>
  16. </el-col>
  17. </el-row>
  18. </el-col>
  19. <el-col :span="24" class="two">
  20. <a-descriptions bordered>
  21. <a-descriptions-item label="行业分类">
  22. {{ getDict(info.type, 'type') }}
  23. </a-descriptions-item>
  24. <a-descriptions-item label="成熟度">
  25. {{ getDict(info.maturity, 'maturity') }}
  26. </a-descriptions-item>
  27. <a-descriptions-item label="技术类型">
  28. {{ getDict(info.skill, 'skill') }}
  29. </a-descriptions-item>
  30. <a-descriptions-item label="行业领域">
  31. {{ getDict(info.field, 'field') }}
  32. </a-descriptions-item>
  33. <a-descriptions-item label="合作类型">
  34. {{ getDict(info.cooperate, 'cooperate') }}
  35. </a-descriptions-item>
  36. <a-descriptions-item label="项目地区">
  37. {{ getArea(info.area) }}
  38. </a-descriptions-item>
  39. <a-descriptions-item label="发布时间">
  40. {{ info.time }}
  41. </a-descriptions-item>
  42. </a-descriptions>
  43. </el-col>
  44. <el-col :span="24" class="pointer">
  45. <div class="money">
  46. 价格:<span> {{ info.money || '面议' }} </span>
  47. </div>
  48. <a-button v-if="info.status == '1'" type="primary" @click="toDocking">
  49. 我要对接
  50. </a-button>
  51. </el-col>
  52. <el-col :span="24" class="pointer" v-if="!user && !user._id">
  53. 提醒:您还没有登录,登录成功后再对接
  54. </el-col>
  55. <el-col :span="24" class="thr">
  56. <el-col :span="24" class="thr_1">
  57. <p>单位信息</p>
  58. </el-col>
  59. <el-row :span="24" class="thr_2">
  60. <el-col :span="17" class="left">
  61. <el-col :span="24" class="name">
  62. {{ userInfo.name || '暂无单位' }}
  63. </el-col>
  64. <el-col :span="24" class="other">
  65. <span>联系人</span>
  66. {{ userInfo.name || '暂无联系人' }}
  67. </el-col>
  68. </el-col>
  69. <el-col :span="4" class="right" v-if="info.status == '1'">
  70. <a-button type="primary" @click="toChat">
  71. <template #icon>
  72. <MessageOutlined />
  73. </template>
  74. 点击在线洽谈
  75. </a-button>
  76. </el-col>
  77. </el-row>
  78. </el-col>
  79. <a-divider />
  80. <el-col :span="24" class="four">
  81. <el-col :span="24" class="four_1">
  82. <p>项目简介</p>
  83. </el-col>
  84. <el-col :span="24" class="four_2">{{ info.brief || '暂无' }}</el-col>
  85. </el-col>
  86. <el-col :span="24" class="four">
  87. <el-col :span="24" class="four_1">
  88. <p>相关推荐</p>
  89. </el-col>
  90. <el-col :span="24" class="four_3">
  91. <a-list :loading="loading" :grid="{ gutter: 16, column: 4 }" :data-source="list">
  92. <template #renderItem="{ item }">
  93. <el-col :span="24" class="list">
  94. <el-col :span="24" class="name textOver">
  95. <el-tooltip effect="dark" :content="item.name" placement="top">
  96. {{ item.name || '暂无名称' }}
  97. </el-tooltip>
  98. </el-col>
  99. <el-col :span="24" class="two_1">
  100. <span>行业领域:</span>{{ getDict(item.field, 'field') }}
  101. </el-col>
  102. <el-col :span="24" class="two_1">
  103. <span>项目地区:</span>{{ getArea(item.area) }}
  104. </el-col>
  105. <el-col :span="24" class="two_1">
  106. <span>单位:</span>{{ item.userName || '暂无单位' }}
  107. </el-col>
  108. <el-col :span="24" class="bottom">
  109. <a-button size="small" type="primary" @click="toView(item)">
  110. 查看详情
  111. </a-button>
  112. </el-col>
  113. </el-col>
  114. </template>
  115. </a-list>
  116. <el-col :span="24" class="page">
  117. <el-pagination
  118. background
  119. layout="total, prev, pager, next"
  120. :page-sizes="[10, 20, 50, 100, 200]"
  121. :total="total"
  122. :page-size="limit"
  123. v-model:current-page="currentPage"
  124. @current-change="changePage"
  125. @size-change="sizeChange"
  126. >
  127. </el-pagination>
  128. </el-col>
  129. </el-col>
  130. </el-col>
  131. </div>
  132. </el-col>
  133. </el-row>
  134. </div>
  135. </template>
  136. <script setup>
  137. import moment from 'moment'
  138. // 基础
  139. import { MessageOutlined } from '@ant-design/icons-vue'
  140. import { get } from 'lodash-es'
  141. const $checkRes = inject('$checkRes')
  142. // 接口
  143. import { ProjectStore } from '@/store/api/platform/project'
  144. import { CollectionStore } from '@/store/api/platform/collection'
  145. import { DictDataStore } from '@/store/api/system/dictData'
  146. const store = ProjectStore()
  147. const collectionStore = CollectionStore()
  148. const dictDataStore = DictDataStore()
  149. import { UserStore } from '@/store/user'
  150. const userStore = UserStore()
  151. const user = computed(() => userStore.user)
  152. // 路由
  153. const route = useRoute()
  154. const router = useRouter()
  155. // 加载中
  156. const loading = ref(false)
  157. const info = ref({})
  158. const userInfo = ref({})
  159. // 字典表
  160. const fieldList = ref([])
  161. const typeList = ref([])
  162. const maturityList = ref([])
  163. const skillList = ref([])
  164. const cooperateList = ref([])
  165. // 成果列表
  166. const list = ref([])
  167. let skip = 0
  168. let limit = inject('limit')
  169. const total = ref(0)
  170. // 请求
  171. onMounted(async () => {
  172. loading.value = true
  173. await searchOther()
  174. await search()
  175. await searchProject({ skip, limit })
  176. loading.value = false
  177. })
  178. const search = async () => {
  179. let id = route.query.id
  180. if (id) {
  181. let res = await store.detail(id)
  182. if (res.errcode == '0') {
  183. info.value = res.data
  184. userInfo.value = res.data.userInfo
  185. }
  186. }
  187. }
  188. const searchProject = async (query = { skip: 0, limit }) => {
  189. const info = {
  190. skip: query.skip,
  191. limit: query.limit,
  192. is_use: '0',
  193. status: '1'
  194. }
  195. const res = await store.list(info)
  196. if (res.errcode == '0') {
  197. list.value = res.data
  198. total.value = res.total
  199. }
  200. }
  201. const searchOther = async () => {
  202. let result
  203. // 行业分类
  204. result = await dictDataStore.query({ code: 'industry', is_use: '0' })
  205. if ($checkRes(result)) typeList.value = result.data
  206. // 成熟度
  207. result = await dictDataStore.query({ code: 'projectMaturity', is_use: '0' })
  208. if ($checkRes(result)) maturityList.value = result.data
  209. // 技术领域
  210. result = await dictDataStore.query({ code: 'field', is_use: '0' })
  211. if ($checkRes(result)) fieldList.value = result.data
  212. // 技术类型
  213. result = await dictDataStore.query({ code: 'technology', is_use: '0' })
  214. if ($checkRes(result)) skillList.value = result.data
  215. // 合作类型
  216. result = await dictDataStore.query({ code: 'projectType', is_use: '0' })
  217. if ($checkRes(result)) cooperateList.value = result.data
  218. }
  219. // 字典数据转换
  220. const getDict = (data, model) => {
  221. let res
  222. if (model == 'skill') res = skillList.value.find((f) => f.value == data)
  223. else if (model == 'cooperate') res = cooperateList.value.find((f) => f.value == data)
  224. else if (model == 'field') res = fieldList.value.find((f) => f.value == data)
  225. else if (model == 'maturity') res = maturityList.value.find((f) => f.value == data)
  226. else if (model == 'type') res = typeList.value.find((f) => f.value == data)
  227. return get(res, 'label')
  228. }
  229. // 地区
  230. const getArea = (data) => {
  231. if (data) return data.join(',')
  232. else return '暂无地区'
  233. }
  234. // 在线洽谈
  235. const toChat = () => {
  236. router.push({ path: '/chat', query: { id: info.value.id || info.value._id } })
  237. }
  238. // 我要对接
  239. const toDocking = () => {
  240. console.log('我要对接')
  241. }
  242. // 收藏
  243. const toCollection = async (status) => {
  244. if (user.value._id) {
  245. let res
  246. let message
  247. const data = {
  248. user: user.value._id,
  249. source: info.value._id,
  250. type: 'project',
  251. time: moment().format('YYYY-MM-DD')
  252. }
  253. if (status == '1') {
  254. message = '收藏成功'
  255. res = await collectionStore.create(data)
  256. } else {
  257. message = '取消收藏成功'
  258. res = await collectionStore.cancel(data)
  259. }
  260. if (res.errcode === 0) {
  261. ElMessage({
  262. message,
  263. type: 'success'
  264. })
  265. await search()
  266. }
  267. } else {
  268. ElMessage({
  269. message: '未登录无法进行收藏 请登录',
  270. type: 'warning'
  271. })
  272. }
  273. }
  274. // 查看
  275. const toView = (item) => {
  276. router.push({ path: '/project/detail', query: { id: item.id || item._id } })
  277. }
  278. const currentPage = ref(1)
  279. // 分页
  280. const changePage = (page = currentPage.value) => {
  281. searchProject({ skip: (page - 1) * limit, limit: limit })
  282. }
  283. const sizeChange = (limits) => {
  284. console.log(limits)
  285. limit = limits
  286. currentPage.value = 1
  287. searchProject({ skip: 0, limit: limit })
  288. }
  289. </script>
  290. <style scoped lang="scss">
  291. .main {
  292. .one {
  293. margin: 10px 0 0 0;
  294. background: #f7f7f7;
  295. padding: 24px;
  296. border-top: 6px solid #2374ff;
  297. overflow: hidden;
  298. border-radius: 0 0 5px 5px;
  299. .one_1 {
  300. margin: 0 0 10px 0;
  301. .title {
  302. font-size: 18px;
  303. font-weight: 700;
  304. color: #383b40;
  305. }
  306. .file {
  307. display: flex;
  308. align-items: center;
  309. justify-content: flex-end;
  310. font-family: PingFangSC-Regular;
  311. font-size: 14px;
  312. color: #2374ff;
  313. span {
  314. margin: 0 0 0 5px;
  315. }
  316. }
  317. }
  318. .one_2 {
  319. display: inline-block;
  320. font-size: 12px;
  321. background: rgba(18, 172, 117, 0.05);
  322. color: #12ac75;
  323. padding: 0 15px;
  324. height: 20px;
  325. line-height: 20px;
  326. border-radius: 10px;
  327. margin-bottom: 2px;
  328. }
  329. }
  330. .two {
  331. background: #f9fafb;
  332. border-radius: 2px;
  333. padding: 30px;
  334. margin: 34px 0 20px;
  335. font-family: PingFangSC-Medium;
  336. font-size: 14px;
  337. color: #383b40;
  338. line-height: 14px;
  339. }
  340. .thr {
  341. margin: 0 0 10px 0;
  342. .thr_1 {
  343. width: 100%;
  344. height: 40px;
  345. line-height: 40px;
  346. border-bottom: 2px solid #2374ff;
  347. margin: 20px 0;
  348. background: #f7f7f7;
  349. p {
  350. float: left;
  351. padding: 0 20px;
  352. height: 40px;
  353. border-bottom: 2px solid #2374ff;
  354. color: #fff;
  355. font-size: 18px;
  356. background: #2374ff;
  357. }
  358. }
  359. .thr_2 {
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. background: #fff;
  364. border: 1px solid #edeff2;
  365. box-shadow: 0 4px 10px 0 rgba(0, 0, 0, 0.03);
  366. border-radius: 2px;
  367. padding: 30px 20px;
  368. .left {
  369. .name {
  370. height: 20px;
  371. font-family: PingFangSC-Semibold;
  372. font-size: 18px;
  373. color: #383b40;
  374. line-height: 20px;
  375. font-weight: 700;
  376. margin-bottom: 8px;
  377. }
  378. .other {
  379. height: 14px;
  380. font-family: PingFangSC-Medium;
  381. font-size: 14px;
  382. color: #383b40;
  383. line-height: 14px;
  384. font-weight: 700;
  385. span {
  386. height: 14px;
  387. font-family: PingFangSC-Regular;
  388. font-size: 14px;
  389. color: #7e8288;
  390. line-height: 14px;
  391. font-weight: 400;
  392. margin-right: 16px;
  393. }
  394. }
  395. }
  396. .right {
  397. display: flex;
  398. justify-content: space-between;
  399. }
  400. }
  401. }
  402. .four {
  403. margin: 0 0 10px 0;
  404. .four_1 {
  405. width: 100%;
  406. height: 40px;
  407. line-height: 40px;
  408. border-bottom: 2px solid #2374ff;
  409. margin: 20px 0;
  410. background: #f7f7f7;
  411. p {
  412. float: left;
  413. padding: 0 20px;
  414. height: 40px;
  415. border-bottom: 2px solid #2374ff;
  416. color: #fff;
  417. font-size: 18px;
  418. background: #2374ff;
  419. }
  420. }
  421. .four_3 {
  422. margin: 20px;
  423. .list {
  424. border: 1px solid #edeff2;
  425. background: #fff;
  426. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.03);
  427. border-radius: 2px;
  428. width: 280px;
  429. height: 180px;
  430. margin-bottom: 15px;
  431. cursor: pointer;
  432. transition: all 0.3s;
  433. padding: 15px;
  434. .name {
  435. font-size: 16px;
  436. color: #121834;
  437. height: 16px;
  438. line-height: 13px;
  439. font-weight: 500;
  440. margin: 10px 0;
  441. }
  442. .name:hover {
  443. color: #2374ff;
  444. }
  445. .two_1 {
  446. font-size: 12px;
  447. text-align: justify;
  448. line-height: 12px;
  449. font-weight: 400;
  450. letter-spacing: 0;
  451. color: #8f97a3;
  452. margin-top: 15px;
  453. span:last-child {
  454. color: #525a68;
  455. }
  456. }
  457. .bottom {
  458. margin: 10px 0 0 0;
  459. text-align: right;
  460. }
  461. }
  462. .list:hover {
  463. background: #f0f7ff;
  464. box-shadow: 0 0 16px rgba(205, 205, 205, 0.6);
  465. }
  466. .page {
  467. display: flex;
  468. flex-direction: row-reverse;
  469. padding: 20px;
  470. }
  471. }
  472. }
  473. .pointer {
  474. display: flex;
  475. align-items: center;
  476. justify-content: flex-end;
  477. font-family: PingFangSC-Regular;
  478. font-size: 14px;
  479. color: #7e8288;
  480. margin: 10px 0 0 0;
  481. .money {
  482. margin: 0 10px 0 0;
  483. span {
  484. font-family: PingFangSC-Semibold;
  485. font-size: 20px;
  486. color: #e94643;
  487. line-height: 20px;
  488. }
  489. }
  490. }
  491. }
  492. </style>