list.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="page">
  3. <view class="content">
  4. <view class="head">
  5. <span class="title">项目列表</span>
  6. <span class="self">
  7. <uni-data-checkbox
  8. multiple
  9. v-model="checkself"
  10. :localdata="self"
  11. @change="checkSelf()"
  12. ></uni-data-checkbox>
  13. </span>
  14. </view>
  15. <scroll-view
  16. class="list"
  17. :scroll-top="scrollTop"
  18. scroll-y="true"
  19. lower-threshold="20"
  20. @scroll="scroll"
  21. @scrolltolower="scrollToLower()"
  22. >
  23. <uni-collapse>
  24. <uni-collapse-item
  25. v-for="project in projectList"
  26. :key="project.id"
  27. :border="false"
  28. title-border="none"
  29. >
  30. <template v-slot:title>
  31. <uni-list>
  32. <uni-list-item
  33. :title="project.project_name"
  34. :note="project.project_full_code"
  35. :rightText="statusList[project.project_status + 1].label"
  36. />
  37. </uni-list>
  38. </template>
  39. <edit :project="project" :user="user"></edit>
  40. </uni-collapse-item>
  41. </uni-collapse>
  42. <view class="loadmore">{{ loadMoreText }}</view>
  43. </scroll-view>
  44. <uni-fab
  45. :horizontal="'right'"
  46. :popMenu="false"
  47. @fabClick="onClickAdd()"
  48. ></uni-fab>
  49. <search-drawer
  50. title="查询项目"
  51. ref="searchDrawer"
  52. @onOk="search"
  53. >
  54. <uni-forms
  55. :modelValue="projectFilter"
  56. label-position="top"
  57. class="form"
  58. >
  59. <uni-forms-item label="项目名称">
  60. <uni-easyinput
  61. type="text"
  62. class="input"
  63. v-model="projectFilter.project_name"
  64. />
  65. </uni-forms-item>
  66. <uni-forms-item label="项目编号">
  67. <uni-easyinput
  68. type="text"
  69. class="input"
  70. v-model="projectFilter.project_code"
  71. />
  72. </uni-forms-item>
  73. <uni-forms-item label="状态">
  74. <picker
  75. @change="selectChangeStatus"
  76. :range="statusList"
  77. :range-key="'label'"
  78. >
  79. <view class="select">
  80. {{
  81. projectFilter.project_status != null
  82. ? statusList[projectFilter.project_status + 1].label
  83. : "全部"
  84. }}
  85. </view>
  86. </picker>
  87. </uni-forms-item>
  88. </uni-forms>
  89. </search-drawer>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import { queryProject } from "@/services/project";
  95. import { mapState } from "vuex";
  96. import mixin from "@/utils/listMixin";
  97. import edit from "./edit.vue";
  98. const statusList = [
  99. { value: null, label: "全部" },
  100. { value: 0, label: "售前" },
  101. { value: 1, label: "转执行" },
  102. { value: 2, label: "转运营" },
  103. { value: 3, label: "转质保" },
  104. ];
  105. export default {
  106. mixins: [mixin],
  107. components: {
  108. edit,
  109. },
  110. computed: {
  111. ...mapState(["currentProject", "depUserTree"]),
  112. },
  113. data() {
  114. return {
  115. user: {},
  116. projectList: [],
  117. projectFilter: {
  118. project_name: "",
  119. project_code: "",
  120. project_status: null,
  121. },
  122. checkself: [],
  123. statusList,
  124. self: [{ text: "只看自己", value: 0 }],
  125. scrollTop: 0,
  126. showSearch: true,
  127. };
  128. },
  129. onLoad() {
  130. this.init();
  131. },
  132. onShow() {
  133. this.initData();
  134. },
  135. onNavigationBarButtonTap() {
  136. uni.reLaunch({
  137. url: "/pages/index/index",
  138. });
  139. },
  140. methods: {
  141. async init() {
  142. this.user = uni.getStorageSync("user");
  143. await this.$store.dispatch("getDep");
  144. },
  145. async getProject(params) {
  146. let res = {};
  147. res = await queryProject(params);
  148. this.pagination.currentPage == 1
  149. ? (this.projectList = res.data.list)
  150. : (this.projectList = this.projectList.concat(res.data.list));
  151. return res.data;
  152. },
  153. async checkSelf() {
  154. this.projectFilter = {
  155. ...this.projectFilter,
  156. filter_type: this.checkself.length,
  157. };
  158. this.pagination.currentPage = 1;
  159. await this.initData();
  160. this.scrollTop = 0;
  161. },
  162. onClickAdd() {
  163. uni.navigateTo({
  164. url: "./add",
  165. });
  166. },
  167. selectChangeStatus(e) {
  168. const item = this.statusList[e.target.value];
  169. this.projectFilter.project_status = item.value;
  170. },
  171. async search() {
  172. this.projectFilter.project_code =
  173. this.projectFilter.project_code.toUpperCase();
  174. this.pagination.currentPage = 1;
  175. await this.initData();
  176. this.$refs.searchDrawer.closeDrawer();
  177. this.scrollTop = 0;
  178. },
  179. scroll(e) {
  180. this.scrollTop = e.detail.scrollTop;
  181. },
  182. scrollToLower() {
  183. if (this.projectList.length >= this.pagination.total) {
  184. this.loadMoreText = "没有更多数据了";
  185. return;
  186. }
  187. this.pagination.currentPage++;
  188. this.initData();
  189. },
  190. },
  191. };
  192. </script>
  193. <style lang="less" scoped>
  194. .content {
  195. display: flex;
  196. justify-content: center;
  197. flex-wrap: wrap;
  198. }
  199. .head {
  200. width: calc(100% - 60rpx);
  201. // box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
  202. padding: 40rpx;
  203. position: fixed;
  204. background: url("~@/static/app-plus/menu-title-bg.png") no-repeat center;
  205. background-size: 100% 100%;
  206. background-color: #fff;
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. .title {
  211. font: 18px bold;
  212. color: #fff;
  213. }
  214. .self {
  215. font: 16px;
  216. padding-left: 20rpx;
  217. background-color: #fff;
  218. }
  219. }
  220. .list {
  221. width: 90%;
  222. margin-top: 150rpx;
  223. }
  224. .project {
  225. border-bottom: 2rpx solid gray;
  226. padding: 30rpx 0px;
  227. font-size: 16px;
  228. }
  229. .loadmore {
  230. padding: 30rpx 0px;
  231. font-size: 16px;
  232. color: gray;
  233. text-align: center;
  234. }
  235. .form {
  236. margin: 0 20px;
  237. }
  238. </style>