<template>
	<div>
		<!-- <el-tabs v-model="activeName" @tab-click="handleClick">
			<el-tab-pane label="岗位分类" name="first"> -->
		<div style="width: 100%;text-align: right;">
			<el-button style="margin-bottom: 20px;" size="mini" type="primary" @click="cancel">刷新
			</el-button>
		</div>
		<el-table v-loading="tableDataLoading" :data="tableData.records">
			<el-table-column prop="intentionId" label="编号" width="80">
			</el-table-column>

			<el-table-column prop="userId" label="用户">
				<template slot-scope="scope">
					<span style="color: #008000;cursor: pointer;"
						@click="updates(scope.row)">{{ scope.row.userName }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="ruleClassifyName" label="职位名称">
			</el-table-column>
			<el-table-column prop="citys" label="期望城市">
			</el-table-column>
			<el-table-column prop="salaryRange" label="薪资范围">
			</el-table-column>
			<el-table-column prop="industry" label="行业">
			</el-table-column>

      <el-table-column prop="isDefault" label="是否是第一意向" width="120">
      	<template slot-scope="scope">
      		<span v-if="scope.row.isDefault==1" style="color: #f56c6c;cursor: pointer;">是</span>
          <span v-else >否</span>
      	</template>
      </el-table-column>
			<el-table-column prop="createTime" label="创建时间" width="160">
			</el-table-column>
			<el-table-column label="操作" prop="id" width="80" fixed='right' align="center">
				<template slot-scope="scope">
					<el-button size="mini" type="danger" :disabled="!isAuth('jobIntention:delete')" style="margin: 5px;"
						@click="classdelete(scope.row)">删除
					</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.total">
			</el-pagination>
		</div>
		<!-- 添加、修改岗位岗位 -->
		<el-dialog :title="titles" :visible.sync="dialogFormVisible9" center>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">岗位名称：</span>
				<el-input style="width:50%;" v-model="ruleClassifyName" type="text" placeholder="请输入岗位名称"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">普通用户获取简历：</span>
				<el-input style="width:50%;" v-model="price" type="text" placeholder="请输入普通用户获取简历"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">会员用户获取简历：</span>
				<el-input style="width:50%;" v-model="memberPrice" type="text" placeholder="请输入会员用户获取简历"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">普通用户精准服务价格：</span>
				<el-input style="width:50%;" v-model="accuratePrice" type="text" placeholder="请输入普通用户精准服务价格"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">会员用户精准服务价格：</span>
				<el-input style="width:50%;" v-model="accurateMemberPrice" type="text" placeholder="请输入会员用户精准服务价格">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">普通用户定制化定金：</span>
				<el-input style="width:50%;" v-model="customizationPrice" type="text" placeholder="请输入普通用户定制化定金">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">会员用户定制化会员价格：</span>
				<el-input style="width:50%;" v-model="customizationMemberPrice" type="text"
					placeholder="请输入会员用户定制化会员价格"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">普通用户定制化线下价格：</span>
				<el-input style="width:50%;" v-model="offlinePrice" type="text" placeholder="请输入普通用户定制化线下价格"></el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">会员用户定制化线下价格：</span>
				<el-input style="width:50%;" v-model="offlineMemberPrice" type="text" placeholder="请输入会员用户定制化线下价格">
				</el-input>
			</div>
			<div style="margin-bottom: 10px;display:flex;">
				<span style="width: 200px;display: inline-block;text-align: right;">排序：</span>
				<el-input-number size="medium" v-model="sort"></el-input-number>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogFormVisible9 = false">取 消</el-button>
				<el-button type="primary" @click="refuseto1()">确 定</el-button>
			</div>
		</el-dialog>
		<!-- 添加、修改专业 -->
		<el-dialog :title="titles" :visible.sync="dialogVisibleGw" center>
			<div style="margin-bottom: 10px;">
				<span style="width: 200px;display: inline-block;text-align: right;">专业名称：</span>
				<el-input style="width:50%;" v-model="rulePostName" type="text" placeholder="请输入专业名称"></el-input>
			</div>

			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogVisibleGw = false">取 消</el-button>
				<el-button type="primary" @click="refusetoList()">确 定</el-button>
			</div>
		</el-dialog>

		<!-- </el-tabs> -->
	</div>
</template>

<script>
	export default {

		data() {
			return {
				size: 10,
				page: 1,
				size1: 10,
				page1: 1,
				limit: 10,
				openValue2: 1,
				closeValue2: 2,
				title: '',
				type: '',
				name: '',
				activeName: 'first',
				tableDataLoading: true,
				tableDataLoading4: false,
				dialogFormVisible9: false,
				status: '', //状态0待审核  1上架  2下架 3驳回 (修改添加不传)
				dialogVisible: false,
				dialogVisibleGw: false,
				tableData: {},
				titles: '添加服务分类',
				renwuTitles: '添加服务',
				ruleClassifyName: '',
				ruleClassifyId: '',
				sort: 1,
				gameStatus: '',
				stationList: {},
				rulePostId: '', //岗位id
				rulePostName: '', //岗位名称
				price: '', //价格
				memberPrice: '', //会员价格
				accuratePrice: '', //精准服务价格
				accurateMemberPrice: '', //精准服务定制化价格
				customizationPrice: '', //定制化价格
				customizationMemberPrice: '', //定制化会员价格
				offlinePrice: '',
				offlineMemberPrice: '',
				rulePostNameT: '',
				classifyBy: 1,
			}
		},
		methods: {
			// 详情跳转
			updates(row) {
				this.$router.push({
					path: '/userDetail',
					query: {
						userId: row.userId
					}
				})
			},
			handleSizeChange(val) {
				this.limit = val
				this.classSelect()
			},
			handleCurrentChange(val) {
				this.page = val
				this.classSelect()
			},
			handleClick(tab, event) {

				this.page = 1
				if (tab._props.label == '岗位分类') {

					this.classSelect()
				}
			},
			// 取消
			cancel() {
				this.page = 1
				this.classSelect()
			},
			// 获取服务分类数据
			classSelect() {
				this.$http({
					url: this.$http.adornUrl('admin/intention/getIntentionList'),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
					})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.tableDataLoading = false
						let returnData = data.data
						this.tableData = returnData
					} else {
						this.$notify({
							title: '提示',
							duration: 1800,
							message: data.msg,
							type: 'warning'
						});
					}


				})
			},

			// 添加服务分类
			classAdd(row) {
				console.log('row', row)
				if (row != 0) {
					this.titles = '修改岗位'
					this.ruleClassifyName = row.ruleClassifyName
					this.ruleClassifyId = row.ruleClassifyId
					this.price = row.price
					this.memberPrice = row.memberPrice
					this.accuratePrice = row.accuratePrice
					this.accurateMemberPrice = row.accurateMemberPrice
					this.customizationPrice = row.customizationPrice
					this.customizationMemberPrice = row.customizationMemberPrice
					this.offlinePrice = row.offlinePrice
					this.offlineMemberPrice = row.offlineMemberPrice
					this.sort = row.sort
					this.gameStatus = row.status
				} else {
					this.titles = '添加岗位'
					this.ruleClassifyName = ''
					this.ruleClassifyId = ''
					this.price = ''
					this.memberPrice = ''
					this.accuratePrice = ''
					this.accurateMemberPrice = ''
					this.customizationPrice = ''
					this.customizationMemberPrice = ''
					this.offlinePrice = ''
					this.offlineMemberPrice = ''
					this.sort = 1
					this.gameStatus = ''
				}
				this.dialogFormVisible9 = true

			},
			// 启用与否
			change(id, status) {
				this.$http({
					url: this.$http.adornUrl('rule/updateRuleClassify'),
					method: 'post',
					data: this.$http.adornData({
						'ruleClassifyId': id,
						'status': status
					})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.$message({
							message: '操作成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.classSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'warning',
							duration: 1500,
							onClose: () => {}
						})
					}

				})
			},
			// 提交修改、添加服务分类
			refuseto1() {
				if (this.ruleClassifyName == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入岗位名称',
						type: 'warning'
					})
					return
				}
				if (this.price == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入价格',
						type: 'warning'
					})
					return
				}
				if (this.memberPrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入会员价格',
						type: 'warning'
					})
					return
				}
				if (this.accuratePrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入精准服务价格',
						type: 'warning'
					})
					return
				}
				if (this.accurateMemberPrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入精准服务定制价格',
						type: 'warning'
					})
					return
				}
				if (this.customizationPrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入定制价格',
						type: 'warning'
					})
					return
				}
				if (this.customizationMemberPrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入定制会员价格',
						type: 'warning'
					})
					return
				}
				if (this.offlinePrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入定制线下价格',
						type: 'warning'
					})
					return
				}
				if (this.offlineMemberPrice == '') {
					this.$notify({
						title: '提示',
						duration: 1800,
						message: '请输入定制线下会员价格',
						type: 'warning'
					})
					return
				}
				if (this.titles == '添加岗位') {
					var urls = 'rule/insertRuleClassify'
				} else {
					var urls = 'rule/updateRuleClassify'
				}
				this.$http({
					url: this.$http.adornUrl(urls),
					method: 'post',
					data: this.$http.adornData({
						'ruleClassifyName': this.ruleClassifyName,
						'status': this.gameStatus,
						'sort': this.sort,
						'ruleClassifyId': this.ruleClassifyId,
						'price': this.price,
						'memberPrice': this.memberPrice,
						'accuratePrice': this.accuratePrice,
						'accurateMemberPrice': this.accurateMemberPrice,
						'customizationPrice': this.customizationPrice,
						'customizationMemberPrice': this.customizationMemberPrice,

						'offlinePrice': this.offlinePrice,
						'offlineMemberPrice': this.offlineMemberPrice,
					})
				}).then(({
					data
				}) => {
					if (data.code == 0) {
						this.dialogFormVisible9 = false
						this.$message({
							message: '操作成功',
							type: 'success',
							duration: 1500,
							onClose: () => {
								this.classSelect()
							}
						})
					} else {
						this.$message({
							message: data.msg,
							type: 'warning',
							duration: 1500,
							onClose: () => {}
						})
					}

				})
			},
			// 删除分类
			classdelete(row) {
				this.$confirm(`确定删除此条信息?`, '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					this.$http({
						url: this.$http.adornUrl('admin/intention/deleteIntention'),
						method: 'post',
						params: this.$http.adornParams({
							'intentionId': row.intentionId
						})
					}).then(({
						data
					}) => {
						if (data.code == 0) {
							this.$message({
								message: '删除成功',
								type: 'success',
								duration: 1500,
								onClose: () => {
									this.classSelect()
								}
							})
						} else {
							this.$message({
								message: data.msg,
								type: 'warning',
								duration: 1500,
								onClose: () => {}
							})
						}

					})
				}).catch(() => {})
			},
		},
		mounted() {
			this.classSelect()
		}
	}
