Companys.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="app-container">
  3. <div class="title h1" style="margin-top: 10px;">服务企业</div>
  4. <div class="filter-container">
  5. <el-input placeholder="公司名字" v-model="listQueryParam.keyword" style="width: 15%; margin-left: 20px; margin-bottom: 20px;"></el-input>
  6. <el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="search">
  7. 搜索
  8. </el-button>
  9. </div>
  10. <div>
  11. <el-table
  12. :data="companys"
  13. border
  14. fit
  15. style="width: 100%"
  16. v-loading="listLoading"
  17. >
  18. <el-table-column label="名字" align="center" min-width="25%">
  19. <template slot-scope="{row}">
  20. <span>{{ row.name }}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="地址" align="center" :show-overflow-tooltip="true" min-width="35%">
  24. <template slot-scope="{row}">
  25. <span>{{ row.address }}</span>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="注册时间" align="center" min-width="20%">
  29. <template slot-scope="{row}">
  30. <span>{{ row.applyTime }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="发包数(个)" align="center" min-width="20%">
  34. <template slot-scope="{row}">
  35. <span>{{ row.projectCount }}</span>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <pagination v-show="total > 0" :total="total" :page.sync="listQueryParam.pageNo" :limit.sync="listQueryParam.pageSize" @pagination="getList" />
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import Http from '@/js/http'
  45. import Api from '@/js/api'
  46. import {notify} from '@/constants'
  47. import Pagination from '@/components/Pagination'
  48. export default {
  49. name: 'Companys',
  50. components: { Pagination },
  51. data: function () {
  52. return {
  53. companys: [],
  54. listLoading: false,
  55. listQueryParam: {
  56. pageNo: 1,
  57. pageSize: 20,
  58. keyword: ''
  59. },
  60. total: 0
  61. }
  62. },
  63. mounted () {
  64. this.getList()
  65. },
  66. methods: {
  67. search () {
  68. this.listQueryParam.pageNo = 1
  69. this.getList()
  70. },
  71. getList () {
  72. this.listLoading = true
  73. let url = Api.COMPANY.PAGE.replace('{pageNo}', this.listQueryParam.pageNo - 1)
  74. .replace('{pageSize}', this.listQueryParam.pageSize)
  75. url = url + '?keyword=' + this.listQueryParam.keyword
  76. Http.get(url).then((res) => {
  77. const companyPage = res.data
  78. this.total = companyPage.totalCount
  79. this.listQueryParam.pageNo = companyPage.pageNo + 1
  80. this.listQueryParam.pageSize = companyPage.pageSize
  81. this.companys.splice(0, this.companys.length)
  82. companyPage.datas.forEach(company => {
  83. this.companys.push(company)
  84. })
  85. }).catch((error) => {
  86. console.error(error)
  87. notify('error', '获取公司数据异常:' + error)
  88. })
  89. this.listLoading = false
  90. }
  91. }
  92. }
  93. </script>
  94. <style scoped>
  95. </style>