Commit 3b2caac1 authored by HuangJunbo's avatar HuangJunbo 💻

项目提成计算器

Signed-off-by: HuangJunbo's avataruuo00_n <uuo00_n@outlook.com>
parents
Pipeline #28 canceled with stages
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/03黄俊博.iml" filepath="$PROJECT_DIR$/.idea/03黄俊博.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<title>项目提成计算器</title>
<style>
* {
margin: 0px;
padding: 0px;
}
header {
text-align: center;
margin-bottom: 15px;
}
#box {
margin: 20px auto 0;
width: 300px;
text-align: center;
}
#bonus {
height: 50px;
width: 280px;
background-color: #F3F3F3;
}
#benefit {
height: 20px;
width: 140px;
}
#roles {
height: 22px;
width: 130px;
vertical-align: bottom;
}
#count {
padding-top: 10px;
padding-right: 11px;
text-align: right;
}
#countBtn {
height: 25px;
width: 70px;
text-align: center;
background-color: #FFFFFF;
cursor: pointer;
}
#dataBox {
padding: 10px 0;
}
#benefit, #roles, #countBtn, #bonus {
border: 1px solid #D4D4D4;
}
</style>
</head>
<body>
<div id="box">
<header>欢迎使用项目提成计算器</header>
<div id="dataBox">
<input type="text" id="bonus" readonly="readonly" placeholder="项目提成">
</div>
<input id="benefit" type="text" value="0">
<select id="roles">
<option value="1">程序员</option>
<option value="2">项目经理</option>
<option value="3">销售人员</option>
</select>
<div id="count">
<input type="button" id="countBtn" value="计算" onclick="countFun()"/>
</div>
</div>
</body>
</html>
<script>
function roles() {
this.programmer = function (data) {
if (data > 10000) {
return data * 0.05;
} else if (data >= 2000) {
return 50;
} else {
return 0;
}
}
this.manager = function (data) {
if (data > 20000) {
return data * 0.2;
} else {
return data * 0.1;
}
}
this.salesman = function (data) {
if (data > 100000) {
return data * 0.3;
} else if (data >= 50000) {
return data * 0.2;
} else {
return data * 0.05;
}
}
}
function bonus() {
this.benefit = 0;
}
bonus.prototype.setBenefit = function (data) {
this.benefit = data;
}
bonus.__proto__ = new roles();
bonus.prototype.getBonus = function (role) {
return role(this.benefit);
}
var bonusCount = new bonus();
var strategies = {
"1": function () {
return bonusCount.getBonus(bonus.programmer);
},
"2": function () {
return bonusCount.getBonus(bonus.manager);
},
"3": function () {
return bonusCount.getBonus(bonus.salesman);
}
}
function countFun() {
var benefit = document.getElementById("benefit").value;
var role = document.getElementById("roles").value;
bonusCount.setBenefit(benefit);
document.getElementById("bonus").value = strategies[role]();
}
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment