tasklist.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="u-p-l-30 u-p-r-30 u-flex f-d-c m-w">
  3. <scroll-view class=" sc-view u-p-l-10 u-p-r-10" @scrolltolower="init()" :scroll-y="true" >
  4. <view>
  5. <u-cell-group v-if="list.length > 0">
  6. <u-cell-item @click="tsanavtask(item)" v-for="(item,index) in list" :key="index"
  7. :label-style="{fontWeight: '400',marginTop:'15rpx'}"
  8. :title-style="{fontSize:'28rpx',fontWeight: 'bold',color:'#333333',}"
  9. :label="`发起人:${item.executors[0]} ${item.publishTime}`" :title="item.title"></u-cell-item>
  10. </u-cell-group>
  11. <block v-else>
  12. <u-empty text="暂无数据" mode="list"></u-empty>
  13. </block>
  14. </view>
  15. </scroll-view>
  16. <u-toast ref="sacast" />
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. execlist,
  22. publishlist,
  23. allList
  24. } from "@/api/index.js";
  25. import dayjs from "dayjs";
  26. export default {
  27. data() {
  28. return {
  29. ifOnShow: false,
  30. list: [],
  31. statid: 0,
  32. totalCount: -1,
  33. curPage: 1,
  34. queryform: {
  35. page: 1,
  36. size: 10,
  37. },
  38. status: undefined,
  39. cameFrom: '', //判断来自哪个页面
  40. };
  41. },
  42. onHide() {
  43. this.ifOnShow = true
  44. },
  45. onShow() {
  46. //回到处理中的列表才刷新列表
  47. if (this.ifOnShow && this.statid == 1) {
  48. this.curPage = 1
  49. this.$nextTick(() => this.getTypeList(this.status, 1))
  50. }
  51. },
  52. onLoad(params) {
  53. if (!params.id) {
  54. this.cameFrom = '首页'
  55. this.$nextTick(() => {
  56. this.init()
  57. })
  58. } else {
  59. this.cameFrom = '临时'
  60. this.statid = params.id;
  61. this.status = params.staus
  62. this.$nextTick(() => {
  63. this.init()
  64. })
  65. }
  66. },
  67. methods: {
  68. tsanavtask(row) {
  69. this.$store.state.user.taskdetail = row;
  70. uni.navigateTo({
  71. url: "../viewtask/viewtask",
  72. });
  73. },
  74. // 从子界面进入
  75. init() {
  76. if (this.cameFrom == '首页') {
  77. this.init1()
  78. } else if (this.cameFrom == '临时') {
  79. this.init2();
  80. }
  81. },
  82. //全部任务列表-首页进入
  83. init1() {
  84. if (this.totalCount == -1) {
  85. this.getAllList(1)
  86. } else {
  87. if (this.list.length < this.totalCount) {
  88. this.getAllList(0)
  89. }
  90. else if (this.list.length == this.totalCount) {
  91. this.$refs.sacast.show({
  92. title: '没有更多了',
  93. type: 'info',
  94. })
  95. }
  96. }
  97. },
  98. //获取全部任务列表-首页进入
  99. async getAllList(page) {
  100. let res = await allList({
  101. page: this.curPage,
  102. size: 10,
  103. })
  104. const {
  105. list,
  106. total
  107. } = res.data;
  108. list.forEach((item) => {
  109. item.publishTime = dayjs(item.publishTime).format(
  110. "YYYY-MM-DD HH:mm:ss"
  111. );
  112. item.finishTime = dayjs(item.finishTime).format(
  113. "YYYY-MM-DD HH:mm:ss"
  114. );
  115. });
  116. if (page == 1) {
  117. this.totalCount = total
  118. this.list = list
  119. } else {
  120. let list1 = JSON.parse(JSON.stringify(this.list));
  121. this.list = [...list1, ...list];
  122. }
  123. this.curPage = this.curPage + 1
  124. },
  125. //任务列表-临时任务页进入
  126. init2() {
  127. if (this.totalCount == -1) {
  128. this.getTypeList(this.status, 1)
  129. } else {
  130. if (this.list.length < this.totalCount) {
  131. this.getTypeList(this.status, 0)
  132. }
  133. else if (this.list.length == this.totalCount) {
  134. this.$refs.sacast.show({
  135. title: '没有更多了',
  136. type: 'info',
  137. })
  138. }
  139. }
  140. },
  141. //获取任务列表-临时任务页进入
  142. getTypeList(status, page) {
  143. if (status == 0) {
  144. //我收到的
  145. execlist({
  146. status: this.statid,
  147. page: this.curPage,
  148. size: 10,
  149. }).then(
  150. ({
  151. data
  152. }) => {
  153. const {
  154. list,
  155. total
  156. } = data;
  157. list.forEach((item) => {
  158. item.publishTime = dayjs(item.publishTime).format(
  159. "YYYY-MM-DD HH:mm:ss"
  160. );
  161. item.finishTime = dayjs(item.finishTime).format(
  162. "YYYY-MM-DD HH:mm:ss"
  163. );
  164. });
  165. if (page == 1) {
  166. this.list = []
  167. this.list = list;
  168. this.totalCount = total
  169. } else {
  170. let list1 = JSON.parse(JSON.stringify(this.list));
  171. this.list = [...list1, ...list];
  172. }
  173. this.curPage = this.curPage + 1;
  174. }
  175. );
  176. } else {
  177. publishlist({
  178. status: this.statid,
  179. page: this.curPage,
  180. size: 10,
  181. }) //我发布的
  182. .then(({
  183. data
  184. }) => {
  185. const {
  186. list,
  187. total
  188. } = data;
  189. let lista = list.map((item) => {
  190. item.finishTimeformate = dayjs(item.finishTime).format(
  191. "YYYY-MM-DD HH:mm:ss"
  192. );
  193. return item;
  194. });
  195. if (page == 1) {
  196. this.list = []
  197. this.list = lista;
  198. this.totalCount = total
  199. } else {
  200. let list1 = JSON.parse(JSON.stringify(this.list));
  201. this.list = [...list1, ...lista];
  202. }
  203. this.curPage = this.curPage + 1;
  204. });
  205. }
  206. },
  207. }
  208. };
  209. </script>
  210. <style>
  211. .sc-view {
  212. height: calc(100vh - 94rpx);
  213. width: 690rpx;
  214. /* background: #FFFFFF;
  215. box-shadow: 0px 0px 6rpx 0px rgba(6, 0, 1, 0.26);
  216. border-radius: 10rpx 10rpx 0px 0px; */
  217. }
  218. </style>