<template>
	<view class="container">
		<z-paging ref="paging" v-model="dataList" @query="queryList">
		<template #top>
			<tui-tabs :tabs="tabsList" :currentTab="currentTab" :height="90" :padding="10" bold :scale="1.1" @change="change"></tui-tabs>
		</template>
		<view class="ul fs-p20">
			<view class="li fs-bg__white fs-p30 fs-size__h4 fs-radius__sm fs-mt20" v-for="(item, index) in dataList">
				<view @click="toDetails(item.planNo)">
					<view class="fs-flex__between">
						<view class="fs-weight__bold fs-flex1 fs-ellipsis">{{item.planName}}</view>
						<tui-text v-if="item.planStatus" text="已完成" type="success"></tui-text>
						<tui-text v-else text="未完成" type="danger"></tui-text>
					</view>
					<view class="fs-flex fs-mt20">
						<view class="fs-flex1">编码：{{item.planNo}}</view>
						<view class="fs-flex1">周期：{{item.levelValue}}{{item.cycleName}}</view>
					</view>
					<view class="fs-flex fs-mt20">
						<view class="fs-flex1">养护类型：{{item.maintainTypeName}}</view>
						<view class="fs-flex1">养护等级：{{item.curingLevelName}}</view>
					</view>
					<view class="fs-flex__between fs-mt20">
						<view class="fs-flex1">计划次数：{{item.planNum}}</view>
						<view class="fs-flex1">完成次数：{{item.planFinishNum}}</view>
					</view>
				</view>
				<view class="fs-mt20 fs-align__right">
					<tui-tag type="primary" padding="12rpx 30rpx" shape="circle" plain @click="toRecord(item.planNo)">巡检记录</tui-tag>
				</view>
			</view>
		</view>
		</z-paging>
	</view>
</template>

<script>
import { apiInspectionList } from '@/api/work'
export default {
	data() {
		return {
			tabsList: [
				{name: "全部", sign: ""}, 
				{name: "已完成", sign: 1},
				{name: "未完成", sign: 0}
			],
			currentTab: 0,
			dataList: []
		}
	},
	onLoad() {

	},
	methods: {
		// 获取巡检列表
		queryList(pageNo, pageSize) {
			const params = {
				pageReq: {isAsc: 'desc', orderByColumn: 'id', pageNum: pageNo, pageSize: pageSize},
				type: 1,
				planStatus: this.tabsList[this.currentTab].sign
			}
			apiInspectionList({data:params}).then(res => {
				this.$refs.paging.complete(res.rows)
			})
		},
		// 切换菜单
		change(e) {
			this.currentTab = e.index
			this.$refs.paging.reload()
		},
		// 跳转详情
		toDetails(planno) {
			uni.$tui.href(`/pages/work/daily/inspection/details?planno=${planno}`)
		},
		// 跳转记录
		toRecord(planno) {
			uni.$tui.href(`/pages/work/daily/inspection/record?planno=${planno}`)
		}
	}
}
</script>

<style lang="scss" scoped>
.ul .li:first-child {
	margin-top: 0;
}
</style>
