<template>
	<view class="check" >
		<view class="navbox">
			<view class="plr12 mt18">
				<view class="search flex0 mb10">
					<image :src="searchimg"></image>
					<input placeholder="输入委员姓名进行查询" v-model="title" @confirm="getSearch"/>
				</view>
			</view>
			<!-- <view class="tablists flexc mb20">
				<view v-for="(ite,idx) in tabList" @click="getTabFn(ite.val)" :class="{act:tabidx==ite.val}" :key="idx">{{ite.tit}}</view>
			</view> -->
		</view>
		<view class="ctip flex0">请左右滑动查看详细信息</view>
		<!-- 表格 -->
		<view class="tables">
			<view class="table">
				<zb-table
				  :show-header="true"
				  :columns="columns"
				  :headbgColor="headbgColor"
				  :stripe="false"
				  :fit="true"
				  :parameter="parameter"
				  @rowClick="rowClick"
				  @toggleRowSelection="toggleRowSelection"
				  @toggleAllSelection="toggleAllSelection"
				  :border="border"
				  :borderr="borderr"
				  @detail="getDetail"
				  @agree="agreeFn"
				  @reject="rejectFn"
				  :data="tableData"></zb-table>	
			</view>
		</view>

		<!-- 弹窗 -->
		<pop-up :type='ptype' :qjsh="qjsh" @getClose="getClose" @getupSubmit="getupSubmit"></pop-up>
	</view>
</template>

