ff212e00 by lihua

修复估值模型

1 parent d74c5536
......@@ -396,6 +396,10 @@
background-color: var(--el-table-current-row-bg-color);
}
thead.is-group th.el-table__cell {
background-color: var(--el-table-header-bg-color);
}
&--border {
.el-table__header,
......
......@@ -586,11 +586,11 @@ const visibleChange = (visible, row) => {
}
const panelChange = (scope, row) => {
if (row.field == 'baseDate' || row.field == 'investYear') {
if (row.field == 'evaluateBaseDate' || row.field == 'baseDate' || row.field == 'investYear') {
const date = new Date();
const year = date.getFullYear();
const datePopperNextBtn = document.querySelector('.date-month-popper .d-arrow-right');
if (row.field == 'baseDate') {
if (row.field == 'baseDate' || row.field == 'evaluateBaseDate') {
const currentYear = scope.date.getFullYear();
if (currentYear >= year) {
datePopperNextBtn.setAttribute("disabled", '');
......@@ -1463,7 +1463,7 @@ const panelChange = (scope, row) => {
@panel-change="(date, mode) => panelChange({ date, mode }, item)"
@visible-change="(vis) => visibleChange(vis, item)" />
<el-date-picker :class="[item.col, { is_block: item.block }]" v-else-if="item.type == 'date-month'"
v-model="formInline[item.field]" type="month" format="YYYY-MM" value-format="YYYY-MM"
v-model="formInline[item.field]" type="month" :format="item.format ?? 'YYYY-MM'" :value-format="item.valueFormat ?? 'YYYY-MM'"
:placeholder="item.placeholder" :unlink-panels="item.unlink ?? false" :shortcuts="item.shortcuts ?? []"
:default-value="item.defaultDate" :disabled="item.disabled ?? false" :disabled-date="item.disabledDate"
:popper-class="item.popperClass" @change="(val) => inputChange(val, item)"
......
......@@ -22,6 +22,17 @@ const route = useRoute();
const fullPath = route.fullPath;
const fullscreenLoading = ref(false);
/** 获取当月的最后一天。 */
const getLastDayOfMonth = (month) => {
const year = parseInt(month.split('-')[0], 10);
const monthIndex = parseInt(month.split('-')[1], 10) - 1; // JavaScript 的月份是从0开始计数的
const date = new Date(year, monthIndex + 1, 0); // 使用0可以得到前一个月的最后一天
const yearString = date.getFullYear();
const monthString = String(date.getMonth() + 1).padStart(2, '0'); // JavaScript 的月份是从0开始计数的
const dayString = String(date.getDate()).padStart(2, '0');
return `${yearString}-${monthString}-${dayString}`;
}
/** 数据产品列表 */
const damProductList: any = ref([]);
......@@ -47,8 +58,10 @@ const valuateFormItems: any = ref([
label: "基准日",
type: "date-month",
field: "evaluateBaseDate",
default: moment(new Date()).format('YYYY-MM'),
default: getLastDayOfMonth(moment(new Date()).format('YYYY-MM')),
placeholder: "请选择",
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
clearable: true,
required: true,
style: { width: 'calc(33.33% - 70px)', 'margin-right': '8px' },
......@@ -126,22 +139,24 @@ const handleValudateFormChange = (val, row, info) => {
valuateFormItems.value.forEach(item => {
item.default = info[item.field];
if (item.field == 'useYears') {
item.visible = item.default != '1';
item.visible = val != '1';
item.default = info.useYears ? info.useYears : 1;
}
})
}
}
/** 获取当月的最后一天。 */
const getLastDayOfMonth = (month) => {
const year = parseInt(month.split('-')[0], 10);
const monthIndex = parseInt(month.split('-')[1], 10) - 1; // JavaScript 的月份是从0开始计数的
const date = new Date(year, monthIndex + 1, 0); // 使用0可以得到前一个月的最后一天
const yearString = date.getFullYear();
const monthString = String(date.getMonth() + 1).padStart(2, '0'); // JavaScript 的月份是从0开始计数的
const dayString = String(date.getDate()).padStart(2, '0');
return `${yearString}-${monthString}-${dayString}`;
const handleInputChange = (val, row, info) => {
if (row.field == 'evaluateBaseDate') {
valuateFormItems.value.forEach(item => {
item.default = info[item.field];
if (item.field == 'useYears') {
item.visible = info.evaluateMethod != '1';
} else if (item.field == 'evaluateBaseDate') {
item.default = getLastDayOfMonth(val);
}
})
}
}
const costTableField: any = ref([
......@@ -433,10 +448,7 @@ const incomeYears = computed(() => {
let year = parseInt(infos[0]);
let month = parseInt(infos[1]);
if (month == 12) {
let a = [{
field: year + '',
label: year + '年'
}];
let a: any = [];
for (var i = 1; i < useYears + 1; i++) {
a.push({
field: year + i + '',
......@@ -447,7 +459,7 @@ const incomeYears = computed(() => {
} else if (month == 1) {
let a = [{
field: evaluateBaseDate + '',
label: year + '年' + `(1)`
label: year + '年' + `(2~12)`
}];
for (var i = 1; i < useYears + 1; i++) {
a.push({
......@@ -459,12 +471,12 @@ const incomeYears = computed(() => {
} else {
let a = [{
field: evaluateBaseDate + '',
label: year + '年' + `(1~${month})`
label: year + '年' + `(${month + 1}~12)`
}];
for (var i = 1; i < useYears + 1; i++) {
a.push({
field: year + i + '',
label: i == useYears ? ((year + i) + '年' + `(${month}~12)`) : ((year + i) + '年')
label: i == useYears ? ((year + i) + '年' + `(1~${month})`) : ((year + i) + '年')
});
}
return a;
......@@ -584,21 +596,29 @@ const incomeCalculateData = computed(() => { //响应式不生效
resultInfo['折现因子'] = [];
resultInfo['折现现值'] = [];
resultInfo['数据资产估值'] = 0;
let formInline = formRef.value.formInline;
let evaluateBaseDate = formInline.evaluateBaseDate;
let infos = evaluateBaseDate.split('-');
let month = parseInt(infos[1]);
let transfer = (v, need = true) => {
return v ? (need ? parseFloat(v) / 100 : parseFloat(v)) : 0;
}
incomeYears.value.forEach((year, i) => {
let C6 = transfer(data[5][year.field])
let C7 = transfer(data[6][year.field])
let sumC7: any = i == 0 ? C7 : incomeYears.value.slice(0, i + 1).reduce(function (prev, curr, idx, arr) {
return transfer(data[6][prev.field]) + transfer(data[6][curr.field]);
let sumC7: any = C7;
incomeYears.value.slice(0, i + 1).forEach((item) => {
sumC7 = sumC7 + transfer(data[6][item.field]);
})
resultInfo['综合分成率'].push(changeNum(C6 * (1 - sumC7 + C7 / 2) * 100, 2, true)); //TODO综合分成率算法有问题
let C1 = transfer(data[0][year.field], false)
let C5 = transfer(data[4][year.field])
resultInfo['现金流'].push(changeNum(C1 * C5 * resultInfo['综合分成率'][i] / 100, 2, true));
if (i == 0) {
resultInfo['折现年期'].push(changeNum(10 / 12 / 2, 2, true));
let cnt = month == 12 ? 12 : (12 - month);
resultInfo['折现年期'].push(changeNum(cnt / 12 / 2, 2, true));
} else if (i == incomeYears.value.length - 1) {
resultInfo['折现年期'].push(changeNum(parseFloat(resultInfo['折现年期'][i - 1]) + (month == 12 ? 1 : (month / 12 / 2)), 2, true))
} else {
resultInfo['折现年期'].push(changeNum(parseFloat(resultInfo['折现年期'][i - 1]) + 1, 2, true))
}
......@@ -619,6 +639,10 @@ const submit = () => {
if (params.evaluateMethod == '1') {
params.valuationCostRQVOList = costTableData.value;
params.damValuation = costTableSummaryValue.value;
if (!costTableData.value.some(table => table.amount !== '')) {
proxy.$ElMessage.error('成本法请至少输入一项指标金额');
return
}
} else {
params.valuationEarningsRQVOList = incomeTableData.value;
params.damValuation = incomeCalculateData.value['数据资产估值'];
......@@ -761,10 +785,10 @@ onMounted(async () => {
<div class="content_main">
<ContentWrap id="id-baseInfo" title="估值类型" instructions="" style="margin-top: 8px;">
<Form ref="formRef" :itemList="valuateFormItems" :rules="valuateFormRules" formId="main-model-edit"
@select-change="handleValudateFormChange" col="col3" />
@select-change="handleValudateFormChange" @input-change="handleInputChange" col="col3" />
</ContentWrap>
<ContentWrap id="id-grade-info" title="填写成本明细"
:instructions="formRef?.formInline?.evaluateMethod == '1' ? '填写时请按照所选数据产品的成本投入进行填写,跟数据产品产生的成本一致' : ''"
:description="formRef?.formInline?.evaluateMethod == '1' ? '填写时请按照所选数据产品的成本投入进行填写,跟数据产品产生的成本一致' : ''"
style="margin-top: 16px;">
<el-table id="cost-table" v-show="formRef?.formInline?.evaluateMethod == '1'" ref="costTableRef"
:data="costTableData" :span-method="costTableSpanMethod" :summary-method="costTableSummaryMethod" show-summary
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!