|
|
@@ -130,19 +130,34 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
watch: {
|
|
|
+ // 每次打开弹窗都按当前字段值重新初始化,避免上次取消后残留的编辑内容
|
|
|
+ visible(visible) {
|
|
|
+ if (visible) {
|
|
|
+ this.initValue();
|
|
|
+ }
|
|
|
+ },
|
|
|
value(newVal) {
|
|
|
- this.stringValue = newVal;
|
|
|
+ this.stringValue = this.normalizeValue(newVal);
|
|
|
|
|
|
if (this.field === 'label_list' && Array.isArray(newVal)) {
|
|
|
this.arrayValue = [...newVal];
|
|
|
}
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initValue() {
|
|
|
+ this.labelInput = '';
|
|
|
+ this.imageId = '';
|
|
|
+ this.stringValue = this.normalizeValue(this.value);
|
|
|
+ this.arrayValue = Array.isArray(this.value) ? [...this.value] : [];
|
|
|
+ },
|
|
|
+ normalizeValue(value) {
|
|
|
if (this.field === 'plan_publish_date') {
|
|
|
const date = new Date();
|
|
|
- this.stringValue = newVal === '0-00-00' ? `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}` : newVal;
|
|
|
+ return value === '0-00-00' ? `${date.getFullYear()}-${date.getMonth()}-${date.getDay()}` : value;
|
|
|
}
|
|
|
+ return value;
|
|
|
},
|
|
|
- },
|
|
|
- methods: {
|
|
|
// 处理标签输入
|
|
|
labelChange() {
|
|
|
if (this.labelInput.trim() !== '') {
|
|
|
@@ -195,6 +210,11 @@ export default {
|
|
|
this.$emit('updateProjectFieldValue', this.field, this.stringValue);
|
|
|
}
|
|
|
if (this.field === 'cover_image_file_url') {
|
|
|
+ // 未重新上传时不能提交,否则会把已有封面清空
|
|
|
+ if (!this.imageId) {
|
|
|
+ this.$message.warning('请先上传封面图片');
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.$emit('updateProjectFieldValue', 'cover_image_file_id', this.imageId);
|
|
|
}
|
|
|
if (this.field === 'label_list') {
|