Browse Source

refactor(公告管理): 重构公告管理模块API和界面

yz 3 tháng trước cách đây
mục cha
commit
85d644ae54
2 tập tin đã thay đổi với 380 bổ sung303 xóa
  1. 111 33
      src/api/announcement/index.js
  2. 269 270
      src/views/announcement/index.vue

+ 111 - 33
src/api/announcement/index.js

@@ -1,73 +1,151 @@
+/**
+ * 公告管理API
+ * @description 提供公告的增删改查功能
+ * @author AI Assistant
+ * @version 2.0.0
+ */
 import request from '@/router/axios';
 
-export const getList = (current, size, params) => {
+/**
+ * 公告查询参数类型定义
+ * @typedef {Object} NoticeQueryParams
+ * @property {number} current - 当前页码
+ * @property {number} size - 每页大小
+ * @property {string} [categoryId] - 分类ID(可选)
+ * @property {string} [title] - 公告标题(搜索用)
+ * @property {string} [content] - 公告内容(搜索用)
+ */
+
+/**
+ * 公告表单数据类型定义
+ * @typedef {Object} NoticeFormData
+ * @property {string} [id] - 公告ID(更新时必填)
+ * @property {string} title - 公告标题
+ * @property {string} content - 公告内容
+ * @property {string} categoryId - 分类ID
+ * @property {string} categoryName - 分类名称
+ * @property {number} orgId - 组织ID
+ * @property {string} orgCode - 组织编码
+ * @property {string} orgName - 组织名称
+ * @property {string} visibleRoles - 可见角色
+ * @property {Object} [brandScope] - 品牌范围
+ * @property {Object} [customerBlacklist] - 客户黑名单
+ * @property {string} [remark] - 备注
+ */
+
+/**
+ * 公告列表项类型定义
+ * @typedef {Object} NoticeRecord
+ * @property {string} id - 公告ID
+ * @property {string} createUser - 创建用户ID
+ * @property {string} createDept - 创建部门ID
+ * @property {string} createTime - 创建时间
+ * @property {string} updateUser - 更新用户ID
+ * @property {string} updateTime - 更新时间
+ * @property {number} status - 状态 1-正常 0-禁用
+ * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
+ * @property {string} title - 公告标题
+ * @property {string} content - 公告内容
+ * @property {string} categoryId - 分类ID
+ * @property {string} categoryName - 分类名称
+ * @property {number} orgId - 组织ID
+ * @property {string} orgCode - 组织编码
+ * @property {string} orgName - 组织名称
+ * @property {string} visibleRoles - 可见角色
+ * @property {Object|null} brandScope - 品牌范围
+ * @property {Object|null} customerBlacklist - 客户黑名单
+ * @property {string} remark - 备注
+ */
+
+/**
+ * 获取公告列表
+ * @param {number} current - 当前页码
+ * @param {number} size - 每页大小
+ * @param {NoticeQueryParams} [params={}] - 查询参数
+ * @returns {Promise<{data: {data: {records: NoticeRecord[], total: number, size: number, current: number}}}}
+ */
+export const getList = (current, size, params = {}) => {
   return request({
-    url: '/api/blade-announcement/list',
+    url: '/blade-factory/api/factory/notice/page',
     method: 'get',
     params: {
-      ...params,
       current,
       size,
+      ...params
     }
-  })
-}
-
-export const remove = (ids) => {
-  return request({
-    url: '/api/blade-announcement/remove',
-    method: 'post',
-    params: {
-      ids,
-    }
-  })
-}
+  });
+};
 
+/**
+ * 添加公告
+ * @param {NoticeFormData} row - 公告表单数据
+ * @returns {Promise<{data: null, code: number, success: boolean, msg: string}>}
+ */
 export const add = (row) => {
   return request({
-    url: '/api/blade-announcement/submit',
+    url: '/blade-factory/api/factory/notice/add',
     method: 'post',
     data: row
-  })
-}
+  });
+};
 
+/**
+ * 更新公告
+ * @param {NoticeFormData} row - 公告表单数据
+ * @returns {Promise<{data: null, code: number, success: boolean, msg: string}>}
+ */
 export const update = (row) => {
   return request({
-    url: '/api/blade-announcement/submit',
+    url: '/blade-factory/api/factory/notice/update',
     method: 'post',
     data: row
-  })
-}
+  });
+};
 
+/**
+ * 获取公告详情
+ * @param {string} id - 公告ID
+ * @returns {Promise<{data: {data: NoticeRecord}}>}
+ */
 export const getAnnouncement = (id) => {
   return request({
-    url: '/api/blade-announcement/detail',
+    url: '/blade-factory/api/factory/notice/detail',
     method: 'get',
     params: {
       id
     }
-  })
-}
+  });
+};
 
-// 获取经销商列表
+/**
+ * 获取经销商列表(保留兼容性)
+ * @returns {Promise<any>}
+ */
 export const getDealerList = () => {
   return request({
     url: '/api/blade-system/dealer/list',
     method: 'get'
-  })
-}
+  });
+};
 
-// 获取品牌列表
+/**
+ * 获取品牌列表(保留兼容性)
+ * @returns {Promise<any>}
+ */
 export const getBrandList = () => {
   return request({
     url: '/api/blade-system/brand/list',
     method: 'get'
-  })
-}
+  });
+};
 
-// 获取分类列表 - 更新为使用新的分类接口
+/**
+ * 获取分类列表
+ * @returns {Promise<any>}
+ */
 export const getCategoryList = () => {
   return request({
     url: '/blade-factory/api/notice/category/list',
     method: 'get'
-  })
-}
+  });
+};

+ 269 - 270
src/views/announcement/index.vue

@@ -1,34 +1,63 @@
 <template>
     <basic-container>
-        <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel"
-            v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave"
-            :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
-            @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
-            @refresh-change="refreshChange" @on-load="onLoad">
+        <avue-crud
+            :option="option"
+            :data="data"
+            ref="crud"
+            v-model="form"
+            :page.sync="page"
+            :permission="permissionList"
+            :before-open="beforeOpen"
+            :table-loading="loading"
+            @row-update="rowUpdate"
+            @row-save="rowSave"
+            @search-change="searchChange"
+            @search-reset="searchReset"
+            @selection-change="selectionChange"
+            @current-change="currentChange"
+            @size-change="sizeChange"
+            @refresh-change="refreshChange"
+            @on-load="onLoad"
+        >
             <template slot="menuLeft">
-                <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.announcement_delete"
-                    @click="handleDelete">删 除
+                <el-button
+                    type="primary"
+                    size="small"
+                    icon="el-icon-view"
+                    plain
+                    @click="handleDetail"
+                    v-if="selectionList.length === 1"
+                >
+                    查看详情
                 </el-button>
             </template>
-            <template slot-scope="{row}" slot="dealer">
-                <el-tag>{{ row.dealerName }}</el-tag>
+            <template slot-scope="{row}" slot="categoryName">
+                <el-tag type="primary">{{ row.categoryName }}</el-tag>
             </template>
-            <template slot-scope="{row}" slot="brand">
-                <el-tag>{{ row.brandName }}</el-tag>
+            <template slot-scope="{row}" slot="status">
+                <el-tag :type="row.status === 1 ? 'success' : 'danger'">
+                    {{ row.status === 1 ? '正常' : '禁用' }}
+                </el-tag>
             </template>
-            <template slot-scope="{row}" slot="detail">
-                <el-button type="text" @click="viewDetail(row)">查看详情</el-button>
+            <template slot-scope="{row}" slot="visibleRoles">
+                <el-tag>{{ getVisibleRolesText(row.visibleRoles) }}</el-tag>
             </template>
         </avue-crud>
 
-        <!-- 详情查看对话框 -->
-        <el-dialog title="公告详情" :visible.sync="detailVisible" width="60%" append-to-body>
-            <div class="detail-content">
-                <h3>{{ currentDetail.title }}</h3>
+        <!-- 详情对话框 -->
+        <el-dialog title="公告详情" :visible.sync="detailVisible" width="60%" :close-on-click-modal="false">
+            <div class="detail-content" v-if="currentDetail.id">
                 <div class="detail-info">
-                    <p><strong>发布时间:</strong>{{ currentDetail.publishTime }}</p>
-                    <p><strong>经销商:</strong>{{ currentDetail.dealerName }}</p>
-                    <p><strong>品牌:</strong>{{ currentDetail.brandName }}</p>
+                    <p><strong>公告标题:</strong>{{ currentDetail.title }}</p>
+                    <p><strong>分类:</strong>{{ currentDetail.categoryName }}</p>
+                    <p><strong>组织:</strong>{{ currentDetail.orgName }}</p>
+                    <p><strong>创建时间:</strong>{{ currentDetail.createTime }}</p>
+                    <p><strong>可见角色:</strong>{{ getVisibleRolesText(currentDetail.visibleRoles) }}</p>
+                    <p><strong>状态:</strong>
+                        <el-tag :type="currentDetail.status === 1 ? 'success' : 'danger'">
+                            {{ currentDetail.status === 1 ? '正常' : '禁用' }}
+                        </el-tag>
+                    </p>
                 </div>
                 <div class="detail-body" v-html="currentDetail.content"></div>
             </div>
@@ -40,36 +69,41 @@
 </template>
 
 <script>
-import { getList, remove, update, add, getAnnouncement, getDealerList, getBrandList, getCategoryList } from "@/api/announcement";
+import { getList, update, add, getAnnouncement, getCategoryList } from "@/api/announcement";
 import { mapGetters } from "vuex";
 
 /**
- * @typedef {Object} AnnouncementItem
- * @property {number} id - 公告ID
+ * 公告数据类型定义
+ * @typedef {Object} NoticeItem
+ * @property {string} id - 公告ID
  * @property {string} title - 公告标题
- * @property {string} customerCode - 客户编号
- * @property {string} publishTime - 发布时间
- * @property {number} dealerId - 经销商ID
- * @property {string} dealerName - 经销商名称
- * @property {number} brandId - 品牌ID
- * @property {string} brandName - 品牌名称
- * @property {number} categoryId - 分类ID
- * @property {string} categoryName - 分类名称
- * @property {string} roleType - 角色类型
  * @property {string} content - 公告内容
+ * @property {string} categoryId - 分类ID
+ * @property {string} categoryName - 分类名称
+ * @property {number} orgId - 组织ID
+ * @property {string} orgCode - 组织编码
+ * @property {string} orgName - 组织名称
+ * @property {string} visibleRoles - 可见角色
+ * @property {Object|null} brandScope - 品牌范围
+ * @property {Object|null} customerBlacklist - 客户黑名单
+ * @property {string} remark - 备注
+ * @property {string} createTime - 创建时间
+ * @property {string} updateTime - 更新时间
+ * @property {number} status - 状态
+ * @property {number} isDeleted - 是否删除
  */
 
 /**
- * @typedef {Object} OptionItem
- * @property {number} id - 选项ID
- * @property {string} dealerName - 经销商名称
- * @property {string} brandName - 品牌名称
- * @property {string} categoryName - 分类名称
- * @property {number} value - 选项值
+ * 分类选项类型定义
+ * @typedef {Object} CategoryOption
+ * @property {string} id - 分类ID
+ * @property {string} name - 分类名称
+ * @property {string} value - 选项值
  * @property {string} label - 选项标签
  */
 
 /**
+ * 分页信息类型定义
  * @typedef {Object} PageInfo
  * @property {number} pageSize - 每页大小
  * @property {number} currentPage - 当前页码
@@ -77,25 +111,22 @@ import { mapGetters } from "vuex";
  */
 
 /**
+ * 查询参数类型定义
  * @typedef {Object} QueryParams
  * @property {string} [title] - 公告标题
- * @property {string} [customerCode] - 客户编号
- * @property {Array<string>} [publishTime] - 发布时间范围
- * @property {number} [dealerId] - 经销商ID
- * @property {number} [brandId] - 品牌ID
- * @property {number} [categoryId] - 分类ID
- * @property {string} [roleType] - 角色类型
+ * @property {string} [categoryId] - 分类ID
+ * @property {string} [content] - 公告内容
  */
 
 /**
  * 公告管理组件
- * @component AnnouncementIndex
+ * @component NoticeIndex
  */
 export default {
-    name: 'AnnouncementIndex',
+    name: 'NoticeIndex',
     data() {
         return {
-            /** @type {AnnouncementItem} 表单数据 */
+            /** @type {NoticeItem} 表单数据 */
             form: {},
             /** @type {QueryParams} 查询参数 */
             query: {},
@@ -103,7 +134,7 @@ export default {
             loading: true,
             /** @type {boolean} 详情对话框显示状态 */
             detailVisible: false,
-            /** @type {AnnouncementItem} 当前查看的详情数据 */
+            /** @type {NoticeItem} 当前查看的详情数据 */
             currentDetail: {},
             /** @type {PageInfo} 分页信息 */
             page: {
@@ -111,19 +142,16 @@ export default {
                 currentPage: 1,
                 total: 0
             },
-            /** @type {Array<AnnouncementItem>} 选中的数据列表 */
+            /** @type {NoticeItem[]} 选中的数据列表 */
             selectionList: [],
-            /** @type {Array<OptionItem>} 经销商选项列表 */
-            dealerOptions: [],
-            /** @type {Array<OptionItem>} 品牌选项列表 */
-            brandOptions: [],
-            /** @type {Array<OptionItem>} 分类选项列表 */
+            /** @type {CategoryOption[]} 分类选项列表 */
             categoryOptions: [],
             /** @type {Object} 表格配置选项 */
             option: {
                 height: 'auto',
                 calcHeight: 30,
-                dialogWidth: 950,
+                dialogWidth: 1000,
+                labelWidth: 120,
                 tip: false,
                 searchShow: true,
                 searchMenuSpan: 6,
@@ -131,8 +159,9 @@ export default {
                 index: true,
                 viewBtn: true,
                 selection: true,
-                excelBtn: false,        // 隐藏下载按钮
-                columnBtn: false,       // 隐藏列设置按钮
+                excelBtn: false,
+                columnBtn: false,
+                delBtn: false, // 根据需求移除删除功能
                 dialogClickModal: false,
                 column: [
                     {
@@ -148,100 +177,80 @@ export default {
                         }]
                     },
                     {
-                        label: "客户编号",
-                        prop: "customerCode",
-                        span: 12,
-                        search: true,
-                        overHidden: true
-                    },
-                    {
-                        label: "发布时间",
-                        prop: "publishTime",
-                        type: "daterange",
-                        format: "yyyy-MM-dd",
-                        valueFormat: "yyyy-MM-dd",
-                        rangeSeparator: "至",
-                        searchRange: true,
-                        startPlaceholder: "开始时间",
-                        endPlaceholder: "结束时间",
-                        overHidden: true,
-                        search: true,
-                        hide: true,  // 在表格中隐藏,只用于搜索
-                        addDisplay: false,  // 新增时不显示
-                        editDisplay: false, // 编辑时不显示
-                        viewDisplay: false  // 查看时不显示
-                    },
-                    {
-                        label: "经销商",
-                        prop: "dealerId",
+                        label: "分类",
+                        prop: "categoryId",
                         type: "select",
                         dicData: [],
                         props: {
-                            label: "dealerName",
+                            label: "name",
                             value: "id"
                         },
                         slot: true,
-                        overHidden: true,
                         search: true,
                         span: 12,
                         rules: [{
                             required: true,
-                            message: "请选择经销商",
+                            message: "请选择分类",
                             trigger: "change"
                         }]
                     },
                     {
-                        label: "品牌",
-                        prop: "brandId",
-                        type: "select",
-                        dicData: [],
-                        props: {
-                            label: "brandName",
-                            value: "id"
-                        },
-                        slot: true,
-                        overHidden: true,
-                        search: true,
+                        label: "组织名称",
+                        prop: "orgName",
                         span: 12,
-                        rules: [{
-                            required: true,
-                            message: "请选择品牌",
-                            trigger: "change"
-                        }]
+                        addDisplay: false,
+                        editDisplay: false,
+                        overHidden: true
                     },
                     {
-                        label: "分类",
-                        prop: "categoryId",
+                        label: "可见角色",
+                        prop: "visibleRoles",
                         type: "select",
-                        dicData: [], // 初始为空,通过loadCategoryOptions方法动态加载
-                        props: {
-                            label: "categoryName", // 根据后端返回的字段名调整
-                            value: "id"
-                        },
-                        search: true,
+                        dicData: [
+                            { label: "管理员", value: "1" },
+                            { label: "普通用户", value: "2" },
+                            { label: "访客", value: "3" },
+                            { label: "VIP用户", value: "4" }
+                        ],
+                        slot: true,
                         span: 12,
                         rules: [{
                             required: true,
-                            message: "请选择分类",
+                            message: "请选择可见角色",
                             trigger: "change"
                         }]
                     },
                     {
-                        label: "角色",
-                        prop: "roleType",
+                        label: "状态",
+                        prop: "status",
                         type: "select",
                         dicData: [
-                            { label: "工厂", value: "factory" },
-                            { label: "经销商", value: "dealer" },
-                            { label: "零售商", value: "retailer" }
+                            { label: "正常", value: 1 },
+                            { label: "禁用", value: 0 }
                         ],
-                        search: true,
-                        span: 12,
-                        rules: [{
-                            required: true,
-                            message: "请选择角色",
-                            trigger: "change"
-                        }]
+                        slot: true,
+                        addDisplay: false,
+                        editDisplay: false,
+                        width: 80
+                    },
+                    {
+                        label: "创建时间",
+                        prop: "createTime",
+                        type: "datetime",
+                        format: "yyyy-MM-dd HH:mm:ss",
+                        valueFormat: "yyyy-MM-dd HH:mm:ss",
+                        addDisplay: false,
+                        editDisplay: false,
+                        overHidden: true,
+                        width: 150
+                    },
+                    {
+                        label: "备注",
+                        prop: "remark",
+                        type: "textarea",
+                        span: 24,
+                        minRows: 3,
+                        hide: true
                     },
                     {
                         label: "公告内容",
@@ -264,24 +273,65 @@ export default {
                             trigger: "blur"
                         }]
                     },
+                    // 隐藏字段
+                    {
+                        label: "组织ID",
+                        prop: "orgId",
+                        type: "number",
+                        hide: true,
+                        addDisplay: false,
+                        editDisplay: false
+                    },
+                    {
+                        label: "组织编码",
+                        prop: "orgCode",
+                        hide: true,
+                        addDisplay: false,
+                        editDisplay: false
+                    },
+                    {
+                        label: "分类名称",
+                        prop: "categoryName",
+                        hide: true,
+                        addDisplay: false,
+                        editDisplay: false
+                    },
+                    {
+                        label: "品牌范围",
+                        prop: "brandScope",
+                        type: "json",
+                        hide: true,
+                        span: 24
+                    },
+                    {
+                        label: "客户黑名单",
+                        prop: "customerBlacklist",
+                        type: "json",
+                        hide: true,
+                        span: 24
+                    }
                 ]
             },
-            /** @type {Array<AnnouncementItem>} 表格数据 */
+            /** @type {NoticeItem[]} 表格数据 */
             data: []
         };
     },
     computed: {
-        ...mapGetters(["permission"]),
+        ...mapGetters(["permission", "userInfo"]),
         /**
          * 权限列表
          * @returns {Object} 权限配置对象
          */
         permissionList() {
             return {
-                addBtn: this.vaildData(this.permission.announcement_add, false),
-                viewBtn: this.vaildData(this.permission.announcement_view, false),
-                delBtn: this.vaildData(this.permission.announcement_delete, false),
-                editBtn: this.vaildData(this.permission.announcement_edit, false)
+                // addBtn: this.vaildData(this.permission.announcement_add, false),
+                // viewBtn: this.vaildData(this.permission.announcement_view, false),
+                // delBtn: false,
+                // editBtn: this.vaildData(this.permission.announcement_edit, false)
+                addBtn: true,
+                viewBtn: true,
+                delBtn: false,
+                editBtn: true,
             };
         },
         /**
@@ -289,7 +339,7 @@ export default {
          * @returns {string} 逗号分隔的ID字符串
          */
         ids() {
-            let ids = [];
+            const ids = [];
             this.selectionList.forEach(ele => {
                 ids.push(ele.id);
             });
@@ -297,9 +347,7 @@ export default {
         }
     },
     created() {
-        this.loadDealerOptions();
-        this.loadBrandOptions();
-        this.loadCategoryOptions(); // 添加分类加载
+        this.loadCategoryOptions();
     },
     methods: {
         /**
@@ -310,37 +358,31 @@ export default {
         async loadCategoryOptions() {
             try {
                 const res = await getCategoryList();
-                // 根据新接口返回的数据结构进行转换
                 const categoryData = res.data.data || [];
-                
-                // 将接口返回的数据转换为页面所需的格式
+
                 this.categoryOptions = categoryData
-                    .filter(item => item.status === 1 && item.isDeleted === 0) // 只显示启用且未删除的分类
+                    .filter(item => item.status === 1 && item.isDeleted === 0)
                     .map(item => ({
                         id: item.id,
                         name: item.name,
-                        categoryName: item.name, // 兼容原有字段名
                         value: item.id,
                         label: item.name,
                         orgId: item.orgId,
                         orgName: item.orgName,
-                        isSystem: item.isSystem,
-                        sortOrder: item.sortOrder
+                        sortOrder: item.sortOrder || 0
                     }))
-                    .sort((a, b) => a.sortOrder - b.sortOrder); // 按排序字段排序
-                
+                    .sort((a, b) => a.sortOrder - b.sortOrder);
+
                 const categoryColumn = this.option.column.find(col => col.prop === 'categoryId');
                 if (categoryColumn) {
                     categoryColumn.dicData = this.categoryOptions;
                 }
             } catch (error) {
                 console.error('加载分类选项失败:', error);
-                // 如果接口不存在,使用模拟数据
+                // 使用默认分类
                 this.categoryOptions = [
-                    { id: 1, name: '系统公告', categoryName: '系统公告', value: 1, label: '系统公告', isSystem: 1, sortOrder: 0 },
-                    { id: 2, name: '产品公告', categoryName: '产品公告', value: 2, label: '产品公告', isSystem: 0, sortOrder: 1 },
-                    { id: 3, name: '活动公告', categoryName: '活动公告', value: 3, label: '活动公告', isSystem: 0, sortOrder: 2 },
-                    { id: 4, name: '维护公告', categoryName: '维护公告', value: 4, label: '维护公告', isSystem: 0, sortOrder: 3 }
+                    { id: '1', name: '系统公告', value: '1', label: '系统公告' },
+                    { id: '2', name: '部门公告', value: '2', label: '部门公告' }
                 ];
                 const categoryColumn = this.option.column.find(col => col.prop === 'categoryId');
                 if (categoryColumn) {
@@ -349,77 +391,66 @@ export default {
             }
         },
         /**
-         * 查看详情
-         * @param {AnnouncementItem} row - 行数据
-         * @returns {void}
+         * 获取可见角色文本
+         * @param {string} visibleRoles - 可见角色值
+         * @returns {string} 角色文本
          */
-        viewDetail(row) {
-            this.currentDetail = row;
-            this.detailVisible = true;
+        getVisibleRolesText(visibleRoles) {
+            const roleMap = {
+                '1': '管理员',
+                '2': '普通用户',
+                '3': '访客',
+                '4': 'VIP用户'
+            };
+            return roleMap[visibleRoles] || '未知角色';
         },
         /**
-         * 加载经销商选项
+         * 查看详情
          * @async
          * @returns {Promise<void>}
          */
-        async loadDealerOptions() {
-            try {
-                const res = await getDealerList();
-                this.dealerOptions = res.data.data || [];
-                const dealerColumn = this.option.column.find(col => col.prop === 'dealerId');
-                if (dealerColumn) {
-                    dealerColumn.dicData = this.dealerOptions;
-                }
-            } catch (error) {
-                // 如果接口不存在,使用模拟数据
-                this.dealerOptions = [
-                    { id: 1, dealerName: '经销商A' },
-                    { id: 2, dealerName: '经销商B' },
-                    { id: 3, dealerName: '经销商C' }
-                ];
-                const dealerColumn = this.option.column.find(col => col.prop === 'dealerId');
-                if (dealerColumn) {
-                    dealerColumn.dicData = this.dealerOptions;
-                }
+        async handleDetail() {
+            if (this.selectionList.length !== 1) {
+                this.$message.warning("请选择一条数据查看详情");
+                return;
             }
-        },
-        /**
-         * 加载品牌选项
-         * @async
-         * @returns {Promise<void>}
-         */
-        async loadBrandOptions() {
             try {
-                const res = await getBrandList();
-                this.brandOptions = res.data.data || [];
-                const brandColumn = this.option.column.find(col => col.prop === 'brandId');
-                if (brandColumn) {
-                    brandColumn.dicData = this.brandOptions;
-                }
+                const res = await getAnnouncement(this.selectionList[0].id);
+                this.currentDetail = res.data.data;
+                this.detailVisible = true;
             } catch (error) {
-                // 如果接口不存在,使用模拟数据
-                this.brandOptions = [
-                    { id: 1, brandName: '品牌A' },
-                    { id: 2, brandName: '品牌B' },
-                    { id: 3, brandName: '品牌C' }
-                ];
-                const brandColumn = this.option.column.find(col => col.prop === 'brandId');
-                if (brandColumn) {
-                    brandColumn.dicData = this.brandOptions;
-                }
+                console.error('获取详情失败:', error);
+                this.$message.error('获取详情失败');
             }
         },
         /**
          * 保存行数据
          * @async
-         * @param {AnnouncementItem} row - 行数据
+         * @param {NoticeItem} row - 行数据
          * @param {Function} done - 完成回调
          * @param {Function} loading - 加载回调
          * @returns {Promise<void>}
          */
         async rowSave(row, done, loading) {
             try {
-                await add(row);
+                // 设置默认值
+                const formData = {
+                    ...row,
+                    orgId: this.userInfo.orgId || 1,
+                    orgCode: this.userInfo.orgCode || 'ORG_0001',
+                    orgName: this.userInfo.orgName || '默认组织',
+                    brandScope: row.brandScope || {},
+                    customerBlacklist: row.customerBlacklist || {},
+                    remark: row.remark || ''
+                };
+
+                // 设置分类名称
+                const selectedCategory = this.categoryOptions.find(cat => cat.id === row.categoryId);
+                if (selectedCategory) {
+                    formData.categoryName = selectedCategory.name;
+                }
+
+                await add(formData);
                 this.onLoad(this.page);
                 this.$message({
                     type: "success",
@@ -427,14 +458,15 @@ export default {
                 });
                 done();
             } catch (error) {
-                console.log(error);
+                console.error('保存失败:', error);
+                this.$message.error('保存失败');
                 loading();
             }
         },
         /**
          * 更新行数据
          * @async
-         * @param {AnnouncementItem} row - 行数据
+         * @param {NoticeItem} row - 行数据
          * @param {number} index - 行索引
          * @param {Function} done - 完成回调
          * @param {Function} loading - 加载回调
@@ -442,7 +474,21 @@ export default {
          */
         async rowUpdate(row, index, done, loading) {
             try {
-                await update(row);
+                // 设置分类名称
+                const selectedCategory = this.categoryOptions.find(cat => cat.id === row.categoryId);
+                if (selectedCategory) {
+                    row.categoryName = selectedCategory.name;
+                }
+
+                // 确保必要字段存在
+                const formData = {
+                    ...row,
+                    brandScope: row.brandScope || {},
+                    customerBlacklist: row.customerBlacklist || {},
+                    remark: row.remark || ''
+                };
+
+                await update(formData);
                 this.onLoad(this.page);
                 this.$message({
                     type: "success",
@@ -450,35 +496,12 @@ export default {
                 });
                 done();
             } catch (error) {
-                console.log(error);
+                console.error('更新失败:', error);
+                this.$message.error('更新失败');
                 loading();
             }
         },
         /**
-         * 删除行数据
-         * @async
-         * @param {AnnouncementItem} row - 行数据
-         * @returns {Promise<void>}
-         */
-        async rowDel(row) {
-            try {
-                await this.$confirm("确定将选择数据删除?", {
-                    confirmButtonText: "确定",
-                    cancelButtonText: "取消",
-                    type: "warning"
-                });
-                await remove(row.id);
-                this.onLoad(this.page);
-                this.$message({
-                    type: "success",
-                    message: "操作成功!"
-                });
-            } catch (error) {
-                // 用户取消删除或删除失败
-                console.log(error);
-            }
-        },
-        /**
          * 重置搜索
          * @returns {void}
          */
@@ -500,7 +523,7 @@ export default {
         },
         /**
          * 选择变化
-         * @param {Array<AnnouncementItem>} list - 选中的数据列表
+         * @param {NoticeItem[]} list - 选中的数据列表
          * @returns {void}
          */
         selectionChange(list) {
@@ -515,34 +538,6 @@ export default {
             this.$refs.crud.toggleSelection();
         },
         /**
-         * 批量删除
-         * @async
-         * @returns {Promise<void>}
-         */
-        async handleDelete() {
-            if (this.selectionList.length === 0) {
-                this.$message.warning("请选择至少一条数据");
-                return;
-            }
-            try {
-                await this.$confirm("确定将选择数据删除?", {
-                    confirmButtonText: "确定",
-                    cancelButtonText: "取消",
-                    type: "warning"
-                });
-                await remove(this.ids);
-                this.onLoad(this.page);
-                this.$message({
-                    type: "success",
-                    message: "操作成功!"
-                });
-                this.$refs.crud.toggleSelection();
-            } catch (error) {
-                // 用户取消删除或删除失败
-                console.log(error);
-            }
-        },
-        /**
          * 打开前回调
          * @async
          * @param {Function} done - 完成回调
@@ -555,8 +550,19 @@ export default {
                     const res = await getAnnouncement(this.form.id);
                     this.form = res.data.data;
                 } catch (error) {
-                    console.log(error);
+                    console.error('获取详情失败:', error);
                 }
+            } else if (type === "add") {
+                // 新增时设置默认值
+                this.form = {
+                    orgId: this.userInfo.orgId || 1,
+                    orgCode: this.userInfo.orgCode || 'ORG_0001',
+                    orgName: this.userInfo.orgName || '默认组织',
+                    visibleRoles: '2', // 默认普通用户
+                    brandScope: {},
+                    customerBlacklist: {},
+                    remark: ''
+                };
             }
             done();
         },
@@ -591,29 +597,22 @@ export default {
          * @returns {Promise<void>}
          */
         async onLoad(page, params = {}) {
-            const { publishTime } = this.query;
-            let values = {
-                ...params,
-            };
-            if (publishTime) {
-                values = {
+            this.loading = true;
+            try {
+                const queryParams = {
                     ...params,
-                    publishTimeStart: publishTime[0],
-                    publishTimeEnd: publishTime[1],
                     ...this.query
                 };
-                values.publishTime = null;
-            }
-            this.loading = true;
-            try {
-                const res = await getList(page.currentPage, page.pageSize, values);
+
+                const res = await getList(page.currentPage, page.pageSize, queryParams);
                 const data = res.data.data;
                 this.page.total = data.total;
                 this.data = data.records;
                 this.loading = false;
                 this.selectionClear();
             } catch (error) {
-                console.log(error);
+                console.error('加载数据失败:', error);
+                this.$message.error('加载数据失败');
                 this.loading = false;
             }
         }