list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. <search-drawer title="查询项目" ref="searchDrawer" @onOk="search">
  31. <uni-forms :modelValue="projectFilter" label-position="top" class="form">
  32. <uni-forms-item label="项目名称">
  33. <uni-easyinput
  34. type="text"
  35. class="input"
  36. v-model="projectFilter.project_name"
  37. />
  38. </uni-forms-item>
  39. <uni-forms-item label="项目编号">
  40. <uni-easyinput
  41. type="text"
  42. class="input"
  43. v-model="projectFilter.project_code"
  44. />
  45. </uni-forms-item>
  46. <uni-forms-item label="状态">
  47. <picker
  48. @change="selectChangeStatus"
  49. :range="statusList"
  50. :range-key="'label'"
  51. >
  52. <view class="select">
  53. {{
  54. projectFilter.project_status != null
  55. ? statusList[projectFilter.project_status + 1].label
  56. : "全部"
  57. }}
  58. </view>
  59. </picker>
  60. </uni-forms-item>
  61. </uni-forms>
  62. </search-drawer>
  63. </view>
  64. </template>
  65. <script>
  66. import { queryProject } from "@/services/project";
  67. import { mapState } from "vuex";
  68. import mixin from "@/utils/listMixin";
  69. const statusList = [
  70. { value: null, label: "全部" },
  71. { value: 0, label: "售前" },
  72. { value: 1, label: "转执行" },
  73. { value: 2, label: "转运营" },
  74. { value: 3, label: "转质保" },
  75. ];
  76. export default {
  77. mixins: [mixin],
  78. computed: {
  79. ...mapState(["currentProject"]),
  80. },
  81. data() {
  82. return {
  83. projectList: [],
  84. projectFilter: {
  85. project_name: "",
  86. project_code: "",
  87. project_status: null,
  88. },
  89. checkself: [],
  90. statusList,
  91. self: [{ text: "只看自己", value: 0 }],
  92. };
  93. },
  94. onShow() {
  95. this.initData();
  96. },
  97. methods: {
  98. async getProject(params) {
  99. let res = {};
  100. res = await queryProject(params);
  101. this.pagination.currentPage == 1
  102. ? (this.projectList = res.data.list)
  103. : (this.projectList = this.projectList.concat(res.data.list));
  104. return res.data;
  105. },
  106. async onClickProject(project) {
  107. await this.$store.commit("setCurrentProject", project);
  108. uni.navigateTo({
  109. url: `./detail?id=${project.id}`,
  110. });
  111. },
  112. checkSelf() {
  113. this.projectFilter = {
  114. ...this.projectFilter,
  115. filter_type: this.checkself.length,
  116. };
  117. this.initData();
  118. },
  119. onClickAdd() {
  120. uni.navigateTo({
  121. url: "./add",
  122. });
  123. },
  124. selectChangeStatus(e) {
  125. const item = this.statusList[e.target.value];
  126. this.projectFilter.project_status = item.value;
  127. },
  128. async search() {
  129. this.projectFilter.project_code = this.projectFilter.project_code.toUpperCase();
  130. this.pagination.currentPage = 1;
  131. await this.initData();
  132. this.$refs.searchDrawer.closeDrawer();
  133. },
  134. },
  135. };
  136. </script>
  137. <style lang="less" scoped>
  138. .content {
  139. display: flex;
  140. justify-content: center;
  141. flex-wrap: wrap;
  142. }
  143. .head {
  144. width: 100%;
  145. padding: 0 20px 20px 20px;
  146. position: fixed;
  147. background: #f8f8f8;
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. .title {
  152. font: 24px bold;
  153. }
  154. .self {
  155. font: 16px;
  156. }
  157. }
  158. .list {
  159. width: 90%;
  160. margin-top: 60px;
  161. border-top: 2px solid gray;
  162. }
  163. .project {
  164. border-bottom: 2px solid gray;
  165. padding: 20px 0px;
  166. font-size: 18px;
  167. }
  168. .loadmore {
  169. padding: 20px 0px;
  170. font-size: 18px;
  171. color: gray;
  172. text-align: center;
  173. }
  174. .form {
  175. margin: 0 20px;
  176. }
  177. </style>