<template>
	<div>
		<div class="crumbs">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item><i class="el-icon-lx-punch"></i> 员工系统</el-breadcrumb-item>
				<el-breadcrumb-item>工资查询</el-breadcrumb-item>
			</el-breadcrumb>
		</div>
		<div class="container">
			<div class="handle-box">
				<el-input v-model="query.name" placeholder="请输入名字" class="handle-input mr10"></el-input>
				<el-input v-model="query.password" type="password" placeholder="请输入密码" class="handle-input mr10"></el-input>
				<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
			</div>

			<div class="wages_form">
				<div style="font-size: 18px;line-height: 34px;">{{this.wageForm.name}}</div>
				<div v-if="this.wageForm.email!=undefined">邮箱 : {{this.wageForm.email}}</div>
				<div v-if="this.wageForm.phone!=undefined">电话 : {{this.wageForm.phone}}</div>
				<div v-if="this.realForm.baseprice!=undefined">基本工资 : {{this.realForm.baseprice}}</div>
				<div v-if="this.realForm.journalprice!=undefined">绩效工资 : {{this.realForm.journalprice}}</div>
				<div v-if="this.realForm.add_price!=undefined">浮动工资 :
					{{parseInt(this.realForm.add_price)-parseInt(this.realForm.sub_price)}}</div>
				<div v-if="this.realForm.baseprice!=undefined">总工资 :
					<b style="font-size: 16px;">{{parseInt(this.realForm.baseprice)+parseInt(this.realForm.journalprice)+parseInt(this.realForm.add_price)-parseInt(this.realForm.sub_price)}}</b>
					</div>
				<!-- <div v-if="this.wageForm.add_price!=undefined">增加工资 : {{this.wageForm.add_price}}</div>
				<div v-if="this.wageForm.add_reason!=undefined">增加原因 : {{this.wageForm.add_reason}}</div>
				<div v-if="this.wageForm.sub_price!=undefined">减少工资 : {{this.wageForm.sub_price}}</div>
				<div v-if="this.wageForm.sub_reason!=undefined">减少原因 : {{this.wageForm.sub_reason}}</div> -->
			</div>
		</div>

	</div>
</template>

<script>
	export default {
		data() {
			return {
				Uw_url: 'special',
				// Uw_url: 'api',
				wageForm: {},
				realForm: {},
				query: {
					name: '',
					password: ''
				},
			};
		},
		created() {
			// this.getData();
		},
		methods: {
			// 获取查询的工资数据
			handleSearch() {
				if (this.query.name == '') {
					this.$message.error("请输入姓名！");
				} else if (this.query.password == '') {
					this.$message.error("请输入密码！");
				} else {
					this.$api
						.post(this.Uw_url+'/Staff/checkStaffLogin', this.query)
						.then(res => {
							if (res.code == 0) {
								this.wageForm = res.data.info;
							} else {
								this.$message.error(res.msg);
							}
						})
						.catch(err => {
							this.$message.error(err);
						});

					this.$api
						.post(this.Uw_url+'/Staff/getStaffRealtime', this.query)
						.then(res => {
							if (res.code == 0) {
								this.realForm = res.data;
							} else {
								this.$message.error(res.msg);
							}
						})
						.catch(err => {
							this.$message.error(err);
						});
				}

			},
		}
	};
</script>

<style scoped>
	.handle-input {
		width: 220px;
		display: inline-block;
	}

	.mr10 {
		margin-right: 10px;
	}

	.wages_form {
		margin-top: 20px;
		font-size: 14px;
	}

	.wages_form>div {
		margin-bottom: 10px;
	}
</style>
