index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <script>
  2. import {getEnterpriseList} from "@/api/commitment";
  3. export default {
  4. props:{
  5. propDataList: {
  6. type: Array,
  7. default: () => []
  8. },
  9. /* 如果为true则不再使用接口请求 */
  10. noRequest: {
  11. type: Boolean,
  12. default: false
  13. }
  14. },
  15. data() {
  16. return {
  17. enterpriseList: [],
  18. loading: false,
  19. finished: false,
  20. current: 0,
  21. size: 10
  22. };
  23. },
  24. mounted() {
  25. if(this.noRequest) {
  26. this.finished = true;
  27. this.loading = false;
  28. }
  29. },
  30. watch: {
  31. propDataList: {
  32. handler(val) {
  33. if(this.noRequest) {
  34. this.enterpriseList = val
  35. }
  36. },
  37. deep:true
  38. }
  39. },
  40. methods: {
  41. /* 获取企业列表 */
  42. async handleGetEnterpriseList() {
  43. this.loading = true; // 开始加载
  44. try {
  45. const res = await getEnterpriseList({
  46. current: this.current + 1,
  47. size: this.size
  48. });
  49. if (res.data.records) {
  50. this.enterpriseList = this.enterpriseList.concat(res.data.records || [])
  51. this.current++;
  52. this.finished = res.data.records.length < this.size; // 判断是否还有更多数据
  53. }
  54. this.loading = false; // 加载结束
  55. } catch (e) {
  56. console.log(e);
  57. this.loading = false;
  58. }
  59. },
  60. handleClick(item) {
  61. this.$router.push({
  62. path: '/subPages/pages/commitment/enterpriseCommitment/index',
  63. query: {
  64. uuid: item.uuid
  65. }
  66. })
  67. }
  68. }
  69. };
  70. </script>
  71. <template>
  72. <van-list
  73. v-model="loading"
  74. @load="handleGetEnterpriseList"
  75. :finished="finished"
  76. finished-text="没有更多数据了"
  77. >
  78. <van-cell
  79. v-for="(item, index) in enterpriseList"
  80. :key="item.uuid"
  81. class="box"
  82. @click="handleClick(item)"
  83. >
  84. <template #default>
  85. <view class="top">
  86. <view class="name">
  87. {{ item.companyName }}
  88. <!--后端计算量大,先去掉-->
  89. <!--<van-tag round color="#f4a40d" style="margin-left: 5px"> {{item.creditGoal || '暂无' }}</van-tag>-->
  90. </view>
  91. </view>
  92. <view class="details">
  93. 最新承诺时间 : {{ item.createTime | date("YYYY-MM-DD HH:mm:ss") }}
  94. </view>
  95. </template>
  96. </van-cell>
  97. </van-list>
  98. </template>
  99. <style scoped lang="scss">
  100. .box {
  101. min-height: 78px;
  102. background: #FFFFFF;
  103. border-radius: 6px;
  104. margin: 12px 10px;
  105. width: auto;
  106. .top {
  107. display: flex;
  108. justify-content: space-between;
  109. .name {
  110. font-size: 16px;
  111. font-weight: bold;
  112. flex: 1;
  113. overflow: hidden;
  114. text-overflow: ellipsis;
  115. white-space: nowrap;
  116. display: flex;
  117. }
  118. }
  119. .details {
  120. font-size: 14px;
  121. color: #666666;
  122. overflow: hidden;
  123. text-overflow: ellipsis;
  124. white-space: nowrap;
  125. }
  126. }
  127. </style>