base.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. <template>
  2. <custom-layout class="main">
  3. <el-col :span="24" class="one">
  4. <el-image class="image" :src="lists" fit="fill" />
  5. </el-col>
  6. <div class="w_1300">
  7. <el-col :span="24" class="two">
  8. <div class="Seacher">
  9. <div class="Left">
  10. <span>行业</span>
  11. </div>
  12. <div v-if="!oneShow" class="Right">
  13. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in plateList.slice(0, 6)" :key="index" @click="toSelect(item, '1')">
  14. {{ item.title }}
  15. </div>
  16. </div>
  17. <div v-else class="Right">
  18. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in plateList" :key="index" @click="toSelect(item, '1')">
  19. {{ item.title }}
  20. </div>
  21. </div>
  22. <div class="button">
  23. <span v-if="!oneShow" @click="oneShow = true">
  24. <el-icon><ArrowDown /></el-icon>
  25. </span>
  26. <span v-else @click="oneShow = false">
  27. <el-icon><ArrowUp /></el-icon>
  28. </span>
  29. </div>
  30. </div>
  31. <div class="Seacher border">
  32. <div class="Left">
  33. <span>所在地</span>
  34. </div>
  35. <div class="Right">
  36. <div class="label" :class="[item.is_active ? 'show' : '']" v-for="(item, index) in cityList" :key="index" @click="toSelect(item, '3')">
  37. {{ item.name }}
  38. </div>
  39. </div>
  40. </div>
  41. <div class="two_ipunt">
  42. <el-input class="input" size="large" v-model="searchForm.name" placeholder="名称" />
  43. <el-input class="input" size="large" v-model="searchForm.tags" placeholder="标签名称" />
  44. <el-button class="button" size="large" type="primary" @click="toSearchInfo">检索</el-button>
  45. </div>
  46. </el-col>
  47. <div class="thr">
  48. <div class="list" v-for="(item, index) in list" :key="index" @click="toView(item)">
  49. <div class="name">{{ item.name || '暂无' }}</div>
  50. <div class="other">
  51. <div class="other_1">
  52. <el-image class="image" :src="getUrl(item.logo)" fit="fill">
  53. <template v-slot:error>
  54. <el-image class="image" :src="companyLogo" fit="fill" />
  55. </template>
  56. </el-image>
  57. </div>
  58. <div class="other_2">
  59. <span class="text"><em>负责人姓名:</em>{{ item.person || '暂无' }}</span>
  60. <span class="text"><em>是否和平台合作标识:</em>{{ getDict(item.cooperate, 'cooperate') || '暂无' }}</span>
  61. <span class="text"><em>地址:</em>{{ getArea(item.area) || '暂无' }}</span>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="four">
  67. <el-pagination background layout="prev, pager, next" :total="total" :page-size="limit" v-model:current-page="currentPage" @current-change="changePage" @size-change="sizeChange" />
  68. </div>
  69. </div>
  70. </custom-layout>
  71. </template>
  72. <script setup>
  73. // 图片引入
  74. import lists from '/images/company.png'
  75. const $checkRes = inject('$checkRes')
  76. import { get } from 'lodash-es'
  77. // 接口
  78. import { IncubatorStore } from '@/store/api/user/incubator'
  79. import { RegionStore } from '@/store/api/system/region'
  80. import { SectorStore } from '@/store/api/platform/sector'
  81. import { DictDataStore } from '@/store/api/system/dictData'
  82. const store = IncubatorStore()
  83. const regionStore = RegionStore()
  84. const sectorStore = SectorStore()
  85. const dictDataStore = DictDataStore()
  86. // 加载中
  87. const loading = ref(false)
  88. // 路由
  89. const router = useRouter()
  90. const list = ref([])
  91. let skip = 0
  92. let limit = 15
  93. const total = ref(0)
  94. // 是否展开
  95. const oneShow = ref(false)
  96. // 字典表
  97. const cityList = ref([])
  98. const plateList = ref([])
  99. const isUseList = ref([])
  100. // 搜索
  101. const searchForm = ref({})
  102. // 查询
  103. const industry = ref([])
  104. const city = ref([])
  105. // 请求
  106. onMounted(async () => {
  107. loading.value = true
  108. await searchOther()
  109. await search({ skip, limit })
  110. loading.value = false
  111. })
  112. const searchOther = async () => {
  113. let result
  114. // 是否使用
  115. result = await dictDataStore.query({ code: 'isUse', is_use: '0' })
  116. if ($checkRes(result)) isUseList.value = result.data
  117. // 城市
  118. result = await regionStore.list({ level: 'city', parent_code: 22 })
  119. if ($checkRes(result)) cityList.value = result.data
  120. cityList.value.unshift({ id: '-1', code: '-1', name: '不限', is_active: true })
  121. // 行业
  122. result = await sectorStore.query({ is_use: '0' })
  123. if ($checkRes(result)) plateList.value = result.data
  124. plateList.value.unshift({ id: '-1', title: '不限', is_active: true })
  125. }
  126. const search = async (query = { skip, limit }) => {
  127. skip = query.skip
  128. limit = query.limit
  129. const info = {
  130. skip: query.skip,
  131. limit: query.limit,
  132. status: '1',
  133. is_show: '0',
  134. ...searchForm.value
  135. }
  136. const res = await store.query(info)
  137. if (res.errcode == '0') {
  138. list.value = res.data
  139. total.value = res.total
  140. }
  141. }
  142. // 查看
  143. const toView = (item) => {
  144. router.push({ path: `/base/detail`, query: { id: item.id || item._id } })
  145. }
  146. const getUrl = (item) => {
  147. if (item && item.length > 0) return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  148. }
  149. // 地区
  150. const getArea = (data) => {
  151. if (data) return data.join('-')
  152. else return '暂无地区'
  153. }
  154. // 字典数据转换
  155. const getDict = (data, model) => {
  156. let res
  157. if (model == 'cooperate') res = isUseList.value.find((f) => f.value == data)
  158. return get(res, 'label')
  159. }
  160. const currentPage = ref(1)
  161. // 分页
  162. const changePage = (page = currentPage.value) => {
  163. search({ skip: (page - 1) * limit, limit: limit })
  164. }
  165. const sizeChange = (limits) => {
  166. limit = limits
  167. currentPage.value = 1
  168. search({ skip: 0, limit: limit })
  169. }
  170. // 筛选条件
  171. const toSearchFind = async () => {
  172. if (industry.value && industry.value.length > 0) {
  173. searchForm.value.industry = industry.value.map((i) => {
  174. return i.title
  175. })
  176. } else delete searchForm.value.industry
  177. if (city.value && city.value.length > 0) {
  178. searchForm.value.area = city.value.map((i) => {
  179. return i.name
  180. })
  181. } else delete searchForm.value.area
  182. await search({ skip, limit })
  183. }
  184. const toSelect = async (data, type) => {
  185. if (data.is_active) {
  186. toDel(data, type)
  187. } else {
  188. if (data.id != '-1') {
  189. if (type == '1') {
  190. for (const val of plateList.value) {
  191. if (data.id == val.id) val.is_active = true
  192. if (val.id == '-1') val.is_active = false
  193. }
  194. const res = industry.value.find((i) => i.id == data.id)
  195. if (!res) industry.value.push(data)
  196. } else {
  197. for (const val of cityList.value) {
  198. if (data.id == val.id) val.is_active = true
  199. if (val.id == '-1') val.is_active = false
  200. }
  201. const res = city.value.find((i) => i.id == data.id)
  202. if (!res) city.value.push(data)
  203. }
  204. } else {
  205. if (type == '1') {
  206. for (const val of plateList.value) {
  207. if (val.id == '-1') val.is_active = true
  208. else val.is_active = false
  209. }
  210. industry.value = []
  211. } else {
  212. for (const val of cityList.value) {
  213. if (val.id == '-1') val.is_active = true
  214. else val.is_active = false
  215. }
  216. city.value = []
  217. }
  218. }
  219. }
  220. await toSearchFind()
  221. }
  222. const toDel = async (data, type) => {
  223. if (type == '1') {
  224. for (const val of plateList.value) {
  225. if (data.id == val.id) val.is_active = false
  226. }
  227. industry.value = industry.value.filter((f) => f.id != data.id)
  228. if (industry.value.length == 0) {
  229. for (const val of plateList.value) {
  230. if (val.id == '-1') val.is_active = true
  231. }
  232. }
  233. } else {
  234. for (const val of cityList.value) {
  235. if (data.id == val.id) val.is_active = false
  236. }
  237. city.value = city.value.filter((f) => f.id != data.id)
  238. if (city.value.length == 0) {
  239. for (const val of cityList.value) {
  240. if (val.id == '-1') val.is_active = true
  241. }
  242. }
  243. }
  244. await toSearchFind()
  245. }
  246. </script>
  247. <style scoped lang="scss">
  248. .main {
  249. .one {
  250. .image {
  251. width: 100%;
  252. height: 350px;
  253. }
  254. }
  255. .active {
  256. .active_1 {
  257. display: inline-flex;
  258. background: #f5f7f9;
  259. border-radius: 2px;
  260. min-height: 28px;
  261. line-height: 28px;
  262. margin: 0 10px 0 0;
  263. position: relative;
  264. background-color: #fff;
  265. padding: 10px;
  266. .active_left {
  267. flex: 0 0 auto;
  268. font-family: PingFangSC-Regular;
  269. color: #525a68;
  270. line-height: 36px;
  271. }
  272. .active_right {
  273. font-family: PingFangSC-Regular;
  274. color: rgba(0, 0, 0, 0.85);
  275. line-height: 28px;
  276. padding-right: 4px;
  277. display: flex;
  278. flex-wrap: wrap;
  279. overflow: hidden;
  280. .active_label {
  281. overflow: hidden;
  282. display: inline-block;
  283. margin-right: 10px;
  284. margin-top: 3px;
  285. margin-bottom: 3px;
  286. padding: 10px;
  287. display: flex;
  288. align-items: center;
  289. flex: none;
  290. box-sizing: border-box;
  291. max-width: 100%;
  292. height: 30px;
  293. background: #f5f5f5;
  294. border: 1px solid #f0f0f0;
  295. border-radius: 2px;
  296. cursor: default;
  297. }
  298. }
  299. }
  300. }
  301. .two {
  302. margin: 10px 0 0 0;
  303. .Seacher {
  304. display: flex;
  305. justify-content: center;
  306. align-items: stretch;
  307. position: relative;
  308. border: solid 1px #e5e5e5;
  309. border-bottom: 0;
  310. font-size: $global-font-size-18;
  311. color: #666;
  312. min-height: 60px;
  313. overflow: hidden;
  314. .Left {
  315. display: flex;
  316. justify-content: center;
  317. align-items: center;
  318. flex-shrink: 0;
  319. width: 110px;
  320. text-align: center;
  321. color: #000;
  322. font-weight: bold;
  323. background-color: #fafafa;
  324. }
  325. .Right {
  326. display: flex;
  327. flex-wrap: wrap;
  328. align-items: center;
  329. padding: 12px;
  330. flex: 1;
  331. border-left: solid 1px #e5e5e5;
  332. background-color: #fff;
  333. .label {
  334. margin-right: 3px;
  335. color: #313131;
  336. margin-bottom: 10px;
  337. padding: 8px 10px;
  338. border-radius: 3px;
  339. background-color: #fff;
  340. border: solid 1px transparent;
  341. cursor: pointer;
  342. }
  343. .show {
  344. color: #0a58c2;
  345. border: solid 1px #006dd2;
  346. }
  347. .label:hover {
  348. color: $global-color-107;
  349. }
  350. }
  351. .button {
  352. display: flex;
  353. align-items: center;
  354. margin: 0 5px 0 0;
  355. }
  356. }
  357. .border {
  358. border: solid 1px #e5e5e5;
  359. border-bottom: 1;
  360. }
  361. .two_ipunt {
  362. display: flex;
  363. align-items: center;
  364. justify-content: space-between;
  365. margin: 10px 0;
  366. .input {
  367. margin: 0 5px 0 0;
  368. }
  369. .button {
  370. margin: 0 0 0 5px;
  371. }
  372. }
  373. }
  374. .thr {
  375. display: flex;
  376. align-items: center;
  377. justify-content: center;
  378. flex-wrap: wrap;
  379. .list {
  380. float: left;
  381. width: 405px;
  382. padding: 15px;
  383. margin: 0 10px 25px 10px;
  384. background: #f0f8ff;
  385. color: #000;
  386. cursor: default;
  387. .name {
  388. height: 57px;
  389. line-height: 57px;
  390. overflow: hidden;
  391. font-size: $global-font-size-18;
  392. font-weight: bold;
  393. }
  394. .other {
  395. display: flex;
  396. .other_1 {
  397. .image {
  398. width: 95px;
  399. height: 95px;
  400. display: inline-block;
  401. }
  402. }
  403. .other_2 {
  404. display: flex;
  405. flex-direction: column;
  406. margin: 0 0 0 10px;
  407. .text {
  408. height: 25px;
  409. display: block;
  410. line-height: 24px;
  411. overflow: hidden;
  412. color: #666;
  413. margin-bottom: 10px;
  414. em {
  415. border: 1px #ccc solid;
  416. background: #fff;
  417. border: 1px #ab94f8 solid;
  418. padding: 1px 5px;
  419. color: #4131bb;
  420. margin-right: 6px;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. }
  427. .four {
  428. display: flex;
  429. justify-content: center;
  430. margin: 20px 0;
  431. }
  432. }
  433. </style>