list.vue 4.6 KB

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