<template>
	<view>
		<view v-for="item in list">
			<uni-card :title=" '客户:'+(item.deptName==null?' ':item.deptName)"
				:extra="'负责人:'+(item.leader==null?' ':item.leader)">
				<view style="position: relative;line-height: 6vw;">
					<u-row>
						<u-col span="8">
							<view>联系电话:{{item.phone}}</view>
							<view>创建时间:{{item.createTime}}</view>
							<view>审核时间:{{item.reviewTime==null?'':item.reviewTime}}</view>
							<uni-tag title="?????"></uni-tag>
							<view>审核状态:<uni-tag size="small" :text="item.status==0?'待审核':'审核完成'"
									:type="item.status==0?'primary':'success'" /></view>
							<view>是否通过:<uni-tag size="small" :text="item.status==0?'待审核':item.delFlag==1?'审核通过':'审核失败'"
									:type="item.status==0?'primary':item.delFlag==1?'success':'error'" /></view>
							<view v-if="item.delFlag==0&&item.delFlag!=''">
								原因:{{item.remark}}
							</view>
						</u-col>
						<u-col span="4">
							<image @click="previewImg(orders(item))" aspectFit style="width: 120px;height: 80px;" :src="orders(item)"></image>
							<u-button :disabled="item.status==1?true:false" icon="eye-fill" type="primary"
								@click="openDetailDialog(item.id)" :plain="true" size="mini" text="审核"></u-button>
						</u-col>

					</u-row>

				</view>
			</uni-card>
		</view>
		<u-modal title="审核是否通过:" @cancel="closeDlg" confirmText="提交" :showCancelButton="true" @confirm="submitReg"
			:show="show">
			<view class="slot-content">
				<view>
					<radio-group @change="change">
						通过:
						<radio value="1"></radio>
						不通过:
						<radio value="0"></radio>
					</radio-group>
				</view>
				<view v-if="chooseUser.delFlag==0&&chooseUser.delFlag!=''">
					<u-input v-model="chooseUser.remark" placeholder="请输入不通过原因..."></u-input>
				</view>
			</view>
		</u-modal>
	</view>

</template>

<script>
	import config from '@/config'
	import {
		listReviews,
		reviewsAdopt,
		reviews
	} from '@/api/user/user';
	export default {
		data() {
			return {
				total:0, //数据总长
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					deptName: undefined,
					leader: undefined,
					phone: undefined,
					status: undefined,
					delFlag: undefined,
				},
				list: [],
				show: false,
				chooseUser: [],
				switchdis: false, //已经审核完禁用
			}
		},
		created() {
			this.queryParams= {
				pageNum: 1,
				pageSize: 10,
				deptName: undefined,
				leader: undefined,
				phone: undefined,
				status: undefined,
				delFlag: undefined,
			},
			this.listReviews()
		},
		onReachBottom() {
			if(this.total>this.list.length){
				this.queryParams.pageNum++
				this.listReviews()
			}
		},
		methods: {
			previewImg(imgurl) {
			    uni.previewImage({
			      current: imgurl,
			      urls: [imgurl]
			    });
			  },
			submitReg() {
				if((this.chooseUser.remark==null||this.chooseUser.remark=='')&&this.chooseUser.delFlag==0){
					uni.showToast({
						title: '请输入原因',
						duration: 1500,
						icon: 'none'
					});
					return;
				}
				
				reviewsAdopt(this.chooseUser).then((response) => {
					this.show = false;
					this.queryParams= {
						pageNum: 1,
						pageSize: 10,
						deptName: undefined,
						leader: undefined,
						phone: undefined,
						status: undefined,
						delFlag: undefined,
					},
					this.listReviews();
				});
			},
			change(event) {
				this.chooseUser.delFlag = event.detail.value
				console.log('this.chooseUser>>>' + JSON.stringify(this.chooseUser))
			},
			closeDlg() {
				console.log('closeDlg>>>>>>>')
				this.show = false
			},
			listReviews() {
				listReviews(this.queryParams).then(res => {
					
					let lists = res.rows
					
					this.total=res.total 
					if(this.total>this.list.length){
					for (let l in lists) {
						this.list.push(lists[l])
					}	
					}
					console.log('list>>' + JSON.stringify(this.list))
				})
			},
			orders(item) {
				let baseUrl = config.baseUrl
				return baseUrl + item.orders
			},
			// 打开信息详情
			openDetailDialog(id) {
				this.show = true;
				reviews(id).then((response) => {
					this.chooseUser = response.data;
					console.log("this.form>>>>>???>>>" + JSON.stringify(this.chooseUser));
				});
			},


		}
	}
</script>

<style>
	.mb-10 {
		margin-bottom: 10px;
	}

	.decoration {
		width: 6px;
		height: 6px;
		margin-right: 4px;
		border-radius: 50%;
		background-color: #18bc37 !default;
	}
</style>