index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * 公告管理API
  3. * @description 提供公告的增删改查功能
  4. * @version 2.0.0
  5. */
  6. import request from '@/router/axios';
  7. /**
  8. * 公告查询参数类型定义
  9. * @typedef {Object} NoticeQueryParams
  10. * @property {number} current - 当前页码
  11. * @property {number} size - 每页大小
  12. * @property {string} [categoryId] - 分类ID(可选)
  13. * @property {string} [title] - 公告标题(搜索用)
  14. * @property {string} [content] - 公告内容(搜索用)
  15. */
  16. /**
  17. * 公告表单数据类型定义
  18. * @typedef {Object} NoticeFormData
  19. * @property {string} [id] - 公告ID(更新时必填)
  20. * @property {string} title - 公告标题
  21. * @property {string} content - 公告内容
  22. * @property {string} categoryId - 分类ID
  23. * @property {string} categoryName - 分类名称
  24. * @property {number} orgId - 组织ID
  25. * @property {string} orgCode - 组织编码
  26. * @property {string} orgName - 组织名称
  27. * @property {string} visibleRoles - 可见角色
  28. * @property {Object} [brandScope] - 品牌范围
  29. * @property {Object} [customerBlacklist] - 客户黑名单
  30. * @property {string} [remark] - 备注
  31. */
  32. /**
  33. * 公告列表项类型定义
  34. * @typedef {Object} NoticeRecord
  35. * @property {string} id - 公告ID
  36. * @property {string} createUser - 创建用户ID
  37. * @property {string} createDept - 创建部门ID
  38. * @property {string} createTime - 创建时间
  39. * @property {string} updateUser - 更新用户ID
  40. * @property {string} updateTime - 更新时间
  41. * @property {number} status - 状态 1-正常 0-禁用
  42. * @property {number} isDeleted - 是否删除 0-未删除 1-已删除
  43. * @property {string} title - 公告标题
  44. * @property {string} content - 公告内容
  45. * @property {string} categoryId - 分类ID
  46. * @property {string} categoryName - 分类名称
  47. * @property {number} orgId - 组织ID
  48. * @property {string} orgCode - 组织编码
  49. * @property {string} orgName - 组织名称
  50. * @property {string} visibleRoles - 可见角色
  51. * @property {Object|null} brandScope - 品牌范围
  52. * @property {Object|null} customerBlacklist - 客户黑名单
  53. * @property {string} remark - 备注
  54. */
  55. /**
  56. * 获取公告列表
  57. * @param {number} current - 当前页码
  58. * @param {number} size - 每页大小
  59. * @param {NoticeQueryParams} [params={}] - 查询参数
  60. * @returns {Promise<AxiosResponse<{data: {data: {records: NoticeRecord[], total: number, size: number, current: number}}}>>}
  61. */
  62. export const getList = (current, size, params = {}) => {
  63. return request({
  64. url: '/api/blade-factory/api/factory/notice/page',
  65. method: 'get',
  66. params: {
  67. current,
  68. size,
  69. ...params
  70. }
  71. });
  72. };
  73. /**
  74. * 新增公告
  75. * @param {NoticeFormData} row - 公告表单数据
  76. * @returns {Promise<AxiosResponse<boolean>>} 操作结果
  77. */
  78. export const add = (row) => {
  79. return request({
  80. url: '/api/blade-factory/api/factory/notice/add',
  81. method: 'post',
  82. data: row
  83. });
  84. };
  85. /**
  86. * 修改公告
  87. * @param {NoticeFormData} row - 公告表单数据
  88. * @returns {Promise<AxiosResponse<boolean>>} 操作结果
  89. */
  90. export const update = (row) => {
  91. return request({
  92. url: '/api/blade-factory/api/factory/notice/update',
  93. method: 'post',
  94. data: row
  95. });
  96. };
  97. /**
  98. * 获取公告详情
  99. * @param {string} id - 公告ID
  100. * @returns {Promise<AxiosResponse<NoticeRecord>>} 公告详情
  101. */
  102. export const getAnnouncement = (id) => {
  103. return request({
  104. url: '/api/blade-factory/api/factory/notice/detail',
  105. method: 'get',
  106. params: {
  107. id
  108. }
  109. });
  110. };
  111. /**
  112. * 获取经销商列表(保留兼容性)
  113. * @returns {Promise<AxiosResponse<Array<{id: string, name: string}>>>}
  114. */
  115. export const getDealerList = () => {
  116. return request({
  117. url: '/api/blade-system/dealer/list',
  118. method: 'get'
  119. });
  120. };
  121. /**
  122. * 获取品牌列表(保留兼容性)
  123. * @returns {Promise<AxiosResponse<Array<{id: string, name: string}>>>}
  124. */
  125. export const getBrandList = () => {
  126. return request({
  127. url: '/api/blade-system/brand/list',
  128. method: 'get'
  129. });
  130. };
  131. /**
  132. * 获取分类列表
  133. * @returns {Promise<any>}
  134. */
  135. export const getCategoryList = () => {
  136. return request({
  137. url: '/api/blade-factory/api/factory/notice/category/list',
  138. method: 'get'
  139. });
  140. };