list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. checkSelf() {
  124. this.projectFilter = {
  125. ...this.projectFilter,
  126. filter_type: this.checkself.length,
  127. };
  128. this.initData();
  129. },
  130. onClickAdd() {
  131. uni.navigateTo({
  132. url: "./add",
  133. });
  134. },
  135. selectChangeStatus(e) {
  136. const item = this.statusList[e.target.value];
  137. this.projectFilter.project_status = item.value;
  138. },
  139. async search() {
  140. this.projectFilter.project_code =
  141. this.projectFilter.project_code.toUpperCase();
  142. this.pagination.currentPage = 1;
  143. await this.initData();
  144. this.$refs.searchDrawer.closeDrawer();
  145. },
  146. },
  147. };
  148. </script>
  149. <style lang="less" scoped>
  150. .content {
  151. display: flex;
  152. justify-content: center;
  153. flex-wrap: wrap;
  154. }
  155. .head {
  156. width: 100%;
  157. padding: 0 20px 20px 20px;
  158. position: fixed;
  159. background: #f8f8f8;
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. .title {
  164. font: 24px bold;
  165. }
  166. .self {
  167. font: 16px;
  168. }
  169. }
  170. .list {
  171. width: 90%;
  172. margin-top: 60px;
  173. border-top: 2px solid gray;
  174. }
  175. .project {
  176. border-bottom: 2px solid gray;
  177. padding: 20px 0px;
  178. font-size: 18px;
  179. }
  180. .loadmore {
  181. padding: 20px 0px;
  182. font-size: 18px;
  183. color: gray;
  184. text-align: center;
  185. }
  186. .form {
  187. margin: 0 20px;
  188. }
  189. </style>