<script>
	import zbTable from "@/work/components/zb-table/zb-tables.vue"
	import {getMeetDetaiFn,getMeetPeoListFn,getzxActivityPeoFn,getzxActivitypsFn,getzxConferencepsFn} from "@/api/mine/meeting.js"
	import popUp from "@/work/components/popup/popup.vue"
	import {getDictionaryFn} from "@/api/mine/register.js"
	export default{
		components:{popUp,zbTable},
		data(){
			return{
				searchimg: require("@/work/static/images/search.png"),
				ccicoimg:require("@/work/static/images/ccico.png"),
				lbicoimg:require("@/work/static/images/lbico.png"),
				backimg:require("@/work/static/images/back.png"),
				upimg:require("@/work/static/images/up.png"),
				backgroundColor:"#1D64E2",
				tabidx:0,
				tabList:[{tit:'全部',val:0},{tit:'已读',val:1},{tit:'未读',val:2},{tit:'请假',val:3}],
				talbList:[{},],
				taztList:[{label:'是',value:'0'},{label:'否',value:'1'}],
				talbidx:'',
				datainfo:{
					talb:'',
				},
				columns: [
				    { name: 'userName', label: '姓名',width:130,align:'center', },
				    { name: 'postName', label: '工作地址及职务',align:'center'},
				    { name: 'replyTime', label: '答复时间',align:'center'},
				    // { name: 'unit', label: '是否参会',align:'center'},
					{ name: 'isJoin', type:'operation',label: '是否参会',key:"qjlist",renders:[
						  {
						    name:'isJoin',
						    type:'detail',
						    func:"detail"
						  },
					]},
					{ name: 'leaveReason', label: '请假事由',align:'center'},
					{ name: 'operation', type:'operation',label: '批示',renders:[
					    {
					      name:'同意',
					      class:'agree',
					      type:"primary",
					      func:'agree' // func 代表子元素点击的事件 父元素接收的事件 父元素 @edit
					    },
					    {
					      name:'驳回',
					      type:'warn', // type 为custom的时候自定义按钮
					      class:"del",
					      func:'reject',
					    },
					  ]},
				],
				ptype:'',//弹窗类型
				border:true,
				borderr:false,
				headbgColor:'#F1F1F1',
				tableData:[],
				id:'',
				title:'',
				parameter:{
					qjlist:[]
				},
				tabidx:"",
				qjsh:'',
				userId:'',
				
			}
		},
		onUnload(){
			uni.$off('refreshlist')
		},
		onLoad(e) {
			this.id=e.id;
			this.tabidx=e.a
			this.getDataFn()
			this.init()
			// this.getDataFn()
			
			// uni.$on('refreshlist', (e) => {
			// 	this.getDataFn()
			// })
		},
		mounted() {
		},
		methods:{
			agreeFn(ite){
				var that=this;
				var type=this.tabidx;
				var userId=ite.userId
				// that.ptype=''
				uni.showModal({
					title: '确认同意',
					content: "是否确认同意",
					cancelText: '取消',
					confirmText: '确认',
					success: function(res) {
						if (res.confirm) {
							var params={
								approval:2
							}
							if(type=='zxhd'){
								params.activityId=that.id
								params.userId=userId
								getzxActivitypsFn(params).then(res=>{
									if(res.code==200){
										that.$toast('已同意')
									}
								}) 
							}else{
								params.conferenceId=that.id
								params.userId=userId
								getzxConferencepsFn(params).then(res=>{
									if(res.code==200){
										that.$toast('已同意')
									}
								}) 
							}
						} else if (res.cancel) {
						}
					}
				});
			},
			rejectFn(ite){
				this.qjsh='3';
				this.ptype='qjps';
				this.userId=ite.userId;
			},
			// 提案状态
			init(){
				// 请假理由
				getDictionaryFn('leave').then(res=>{
					if(res.code==200&&res.data.length){
						this.parameter.qjlist = res.data.map(v => {
							return {
								label: v.dictLabel,
								value: v.dictValue
							}
						})
					}
				})
			},
			getupSubmit(data){
				var params=JSON.parse(JSON.stringify(data))
				var that=this;
				var type=this.tabidx;
				if(type=='zxhd'){
					params.activityId=that.id
					params.userId=that.userId
					getzxActivitypsFn(params).then(res=>{
						if(res.code==200){
							that.$toast('已驳回')
							that.ptype='';
						}
					}) 
				}else{
					params.conferenceId=that.id
					params.userId=that.userId
					getzxConferencepsFn(params).then(res=>{
						if(res.code==200){
							that.$toast('已驳回')
							that.ptype='';
						}
					}) 
				}
			},
			getClose(){
				this.ptype=""
			},
			getTabFn(idx){
				this.tabidx=idx;
			},
			getBack(){
				uni.navigateBack({
					delta:1
				})
			},
			rowClick(){
				
			},
			getDetail(data){
				console.log(52)
				// this.$tab.navigateTo('/work/pages/case/details?id='+data)	
			},
			getSearch(){
				this.getDataFn()
			},
			getDataFn(){
				var params={
					userName:this.title
				}
				var type=this.tabidx;
				if(type=='zxhd'){
					params.activityId=this.id
					getzxActivityPeoFn(params).then(res=>{
						if(res.code==200){
							this.tableData=res.rows
						}
					}) 
				}else{
					params.conferenceId=this.id
					getMeetPeoListFn(params).then(res=>{
						if(res.code==200){
							this.tableData=res.rows
						}
					}) 
				}
				
				
			},
		}
	}
</script>

<style scoped lang="scss">
page{background-color: #FFFFFF;}
.check{height: 100vh;display: flex;flex-direction: column;
	.tables{flex:0 1 auto;overflow: auto;padding: 0 24rpx;
		.table{
			height: 100%;
		}
	}
	.ctip{font-weight: 500;padding: 22rpx 24rpx 26rpx;font-size: 26rpx;color: #FF0000;}
	.cbtn{margin: 0 24rpx;height: 80rpx;background: #1D64E2;border-radius: 80rpx;font-weight: bold;font-size: 30rpx;color: #FFFFFF;}
}
.navbox{background-color: $com-cd3;flex: 0 0 auto;
	.tablists{
		overflow: auto;flex-wrap: nowrap;
		view{font-weight: bold;font-size: 26rpx;color: #FFFFFF;position: relative;flex: 1;padding: 22rpx 24rpx;margin-right: 6rpx;box-sizing: border-box;
				text-align: center;
			&:last-child{margin-right: 0;}
			&.act{font-size: 30rpx;
				&::after{content: '';width: 62rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -31rpx;bottom: 0rpx;position: absolute;}
			}
		}
	}
}
</style>