list.vue 6.6 KB

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