Browse Source

DIIA网站制作完成

master
gxwebsoft 1 year ago
parent
commit
a0101012d4
  1. 1
      src/api/cms/design/model/index.ts
  2. 85
      src/api/tennat/index.ts
  3. 32
      src/api/tennat/model/index.ts
  4. 4
      src/store/modules/tenant.ts
  5. 8
      src/utils/request.ts
  6. 24
      src/views/about/components/detail.vue

1
src/api/cms/design/model/index.ts

@ -41,5 +41,6 @@ export interface DesignParam extends PageParam {
pageId?: string; pageId?: string;
name?: number; name?: number;
type?: number; type?: number;
path?: string;
userId?: number; userId?: number;
} }

85
src/api/tennat/index.ts

@ -0,0 +1,85 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { Tenant, TenantParam } from './model/index';
/**
*
*/
export async function pageTenant(params: TenantParam) {
const res = await request.get<ApiResult<PageResult<Tenant>>>('/tenant/page', {
params
});
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function listTenant(params?: TenantParam) {
const res = await request.get<ApiResult<Tenant[]>>('/tenant', {
params
});
if (res.data.code === 0 && res.data.data) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function addTenant(data: Tenant) {
const res = await request.post<ApiResult<unknown>>('/tenant', data);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function updateTenant(data: Tenant) {
const res = await request.put<ApiResult<unknown>>('/tenant', data);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
*
*/
export async function updateTenantPassword(
tenantId?: number,
password = 'gxwebsoft.com'
) {
const res = await request.put<ApiResult<unknown>>('/tenant/password', {
tenantId,
password
});
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}
/**
* IP是否存在
*/
export async function checkExistence(
field: string,
value: string,
id?: number
) {
const res = await request.get<ApiResult<unknown>>('/tenant/existence', {
params: { field, value, id }
});
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}

32
src/api/tennat/model/index.ts

@ -0,0 +1,32 @@
import type { PageParam } from '@/api';
import { Company } from "@/api/system/company/model";
/**
*
*/
export interface Tenant {
// 租户id
tenantId?: number;
// 租户名称
tenantName?: string;
// 客户ID
customerId?: string;
// 备注
comments?: string;
// 创建时间
createTime?: string;
// 状态
status?: string;
// 企业信息
company?: Company;
// 配置信息
config?: any;
}
/**
*
*/
export interface TenantParam extends PageParam {
tenantName?: string;
customerId?: number;
}

4
src/store/modules/tenant.ts

@ -57,10 +57,6 @@ export const useTenantStore = defineStore({
if(d.type == 0){ if(d.type == 0){
d.path = `/article/${d.categoryId}` d.path = `/article/${d.categoryId}`
} }
// 页面
if(d.type == 1){
d.path = `/page/${d.pageId}`
}
// 链接 // 链接
if(d.type == 2){ if(d.type == 2){
d.path = `${d.path}` d.path = `${d.path}`

8
src/utils/request.ts

@ -15,7 +15,7 @@ import {
import { getToken, setToken } from './token-util'; import { getToken, setToken } from './token-util';
import { logout } from './page-tab-util'; import { logout } from './page-tab-util';
import type { ApiResult } from '@/api'; import type { ApiResult } from '@/api';
import {getTenantId} from "@/utils/domain";
// import {getTenantId} from "@/utils/domain";
const service = axios.create({ const service = axios.create({
baseURL: API_BASE_URL baseURL: API_BASE_URL
@ -35,9 +35,9 @@ service.interceptors.request.use(
if(config.headers){ if(config.headers){
config.headers.common['TenantId'] = TENANT_ID; config.headers.common['TenantId'] = TENANT_ID;
// 解析二级域名获取租户ID // 解析二级域名获取租户ID
if(getTenantId() != null && getTenantId() != '0'){
config.headers.common['TenantId'] = getTenantId();
}
// if(getTenantId() != null && getTenantId() != '0'){
// config.headers.common['TenantId'] = getTenantId();
// }
} }
return config; return config;
}, },

24
src/views/about/components/detail.vue

@ -21,7 +21,7 @@
import {toDateString} from "ele-admin-pro"; import {toDateString} from "ele-admin-pro";
import {ref, unref, watch} from "vue"; import {ref, unref, watch} from "vue";
import {Design} from "@/api/cms/design/model"; import {Design} from "@/api/cms/design/model";
import {getDesign} from "@/api/cms/design";
import {getDesign, listDesign} from "@/api/cms/design";
import {useThemeStore} from "@/store/modules/theme"; import {useThemeStore} from "@/store/modules/theme";
import {storeToRefs} from "pinia"; import {storeToRefs} from "pinia";
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
@ -36,6 +36,7 @@ const list = ref<Design[]>([]);
const activeKey = ref('1'); const activeKey = ref('1');
const newsBg3 = ref(''); const newsBg3 = ref('');
const pageId = ref<number>(0); const pageId = ref<number>(0);
const pagePath = ref<string>();
const currentPage = ref(1); const currentPage = ref(1);
const total = ref(); const total = ref();
@ -49,23 +50,24 @@ const { form,assignFields } = useFormData<Design>({
}); });
const reload = () => { const reload = () => {
getDesign(pageId.value).then(data => {
assignFields(data)
listDesign({path: pagePath.value}).then(data => {
if(data.length){
assignFields((data[0]));
}
}) })
// getDesign(pageId.value).then(data => {
// assignFields(data)
// })
} }
watch( watch(
currentRoute, currentRoute,
(route) => { (route) => {
const { redirectedFrom } = unref(route);
if(redirectedFrom){
const { params } = redirectedFrom;
const { id } = params;
if (id) {
pageId.value = Number(id);
}
const { path } = unref(route);
if(path){
pagePath.value = path;
reload();
} }
reload();
}, },
{ immediate: true } { immediate: true }
); );

Loading…
Cancel
Save