list.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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", "depUserTree"]),
  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. onLoad() {
  95. this.init();
  96. },
  97. onShow() {
  98. this.initData();
  99. },
  100. methods: {
  101. async init() {
  102. await this.$store.dispatch("getDep");
  103. },
  104. async getProject(params) {
  105. let res = {};
  106. res = await queryProject(params);
  107. this.pagination.currentPage == 1
  108. ? (this.projectList = res.data.list)
  109. : (this.projectList = this.projectList.concat(res.data.list));
  110. return res.data;
  111. },
  112. async onClickProject(project) {
  113. await this.$store.commit("setCurrentProject", project);
  114. uni.navigateTo({
  115. url: `./detail?id=${project.id}`,
  116. });
  117. },
  118. checkSelf() {
  119. this.projectFilter = {
  120. ...this.projectFilter,
  121. filter_type: this.checkself.length,
  122. };
  123. this.initData();
  124. },
  125. onClickAdd() {
  126. uni.navigateTo({
  127. url: "./add",
  128. });
  129. },
  130. selectChangeStatus(e) {
  131. const item = this.statusList[e.target.value];
  132. this.projectFilter.project_status = item.value;
  133. },
  134. async search() {
  135. this.projectFilter.project_code =
  136. this.projectFilter.project_code.toUpperCase();
  137. this.pagination.currentPage = 1;
  138. await this.initData();
  139. this.$refs.searchDrawer.closeDrawer();
  140. },
  141. },
  142. };
  143. </script>
  144. <style lang="less" scoped>
  145. .content {
  146. display: flex;
  147. justify-content: center;
  148. flex-wrap: wrap;
  149. }
  150. .head {
  151. width: 100%;
  152. padding: 0 20px 20px 20px;
  153. position: fixed;
  154. background: #f8f8f8;
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. .title {
  159. font: 24px bold;
  160. }
  161. .self {
  162. font: 16px;
  163. }
  164. }
  165. .list {
  166. width: 90%;
  167. margin-top: 60px;
  168. border-top: 2px solid gray;
  169. }
  170. .project {
  171. border-bottom: 2px solid gray;
  172. padding: 20px 0px;
  173. font-size: 18px;
  174. }
  175. .loadmore {
  176. padding: 20px 0px;
  177. font-size: 18px;
  178. color: gray;
  179. text-align: center;
  180. }
  181. .form {
  182. margin: 0 20px;
  183. }
  184. </style>