<template>
	<div>
		<el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="学历提升" name="first">
				<div style="display: inline-block;">
					<!-- <span>状态：</span>
					<el-select v-model="status" style="width:150px;margin-left: 10px;" @change="select()">
						<el-option v-for="item in statesnum" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>&nbsp;&nbsp; -->
					<div style="position: relative;display: inline-block;">
						<span>姓名：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入姓名"
							v-model="userName">
						</el-input>&nbsp;&nbsp;
					</div>
					<div style="position: relative;display: inline-block;">
						<span>电话：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入电话"
							v-model="applyPhone">
						</el-input>&nbsp;&nbsp;
					</div>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="select">查询
					</el-button>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="cleans">重置
					</el-button>
				</div>
				<el-table v-loading="tableDataLoading" :data="tableData.list">
					<el-table-column prop="applyId" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="applyName" label="姓名" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;cursor: pointer;"
								@click="updates(scope.row)">{{scope.row.applyName ? scope.row.applyName : '未绑定'}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyPhone" label="电话" width="150">
					</el-table-column>
					<el-table-column prop="classify" label="类型" width="80">
						<template slot-scope="scope">
							<span v-if="scope.row.classify==1">学历提升</span>
							<span v-else-if="scope.row.classify==2">证书培训</span>
							<span v-else-if="scope.row.classify==3">职称评审</span>
							<span v-else-if="scope.row.classify==4">培训报名</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyAge" label="年龄">
					</el-table-column>
					<el-table-column prop="applyContent" label="内容" width="160">
						<template slot-scope="scope">
							<el-popover placement="top-start" title="" trigger="hover">
								<div style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;max-height:80px;white-space: break-all;"
									slot="reference">{{scope.row.applyContent}}</div>
								<div style="width: 300px;word-break:break-all;">{{scope.row.applyContent}}</div>
							</el-popover>
						</template>
					</el-table-column>
					<!-- <el-table-column prop="auditContent" label="审核内容" width="160">
					</el-table-column> -->
					<el-table-column prop="createTime" label="创建时间" width="160">
					</el-table-column>
					<!-- <el-table-column fixed='right' prop="status" label="状态" width="160">
						<template slot-scope="scope">
							<span v-if="scope.row.status == 1">待审核</span>
							<span v-if="scope.row.status == 2">审核成功</span>
							<span v-if="scope.row.status == 3">已拒绝</span>
						</template>
					</el-table-column> -->
					<el-table-column fixed='right' label="操作" width="100">
						<template slot-scope="scope">
							<!-- <el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:jujue')"
								@click="refuseClick(scope.row)" style="margin: 5px;">
								拒绝
							</el-button>
							<el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:tongguo')"
								@click="passClicks(scope.row)" style="margin: 5px;">
								通过
							</el-button> -->
							<el-button size="mini" type="danger" :disabled="!isAuth('recruitList:delete')"
								@click="deleteClicks(scope.row)" style="margin: 5px;">
								删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
					</el-pagination>
				</div>
			</el-tab-pane>
			<el-tab-pane label="证书培训" name="zhengshu">
				<div style="display: inline-block;">
					<!-- <span>状态：</span>
					<el-select v-model="status" style="width:150px;margin-left: 10px;" @change="select()">
						<el-option v-for="item in statesnum" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>&nbsp;&nbsp; -->
					<div style="position: relative;display: inline-block;">
						<span>姓名：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入姓名"
							v-model="userName">
						</el-input>&nbsp;&nbsp;
					</div>
					<div style="position: relative;display: inline-block;">
						<span>电话：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入电话"
							v-model="applyPhone">
						</el-input>&nbsp;&nbsp;
					</div>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="select">查询
					</el-button>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="cleans">重置
					</el-button>
				</div>
				<el-table v-loading="tableDataLoading" :data="tableData.list">
					<el-table-column prop="applyId" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="applyName" label="姓名" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;cursor: pointer;"
								@click="updates(scope.row)">{{scope.row.applyName ? scope.row.applyName : '未绑定'}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyPhone" label="电话" width="150">
					</el-table-column>
					<el-table-column prop="classify" label="类型" width="80">
						<template slot-scope="scope">
							<span v-if="scope.row.classify==1">学历提升</span>
							<span v-else-if="scope.row.classify==2">证书培训</span>
							<span v-else-if="scope.row.classify==3">职称评审</span>
							<span v-else-if="scope.row.classify==4">培训报名</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyAge" label="年龄">
					</el-table-column>
					<el-table-column prop="applyContent" label="内容" width="160">
						<template slot-scope="scope">
							<el-popover placement="top-start" title="" trigger="hover">
								<div style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;max-height:80px;white-space: break-all;"
									slot="reference">{{scope.row.applyContent}}</div>
								<div style="width: 300px;word-break:break-all;">{{scope.row.applyContent}}</div>
							</el-popover>
						</template>
					</el-table-column>
					<!-- <el-table-column prop="auditContent" label="审核内容" width="160">
					</el-table-column> -->
					<el-table-column prop="createTime" label="创建时间" width="160">
					</el-table-column>
					<!-- <el-table-column fixed='right' prop="status" label="状态" width="160">
						<template slot-scope="scope">
							<span v-if="scope.row.status == 1">待审核</span>
							<span v-if="scope.row.status == 2">审核成功</span>
							<span v-if="scope.row.status == 3">已拒绝</span>
						</template>
					</el-table-column> -->
					<el-table-column fixed='right' label="操作" width="100">
						<template slot-scope="scope">
							<!-- <el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:jujue')"
								@click="refuseClick(scope.row)" style="margin: 5px;">
								拒绝
							</el-button>
							<el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:tongguo')"
								@click="passClicks(scope.row)" style="margin: 5px;">
								通过
							</el-button> -->
							<el-button size="mini" type="danger" :disabled="!isAuth('recruitList:delete')"
								@click="deleteClicks(scope.row)" style="margin: 5px;">
								删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
					</el-pagination>
				</div>
			</el-tab-pane>
			<el-tab-pane label="职称评审" name="zhicheng">
				<div style="display: inline-block;">
					<!-- <span>状态：</span>
					<el-select v-model="status" style="width:150px;margin-left: 10px;" @change="select()">
						<el-option v-for="item in statesnum" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>&nbsp;&nbsp; -->
					<div style="position: relative;display: inline-block;">
						<span>姓名：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入姓名"
							v-model="userName">
						</el-input>&nbsp;&nbsp;
					</div>
					<div style="position: relative;display: inline-block;">
						<span>电话：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入电话"
							v-model="applyPhone">
						</el-input>&nbsp;&nbsp;
					</div>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="select">查询
					</el-button>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="cleans">重置
					</el-button>
				</div>
				<el-table v-loading="tableDataLoading" :data="tableData.list">
					<el-table-column prop="applyId" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="applyName" label="姓名" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;cursor: pointer;"
								@click="updates(scope.row)">{{scope.row.applyName ? scope.row.applyName : '未绑定'}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyPhone" label="电话" width="150">
					</el-table-column>
					<el-table-column prop="classify" label="类型" width="80">
						<template slot-scope="scope">
							<span v-if="scope.row.classify==1">学历提升</span>
							<span v-else-if="scope.row.classify==2">证书培训</span>
							<span v-else-if="scope.row.classify==3">职称评审</span>
							<span v-else-if="scope.row.classify==4">培训报名</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyAge" label="年龄">
					</el-table-column>
					<el-table-column prop="applyContent" label="内容" width="160">
						<template slot-scope="scope">
							<el-popover placement="top-start" title="" trigger="hover">
								<div style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;max-height:80px;white-space: break-all;"
									slot="reference">{{scope.row.applyContent}}</div>
								<div style="width: 300px;word-break:break-all;">{{scope.row.applyContent}}</div>
							</el-popover>
						</template>
					</el-table-column>
					<!-- <el-table-column prop="auditContent" label="审核内容" width="160">
					</el-table-column> -->
					<el-table-column prop="createTime" label="创建时间" width="160">
					</el-table-column>
					<!-- <el-table-column fixed='right' prop="status" label="状态" width="160">
						<template slot-scope="scope">
							<span v-if="scope.row.status == 1">待审核</span>
							<span v-if="scope.row.status == 2">审核成功</span>
							<span v-if="scope.row.status == 3">已拒绝</span>
						</template>
					</el-table-column> -->
					<el-table-column fixed='right' label="操作" width="100">
						<template slot-scope="scope">
							<!-- <el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:jujue')"
								@click="refuseClick(scope.row)" style="margin: 5px;">
								拒绝
							</el-button>
							<el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:tongguo')"
								@click="passClicks(scope.row)" style="margin: 5px;">
								通过
							</el-button> -->
							<el-button size="mini" type="danger" :disabled="!isAuth('recruitList:delete')"
								@click="deleteClicks(scope.row)" style="margin: 5px;">
								删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
					</el-pagination>
				</div>
			</el-tab-pane>
			<el-tab-pane label="培训报名" name="peixun">
				<div style="display: inline-block;">
					<!-- <span>状态：</span>
					<el-select v-model="status" style="width:150px;margin-left: 10px;" @change="select()">
						<el-option v-for="item in statesnum" :key="item.value" :label="item.label" :value="item.value">
						</el-option>
					</el-select>&nbsp;&nbsp; -->
					<div style="position: relative;display: inline-block;">
						<span>姓名：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入姓名"
							v-model="userName">
						</el-input>&nbsp;&nbsp;
					</div>
					<div style="position: relative;display: inline-block;">
						<span>电话：</span>
						<el-input style="width: 200px;" @keydown.enter.native="select" placeholder="请输入电话"
							v-model="applyPhone">
						</el-input>&nbsp;&nbsp;
					</div>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="select">查询
					</el-button>
					<el-button style='margin-left:15px;' size="mini" type="primary" icon="document" @click="cleans">重置
					</el-button>
				</div>
				<el-table v-loading="tableDataLoading" :data="tableData.list">
					<el-table-column prop="applyId" label="编号" width="80">
					</el-table-column>
					<el-table-column prop="applyName" label="姓名" width="100">
						<template slot-scope="scope">
							<span style="color: #4f9dec;cursor: pointer;"
								@click="updates(scope.row)">{{scope.row.applyName ? scope.row.applyName : '未绑定'}}</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyPhone" label="电话" width="150">
					</el-table-column>
					<el-table-column prop="classify" label="类型" width="80">
						<template slot-scope="scope">
							<span v-if="scope.row.classify==1">学历提升</span>
							<span v-else-if="scope.row.classify==2">证书培训</span>
							<span v-else-if="scope.row.classify==3">职称评审</span>
							<span v-else-if="scope.row.classify==4">培训报名</span>
						</template>
					</el-table-column>
					<el-table-column prop="applyAge" label="年龄">
					</el-table-column>
					<el-table-column prop="applyContent" label="内容" width="160">
						<template slot-scope="scope">
							<el-popover placement="top-start" title="" trigger="hover">
								<div style="display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;max-height:80px;white-space: break-all;"
									slot="reference">{{scope.row.applyContent}}</div>
								<div style="width: 300px;word-break:break-all;">{{scope.row.applyContent}}</div>
							</el-popover>

						</template>
					</el-table-column>
					<!-- <el-table-column prop="auditContent" label="审核内容" width="160">
					</el-table-column> -->
					<el-table-column prop="createTime" label="创建时间" width="160">
					</el-table-column>
					<!-- <el-table-column fixed='right' prop="status" label="状态" width="160">
						<template slot-scope="scope">
							<span v-if="scope.row.status == 1">待审核</span>
							<span v-if="scope.row.status == 2">审核成功</span>
							<span v-if="scope.row.status == 3">已拒绝</span>
						</template>
					</el-table-column> -->
					<el-table-column fixed='right' label="操作" width="100">
						<template slot-scope="scope">
							<!-- <el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:jujue')"
								@click="refuseClick(scope.row)" style="margin: 5px;">
								拒绝
							</el-button>
							<el-button size="mini" type="primary"
								:disabled="scope.row.status !== 1 || !isAuth('recruitList:tongguo')"
								@click="passClicks(scope.row)" style="margin: 5px;">
								通过
							</el-button> -->
							<el-button size="mini" type="danger" :disabled="!isAuth('recruitList:delete')"
								@click="deleteClicks(scope.row)" style="margin: 5px;">
								删除
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div style="text-align: center;margin-top: 10px;">
					<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
						:page-sizes="[10, 20, 30, 40]" :page-size="limit" :current-page="page"
						layout="total,sizes, prev, pager, next,jumper" :total="tableData.totalCount">
					</el-pagination>
				</div>
			</el-tab-pane>
			<!-- 服务拒绝弹框 -->
			<el-dialog title="服务拒绝" :visible.sync="dialogFormVisible" center>
				<div style="margin-bottom: 10px;">
					<span
						style="width: 200px;display: inline-block;text-align: right;position: relative;top: -70px;">拒绝理由：</span>
					<el-input style="width:50%;" v-model="content" type="textarea" :rows="4" placeholder="请输入拒绝理由">
					</el-input>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button @click="dialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="refuseto()">确 定</el-button>
				</div>
			</el-dialog>
		</el-tabs>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				limit: 10,
				page: 1,
				content: '',
				status: '',
				statesnum: [{
						value: '',
						label: '全部'
					},
					{
						value: 1,
						label: '待审核'
					}, {
						value: 2,
						label: '审核成功'
					}, {
						value: 3,
						label: '拒绝'
					}
				],
				classify: 1,
				classlyList: [{
					value: '',
					label: '全部'
				}, {
					value: 1,
					label: '个人'
				}, {
					value: 2,
					label: '企业'
				}],
				userName: '',
				activeName: 'first',
				tableDataLoading: false,
				dialogFormVisible: false,
				tableData: {},
				checkBoxData: [], //多选框选择的值
				shopId: '',
				applyPhone: '',
			}
		},
		methods: {
			// 多选
			changeFun(val) {
				this.checkBoxData = val;
			},
			// 详情跳转
			updates(row) {
				this.$router.push({
					path: '/userDetail',
					query: {
						userId: row.userId
					}
				})
			},
			handleSizeChange(val) {
				this.limit = val;
				this.dataSelect()
			},
			handleCurrentChange(val) {
				this.page = val;
				this.dataSelect()
			},
			// tabs切换
			handleClick(tab, event) {
				if (tab._props.label == '学历提升') {
					this.page = 1
					this.limit = 10
					this.classify = 1
					this.dataSelect()
				}
				if (tab._props.label == '证书培训') {
					this.page = 1
					this.limit = 10
					this.classify = 2
					this.dataSelect()
				}
				if (tab._props.label == '职称评审') {
					this.page = 1
					this.limit = 10
					this.classify = 3
					this.dataSelect()
				}
				if (tab._props.label == '培训报名') {
					this.page = 1
					this.limit = 10
					this.classify = 4
					this.dataSelect()
				}
			},
			//服务通过
			passClick(id) {
				this.status = 1
				this.content = '同意'
				var ids = id ? [id] : this.checkBoxData.map(item => {
					return item.id
				})
				this.$http({
					url: this.$http.adornUrl(
						`student/auditStudentAuthentication/${ids}/${this.status}/${this.content}`),
					method: 'post',
					data: this.$http.adornData({})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.$message({
							message: '操作成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.content = ''
								this.status = ''
								this.dataSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'error',
							duration: 1500,
							onClose: () => {
								this.content = ''
								this.status = ''
								this.dataSelect()
							}
						})
					}
				})
			},
			//单条服务通过
			passClicks(row) {
				this.status = 1
				this.content = '同意'
				this.$http({
					url: this.$http.adornUrl('apply/auditApply'),
					method: 'post',
					params: this.$http.adornParams({
						'status': this.status,
						'ids': row.applyId,
						'remek': '通过'
					})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.$message({
							message: '操作成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.content = ''
								this.status = ''
								this.dataSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'error',
							duration: 1500,
							onClose: () => {
								this.content = ''
								this.status = ''
								this.dataSelect()
							}
						})
					}

				})
			},
			//服务拒绝
			refuseClick(rows) {
				console.log('rows', rows)
				this.status = 2
				this.shopId = rows.applyId
				this.helpTakeId = rows.userId
				this.content = ''
				this.dialogFormVisible = true
			},
			refuseto() {
				if (this.content == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入拒绝理由',
						type: 'warning'
					});
					return
				}
				this.$http({
					url: this.$http.adornUrl('apply/auditApply'),
					method: 'post',
					params: this.$http.adornParams({
						'status': this.status,
						'ids': this.shopId,
						'content': this.content
					})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.dialogFormVisible = false
						this.$message({
							message: '操作成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.content = ''
								this.status = ''
								this.dataSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'error',
							duration: 1500,
							onClose: () => {}
						})
					}

				})
			},
			// 查询
			select() {
				this.page = 1
				this.limit = 10
				this.dataSelect()
			},
			// 重置
			cleans() {
				this.status = ''
				this.userName = ''
				this.applyPhone = ''
				this.dataSelect()
			},
			// 获取派单数据列表
			dataSelect() {
				this.tableDataLoading = true
				this.$http({
					url: this.$http.adornUrl('apply/selectApplyList'),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
						'status': this.status,
						'applyName': this.userName,
						'applyPhone': this.applyPhone,
						'classify': this.classify
					})
				}).then(({
					data
				}) => {
					this.tableDataLoading = false
					for (var i in data.data.list) {
						if (data.data.list[i].addressImg) {
							data.data.list[i].addressImg = data.data.list[i].addressImg.split(',')
						}
					}
					this.tableData = data.data
				})
				// let returnData = data.data;


			},
			deleteClicks(row) {
				let delid = row.id
				this.$confirm(`确定删除此条信息?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http({
						url: this.$http.adornUrl('apply/deleteApply'),
						method: 'post',
						params: this.$http.adornParams({
							'applyId': row.applyId
						})
					}).then(({
						data
					}) => {
						if (data.code == 0) {
							this.$message({
								message: '删除成功',
								type: 'success',
								duration: 1500,
								onClose: () => {
									this.dataSelect()
								}
							})
						} else {
							this.$message({
								message: data.msg,
								type: 'error',
								duration: 1500,
								onClose: () => {}
							})
						}
					})
				}).catch(() => {})
			},
		},
		mounted() {
			this.dataSelect()
		}
	};
</script>

<style>

</style>
