From 92f4a17803d9991cff089abfd017836d46fb26a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BB=A4?= <2603820757@qq.com> Date: Fri, 28 Oct 2022 17:33:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:alien:=20=E9=85=8D=E5=90=88=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E4=BF=AE=E6=94=B9=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/auth/client.ts | 24 +++++++++++++++++++ src/api/modules/auth/oauth.ts | 21 ---------------- .../client/components/client-drawer.vue | 10 ++++---- src/views/system/client/index.vue | 6 ++--- 4 files changed, 32 insertions(+), 29 deletions(-) create mode 100644 src/api/modules/auth/client.ts diff --git a/src/api/modules/auth/client.ts b/src/api/modules/auth/client.ts new file mode 100644 index 0000000..844c9a9 --- /dev/null +++ b/src/api/modules/auth/client.ts @@ -0,0 +1,24 @@ +import axios from "axios"; +import { ExampleClient } from "@/types/modules/auth"; + +const contentPath = '/auth/client' + +export function create(client: ExampleClient) { + return axios.post(`${contentPath}`, client) +} + +export function update(client: ExampleClient) { + return axios.put(`${contentPath}`, client) +} + +export function deleteById(id: string) { + return axios.delete(`${contentPath}/${id}`) +} + +export function findById(id: string) { + return axios.get(`${contentPath}/${id}`) +} + +export function findList() { + return axios.get(`${contentPath}/list`) +} diff --git a/src/api/modules/auth/oauth.ts b/src/api/modules/auth/oauth.ts index 8579d06..dce964e 100644 --- a/src/api/modules/auth/oauth.ts +++ b/src/api/modules/auth/oauth.ts @@ -3,7 +3,6 @@ import qs from "query-string"; import { grantTypes, client } from '@/config/website.json' import type { LoginData, OAuth2AccessToken, UserToken } from '@/types/modules/auth' import { Pageable, Pagination } from '@/types/global' -import { ExampleClient } from "@/types/modules/auth"; const contentPath = '/auth/oauth' @@ -40,23 +39,3 @@ export function tokenWithPagination(pageable: Pageable) { } }) } - -export function createClient(client: ExampleClient) { - return axios.post(`${contentPath}/client`, client) -} - -export function updateClient(client: ExampleClient) { - return axios.put(`${contentPath}/client`, client) -} - -export function deleteClientById(id: string) { - return axios.delete(`${contentPath}/client/${id}`) -} - -export function findClientById(id: string) { - return axios.get(`${contentPath}/client/${id}`) -} - -export function findClientList() { - return axios.get(`${contentPath}/client/list`) -} diff --git a/src/views/system/client/components/client-drawer.vue b/src/views/system/client/components/client-drawer.vue index 54d4bc3..54afc0a 100644 --- a/src/views/system/client/components/client-drawer.vue +++ b/src/views/system/client/components/client-drawer.vue @@ -82,8 +82,8 @@ import useLoading from "@/hooks/loading"; import { Operation } from "@/types/global"; import { ExampleClient } from "@/types/modules/auth"; import { ValidatedError } from "@arco-design/web-vue/es/form/interface"; -import { createClient, findClientById, updateClient } from "@/api/modules/auth/oauth"; import { Message } from "@arco-design/web-vue"; +import { create, findById, update } from "@/api/modules/auth/client"; const defaultFormData = () => ({ clientId: undefined, @@ -110,7 +110,7 @@ const createHandle = async () => { } const updateHandle = async (id: string) => { - const { data } = await findClientById(id) + const { data } = await findById(id) formData.value = { ...data } @@ -119,7 +119,7 @@ const updateHandle = async (id: string) => { } const previewHandle = async (id: string) => { - formData.value = (await findClientById(id)).data + formData.value = (await findById(id)).data openModel('预览客户端信息', true, false, Operation.PREVIEW) } @@ -138,13 +138,13 @@ const handleOk = async () => { clientDrawerForm.value?.validate(async (errors: undefined | Record) => { if (!errors) { if (dataModel.type === Operation.CREATE) { - await createClient(formData.value) + await create(formData.value) Message.success({ content: "添加成功", duration: 2000 }); } else if (dataModel.type === Operation.UPDATE) { - await updateClient(formData.value) + await update(formData.value) Message.success({ content: "修改成功", duration: 2000 diff --git a/src/views/system/client/index.vue b/src/views/system/client/index.vue index fcced1f..093df46 100644 --- a/src/views/system/client/index.vue +++ b/src/views/system/client/index.vue @@ -43,7 +43,7 @@ import { onMounted, ref } from "vue"; // eslint-disable-next-line @typescript-eslint/no-unused-vars import ClientDrawer from "@/views/system/client/components/client-drawer.vue"; import useLoading from "@/hooks/loading"; -import { deleteClientById, findClientList } from "@/api/modules/auth/oauth"; +import { deleteById, findList } from "@/api/modules/auth/client"; import { ExampleClient } from "@/types/modules/auth"; const tableColumns = [{ @@ -118,14 +118,14 @@ const { loading, setLoading } = useLoading(); const refresh = async () => { setLoading(true) - tbData.value = (await findClientList()).data + tbData.value = (await findList()).data setLoading(false) } const onDelete = async (clientId: string) => { try { setLoading(true) - await deleteClientById(clientId) + await deleteById(clientId) setLoading(false) } finally { await refresh() -- Gitee From 3d933960a023efea7f1c8eb9b24bc1fb46fa0a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BB=A4?= <2603820757@qq.com> Date: Sat, 29 Oct 2022 09:22:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:necktie:=20=E5=AD=97=E5=85=B8=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/modules/system/dict.ts | 38 +++ src/types/modules/system.ts | 32 +++ .../system/dict/components/dict-drawer.vue | 129 ++++++++++ .../dict/components/dict-item-drawer.vue | 117 +++++++++ src/views/system/dict/index.vue | 233 ++++++++++++++++++ .../system/role/components/role-drawer.vue | 4 +- 6 files changed, 550 insertions(+), 3 deletions(-) create mode 100644 src/api/modules/system/dict.ts create mode 100644 src/views/system/dict/components/dict-drawer.vue create mode 100644 src/views/system/dict/components/dict-item-drawer.vue create mode 100644 src/views/system/dict/index.vue diff --git a/src/api/modules/system/dict.ts b/src/api/modules/system/dict.ts new file mode 100644 index 0000000..2775dc6 --- /dev/null +++ b/src/api/modules/system/dict.ts @@ -0,0 +1,38 @@ +import axios from "axios"; +import { Pageable, Pagination } from '@/types/global' +import { DictDto, DictItemVo, DictQry, DictVo } from '@/types/modules/system' + +const contentPath = '/system/dict' + +export function create(dictDto: DictDto) { + return axios.post(`${contentPath}`, dictDto) +} + +export function addItem(id: number, dictItemDto: DictItemVo) { + return axios.post(`${contentPath}/${id}/item`, dictItemDto) +} + +export function update(dictDto: DictDto) { + return axios.put(`${contentPath}`, dictDto) +} + +export function deleteById(id: number) { + return axios.delete(`${contentPath}/${id}`) +} + +export function findById(id: number) { + return axios.get(`${contentPath}/${id}`) +} + +export function listWithPagination(pageable: Pageable, qry: DictQry) { + return axios.get>(`${contentPath}/pagination`, { + params: { + ...pageable, + ...qry + } + }) +} + +export function findAllItemByDictId(id: number) { + return axios.get(`${contentPath}/${id}/item`) +} diff --git a/src/types/modules/system.ts b/src/types/modules/system.ts index 7ed6dee..0e7ebdb 100644 --- a/src/types/modules/system.ts +++ b/src/types/modules/system.ts @@ -145,3 +145,35 @@ export interface DeptVo { createTime?: number updateTime?: number } + +export interface DictDto { + id: number + name: string + code: string +} + +export interface DictVo { + id: number + name: string + code: string + createTime: string + updateTime: string +} + +export interface DictQry { + name: string + code: string +} + +export interface DictItemVo { + id: number + dictId: number + name: string + value: string +} +export interface DictItemDto { + id: number + dictId: number + name: string + value: string +} diff --git a/src/views/system/dict/components/dict-drawer.vue b/src/views/system/dict/components/dict-drawer.vue new file mode 100644 index 0000000..736721a --- /dev/null +++ b/src/views/system/dict/components/dict-drawer.vue @@ -0,0 +1,129 @@ + + + + + + + diff --git a/src/views/system/dict/components/dict-item-drawer.vue b/src/views/system/dict/components/dict-item-drawer.vue new file mode 100644 index 0000000..53a548c --- /dev/null +++ b/src/views/system/dict/components/dict-item-drawer.vue @@ -0,0 +1,117 @@ + + + + + + + diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue new file mode 100644 index 0000000..34c7285 --- /dev/null +++ b/src/views/system/dict/index.vue @@ -0,0 +1,233 @@ + + + + + + + diff --git a/src/views/system/role/components/role-drawer.vue b/src/views/system/role/components/role-drawer.vue index 908b928..90e6646 100644 --- a/src/views/system/role/components/role-drawer.vue +++ b/src/views/system/role/components/role-drawer.vue @@ -47,9 +47,7 @@ import { Operation } from "@/types/global"; const defaultFormData = () => ({ id: -1, name: "", - code: "", - parentId: 0, - order: 1 + code: "" }); const formData = ref(defaultFormData()); -- Gitee