Browse Source

feat(api): 添加全局类型定义和客户API模块

yz 2 weeks ago
parent
commit
aa8afc5f9e
3 changed files with 63 additions and 1 deletions
  1. 1 1
      src/api/announcement/index.js
  2. 47 0
      src/api/common/customer.js
  3. 15 0
      src/types/global.d.ts

+ 1 - 1
src/api/announcement/index.js

@@ -61,7 +61,7 @@ import request from '@/router/axios';
  * @param {number} current - 当前页码
  * @param {number} size - 每页大小
  * @param {NoticeQueryParams} [params={}] - 查询参数
- * @returns {Promise<{data: {data: {records: NoticeRecord[], total: number, size: number, current: number}}}}
+ * @returns {Promise<AxiosResponse<{data: {data: {records: NoticeRecord[], total: number, size: number, current: number}}}>>}
  */
 export const getList = (current, size, params = {}) => {
   return request({

+ 47 - 0
src/api/common/customer.js

@@ -0,0 +1,47 @@
+/**
+ * 获取客户列表
+ * @param {Object} params - 查询参数
+ * @param {number} params.size - 每页条数
+ * @param {number} params.current - 当前页码
+ * @param {string} [params.customerName] - 客户名称筛选
+ * @returns {Promise<AxiosResponse<CustomerResponse>>} 分页客户数据
+ */
+export const getCustomerList = async (params) => {
+    return request({
+        url: '/api/blade-factory/api/factory/view-customer',
+        method: 'get',
+        params: {
+            ...params,
+            // 确保分页参数类型正确
+            size: Number(params.size),
+            current: Number(params.current)
+        }
+    });
+};
+
+/**
+ * @typedef {Object} CustomerRecord
+ * @property {string} id - 客户ID
+ * @property {number} ORG_ID - 组织ID
+ * @property {string} Customer_CODE - 客户编码
+ * @property {string} Customer_NAME - 客户名称
+ * @property {string} Customer_ShortName - 客户简称
+ * @property {string} TaxSchedule_NAME - 税率名称
+ * @property {number} TaxRate - 税率
+ * @property {string} TradeCurrency_NAME - 交易币种
+ * @property {string} ShippmentRule_NAME - 出货规则
+ * @property {string} RecervalTerm_NAME - 收款条件
+ * @property {string} CreatedOn - 创建时间
+ */
+
+/**
+ * @typedef {Object} CustomerResponse
+ * @property {number} code - 状态码
+ * @property {boolean} success - 请求状态
+ * @property {Object} data - 响应数据
+ * @property {CustomerRecord[]} data.records - 客户记录
+ * @property {number} data.total - 总记录数
+ * @property {number} data.size - 每页大小
+ * @property {number} data.current - 当前页码
+ * @property {string} msg - 消息描述
+ */

+ 15 - 0
src/types/global.d.ts

@@ -0,0 +1,15 @@
+declare interface AxiosResponse<T = any> {
+    data: T;
+    status: number;
+    statusText: string;
+    headers: {
+        [key: string]: string;
+        'content-type'?: string;
+    };
+    config: {
+        method?: string;
+        url?: string;
+        params?: Record<string, any>;
+        headers?: Record<string, any>;
+    };
+}