| @@ -209,7 +209,7 @@ | |||
| <van-field label="净残值(元)" input-align="right" :border="false"> | |||
| <template #input> | |||
| <van-stepper v-model="form.netSalvage" input-width="100" min="0.00" :decimal-length="2" @change="changeNetSalvage" /> | |||
| <van-stepper v-model="form.netSalvage" input-width="100" min="0.00" :decimal-length="2" @changexxx="changeNetSalvage" /> | |||
| </template> | |||
| </van-field> | |||
| @@ -262,7 +262,12 @@ | |||
| <van-stepper v-model="form.depreciationYears" input-width="100" min="0" @change="changeDepreciationYears" /> | |||
| </template> | |||
| </van-field> | |||
| <van-field readonly v-model="form.depreciationValue" label="累计折旧(元)" placeholder="0" input-align="right" :border="false" @change="changeDepreciationValue" /> | |||
| <van-field readonly v-model="form.depreciationValue" label="累计折旧(元)" placeholder="0" input-align="right" :border="false" @change="changeDepreciationValue" | |||
| > | |||
| <template #button> | |||
| <van-button size="small" type="primary" round @click="calcDepreciationValue" native-type="button">重新计算</van-button> | |||
| </template> | |||
| </van-field> | |||
| </div> | |||
| <div style="margin: 16px auto;width: 50%;"> | |||
| @@ -282,7 +287,6 @@ | |||
| minDate:new Date(1900,1,1), | |||
| applicationList:[], | |||
| applicationListSecond:[], | |||
| assetStatusOptions:[], | |||
| form:{ | |||
| assetType:'151001', | |||
| operationType:'1', | |||
| @@ -433,18 +437,42 @@ | |||
| }, | |||
| // 累计折旧变动监听 | |||
| changeDepreciationValue(val) { | |||
| if (this.form.originalValue != null) { | |||
| // 净值 = 原值-累计折旧 | |||
| this.form.netValue = this.form.originalValue - val; | |||
| } | |||
| if (val == null) | |||
| return; | |||
| // 每期折旧额 = (原值-净残值)/ 预计使用期数 | |||
| let depreciation = this.form.originalValue - this.form.netSalvage; | |||
| depreciation -= val; | |||
| let periods = this.form.expectedYears - (this.form.depreciationYears || 0); | |||
| if(periods > 0 && depreciation > 0) | |||
| this.form.perYearDepreciationValue = (depreciation / periods).toFixed(2); | |||
| else | |||
| this.form.perYearDepreciationValue = 0; | |||
| // 净值 = 原值-累计折旧 | |||
| this.form.netValue = (this.form.originalValue || 0) - val; | |||
| }, | |||
| // 残值率变动监听 | |||
| changeResidualsRate(val) { | |||
| if (this.form.originalValue != null) { | |||
| // 净残值 = 原值*残值率 | |||
| this.form.netSalvage = (this.form.originalValue * val) / 100; | |||
| if (val == null) | |||
| return; | |||
| // 净残值 = 原值*残值率 | |||
| this.form.netSalvage = val > 0 ? ((this.form.originalValue * val) / 100).toFixed(2) : 0; | |||
| if (this.form.expectedYears > 0) { | |||
| // 每期折旧额 = (原值-净残值)/ 预计使用期数 | |||
| let depreciation = this.form.originalValue - (this.form.netSalvage || 0); | |||
| depreciation -= (this.form.depreciationValue || 0); | |||
| let periods = this.form.expectedYears - (this.form.depreciationYears || 0); | |||
| if(periods > 0 && depreciation > 0) | |||
| this.form.perYearDepreciationValue = (depreciation / periods).toFixed(2); | |||
| else | |||
| this.form.perYearDepreciationValue = 0; | |||
| } | |||
| else | |||
| this.form.perYearDepreciationValue = 0; | |||
| }, | |||
| // 净残值变动监听 | |||
| @@ -458,18 +486,36 @@ | |||
| // 预计使用年数变动监听 | |||
| changeExpectedYears(val) { | |||
| if (this.form.originalValue != null && this.form.netSalvage != null) { | |||
| // 每年折旧额:(原值-净残值)/ 预计使用年数 | |||
| this.form.perYearDepreciationValue = | |||
| (this.form.originalValue - this.form.netSalvage) / val; | |||
| } | |||
| if (val == null) | |||
| return; | |||
| // 每期折旧额 = (原值-净残值)/ 预计使用期数 | |||
| let depreciation = this.form.originalValue - this.form.netSalvage; | |||
| depreciation -= this.form.depreciationValue; | |||
| let periods = val - (this.form.depreciationYears || 0); | |||
| if(periods > 0 && depreciation > 0) | |||
| this.form.perYearDepreciationValue = (depreciation / periods).toFixed(2); | |||
| else | |||
| this.form.perYearDepreciationValue = 0; | |||
| }, | |||
| // 已折旧年数变动监听 | |||
| changeDepreciationYears(val) { | |||
| if (this.form.perYearDepreciationValue != null) { | |||
| this.form.depreciationValue = val * this.form.perYearDepreciationValue; | |||
| if (val == null) | |||
| return; | |||
| //if(!this.form.depreciationValueManual) | |||
| { | |||
| if (this.form.perYearDepreciationValue > 0) { | |||
| // 累计折旧 = 已折旧期数 * 每期折旧额 | |||
| this.form.depreciationValue = val * this.form.perYearDepreciationValue; | |||
| } | |||
| else | |||
| this.form.depreciationValue = 0; | |||
| } | |||
| // 净值 = 原值-累计折旧 | |||
| this.form.netValue = (this.form.originalValue || 0) - (this.form.depreciationValue || 0); | |||
| }, | |||
| onSubmit(){ | |||
| addPermanent(this.form).then((response) => { | |||
| @@ -480,7 +526,15 @@ | |||
| },2000) | |||
| } | |||
| }); | |||
| } | |||
| }, | |||
| calcDepreciationValue() { | |||
| this.form.depreciationValue = 0; | |||
| const depreciationYears = this.form.depreciationYears; | |||
| this.form.depreciationYears = 0; | |||
| this.changeOriginalValue(this.form.originalValue); | |||
| this.form.depreciationYears = depreciationYears; | |||
| this.changeDepreciationYears(depreciationYears); | |||
| }, | |||
| }, | |||
| } | |||
| </script> | |||