index.vue 17 KB

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