演示視頻
修改方法
找到\src\views\customer\contract\components\contractDialog.vue
在截圖位置
this.rules.amount = nVal.data.num || undefined
的下面添加如下代碼
// 點(diǎn)擊付款按鈕后,到期時(shí)間自動(dòng)填入并增加一年
if (nVal.data.types == 1 && !this.rules.endDate) {
let newDate = new Date(nVal.data.time);
newDate.setFullYear(newDate.getFullYear() + 1); // 增加一年
this.rules.endDate = newDate;
}
其他說明
如果需要自動(dòng)其他時(shí)間,請(qǐng)將對(duì)象getFullYear()改成對(duì)應(yīng)的。
ps:getFullYear()為年,getMonth()為月,getDate()為天。
例如:
// 增加5年
newDate.setFullYear(newDate.getFullYear() + 5);
// 增加4個(gè)月
newDate.setMonth(newDate.getMonth() + 4);
// 增加三天
newDate.setDate(newDate.getDate() + 3);
UNI-APP部分修改
找到\pages\customer\contract\addPayment.vue文件
在
formData.num = config.num
下面添加如下代碼
const newDate = new Date(config.time);
newDate.setFullYear(newDate.getFullYear() + 1);
formData.end_date = newDate.toISOString().split('T')[0];