<template>
	<view class="container">
		<z-paging ref="paging" v-model="dataList" @query="queryList" :auto="false">
		<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.problemNo)">
					<view class="fs-flex__between">
						<view>问题单号：{{item.problemNo}}</view>
						<view>紧急程度：
							<tui-text v-if="item.pressingType == 1" type="primary" text="特急"></tui-text>
							<tui-text v-else-if="item.pressingType == 2" type="primary" text="紧急"></tui-text>
							<tui-text v-else-if="item.pressingType == 3" type="primary" text="一般"></tui-text>
						</view>
					</view>
					<view class="fs-flex__between fs-mt16"> 
						<view>
							指派状态：
							<tui-text v-if="item.distributeStatus == 2" text="已指派" type="success"></tui-text>
							<tui-text v-else text="待指派" type="danger"></tui-text>
						</view>
						<view>
							领导确认：
							<tui-text v-if="item.leaderConfrimStatus == 2" text="已确认" type="success"></tui-text>
							<tui-text v-else text="待确认" type="danger"></tui-text>
						</view>
					</view>
					<view class="fs-mt16">道路名称：{{item.roadName}}</view>
					<view class="fs-mt16 fs-ellipsis__2">问题描述：{{item.remark}}</view>
					<view class="fs-mt16">提交日期：{{item.createTime}}</view>
				</view>
				<view class="fs-mt16 fs-align__right">
					<tui-tag type="danger" padding="12rpx 30rpx" shape="circle" plain @click="modalShow(item.problemNo)">驳回</tui-tag>
					<tui-tag type="primary" padding="12rpx 30rpx" shape="circle" plain margin="0 0 0 20rpx" @click="toAllocation(item.problemNo)">分配</tui-tag>
				</view>
			</view>
		</view>
		</z-paging>
		<tui-modal :show="modal" custom padding="30rpx 30rpx">
			<view class="fs-size__28 fs-mb20">问题单号：{{problemNo}}</view>
			<tui-textarea placeholder="请输入驳回原因" isCounter v-model="content" :maxlength="60" textareaBorder borderColor="#577ee3" :size="28" :radius="20" height="130rpx" min-height="130rpx"></tui-textarea>
			<tui-white-space size="large"></tui-white-space>
			<view class="fs-flex__center">
				<tui-button plain width="200rpx" height="60rpx" :size="28" shape="circle" margin="0 50rpx 0 0" @click="modalClose">取消</tui-button>
				<tui-button width="200rpx" height="60rpx" :size="28" shape="circle" @click="confrim">确定</tui-button>
		    </view>
		</tui-modal>
	</view>
</template>

<script>
import { apiWaitDistrList, apiTaskReject } from '@/api/work'
export default {
	data() {
		return {
			dataList: [],
			problemNo: '',
			content: '',
			modal: false
		}
	},
	onLoad() {

	},
  onShow(){
    if (this.$refs.paging) {
      this.$refs.paging.refresh() // 重置到第一页并触发query事件
    }
  },
	methods: {
		// 获取记录列表
		queryList(pageNo, pageSize) {
			const params = {
				pageReq: {isAsc: 'desc', orderByColumn: 'id', pageNum: pageNo, pageSize: pageSize},
				distributeStatus: 1
			}
			apiWaitDistrList({data:params}).then(res => {
				this.$refs.paging.complete(res.rows)
			})
		},
		// 刷新列表
		refreshList() {
			this.$refs.paging.refresh()
		},
		// 跳转详情
		toDetails(problemNo) {
			uni.$tui.href(`/pages/work/daily/details?problem_no=${problemNo}`)
		},
		// 跳转分配
		toAllocation(problemNo) {
			uni.$tui.href(`/pages/work/case/allocation?problem_no=${problemNo}`)
		},
		// 领导驳回
		modalShow(problemNo) {
			this.problemNo = problemNo
			this.content = ''
			this.modal = true
		},
		// 关闭驳回弹窗
		modalClose() {
			this.modal = false
		},
		// 提交驳回
		confrim() {
			if (!this.content) {
				uni.$tui.toast('请输入驳回原因')
				return
			}
			this.modalClose()
			apiTaskReject({data:{problemNo:this.problemNo,remark:this.content}}).then(res => {
				this.problemNo = ''
				uni.$tui.toast('提交成功')
				setTimeout(() => { this.$refs.paging.reload() }, 1500)
			})
		}
	}
}
</script>

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