<template>
	<div class="app-container">

		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
			label-width="68px">


			<!-- <el-form-item label="开始日期" prop="beginTime">
				<div class="block">
					<el-date-picker  v-model="queryParams.beginTime" value-format="yyyy-MM-dd"
						type="date" placeholder="选择日期" style="width: 200px;">
					</el-date-picker>
				</div>
			</el-form-item>
			<el-form-item label="结束日期" prop="endTime">
				<div class="block">
					<el-date-picker  v-model="queryParams.endTime" type="date"
						value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 200px;">
					</el-date-picker>
				</div>
			</el-form-item> -->
			<el-form-item label="姓名" prop="customerName">
				<el-input v-model="queryParams.customerName"  style="width: 200px;" placeholder="请输入姓名"
					clearable @keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="账号" prop="gameAccount">
				<el-input v-model="queryParams.gameAccount"  style="width: 200px;" placeholder="请输入账号"
					clearable @keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="手机号" prop="phone">
				<el-input v-model="queryParams.phone"  style="width: 200px;" placeholder="请输入手机号"
					clearable @keyup.enter.native="handleQuery" />
			</el-form-item>
			
			<el-form-item>
				<el-button  type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
				</el-button>
				
				<el-button style="margin-left: 20px;" icon="el-icon-refresh" size="mini" @click="resetQuery">重置
				</el-button>
			</el-form-item>
		</el-form>
		<el-row :gutter="10" class="mb8">
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
					v-hasPermi="['system:goods:add']">新增
				</el-button>
			</el-col>
			<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
		</el-row>
		<el-table  :data="tableData" style="width: 100%">
			<el-table-column prop="id" label="编号">
			</el-table-column>
			<el-table-column prop="nickName" label="im编号">
			</el-table-column>
			<el-table-column prop="customerName" label="客户姓名">
			</el-table-column>
			<el-table-column prop="gameAccount" label="游戏账号">
			</el-table-column>
			<el-table-column prop="phone" label="客户手机号">
			</el-table-column>
			<el-table-column prop="idCard" label="身份证">
			</el-table-column>
			<el-table-column prop="idCardFront" label="身份证正面照片">
				<template slot-scope="scope">
					<image-preview :src="pictureServerPath+scope.row.idCardFront" :width="50" :height="50" />
				</template>
			</el-table-column>
			<el-table-column prop="idCardOpposite" label="身份证反面照片">
				<template slot-scope="scope">
					<image-preview :src="pictureServerPath+scope.row.idCardOpposite" :width="50" :height="50" />
				</template>
			</el-table-column>
			<el-table-column prop="parentsName" label="直系亲属姓名1">
			</el-table-column>
			<el-table-column prop="parentsPhone" label="直系亲属电话1">
			</el-table-column>
			<el-table-column prop="parentsLink" label="直系亲属关系1">
			</el-table-column>
			<el-table-column prop="parentsName2" label="直系亲属姓名2">
			</el-table-column>
			<el-table-column prop="parentsPhone2" label="直系亲属电话2">
			</el-table-column>
			<el-table-column prop="parentsLink2" label="直系亲属关系2">
			</el-table-column>
			<el-table-column prop="contactAddress" label="近期联系地址">
				<template slot-scope="scope">
					<image-preview :src="pictureServerPath+scope.row.contactAddress" :width="50" :height="50" />
				</template>
			</el-table-column>
			<el-table-column prop="accountNumber" label="收款账号">
			</el-table-column>
			<el-table-column prop="status" label="状态">
				<template slot-scope="scope">
					<span v-if="scope.row.status=='Y'">通过</span>
					<span v-if="scope.row.status=='N'">待审核</span>
					<span v-if="scope.row.status=='X'">驳回</span>
				</template>
			</el-table-column>
			<el-table-column prop="createTime" label="创建时间">
			</el-table-column>
			<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑
					</el-button>
					<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除
					</el-button>
				</template>
			</el-table-column>
		</el-table>
		
		<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
			@pagination="getList" />
		<!-- 查看账号信息对话框 -->
		<el-dialog v-if="ck" title="新增账号" :visible.sync="ck" append-to-body width="1000px">
			<div style="padding: 10px;overflow: auto">
				<el-form ref="form2" :model="form2" :rules="rules" label-width="80px">
					<el-row>
						<el-col :span="12">
							<el-form-item label="店铺ID" prop="shopId">
								<el-select v-model="form2.shopId" style="width: 200px" clearable placeholder="请选择店铺名称">
									<el-option v-for="(item,index) in deptOptions" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
								<!-- <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"
									placeholder="请选择归属部门" /> -->
								<!-- <el-autocomplete class="inline-input" v-model="form2.shopId" :fetch-suggestions="querySearch"
									placeholder="请输入店铺名称" @select="handleSelect" :trigger-on-focus="false"></el-autocomplete> -->
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="游戏价格" prop="gameEnterPrice">
								<el-input v-model="form2.gameEnterPrice"placeholder="请输入游戏价格" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="包赔服务" prop="compensation">
								<el-select v-model="form2.compensation" style="width: 200px" clearable placeholder="请选择包赔">
									<el-option v-for="(item,index) in options2" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="包赔费用" prop="compensationPrice">
								<el-input v-model="form2.compensationPrice" placeholder="请输入包赔费用" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="游戏账号" prop="gameAccount">
								<el-input v-model="form2.gameAccount" placeholder="请输入游戏账号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="客户姓名" prop="customerName">
								<el-input v-model="form2.customerName" placeholder="请输入客户姓名" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="手机号" prop="phone">
								<el-input v-model="form2.phone" placeholder="请输入手机号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="身份证号" prop="idCard">
								<el-input v-model="form2.idCard" placeholder="请输入身份证号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属姓名" prop="parentsName">
								<el-input v-model="form2.parentsName" placeholder="请输入亲属姓名" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属电话" prop="parentsPhone">
								<el-input v-model="form2.parentsPhone" placeholder="请输入亲属电话" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属关系" prop="parentsPhone">
								<el-input v-model="form2.parentsLink" placeholder="请输入亲属关系" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属姓名2" prop="parentsName">
								<el-input v-model="form2.parentsName2" placeholder="请输入亲属姓名2" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属电话2" prop="parentsPhone">
								<el-input v-model="form2.parentsPhone2" placeholder="请输入亲属电话2" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="亲属2关系" prop="parentsPhone">
								<el-input v-model="form2.parentsLink2" placeholder="请输入亲属2关系" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="收款账号" prop="phone">
								<el-input v-model="form2.accountNumber" placeholder="请输入收款账号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="审核状态" prop="status">
								<el-select v-model="form2.status" style="width: 100%"  placeholder="请选择审核状态">
									<el-option v-for="(item,index) in options4" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="是否回收" prop="status">
								<el-select v-model="form2.recycle" style="width: 100%"  placeholder="请选择是否回收">
									<el-option v-for="(item,index) in options6" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="是否黑号" prop="status">
								<el-select v-model="form2.blackAccount" style="width: 100%"  placeholder="请选择是否黑号">
									<el-option v-for="(item,index) in options5" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="备注" prop="remark">
								<el-input v-model="form2.remark" placeholder="请输入备注" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="正面照片" prop="idCardFront">
								<el-input v-model="form2.idCardFront" placeholder="请输入正面照片" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="反面照片" prop="idCardOpposite">
								<el-input v-model="form2.idCardOpposite" placeholder="请输入反面照片" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="近期地址" prop="contactAddress">
								<el-input v-model="form2.contactAddress" placeholder="请输入近期地址" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="个人视频" prop="video">
								<el-input v-model="form2.video" placeholder="请输入个人视频" />
							</el-form-item>
						</el-col>
		
					</el-row>
				</el-form>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="submitForm">确 定</el-button>
				<el-button @click="cancel">取 消</el-button>
			</div>
		</el-dialog>
		<el-dialog v-if="openFkpz1" title="个人视频" :visible.sync="openFkpz1" append-to-body width="800px">
			<div style="display: flex;flex-wrap: wrap;">
				<el-image style="width: 200px;height: 200px;" :preview-src-list="srcList"
					:src="pictureServerPath+this.path">
				</el-image>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="openFkpz1=false">确 定</el-button>
				<el-button @click="openFkpz1=false">取 消</el-button>
			</div>
		</el-dialog>
		

	</div>
