<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="accountNumber">
				<el-input v-model="queryParams.accountNumber"  style="width: 200px;" placeholder="请输入账号"
					clearable @keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="绑定手机" prop="accountPhone">
				<el-input v-model="queryParams.accountPhone"  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:gameBlacklist:add']">新增
				</el-button> -->
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
					>新增
				</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="createBy" label="创建人">
			</el-table-column>
			<el-table-column prop="createTime" label="创建时间">
				<template slot-scope="scope">
					<span>{{scope.row.createTime.slice(0,10)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="accountNumber" label="账号">
			</el-table-column>
			<el-table-column prop="accountPhone" label="绑定手机">
			</el-table-column>
			<el-table-column prop="checkInterval" label="检查间隔">
				<template slot-scope="scope">
					<span v-if="scope.row.intervalType=='0'">{{scope.row.checkInterval}}分钟</span>
					<span v-if="scope.row.intervalType=='1'">{{scope.row.checkInterval}}小时</span>
					<span v-if="scope.row.intervalType=='2'">{{scope.row.checkInterval}}天</span>
				</template>
			</el-table-column>
			<el-table-column prop="intervalType" label="间隔类型">
				<template slot-scope="scope">
					<span v-if="scope.row.intervalType=='0'">分钟</span>
					<span v-if="scope.row.intervalType=='1'">小时</span>
					<span v-if="scope.row.intervalType=='2'">天</span>
				</template>
			</el-table-column>
			<el-table-column prop="taskType" label="任务状态">
				<template slot-scope="scope">
					<span v-if="scope.row.taskType=='1'">找回</span>
					<span v-if="scope.row.taskType=='2'">转手</span>
					<span v-if="scope.row.taskType=='3'">一次性查找回</span>
				</template>
			</el-table-column>
			<el-table-column prop="autoSwitchType" label="查转手">
				<template slot-scope="scope">
					<span v-if="scope.row.autoSwitchType=='0'">不开启</span>
					<span v-if="scope.row.autoSwitchType=='1'">开启</span>
				</template>
			</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-delete" @click="handleDelete(scope.row)"
						v-hasPermi="['system:gameBlacklist:remove']">删除
					</el-button>
					<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(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="xz" :title="title" :visible.sync="xz" append-to-body width="1000px">
			<div style="padding: 10px;overflow: auto">
				<el-form ref="form" :model="form1" :rules="rules" label-width="80px">
					<el-row>
						<el-col :span="12">
							<el-form-item label="账号" prop="accountNumber">
								<el-input v-model="form1.accountNumber" placeholder="请输入账号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="绑定手机" prop="accountPhone">
								<el-input v-model="form1.accountPhone" placeholder="请输入手机号" />
							</el-form-item>
						</el-col>
						
						
						<!-- <el-col :span="12">
							<el-form-item label="间隔时间" prop="checkInterval">
								<el-select v-model="form1.checkInterval" style="width: 100%" filterable
									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="checkInterval">
								<el-input v-model="form1.checkInterval" placeholder="如:1、2、3、" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="间隔类型" prop="intervalType">
								<el-select v-model="form1.intervalType" style="width: 100%" filterable
									placeholder="请选择间隔类型">
									<el-option v-for="(item,index) in options3" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="任务状态" prop="taskType">
								<el-select v-model="form1.taskType" style="width: 100%" filterable
									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="autoSwitchType">
								<el-select v-model="form1.autoSwitchType" style="width: 100%" filterable
									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="form1.remark" 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="ck" title="详细" :visible.sync="ck" append-to-body width="1000px">
			<div style="padding: 10px;overflow: auto">
				<el-form ref="form" :model="form2" :rules="rules" label-width="80px">
					<el-row>
						<el-col :span="12">
							<el-form-item label="账号" prop="accountNumber">
								<el-input v-model="form2.accountNumber" disabled placeholder="请输入账号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="手机号" prop="accountPhone">
								<el-input v-model="form2.accountPhone" disabled placeholder="请输入手机号" />
							</el-form-item>
						</el-col>
						
						<el-col :span="12">
							<el-form-item label="检查间隔" prop="checkInterval">
								<el-input v-model="form2.checkInterval" disabled placeholder="请输入检查间隔" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="间隔类型" prop="intervalType">
								<el-select v-model="form2.intervalType" style="width: 100%" filterable
								disabled	placeholder="请选择间隔类型">
									<el-option v-for="(item,index) in options3" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="任务类型" prop="taskType">
								<el-select v-model="form2.taskType" style="width: 100%" filterable
								disabled	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="autoSwitchType">
								<el-select v-model="form2.autoSwitchType" style="width: 100%" filterable
								disabled	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 disabled v-model="form2.remark" placeholder="请输入备注" />
							</el-form-item>
						</el-col>
		
					</el-row>
					<el-row>
						
						<el-col :span="12">
							<el-form-item label="QQ" prop="qq">
								<el-input disabled v-model="form2.qq" placeholder="请输入手机号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="手机号" prop="telephone">
								<el-input disabled v-model="form2.telephone" placeholder="请输入手机号" />
							</el-form-item>
						</el-col>
						<el-col :span="12">
							<el-form-item label="账号状态" prop="autoSwitchType">
								<el-select v-model="form2.status" style="width: 100%" filterable
								disabled	placeholder="请选择是否开启查转手">
									<el-option v-for="(item,index) in options1" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</el-form-item>
							
						</el-col>
						<el-col :span="12">
							<el-form-item label="总控开关" prop="autoSwitchType">
								<el-select v-model="form2.enabled" style="width: 100%" filterable
								disabled	placeholder="请选择是否开启查转手">
									<el-option v-for="(item,index) in options7" :label="item.label" :value="item.value">
									</el-option>
								</el-select>
							</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>
		

	</div>
</template>

<script>
	import {
		getSysDeptInfo,
		getDeptInfo,
		accountMonitoring,
		add,
		view,
		deleteMonitoring,
		getInitGoodsManager,
		getPaymentInfo,
		updateOriginalPrice,
		getTBusGoodsPaymentSum,
		updatePaymentStatus
	} from "@/api/data/monitoring";
	import Cookies from 'js-cookie';
	import {
		getToken
	} from "@/utils/auth";
	export default {

		data() {
			return {
				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: '1',
					label: '找回'
				}, {
					value: '2',
					label: '转手'
				},
				{
					value: '3',
					label: '一次性查找回'
				}
				],
				// 是否开启
				options5: [{
					value: '0',
					label: '不开启'
				}, {
					value: '1',
					label: '开启'
				}],
				// 间隔时间
				options6: [{
					value: '1',
					label: '一小时'
				}, {
					value: '2',
					label: '二小时'
				},
				{
					value: '3',
					label: '三小时'
				}],
				// 账号状态
				options1: [{
					value: '0',
					label: '正常'
				}, {
					value: '1',
					label: '被找回'
				},
				{
					value: '2',
					label: '二变无'
				},
				{
					value: '3',
					label: '今日上限'
				},
				{
					value: '4',
					label: '账号错误'
				}],
				// 任务状态
				options2: [{
					value: '0',
					label: '待执行'
				}, {
					value: '1',
					label: '执行中'
				},
				{
					value: '2',
					label: '已完成'
				},
				{
					value: '3',
					label: '异常'
				}],
				//是否启用
				options7: [{
					value: '0',
					label: '停用'
				}, {
					value: '1',
					label: '启用'
				}],
				rules: {
					accountNumber: [{
						required: true,
						message: '请输入账号',
						trigger: 'blur'
					}],
					accountPhone: [{
						required: true,
						message: '请输入手机号',
						trigger: 'blur'
					}],
					checkInterval: [{
						required: true,
						message: '请输入检查间隔',
						trigger: 'blur'
					}],
					intervalType: [{
						required: true,
						message: '请选择检查类型',
						trigger: 'blur'
					}],
					taskType: [{
						required: true,
						message: '请选择任务状态',
						trigger: 'blur'
					}],
					autoSwitchType: [{
						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.getList();
		},
		methods: {
			/** 新增按钮操作 */
			handleAdd() {
				this.resetQuery();
				this.xz = true;
				this.title = "添加账号信息";
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				const id = row.id 
				let query={
					id:id,
				}
				const names = row.accountNumber 
				this.$modal.confirm('是否确认删除账号["' + names + '"]的数据项？').then(function() {
					return deleteMonitoring(query);
				}).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){
				let query = {
					id: row.id
				}
				view(query).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.handleQuery();
			},
			


			
			
			// 新增确定按钮
			submitForm() {
				add(this.form1).then(res=>{
					this.getList();
					this.xz=false;
					// console.log(res)
				})
			},
			
			
			cancel() {
				this.xz=false;
				this.open1 = false;
				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>
