moneyText 생성 완료

This commit is contained in:
2023-01-03 18:59:57 +09:00
parent 27285e1605
commit bfbfb2b452
2 changed files with 40 additions and 36 deletions
@@ -29,7 +29,8 @@ let appVue = new Vue({
petName: '', petName: '',
insertType: 'change', insertType: 'change',
usim: '0', usim: '0',
formula: '' formula: '',
faceValueRebate: ''
}, },
mounted: function () { mounted: function () {
this.init(); this.init();
@@ -47,14 +48,13 @@ let appVue = new Vue({
$(".money").on('blur', function(e){ $(".money").on('blur', function(e){
e.stopPropagation(); e.stopPropagation();
e.stopImmediatePropagation(); e.stopImmediatePropagation();
let value = e.target.value; var value;
value = Number(value.replaceAll(',', '')); if(e.target.value < 100){
if(isNaN(value)) { //NaN인지 판별 value = e.target.value*10000;
e.target.value = 0; }else{
}else { //NaN이 아닌 경우 value = e.target.value;
const formatValue = value.toLocaleString('ko-KR'); }
e.target.value = formatValue; e.target.value = $this.moneyText(value.toString());
}
}); });
}, },
bindData: function () { bindData: function () {
@@ -148,32 +148,36 @@ let appVue = new Vue({
formulaChange: function(e){ formulaChange: function(e){
let $this = this; let $this = this;
var result = 0; var result = 0;
var calc = e.target.value; //1+7+8-5-4+4 = 11 var calc = e.target.value; //-1-2-3 = -6
var calcList = calc.split('+');//1//7//8-5-4//4 var plusList = calc.split('+');//-1-2-3
calcList.forEach(function(num1, i){
if(num1.indexOf('-') == -1){ //only 숫자 for(var i=0;i<plusList.length;i++){
result += parseInt(num1); if(plusList[i].indexOf('-') == -1){ //only 숫자
console.log("+"+num1); result += Number(plusList[i]);
}else{//빼기 8-5-4 }else{
num1.split('-').forEach(function(num2, j){ var subList = plusList[i].split('-');//-1-2-3
if(j==0 && i==0){ for(var j=0;j<subList.length;j++){
result =parseInt(num1); if(subList[j] == '' && j == 0){
console.log("="+num1);
j++; }else if(subList[j] != '' && j == 0){
}else if(j==0){ result +=Number(subList[j]);
result +=parseInt(num2); }else{
console.log("+"+num2); result -=Number(subList[j]);
} }
else{ }
result -=parseInt(num2);
console.log("-"+num1);
}
});
} }
}); }
var value = result*10000;
console.log(result); $this.faceValueRebate = $this.moneyText(value.toString());
},
moneyText: function(value){
value = Number(value.replaceAll(',', ''));
if(isNaN(value)) { //NaN인지 판별
return 0;
}else { //NaN이 아닌 경우
const formatValue = value.toLocaleString('ko-KR');
return formatValue;
}
} }
} }
}); });
+3 -3
View File
@@ -38,7 +38,7 @@
</div> </div>
<label for="mobileCarrier" class="col-sm-1 col-form-label mb-3 pt-3">통신사</label> <label for="mobileCarrier" class="col-sm-1 col-form-label mb-3 pt-3">통신사</label>
<div class="col-sm-3 mb-3 pt-3"> <div class="col-sm-3 mb-3 pt-3">
<input type="text" readonly class="form-control" id="mobileCarrier" v-model="mobileCarrier" value="" tabindex="3"> <input type="text" readonly class="form-control" id="mobileCarrier" v-model="mobileCarrier" disabled="disabled" tabindex="3">
</div> </div>
</div> </div>
</div> </div>
@@ -143,9 +143,9 @@
<input type="text" class="form-control" id="formula" value="1+2+4+5+6-2" v-model="formula" @input="formulaChange"> <input type="text" class="form-control" id="formula" value="1+2+4+5+6-2" v-model="formula" @input="formulaChange">
</div> </div>
<div class="vr p-0 m-0"></div> <div class="vr p-0 m-0"></div>
<label for="pname" class="col-sm-2 col-form-label mb-3 pt-3">액면R/B</label> <label for="faceValueRebate" class="col-sm-2 col-form-label mb-3 pt-3">액면R/B</label>
<div class="col-sm-3 mb-3 pt-3"> <div class="col-sm-3 mb-3 pt-3">
<input type="text" class="form-control money" id="pname" readonly value="160000"> <input type="text" class="form-control money" id="faceValueRebate" v-model="faceValueRebate" disabled="disabled" value="160000">
</div> </div>
</div> </div>