list.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="content">
  3. <view class="head">
  4. <span class="title">项目列表</span>
  5. <span class="self">
  6. <uni-data-checkbox
  7. multiple
  8. v-model="checkself"
  9. :localdata="self"
  10. @change="checkSelf()"
  11. ></uni-data-checkbox>
  12. </span>
  13. </view>
  14. <view class="list">
  15. <view
  16. class="project"
  17. v-for="project in projectList"
  18. :key="project.id"
  19. @click="onClickProject(project)"
  20. >
  21. {{ `${project.project_name}(${project.project_full_code})` }}
  22. </view>
  23. <view class="loadmore">{{ loadMoreText }}</view>
  24. </view>
  25. <uni-fab
  26. :horizontal="'right'"
  27. :popMenu="false"
  28. @fabClick="onClickAdd()"
  29. ></uni-fab>
  30. </view>
  31. </template>
  32. <script>
  33. import { queryProject } from "@/services/project";
  34. import { mapState } from "vuex";
  35. import mixin from "@/utils/listMixin";
  36. export default {
  37. mixins: [mixin],
  38. computed: {
  39. ...mapState(["currentProject"]),
  40. },
  41. data() {
  42. return {
  43. checkself: [],
  44. projectList: [],
  45. self: [{ text: "只看自己", value: 0 }],
  46. };
  47. },
  48. onShow() {
  49. this.initData();
  50. },
  51. methods: {
  52. async getProject(params) {
  53. let res = {};
  54. res = await queryProject(params);
  55. this.pagination.currentPage == 1
  56. ? (this.projectList = res.data.list)
  57. : (this.projectList = this.projectList.concat(res.data.list));
  58. return res.data;
  59. },
  60. async onClickProject(project) {
  61. await this.$store.commit("setCurrentProject", project);
  62. uni.navigateTo({
  63. url: `./detail?id=${project.id}`,
  64. });
  65. },
  66. checkSelf() {
  67. this.projectFilter = {
  68. ...this.projectFilter,
  69. filter_type: this.checkself.length,
  70. };
  71. this.initData();
  72. },
  73. onClickAdd() {
  74. uni.navigateTo({
  75. url: "./add",
  76. });
  77. },
  78. },
  79. };
  80. </script>
  81. <style lang="less" scoped>
  82. .content {
  83. display: flex;
  84. justify-content: center;
  85. flex-wrap: wrap;
  86. }
  87. .head {
  88. width: 100%;
  89. padding: 0 20px 20px 20px;
  90. position: fixed;
  91. background: #f8f8f8;
  92. display: flex;
  93. justify-content: space-between;
  94. align-items: center;
  95. .title {
  96. font: 24px bold;
  97. }
  98. .self {
  99. font: 16px;
  100. }
  101. }
  102. .list {
  103. width: 90%;
  104. margin-top: 60px;
  105. border-top: 2px solid gray;
  106. }
  107. .project {
  108. border-bottom: 2px solid gray;
  109. padding: 20px 0px;
  110. font-size: 18px;
  111. }
  112. .loadmore {
  113. padding: 20px 0px;
  114. font-size: 18px;
  115. color: gray;
  116. text-align: center;
  117. }
  118. </style>