1/* 2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { defHttp } from '/@/utils/http/axios'; 17import { Modal } from 'ant-design-vue'; 18 19enum Api { 20 LIST = '/sample/businessGoods/list', 21 DETAIL = '/sample/businessGoods/detail', 22 DETAIL_BUSINESS = '/sample/business/detail', 23 SAVE = '/sample/businessGoods/add', 24 EDIT = '/sample/businessGoods/edit', 25 DELETE = '/sample/businessGoods/delete', 26 DELETE_BATCH = '/sample/businessGoods/deleteBatch', 27} 28 29/** 30 * 列表接口 31 */ 32export const listGoods = (params): Promise<string> => defHttp.get({ url: Api.LIST, params }); 33 34/** 35 * 详情接口 36 */ 37export const detail = (params): Promise<string> => defHttp.get({ url: Api.DETAIL, params }); 38 39/** 40 * 商家详情接口 41 */ 42export const detailBusiness = (params): Promise<string> => defHttp.get({ url: Api.DETAIL_BUSINESS, params }); 43 44/** 45 * 删除 46 */ 47export const deleteGoods = (params, handleSuccess): Promise<void> => { 48 return defHttp.delete({ url: Api.DELETE, params }, { joinParamsToUrl: true }).then(() => { 49 handleSuccess(); 50 }); 51}; 52 53/** 54 * 批量删除 55 */ 56export const batchDeleteGoods = (params, handleSuccess): void => { 57 Modal.confirm({ 58 title: '确认删除', 59 content: '是否删除选中数据', 60 okText: '确认', 61 cancelText: '取消', 62 onOk: () => { 63 return defHttp.delete({ url: Api.DELETE_BATCH, data: params }, { joinParamsToUrl: true }).then(() => { 64 handleSuccess(); 65 }); 66 }, 67 }); 68}; 69 70/** 71 * 保存或者更新 72 */ 73export const saveOrUpdateGoods = (params, isUpdate): Promise<string> => { 74 const url = isUpdate ? Api.EDIT : Api.SAVE; 75 return defHttp.post({ url: url, params }); 76}; 77