214 lines
5.9 KiB
TypeScript
214 lines
5.9 KiB
TypeScript
import Dialog from '@vant/weapp/dialog/dialog';
|
|
import { deleteAction, postAction } from '../../../api/base';
|
|
Page({
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
type: '', // add 测算 check 详情
|
|
issubmit: false,
|
|
// 展开/收起
|
|
showBox: {
|
|
base: true, // 基本信息
|
|
vehicle: true, // 车型信息
|
|
result: true, // 测试机构
|
|
rentalIncome: true, // 租金收入
|
|
manageCostList: true, // 管理、运维、保险费用
|
|
incomeAndTax: true, // 收入与税金表
|
|
costAndProfitList: true, // 成本与利润表
|
|
showBoxChild: {}
|
|
},
|
|
dataInfo: {} as any, // 数据
|
|
showList: {
|
|
// 基本信息
|
|
baseInfo: [
|
|
{ label: '所属项目', prop: 'projectId' },
|
|
{ label: '租赁年限', prop: 'yearLimit', append: '年' },
|
|
{ label: '融资比例', prop: 'financingRatio', append: '%' },
|
|
{ label: '融资利率', prop: 'financingRate', append: '%' },
|
|
{ label: '管理分担费用', prop: 'overheadSharing', append: '%' }
|
|
],
|
|
// 车型信息
|
|
vehicleInfo: [
|
|
{ label: '车型', prop: 'vehicleType' },
|
|
{ label: '单价', prop: 'unitPrice', append: '万元' },
|
|
{ label: '上牌费用/购置税', prop: 'purchaseTax', append: '万元' },
|
|
{ label: '保险', prop: 'insurance', append: '万元' },
|
|
{ label: '维修及易损件(台/年)', prop: 'repair', append: '万元' },
|
|
{ label: '保养', prop: 'upkeep', append: '万元' },
|
|
{ label: '年审', prop: 'annualAudit', append: '万元' }
|
|
],
|
|
// 测试结果
|
|
result: [
|
|
{ label: '购车成本回收期', prop: 'carCostRecovery', append: '年' },
|
|
{ label: '融资成本', prop: 'financingCost', append: '万元' },
|
|
{ label: '内部收益率', prop: 'internalRate', append: '%' },
|
|
{ label: '实缴增值税及附加', prop: 'vatAndAdditional', append: '万元' },
|
|
{ label: '所得税', prop: 'incomeTax', append: '万元' },
|
|
{ label: '净利润', prop: 'netProfit', append: '万元' },
|
|
{ label: '残值', prop: 'salvageValue', append: '万元' }
|
|
],
|
|
// 固定模板 一至八年
|
|
yearList: [
|
|
{ label: '第一年', prop: 'oneYear', append: '万元' },
|
|
{ label: '第二年', prop: 'twoYear', append: '万元' },
|
|
{ label: '第三年', prop: 'threeYear', append: '万元' },
|
|
{ label: '第四年', prop: 'fourYear', append: '万元' },
|
|
{ label: '第五年', prop: 'fiveYear', append: '万元' },
|
|
{ label: '第六年', prop: 'sixYear', append: '万元' },
|
|
{ label: '第七年', prop: 'sevenYear', append: '万元' },
|
|
{ label: '第八年', prop: 'eightYear', append: '万元' }
|
|
]
|
|
}
|
|
},
|
|
// 展示和收起
|
|
showBoxInf(e: any) {
|
|
let data: any = { ...this.data };
|
|
let { fieldname, type, index } = e.currentTarget.dataset;
|
|
if (type) {
|
|
data.showBox.showBoxChild[fieldname][index] =
|
|
!data.showBox.showBoxChild[fieldname][index];
|
|
} else data.showBox[fieldname] = !data.showBox[fieldname];
|
|
this.setData(data);
|
|
},
|
|
// 删除
|
|
delete() {
|
|
Dialog.confirm({
|
|
title: '',
|
|
message: '是否确认删除当前项?'
|
|
})
|
|
.then(() => {
|
|
deleteAction('api/finance/calculate/delete', {
|
|
id: this.data.dataInfo.id
|
|
})
|
|
.then((res: any) => {
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: '删除成功',
|
|
icon: 'success'
|
|
});
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 1
|
|
});
|
|
}, 1000);
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
})
|
|
.catch((err: any) => {
|
|
console.log(err);
|
|
});
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
// 上一步
|
|
goback() {
|
|
wx.navigateBack();
|
|
},
|
|
// 提交
|
|
submit() {
|
|
if (this.data.issubmit) return;
|
|
this.setData({
|
|
issubmit: true
|
|
});
|
|
wx.showLoading({
|
|
title: '加载中'
|
|
});
|
|
postAction('api/finance/calculate/add', this.data.dataInfo)
|
|
.then((res: any) => {
|
|
if (res.success) {
|
|
wx.showToast({
|
|
title: '提交成功',
|
|
icon: 'none'
|
|
});
|
|
setTimeout(() => {
|
|
wx.navigateBack({
|
|
delta: 2
|
|
});
|
|
}, 1000);
|
|
} else {
|
|
wx.showToast({
|
|
title: res.message,
|
|
icon: 'none'
|
|
});
|
|
}
|
|
this.setData({
|
|
issubmit: false
|
|
});
|
|
wx.hideLoading();
|
|
})
|
|
.catch(err => {
|
|
console.log(err);
|
|
this.setData({
|
|
issubmit: false
|
|
});
|
|
wx.hideLoading();
|
|
});
|
|
},
|
|
// 获取数据
|
|
getInf() {
|
|
let { info, type } = wx.getStorageSync('costEstimationData');
|
|
let list = {
|
|
manageCostList: [],
|
|
incomeAndTax: [],
|
|
costAndProfitList: []
|
|
} as any;
|
|
let keys = Object.keys(list);
|
|
keys.forEach((item: any) => {
|
|
for (let index = 0; index < info.calculateObject[item].length; index++) {
|
|
list[item].push(true);
|
|
}
|
|
});
|
|
this.setData({
|
|
dataInfo: info,
|
|
['showBox.showBoxChild']: list,
|
|
type: type
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
this.getInf();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {}
|
|
});
|