<template>
	<scroll-view style="flex:1">
		<view class="tableTop">
			<u-subsection bg-color="rgb(215,224,233)" button-color="rgb(0,99,208)" active-color="white" :list="list" @change="subChange"></u-subsection>
			<view class="operation">
				<uni-easyinput placeholder="请输入编号"></uni-easyinput>
				<u-button type="primary" size="medium" ripple>查询</u-button>
				<u-button size="medium" ripple>刷新</u-button>
			</view>
		</view>
		<u-line length="95%" margin="auto" color="#000"/>
		<myTable 
			:column="column" 
			:tableData="tableData"
			:pageCurrent="pageCurrent"
			:pageSize="pageSize"
			:total="total"
			blUrl="/pages/information/information?url=/pages/handleMeeting/handleMeeting"
		></myTable>
	</scroll-view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onReady } from"@dcloudio/uni-app"
	import { ApiRequest } from "@/utils/request.js"

	const list = ref([{name: '待办'}, {name: '已办'}, {name: '办结'}])
	
	const currentUrl = ref('/g2work/routeinfo/queryDataTodoWithPage')
	const pageCurrent = ref(1)
	const pageSize = ref(15)
	const total = ref(0)
	const column = ref(["紧急程度", "流程名称", "编号", "承办部门", "标题", "会议室", "参会人数", "当前节点", "接收时间", "操作"])
	const tableData = ref([])
	
	//切换页签
	function subChange(e){
		pageCurrent.value = 1 //重置当前页码
		switch (e){
			case 0: //待办
				currentUrl.value = '/g2work/routeinfo/queryDataTodoWithPage'
				getTableList('/g2work/routeinfo/queryDataTodoWithPage')
				break;
			case 1: //已办
				currentUrl.value = '/g2work/routeinfo/queryDataDoneWithPage'
				getTableList('/g2work/routeinfo/queryDataDoneWithPage')
				break;
			case 2: //办结
				currentUrl.value = '/g2work/routeinfo/queryDataFinishWithPage'
				getTableList('/g2work/routeinfo/queryDataFinishWithPage')
				break;
		}
	}
	
	function getTableList(url, pageno){
		ApiRequest({
			url: url,
			method: 'POST',
			data:{
				pageno: pageno || pageCurrent.value,
				pagesize: pageSize.value,
				userid: uni.getStorageSync('GlWorkPlatform-userid'),
				querycondition: "[]",
				ordercondition:  "",
				flowid: "AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06"
			}
		}).then(res=>{
			if(res.code === 0 && res.success){
				tableData.value = res.data.map(item=>{
					return {
						'FW_WFH.JJCDCAPTION': item['FW_WFH.JJCDCAPTION'],
						'FLOWNAME': item['FLOWNAME'],
						'FW_WFH.BT': item['FW_WFH.BT'],
						'FW_WFH.FWZH': item['FW_WFH.FWZH'],
						'FW_WFH.ZS': item['FW_WFH.ZS'],
						'FW_WFH.SFXYJDCAPTION': item['FW_WFH.SFXYJDCAPTION']
					}
				})
				total.value = res.meta.totalCount
			}
		})
	}
	
	//更改页码
	function pageChange(val){
		pageCurrent.value = val
		getTableList(currentUrl.value, val)
	}
	
	onReady(()=>{
		getTableList('/g2work/routeinfo/queryDataTodoWithPage')
	})
</script>

<style lang="scss" scoped>
	::v-deep .uni-table-scroll{
		margin: 0 50rpx !important;
		width: calc(100vw - 100rpx) !important;
	}
</style>
