|
@@ -385,6 +385,18 @@ export default {
|
|
|
this.loadCategoryOptions();
|
|
|
},
|
|
|
|
|
|
+ watch: {
|
|
|
+ announcementFormVisible(val) {
|
|
|
+ if (val === true) {
|
|
|
+ // 打开表单时,立即重新加载分类列表(表单与列表都会受益)
|
|
|
+ this.loadCategoryOptions();
|
|
|
+ } else {
|
|
|
+ // 关闭表单后,avue-crud 会通过 v-if 重新渲染,需等 DOM 恢复后再刷新字典
|
|
|
+ this.$nextTick(() => this.loadCategoryOptions());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
methods: {
|
|
|
// 导入常量工具函数
|
|
|
calculateRolesMask,
|
|
@@ -427,6 +439,10 @@ export default {
|
|
|
const categoryColumn = this.option.column.find((/** @type {TableColumn} */ col) => col.prop === 'categoryName');
|
|
|
if (categoryColumn) {
|
|
|
categoryColumn.dicData = this.categoryOptions;
|
|
|
+ // 重新初始化 avue-crud 的字典,确保搜索下拉及时更新
|
|
|
+ if (this.$refs && this.$refs.crud && typeof this.$refs.crud.dicInit === 'function') {
|
|
|
+ this.$nextTick(() => this.$refs.crud.dicInit());
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('加载分类选项失败:', error);
|
|
@@ -442,6 +458,10 @@ export default {
|
|
|
const categoryColumn = this.option.column.find((/** @type {TableColumn} */ col) => col.prop === 'categoryName');
|
|
|
if (categoryColumn) {
|
|
|
categoryColumn.dicData = this.categoryOptions;
|
|
|
+ // 重新初始化 avue-crud 的字典,确保搜索下拉及时更新
|
|
|
+ if (this.$refs && this.$refs.crud && typeof this.$refs.crud.dicInit === 'function') {
|
|
|
+ this.$nextTick(() => this.$refs.crud.dicInit());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -564,6 +584,8 @@ export default {
|
|
|
* @this {import('@/views/announcement/types').AnnouncementComponent & import('vue').default}
|
|
|
*/
|
|
|
refreshChange() {
|
|
|
+ // 刷新列表与分类字典
|
|
|
+ this.loadCategoryOptions();
|
|
|
this.onLoad(this.page, this.query);
|
|
|
},
|
|
|
|
|
@@ -810,6 +832,8 @@ export default {
|
|
|
this.announcementFormVisible = false;
|
|
|
this.isEditMode = false;
|
|
|
this.editAnnouncementId = null;
|
|
|
+ // 刷新分类字典
|
|
|
+ this.loadCategoryOptions();
|
|
|
// 刷新列表数据
|
|
|
this.onLoad(this.page);
|
|
|
}
|