A Pen by Filipp Chapkovski on CodePen.
Created
May 23, 2020 23:26
-
-
Save chapkovski/c9495862578f50da46cc8a28d7313320 to your computer and use it in GitHub Desktop.
calc_embez
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container" id='vue-app'> | |
<div class="row"> | |
<div class="col"> | |
<div class="form-group required"> | |
<label class="col-form-label" for="id_k_declare_0">Выберите для примера значение коэффициента К:</label> | |
<div class="controls field-k_declare"> | |
<div class="form-check form-check-inline" v-for='(i, ind) in KChoices'> | |
<input type="radio" name="k_declare" :value='i' v-model='trueK' required :id="`id_true_k_${ind}`" class="form-check-input"> | |
<label :for="`id_true_k_${ind}`" class="form-check-label">[[i]]</label> | |
</div> | |
</div> | |
</div> | |
<div class="alert alert-danger my-3"> | |
Истинное значение коэффициента: [[trueK]] | |
</div> | |
<div class="form-group required"> | |
<label class="col-form-label" for="id_k_declare_0">Выберите значение коэффициента, которое Вы объявите Гражданину:</label> | |
<div class="controls field-k_declare"> | |
<div class="form-check form-check-inline" v-for='(i, ind) in KDchoices'> | |
<input type="radio" name="k_declare" :value='i' v-model='declaredK' required :id="`id_k_declare_${ind}`" class="form-check-input"> | |
<label :for="`id_k_declare_${ind}`" class="form-check-label">[[i]]</label> | |
</div> | |
</div> | |
</div> | |
<div class="info" v-if='declaredK'> | |
<div class="alert alert-info"> | |
Вы уменьшаете бонус Гражданина на [[citizenBonusDiff()]] | |
</div> | |
<div class="alert alert-info"> | |
Вы увеличиваете свой бонус на [[officerBonusDiff()]] | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = new Vue({ | |
el: "#vue-app", | |
data() { | |
return { | |
initialK: null, | |
KChoices: [1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3], | |
trueK: null, | |
totalTaxesPaid: 10, | |
declaredK: null | |
}; | |
}, | |
computed: { | |
kDiff() { | |
return this.trueK - this.declaredK; | |
}, | |
KDchoices() { | |
return _.map(_.range(1, this.trueK + 0.001, 0.25), (i) => _.round(i, 2)); | |
} | |
}, | |
methods: { | |
citizenBonusDiff() { | |
return (this.kDiff * this.totalTaxesPaid) / 2; | |
}, | |
officerBonusDiff() { | |
return this.kDiff * this.totalTaxesPaid; | |
} | |
}, | |
delimiters: ["[[", "]]"] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment