Переглянути джерело

feat(地址): 为地址列表接口添加查询参数支持

yz 2 тижнів тому
батько
коміт
38dd15e142

+ 3 - 1
src/api/order/address.js

@@ -61,13 +61,15 @@ export const getDetail = async (id) => {
 
 /**
  * 获取客户地址列表
+ * @param {import('../types/address').AddressQueryParam} params - 查询参数
  * @returns {Promise<import('../types/address').CustomerAddressFullListResponse>} 客户地址列表
  */
-export const getAddressList = async () => {
+export const getAddressList = async (params) => {
   return request({
     url: '/api/blade-factory/api/factory/salesOrder/getAddressList',
     method: 'get',
     params: {
+        ...params
     }
   })
 }

+ 2 - 1
src/api/types/address.d.ts

@@ -28,6 +28,7 @@ export interface CustomerAddressForm {
 
 // 使用类型操作从CustomerAddressForm中排除客户相关字段
 export type AddressForm = Omit<CustomerAddressForm, 'customerId' | 'customerCode' | 'customerName'>;
+export type AddressQueryParam = Partial<AddressForm>;
 
 export interface CustomerAddressRecord extends BaseEntity {
   customerId: number;
@@ -50,4 +51,4 @@ export type CustomerAddressDetailResponse = AxiosResponse<ApiResponseData<Custom
 
 export type CustomerAddressOperationResponse = AxiosResponse<ApiResponseData<boolean>>;
 
-export type CustomerAddressFullListResponse = AxiosResponse<ApiResponseData<CustomerAddressRecord[]>>;
+export type CustomerAddressFullListResponse = AxiosResponse<ApiResponseData<CustomerAddressRecord[]>>;

+ 5 - 4
src/views/order/address/addressMixin.js

@@ -478,8 +478,9 @@ export default {
     async onLoad(params = {}) {
       this.loading = true
       try {
-        // const customerId = params['customerId'] || this.query['customerId']
-        const res = await getAddressList()
+        // 合并查询参数
+        const queryParams = { ...this.query, ...params }
+        const res = await getAddressList(queryParams)
         this.data = res.data.data || []
         this.loading = false
         this.selectionClear()
@@ -638,14 +639,14 @@ export default {
           cancelButtonText: '取消',
           type: 'warning'
         })
-        
+
         const loading = this.$loading({
           lock: true,
           text: '设置中...',
           spinner: 'el-icon-loading',
           background: 'rgba(0, 0, 0, 0.7)'
         })
-        
+
         try {
           await setDefaultAddress(row.id)
           this.$message.success('设置默认地址成功')