<template>
	<scroll-view :style="{height: `calc(${approveListHeight}px - 20rpx)`}" class="di-scroll" scroll-y @scrolltolower="handleOnreachBottom" :refresher-triggered="triggered"
		refresher-enabled @refresherrefresh="handlePullDownRefresh">
		<view class="di-scroll-list">
			<!-- 右滑 -->
			<u-swipe-action
			    style="margin-bottom: 20rpx;border-radius: 10rpx;overflow: hidden;"
				v-for="(item, index) in list"
				:show="activeIndex === item[primaryKey]"
				:key="index" 
				:index='item.id'    
				@content-click="(id) => handle2ProcessTask('', item.id, item.category, item.procDefId, false)">
				<di-descriptions :title="item.processDefinitionName" label-col="3" value-col="9" :border-bottom="true" >
					<u-tag slot="right" size="mini" :text="item.statusLabel" :type="statusColorMap[item.statusLabel]" mode="light" />
					<!-- <di-descriptions-item label="流程名称" :value="item.processDefinitionName" :ellipsis="true"/>
					<di-descriptions-item label="开始时间" :value="item.startTime" :ellipsis="true"/>
					<di-descriptions-item label="结束时间" :value="item.endTime" :ellipsis="true"/>
					<di-descriptions-item label="流程耗时" :value="item.durationLabel" :ellipsis="true"/> -->
                    <!-- 后端说单号是id 查询是procInstId -->
					<di-descriptions-item label="流程单号" :value="item.processNo" :ellipsis="true"/>
					<di-descriptions-item label="当前节点" :value="item.taskDefName" :ellipsis="true"/>
					<di-descriptions-item label="申请人" :value="item.applyUserName" :ellipsis="true"/>
					<di-descriptions-item label="申请时间" :value="item.applyTime" :ellipsis="true"/>


                    <u-row style="justify-content: flex-end;">
                        <u-col :span="2" v-if="item.endTime == null">
                          <u-button type="primary" plain size="mini"  @click="handle2Click(item.id, 'cancel')">撤销</u-button>
                         </u-col>
                         <u-col :span="2.5" v-if="['已撤销', '不通过'].indexOf(item.statusLabel) > -1">
                          <u-button type="primary" plain size="mini"  @click="handle2RestartWorkflow(item)">重新发起</u-button>
                         </u-col>
                    </u-row>
                </di-descriptions>
            </u-swipe-action>
		</view>
		<u-loadmore v-if="!triggered" :status="status" :loadText='loadText' margin-top="24" margin-bottom="20" />
	</scroll-view>
</template>

<script>
   
	import approveList from './approveList'
	export default {
		mixins: [approveList],
        // inject: ['applyTime'],
		data() {
			return {
				baseApi: '/cusFlowTask',
				listApi: 'myApplyList',
				statusColorMap: {
				  '已完成': 'success',
				  '进行中': 'warning',
				  '已撤销': 'info',
				  '不通过': 'error'
				}
			}
		},
        methods: {
         
        }
	}
</script>

<style>
.di-scroll-list {
	background: none;
}
</style>
