index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="default-width">
  3. <div class="white-bgc py-3">
  4. <headSearch></headSearch>
  5. <div class="px-5 mt-3 clear-parent">
  6. <areaType class="mb-3" :isClear="clear" @handleClick="handleSearch"></areaType>
  7. <industryType :isClear="clear" @handleClick="handleSearch"></industryType>
  8. <natureType class="my-5" :isClear="clear" @handleClick="handleSearch"></natureType>
  9. <scaleType :isClear="clear" @clear="clear = false" @handleClick="handleSearch"></scaleType>
  10. <div class="clear" @click="handleClear">清空筛选条件</div>
  11. </div>
  12. </div>
  13. <companyItem class="mt-3" :list="items"></companyItem>
  14. <MPagination
  15. :total="total"
  16. :page="pageInfo.pageNo"
  17. :limit="pageInfo.pageSize"
  18. @handleChange="handleChangePage"
  19. ></MPagination>
  20. </div>
  21. </template>
  22. <script setup>
  23. defineOptions({name: 'retrieval-company-page'})
  24. import { ref } from 'vue'
  25. import { getEnterpriseSearch } from '@/api/enterprise'
  26. import { dealDictData } from '../position/components/dict'
  27. import headSearch from '@/components/headSearch'
  28. import scaleType from './components/scaleType'
  29. import natureType from './components/natureType'
  30. import industryType from './components/industryType'
  31. import areaType from './components/areaType'
  32. import companyItem from './components/companyItem'
  33. import MPagination from '@/components/CtPagination'
  34. const clear = ref(false)
  35. const handleClear = () => {
  36. clear.value = true
  37. query.value = {
  38. ...pageInfo.value
  39. }
  40. }
  41. const total = ref(0)
  42. const items = ref([])
  43. const pageInfo = ref({
  44. pageSize: 10,
  45. pageNo: 1
  46. })
  47. const query = ref({
  48. ...pageInfo.value
  49. })
  50. // 搜索
  51. const handleSearch = async (val, key) => {
  52. query.value.pageNo = 1
  53. // val为-1时选择的是不限或者全国, 此时选中的字段不传
  54. if (val === -1) delete query.value[key]
  55. else query.value[key] = val
  56. await getCompanyData()
  57. }
  58. const getCompanyData = async () => {
  59. const { list, total: number } = await getEnterpriseSearch(query.value)
  60. total.value = number
  61. items.value = dealDictData(items.value, list)
  62. }
  63. getCompanyData()
  64. // 分页
  65. const handleChangePage = (index) => {
  66. pageInfo.value.pageNo = index
  67. getCompanyData()
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. .clear-parent {
  72. position: relative
  73. }
  74. .clear {
  75. position: absolute;
  76. bottom: 0;
  77. right: 30px;
  78. color: #999;
  79. font-size: 14px;
  80. cursor: pointer;
  81. &:hover {
  82. color: var(--v-primary-base);
  83. }
  84. }
  85. </style>