- 更新 API 请求方式,使用正确的 request-legacy 导入 - 在优惠券页面添加详细的调试日志,帮助排查显示问题 - 修复 Tabs 组件的类型错误,确保类型安全- 优化页面渲染逻辑,增加可视化调试信息 - 更新文档,提供详细的调试步骤和常见问题分析
163 lines
3.6 KiB
TypeScript
163 lines
3.6 KiB
TypeScript
import request from '@/utils/request-legacy';
|
|
import type { ApiResult } from '@/api/index';
|
|
import type { Company, CompanyParam } from './model';
|
|
import { PageResult } from '@/api/index';
|
|
import {SERVER_API_URL} from "@/utils/server";
|
|
|
|
/**
|
|
* 查询企业资料
|
|
*/
|
|
export async function getCompany(params?: CompanyParam) {
|
|
const res = await request.get<ApiResult<Company>>(
|
|
SERVER_API_URL + '/system/company/profile',
|
|
{
|
|
params
|
|
}
|
|
);
|
|
if (res.code === 0 && res.data) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 查询企业资料不限租户
|
|
*/
|
|
export async function getCompanyAll(companyId: number) {
|
|
const res = await request.get<ApiResult<Company>>(
|
|
SERVER_API_URL + '/system/company/profileAll/' + companyId
|
|
);
|
|
if (res.code === 0 && res.data) {
|
|
console.log(res.data);
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 查询Company列表
|
|
*/
|
|
export async function pageCompany(params: CompanyParam) {
|
|
const res = await request.get<ApiResult<PageResult<Company>>>(
|
|
SERVER_API_URL + '/system/company/page',
|
|
{ params }
|
|
);
|
|
if (res.code === 0) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 查询Company列表不限租户
|
|
*/
|
|
export async function pageCompanyAll(params: CompanyParam) {
|
|
const res = await request.get<ApiResult<PageResult<Company>>>(
|
|
SERVER_API_URL + '/system/company/pageAll',
|
|
{ params }
|
|
);
|
|
if (res.code === 0) {
|
|
return res.data;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 添加Company
|
|
*/
|
|
export async function addCompany(data: Company) {
|
|
const res = await request.post<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company',
|
|
data
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 修改Company
|
|
*/
|
|
export async function updateCompany(data: Company) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company',
|
|
data
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 修改CompanyAll
|
|
*/
|
|
export async function updateCompanyAll(data: Company) {
|
|
const res = await request.put<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company/updateCompanyAll',
|
|
data
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 删除Company
|
|
*/
|
|
export async function removeCompany(id?: number) {
|
|
const res = await request.del<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company/' + id
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
// 销毁租户
|
|
export async function destructionTenant(id?: number) {
|
|
const res = await request.del<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company/destruction/' + id
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
/**
|
|
* 批量删除Company
|
|
*/
|
|
export async function removeBatchCompany(data: (number | undefined)[]) {
|
|
const res = await request.del<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company/batch',
|
|
{
|
|
data
|
|
}
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|
|
|
|
export async function checkExistence(
|
|
field: string,
|
|
value: string,
|
|
id?: number
|
|
) {
|
|
const res = await request.get<ApiResult<unknown>>(
|
|
SERVER_API_URL + '/system/company/existence',
|
|
{
|
|
params: { field, value, id }
|
|
}
|
|
);
|
|
if (res.code === 0) {
|
|
return res.message;
|
|
}
|
|
return Promise.reject(new Error(res.message));
|
|
}
|