|
@@ -152,7 +152,10 @@ export default {
|
|
|
editData: {
|
|
|
handler(newData) {
|
|
|
if (newData && this.isEdit) {
|
|
|
- this.formData = { ...newData }
|
|
|
+ this.formData = {
|
|
|
+ ...newData,
|
|
|
+ year: newData.year ? newData.year.toString() : ''
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
immediate: true,
|
|
@@ -196,9 +199,12 @@ export default {
|
|
|
* 初始化表单数据
|
|
|
*/
|
|
|
initFormData() {
|
|
|
- if (this.isEdit && this.editData) {
|
|
|
- // 编辑模式:使用传入的数据
|
|
|
- this.formData = { ...this.editData }
|
|
|
+ if (this.isEdit && this.editData) {
|
|
|
+ // 编辑模式:使用传入的数据,确保year字段为字符串格式
|
|
|
+ this.formData = {
|
|
|
+ ...this.editData,
|
|
|
+ year: this.editData.year ? this.editData.year.toString() : ''
|
|
|
+ }
|
|
|
} else {
|
|
|
// 新增模式:使用默认数据,自动填入下个月
|
|
|
const now = new Date()
|