1
2
3
4
5
| <script setup lang="ts">
| import { computed,ref } from "vue";import { onPullDownRefresh,onReachBottom,onShow } from "@dcloudio/uni-app";import { getTaskManagerPage,type BpmTask } from "../../../../api/bpm";import { getSimpleDictDataList,type DictData } from "../../../../api/crm";import { useAuth } from "../../../../stores/auth";import { DICT,dateTimeText,dictLabel,durationText,taskStatusText } from "../../shared";import { statusToneClass } from "../../../../utils/status";
| const {hasPermission,state}=useAuth(),keyword=ref(""),rows=ref<BpmTask[]>([]),dicts=ref<DictData[]>([]),pageNo=ref(1),total=ref(0),loading=ref(false),error=ref("");const canQuery=computed(()=>hasPermission("bpm:task:query")),hasMore=computed(()=>rows.value.length<total.value);function statusText(v?:number){return dictLabel(dicts.value,DICT.BPM_TASK_STATUS,v,taskStatusText(v))}async function load(reset=false){if(!state.accessToken||loading.value||!canQuery.value)return;if(reset){pageNo.value=1;rows.value=[]}loading.value=true;error.value="";try{if(!dicts.value.length)dicts.value=await getSimpleDictDataList(state.accessToken);const d=await getTaskManagerPage(state.accessToken,{pageNo:pageNo.value,pageSize:15,name:keyword.value.trim()||undefined});total.value=d.total||0;rows.value=reset?(d.list||[]):rows.value.concat(d.list||[]);pageNo.value+=1}catch(e){error.value=e instanceof Error?e.message:"流程任务加载失败"}finally{loading.value=false}}function history(row:BpmTask){const id=row.processInstance?.id||row.processInstanceId;if(id)uni.navigateTo({url:`/pages/bpm/process-instance/detail?id=${encodeURIComponent(id)}`})}onShow(()=>load(true));onPullDownRefresh(async()=>{await load(true);uni.stopPullDownRefresh()});onReachBottom(()=>hasMore.value&&load());
| </script>
| <template><view class="page"><view class="search"><input v-model="keyword" placeholder="搜索任务名称" confirm-type="search" @confirm="load(true)"/><text @click="load(true)">搜索</text></view><view v-if="!canQuery" class="state">暂无流程任务查看权限</view><view v-if="error" class="state error" @click="load(true)">{{error}}</view><view v-for="row in rows" :key="row.id" class="card"><view class="head"><view><text class="name">{{row.processInstance?.name||'流程任务'}}</text><text>{{row.name||'暂无当前任务'}}</text></view><text :class="['tag',statusToneClass(row.status,statusText(row.status))]">{{statusText(row.status)}}</text></view><view class="grid two"><text>发起人:{{row.processInstance?.startUser?.nickname||'--'}}</text><text>审批人:{{row.assigneeUser?.nickname||'--'}}</text><text>开始:{{dateTimeText(row.createTime||row.startTime)}}</text><text>结束:{{dateTimeText(row.endTime)}}</text><text>耗时:{{durationText(row.durationInMillis)}}</text><text>审批建议:{{row.reason||'--'}}</text><text>流程编号:{{row.processInstanceId||'--'}}</text><text>任务编号:{{row.id||'--'}}</text></view><view class="actions"><button @click="history(row)">历史</button></view></view><view v-if="canQuery&&!rows.length&&!loading" class="state">暂无流程任务</view><view v-else-if="rows.length" class="more">{{hasMore?(loading?'加载中...':'上拉加载更多'):'没有更多了'}}</view></view></template><style lang="scss" scoped>@import "../../../ai/list.scss";.tag-success,.tag-approved,.tag-finished{color:#0e9663;background:#e9fbf2}.tag-danger,.tag-cancelled{color:#c65050;background:#fff0f0}.tag-info,.tag-progress{color:var(--color-primary, #1769d8);background:var(--color-primary-soft, #eef6ff)}.tag-warning,.tag-draft{color:#c78210;background:#fff8e8}</style>
|
|