</template>

<script>
	import {
		queryTBusShop
	} from "@/api/data/goodsPayment";
	import {
		getConfigKey
	} from "@/api/system/config";
	import Treeselect from "@riophae/vue-treeselect";
	import "@riophae/vue-treeselect/dist/vue-treeselect.css";
	import {
		getSysDeptInfo,
		getDeptInfo,
		accountMonitoring,
		add,
		view,
		deleteMonitoring,
		getInitGoodsManager,
		getPaymentInfo,
		updateOriginalPrice,
		getTBusGoodsPaymentSum,
		updatePaymentStatus
	} from "@/api/data/informationReview";
	import Cookies from 'js-cookie';
	import {
		getToken
	} from "@/utils/auth";
	export default {

		data() {
			return {
				pictureServerPath: null,
				path:'',
				srcList:[],
				shopId1:'',
				form2:{
				},
				options11: [],
				uploadImgUrl: process.env.VUE_APP_BASE_API + "/file/uploadNew", // 上传的图片服务器地址
				headers: {
					Authorization: "Bearer " + getToken(),
				},
				// electronicDataList: [],
				// 表单参数
				form: {
					electronicDataList: [],
					// electronicDataList: '',
					gamePicture: [],
					//创建一个游戏属性数值
					arrayLIst: []
				},
				// 统计
				originalprice: 0,
				salesprice: 0,
				paidinprice: 0,
				lr: 0,
				bplr:0,
				allPrice: 0,
				// 筛选
				// activeNames: ['1'],
				cs: 0,
				cs1: 0,
				cs2: 0,
				cs3: 0,
				input: '',
				ck:false,
				yxbh: false,
				yxdq: false,
				spbh: false,
				sjbh: false,
				disabled: true,
				block: false,
				originalPrice1open: false,
				originalPriceopen: false,
				xz:false,
				open1: false,
				openPicture: false,
				cbj: false,
				cbj1: false,
				cbj2: true,
				fl:false,
				openFkpz1:false,
				bp:false,
				zybd:true,
				sjbd:false,
				bpLr:false,
				// 付款凭证
				attach_list: [],
				carouselImg:[],
				// 间隔状态
				options3: [{
					value: '0',
					label: '分钟'
				}, {
					value: '1',
					label: '小时'
				},
				{
					value: '2',
					label: '天'
				}],
				// 任务类型
				options4: [{
					value: 'Y',
					label: '通过'
				}, {
					value: 'N',
					label: '待审核'
				},
				{
					value: 'X',
					label: '驳回'
				}
				],
				// 是否黑号
				options5: [{
					value: 'Y',
					label: '是'
				}, {
					value: 'X',
					label: '否'
				}],
				// 是否回收
				options6: [{
					value: 'Y',
					label: '是'
				}, {
					value: 'N',
					label: '否'
				}],
				//包赔
				options2: [{
					value: "Y",
					label: '是'
				}, {
					value: "X",
					label: '否'
				}],
				deptOptions: [{
					value: "",
					label: ''
				}],
				rules: {
					accountNumber: [{
						required: true,
						message: '请输入账号',
						trigger: 'blur'
					}],
					shopId: [{
						required: true,
						message: '请选择店铺',
						trigger: 'blur'
					}],
					gameEnterPrice: [{
						required: true,
						message: '请输入游戏价格',
						trigger: 'blur'
					},
					{
						validator(rule, value, callback) {
							if (/(^[1-9]\d*$)/.test(value)) {
								callback()
							} else {
								callback(new Error('请输入正整数'))
							}
						},
						trigger: 'blur'
					}],
					compensation: [{
						required: true,
						message: '请选择包赔服务',
						trigger: 'blur'
					}],
					compensationPrice: [{
						required: true,
						message: '请输入包赔价格',
						trigger: 'blur'
					}
					],
				},
				gameList: [],
				tableData: [],
				// 遮罩层
				loading: true,
				// open:false

				// 总条数
				total: 0,
				// 弹出层标题
				title: "",
				// 显示搜索条件
				showSearch: true,
				// 是否显示弹出层
				open: false,
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					accountNumber:null,
					accountPhone:null,
					intervalType:null,
					taskType:null,
					autoSwitchType:null,
				},

				// 表单参数
				form1: {
					accountNumber:null,
					accountPhone:null,
					intervalType:null,
					taskType:null,
					autoSwitchType:null,
					remark:null
				},
				queryForm: {
					accountNumber:null,
					accountPhone:null,
					intervalType:null,
					taskType:null,
					autoSwitchType:null,
				},
			};
		},
		created() {
			this.getServierPicture();
			this.getList();
		},
		mounted() {
			this.restaurants = this.loadAll();
		},
		methods: {
			getServierPicture() {
				let that = this
				getConfigKey('pictureServerPath').then(res => {
					that.pictureServerPath = res.msg
				})
			},
			look(item){
				this.path=item
				this.srcList.push(this.pictureServerPath + item)
				this.openFkpz1 = true
			},
			//店铺名称
			querySearch(queryString, cb) {
				var restaurants = this.restaurants;
				var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
				// 调用 callback 返回建议列表的数据
				cb(results);
			},
			createFilter(queryString) {
				return (restaurant) => {
					return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) !== -1);
				};
			},
			loadAll() {
				queryTBusShop().then(response => {
					response.data.forEach((item) => {
						this.deptOptions.push({
							label: item.name,
							value: item.id,
						});
					});
				});
				return this.deptOptions;
			},
			// handleSelect(item) {
			// 	this.shopId1=item.label
			// },
			/** 新增按钮操作 */
			handleAdd() {
				this.resetQuery();
				this.ck=true;
				this.title = "添加账号信息";
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				const id = row.id 
				const names = row.customerName 
				this.$modal.confirm('是否确认删除["' + names + '"]的数据项？').then(function() {
					return deleteMonitoring(id);
				}).then(() => {
					this.getList();
					this.$modal.msgSuccess("删除成功");
				}).catch(() => {});
			},
			
			/** 查询账号信息列表 */
			getList() {
				this.loading = true;
				accountMonitoring(this.queryParams).then(response => {
					console.log(response)
					this.tableData = response.rows;
					this.total = response.total
					this.loading = false;
				});
			},
			//查看
			handleUpdate(row){
				view(row.id).then(res=>{
					this.ck=true;
					this.form2=res.data;
				})
			},
			

			/** 搜索按钮操作 */
			handleQuery() {
				this.disabled = true;
				this.block = false;
				this.queryParams.pageNum = 1;
				this.getList();
			},
			
			/** 重置按钮操作 */
			resetQuery() {
				this.block = false;
				this.disabled = true;
				this.resetForm("queryForm");
				this.resetForm("form2");
				// this.handleQuery();
			},
			


			
			
			// 新增确定按钮
			submitForm() {
				this.$refs["form2"].validate(valid => {
					if (valid) {
						add(this.form2).then(res=>{
							if (res.code==200) {
								this.$message({
									type: 'success',
									message: '添加成功'
								})
								this.ck=false;
								this.getList();
							} else{
								this.$message.error(res.msg);
							}
						})
					}
				});
			},
			
			
			cancel() {
				this.ck=false;
				this.open1 = false;
				this.resetForm("form2");
				this.resetForm("form");
			},
			


		}
	};
</script>
<style>
	.father {
		height: 80px;
		line-height: 80px;
		font-size: 25px;
		display: flex;
		justify-content: space-around;
	}

	.el-icon-loading {
		color: green;
		margin-right: 5px;
	}

	.el-icon-message-solid {
		color: green;
		margin-right: 5px;
	}

	.el-icon-check {
		color: green;
		margin-right: 5px;
	}

	.el-icon-coin {
		color: green;
		margin-right: 5px;
	}
</style>
