| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <template>
- <view class="u-p-l-30 u-p-r-30 u-flex f-d-c m-w">
- <scroll-view class=" sc-view u-p-l-10 u-p-r-10" @scrolltolower="init()" :scroll-y="true" >
- <view>
- <u-cell-group v-if="list.length > 0">
- <u-cell-item @click="tsanavtask(item)" v-for="(item,index) in list" :key="index"
- :label-style="{fontWeight: '400',marginTop:'15rpx'}"
- :title-style="{fontSize:'28rpx',fontWeight: 'bold',color:'#333333',}"
- :label="`发起人:${item.executors[0]} ${item.publishTime}`" :title="item.title"></u-cell-item>
- </u-cell-group>
- <block v-else>
- <u-empty text="暂无数据" mode="list"></u-empty>
- </block>
- </view>
- </scroll-view>
- <u-toast ref="sacast" />
- </view>
- </template>
- <script>
- import {
- execlist,
- publishlist,
- allList
- } from "@/api/index.js";
- import dayjs from "dayjs";
- export default {
- data() {
- return {
- ifOnShow: false,
- list: [],
- statid: 0,
- totalCount: -1,
- curPage: 1,
- queryform: {
- page: 1,
- size: 10,
- },
- status: undefined,
- cameFrom: '', //判断来自哪个页面
- };
- },
- onHide() {
- this.ifOnShow = true
- },
- onShow() {
- //回到处理中的列表才刷新列表
- if (this.ifOnShow && this.statid == 1) {
- this.curPage = 1
- this.$nextTick(() => this.getTypeList(this.status, 1))
- }
- },
- onLoad(params) {
- if (!params.id) {
- this.cameFrom = '首页'
- this.$nextTick(() => {
- this.init()
- })
- } else {
- this.cameFrom = '临时'
- this.statid = params.id;
- this.status = params.staus
- this.$nextTick(() => {
- this.init()
- })
- }
- },
- methods: {
- tsanavtask(row) {
- this.$store.state.user.taskdetail = row;
- uni.navigateTo({
- url: "../viewtask/viewtask",
- });
- },
- // 从子界面进入
- init() {
- if (this.cameFrom == '首页') {
- this.init1()
- } else if (this.cameFrom == '临时') {
- this.init2();
- }
- },
- //全部任务列表-首页进入
- init1() {
- if (this.totalCount == -1) {
- this.getAllList(1)
- } else {
- if (this.list.length < this.totalCount) {
- this.getAllList(0)
- }
- else if (this.list.length == this.totalCount) {
- this.$refs.sacast.show({
- title: '没有更多了',
- type: 'info',
- })
- }
- }
- },
- //获取全部任务列表-首页进入
- async getAllList(page) {
- let res = await allList({
- page: this.curPage,
- size: 10,
- })
- const {
- list,
- total
- } = res.data;
- list.forEach((item) => {
- item.publishTime = dayjs(item.publishTime).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- item.finishTime = dayjs(item.finishTime).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- });
- if (page == 1) {
- this.totalCount = total
- this.list = list
- } else {
- let list1 = JSON.parse(JSON.stringify(this.list));
- this.list = [...list1, ...list];
- }
- this.curPage = this.curPage + 1
- },
- //任务列表-临时任务页进入
- init2() {
- if (this.totalCount == -1) {
- this.getTypeList(this.status, 1)
- } else {
- if (this.list.length < this.totalCount) {
- this.getTypeList(this.status, 0)
- }
- else if (this.list.length == this.totalCount) {
- this.$refs.sacast.show({
- title: '没有更多了',
- type: 'info',
- })
- }
- }
- },
- //获取任务列表-临时任务页进入
- getTypeList(status, page) {
- if (status == 0) {
- //我收到的
- execlist({
- status: this.statid,
- page: this.curPage,
- size: 10,
- }).then(
- ({
- data
- }) => {
- const {
- list,
- total
- } = data;
- list.forEach((item) => {
- item.publishTime = dayjs(item.publishTime).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- item.finishTime = dayjs(item.finishTime).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- });
- if (page == 1) {
- this.list = []
- this.list = list;
- this.totalCount = total
- } else {
- let list1 = JSON.parse(JSON.stringify(this.list));
- this.list = [...list1, ...list];
- }
- this.curPage = this.curPage + 1;
- }
- );
- } else {
- publishlist({
- status: this.statid,
- page: this.curPage,
- size: 10,
- }) //我发布的
- .then(({
- data
- }) => {
- const {
- list,
- total
- } = data;
- let lista = list.map((item) => {
- item.finishTimeformate = dayjs(item.finishTime).format(
- "YYYY-MM-DD HH:mm:ss"
- );
- return item;
- });
- if (page == 1) {
- this.list = []
- this.list = lista;
- this.totalCount = total
- } else {
- let list1 = JSON.parse(JSON.stringify(this.list));
- this.list = [...list1, ...lista];
- }
- this.curPage = this.curPage + 1;
- });
- }
- },
- }
- };
- </script>
- <style>
-
- .sc-view {
- height: calc(100vh - 94rpx);
- width: 690rpx;
- /* background: #FFFFFF;
- box-shadow: 0px 0px 6rpx 0px rgba(6, 0, 1, 0.26);
- border-radius: 10rpx 10rpx 0px 0px; */
- }
- </style>
|