演示視頻
修改方法
找到\src\views\customer\contract\components\contractDialog.vue
在截圖位置
this.rules.amount = nVal.data.num || undefined
的下面添加如下代碼
// 點擊付款按鈕后,到期時間自動填入并增加一年
if (nVal.data.types == 1 && !this.rules.endDate) {
let newDate = new Date(nVal.data.time);
newDate.setFullYear(newDate.getFullYear() + 1); // 增加一年
this.rules.endDate = newDate;
}
其他說明
如果需要自動其他時間,請將對象getFullYear()改成對應的。
ps:getFullYear()為年,getMonth()為月,getDate()為天。
例如:
// 增加5年
newDate.setFullYear(newDate.getFullYear() + 5);
// 增加4個月
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];