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 */ 15import { defHttp } from '/@/utils/http/axios'; 16import { Modal } from 'ant-design-vue'; 17 18enum Api { 19 LIST = '/sample/business/list', 20 SAVE = '/sample/business/add', 21 EDIT = '/sample/business/edit', 22 DELETE = '/sample/business/delete', 23 DELETE_BATCH = '/sample/business/deleteBatch', 24 LIST_COMMENT = '/sample/businessComment/list', 25} 26 27/** 28 * 列表接口 29 */ 30export const list = (params): Promise<string> => defHttp.get({ url: Api.LIST, params }); 31 32/** 33 * 评论列表接口 34 */ 35export const listComment = (params): Promise<string> => defHttp.get({ url: Api.LIST_COMMENT, params }); 36 37/** 38 * 删除 39 */ 40export const deleteBusiness = (params, handleSuccess): Promise<void> => { 41 return defHttp.delete({ url: Api.DELETE, params }, { joinParamsToUrl: true }).then(() => { 42 handleSuccess(); 43 }); 44}; 45 46/** 47 * 批量删除 48 */ 49export const batchDeleteBusiness = (params, handleSuccess): void => { 50 Modal.confirm({ 51 title: '确认删除', 52 content: '是否删除选中数据', 53 okText: '确认', 54 cancelText: '取消', 55 onOk: () => { 56 return defHttp.delete({ url: Api.DELETE_BATCH, data: params }, { joinParamsToUrl: true }).then(() => { 57 handleSuccess(); 58 }); 59 }, 60 }); 61}; 62 63/** 64 * 保存或者更新 65 */ 66export const saveOrUpdate = (params, isUpdate): Promise<string> => { 67 const url = isUpdate ? Api.EDIT : Api.SAVE; 68 return defHttp.post({ url: url, params }); 69}; 70