company.vue 16 KB

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