前端实现输出员工工资表

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>输出员工工资表</title>
	<script src="https://cdn.jsdelivr.net/npm/vue@2.7.14/dist/vue.js"></script>
	<style>
		body {
			font-family: 微软雅黑;
			font-size: 14px
		}

		.title {
			background: #f6f6f6;
			font-size: 18px;
		}

		.title,
		.content {
			width: 500px;
			height: 36px;
			line-height: 36px;
			border: 1px solid #dddddd;
		}

		.title:not(:first-child),
		.content {
			border-top: none;
		}

		.title div {
			width: 100px;
			text-align: center;
			float: left
		}

		.content {
			clear: both
		}

		.content div {
			width: 100px;
			text-align: center;
			float: left
		}
	</style>
</head>

<body>
	<div id="app">
		<div class="title">
			<div>姓名</div>
			<div>月度收入</div>
			<div>专项扣除</div>
			<div>个税</div>
			<div>工资</div>
		</div>
		<div class="content" v-for="(value,index) in staff">
			<div>{{value.name}}</div>
			<div>{{value.income}}</div>
			<div>{{insurance}}</div>
			<div>{{wages[index]}}</div>
			<div>{{value.income-insurance-wages[index]}}</div>
		</div>
	</div>
	<script>
		var vm = new Vue({
			el: '#app',
			data: {
				insurance: 1000,
				threshold: 5000,
				tax: 0.03,
				staff: [{
					name: '张三',
					income: 6000
				}, {
					name: '李四',
					income: 7000
				}, {
					name: '麻子',
					income: 8000
				}]
			},
			computed: {
				wages: function () {
					var t = this;
					var taxArr = [];
					this.staff.forEach(function (s) {
						taxArr.push((s.income - t.threshold - t.insurance) * t.tax)
					});
					return taxArr
				}
			}
		})
	</script>
</body>

</html>

运行结果如图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值