</script>

<style>
	.customWidth {
		width: 80% !important;
	}

	.adver_main.box {
		display: block;
		max-width: 100%;
		text-align: center;
		border: 1px dotted rgba(67, 79, 103, .4);
	}

	.cards {
		padding: 0 8px;
		margin-bottom: 15px;
	}

	.adver_main.box a {
		display: flex;
		justify-content: center;
		height: 150px;
		line-height: 150px;
		text-decoration: none
	}

	.bannerManin {
		border: 1px solid #e8e8e8;
		font-size: 14px;
		padding: 0 24px;
		display: flex;
		justify-content: center;
		align-items: center;
		height: 113px;
		color: rgba(0, 0, 0, .65);
	}

	.bannerManin span {
		display: inline-block;
		margin-left: 5px;
	}

	.bannerManin img {
		width: 48px;
		height: 48px;
		border-radius: 50%;
	}

	.bannerbtn {
		display: flex;
		border-top: none !important;
		border: 1px solid #e8e8e8;
		padding: 11px;
		font-size: 14px;
		color: #3E8EF7;
	}

	.bannerbtn a {
		flex: 1;
		text-align: center;
		color: #3E8EF7 !important;
		text-decoration: none;
	}

	.imgs {
		position: relative;
		border-radius: 6px;
		width: 148px;
		height: 148px;
		margin-right: 10px;
		display: inline-block;
	}

	.dels {
		position: absolute;
		top: 0;
		left: 0;
		display: none;
	}

	.dels .el-icon-delete {
		line-height: 148px;
		padding-left: 58px;
		font-size: 25px;
		color: #fff;
	}

	.imgs:hover .dels {
		width: 100%;
		height: 100%;
		background: #000;
		display: block;
		opacity: 0.5;
	}

	.bqList {
		padding: 4px 14px;
		margin: 4px;
		border: 1px solid #efefef;
		font-size: 12px;
		color: #999;
		border-radius: 4px;
		margin-right: 15px;
	}

	.delss {
		display: none;
		position: relative;
	}

	.delss .el-icon-delete {
		position: absolute;
		top: 0;
	}

	.bqList:hover .delss {
		display: initial;
		opacity: 0.5;

	}

	.tj {
		padding: 6px !important;
		margin: 4px;
		font-size: 12px;
		border: 1px solid #ccc;
		border-radius: 4px;
	}
</style>
