list.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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>
  24. </view>
  25. </template>
  26. <script>
  27. import { queryProject } from "@/services/project";
  28. import { mapState } from "vuex";
  29. import uniDataCheckbox from "../../uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue";
  30. export default {
  31. components: { uniDataCheckbox },
  32. computed: {
  33. ...mapState(["currentProject"]),
  34. },
  35. data() {
  36. return {
  37. checkself: [],
  38. projectList: [],
  39. self: [{ text: "只看自己", value: 0 }],
  40. };
  41. },
  42. onShow() {
  43. this.getProject({});
  44. },
  45. methods: {
  46. async getProject(params) {
  47. let res = {};
  48. res = await queryProject(params);
  49. this.projectList = res.data.list;
  50. },
  51. async onClickProject(project) {
  52. await this.$store.commit("setCurrentProject", project);
  53. uni.navigateTo({
  54. url: `./detail?id=${project.id}`,
  55. });
  56. },
  57. checkSelf() {
  58. this.getProject({
  59. filter_type: this.checkself.length,
  60. });
  61. },
  62. },
  63. };
  64. </script>
  65. <style lang="less" scoped>
  66. .content {
  67. display: flex;
  68. justify-content: center;
  69. flex-wrap: wrap;
  70. }
  71. .head {
  72. width: 100%;
  73. padding: 0 20px 20px 20px;
  74. position: fixed;
  75. background: #f8f8f8;
  76. display: flex;
  77. justify-content: space-between;
  78. align-items: center;
  79. .title {
  80. font: 24px bold;
  81. }
  82. .self {
  83. font: 16px;
  84. }
  85. }
  86. .list {
  87. width: 90%;
  88. margin-top: 60px;
  89. border-top: 2px solid gray;
  90. }
  91. .project {
  92. border-bottom: 2px solid gray;
  93. padding: 20px 0px;
  94. font-size: 18px;
  95. }
  96. </style>