From 42491947c4952fd13e41d76bd04c0381bced3404 Mon Sep 17 00:00:00 2001 From: H0nGzA1 <2505811377@qq.com> Date: Mon, 6 Feb 2023 15:45:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=AE=8C=E6=88=90=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=9F=BA=E7=A1=80=E5=8A=9F=E8=83=BD):=20?= =?UTF-8?q?=E2=9C=A8=20=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=80=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F=20large=20->=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/stores/themeConfig.ts | 2 +- web/src/views/system/dept/api.ts | 41 ++++ .../views/system/dept/component/addDept.vue | 173 -------------- .../views/system/dept/component/editDept.vue | 179 -------------- web/src/views/system/dept/crud.tsx | 223 ++++++++++++++++++ web/src/views/system/dept/index.vue | 177 ++------------ 6 files changed, 285 insertions(+), 510 deletions(-) create mode 100644 web/src/views/system/dept/api.ts delete mode 100644 web/src/views/system/dept/component/addDept.vue delete mode 100644 web/src/views/system/dept/component/editDept.vue create mode 100644 web/src/views/system/dept/crud.tsx diff --git a/web/src/stores/themeConfig.ts b/web/src/stores/themeConfig.ts index f2663b5..02b0269 100644 --- a/web/src/stores/themeConfig.ts +++ b/web/src/stores/themeConfig.ts @@ -135,7 +135,7 @@ export const useThemeConfig = defineStore('themeConfig', { // 默认初始语言,可选值"",默认 zh-cn globalI18n: 'zh-cn', // 默认全局组件大小,可选值"",默认 'large' - globalComponentSize: 'large', + globalComponentSize: 'default', }, }), actions: { diff --git a/web/src/views/system/dept/api.ts b/web/src/views/system/dept/api.ts new file mode 100644 index 0000000..199acee --- /dev/null +++ b/web/src/views/system/dept/api.ts @@ -0,0 +1,41 @@ +import { request } from '/@/utils/service'; +import { PageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud'; + +export const apiPrefix = '/api/system/dept/'; +export function GetList(query: PageQuery) { + return request({ + url: apiPrefix, + method: 'get', + data: query, + }); +} +export function GetObj(id: InfoReq) { + return request({ + url: apiPrefix + id, + method: 'get', + }); +} + +export function AddObj(obj: AddReq) { + return request({ + url: apiPrefix, + method: 'post', + data: obj, + }); +} + +export function UpdateObj(obj: EditReq) { + return request({ + url: apiPrefix + obj.id + '/', + method: 'put', + data: obj, + }); +} + +export function DelObj(id: DelReq) { + return request({ + url: apiPrefix + id + '/', + method: 'delete', + data: { id }, + }); +} diff --git a/web/src/views/system/dept/component/addDept.vue b/web/src/views/system/dept/component/addDept.vue deleted file mode 100644 index e4063e4..0000000 --- a/web/src/views/system/dept/component/addDept.vue +++ /dev/null @@ -1,173 +0,0 @@ - - - diff --git a/web/src/views/system/dept/component/editDept.vue b/web/src/views/system/dept/component/editDept.vue deleted file mode 100644 index 7b16f44..0000000 --- a/web/src/views/system/dept/component/editDept.vue +++ /dev/null @@ -1,179 +0,0 @@ - - - diff --git a/web/src/views/system/dept/crud.tsx b/web/src/views/system/dept/crud.tsx new file mode 100644 index 0000000..f83e768 --- /dev/null +++ b/web/src/views/system/dept/crud.tsx @@ -0,0 +1,223 @@ +import * as api from "./api"; +import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, } from "@fast-crud/fast-crud"; +import { request } from "/@/utils/service"; +import { dictionary } from "/@/utils/dictionary"; +interface CreateCrudOptionsTypes { + crudOptions: CrudOptions; +} + +export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes { + const pageRequest = async (query: PageQuery) => { + return await api.GetList(query); + }; + const editRequest = async ({ form, row }: EditReq) => { + form.id = row.id; + return await api.UpdateObj(form); + }; + const delRequest = async ({ row }: DelReq) => { + return await api.DelObj(row.id); + }; + const addRequest = async ({ form }: AddReq) => { + return await api.AddObj(form); + }; + return { + crudOptions: { + request: { + pageRequest, + addRequest, + editRequest, + delRequest + }, + columns: { + _index: { + title: '序号', + form: { show: false }, + column: { + //type: 'index', + align: 'center', + width: '70px', + columnSetDisabled: true, //禁止在列设置中选择 + formatter: (context) => { + //计算序号,你可以自定义计算规则,此处为翻页累加 + let index = context.index ?? 1; + let pagination = crudExpose.crudBinding.value.pagination; + return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1; + }, + }, + }, + search: { + title: '关键词', + column: { + show: false + }, + search: { + show: true, + component: { + props: { + clearable: true + }, + placeholder: '请输入关键词' + } + }, + form: { + show: false, + component: { + props: { + clearable: true + } + } + }, + }, + parent: { + column: { + show: false + }, + title: '上级部门', + type: 'dict-tree', + dict: dict({ + url: '/api/system/dept/all_dept/', + value: 'id', + label: 'name', + isTree: true, + getData: async ({ url }: { url: string }) => { + return request({ + url: url, + }).then((ret: any) => { + return ret.data + }) + } + }), + form: { + helper: '默认留空为创建者的部门', + component: { + span: 12, + props: { + props: { + value: "id", + label: "name", + } + } + } + } + }, + name: { + title: '部门名称', + sortable: true, + treeNode: true, // 设置为树形列 + search: { + disabled: false, + component: { + props: { + clearable: true + } + } + }, + width: 180, + type: 'input', + form: { + rules: [ + // 表单校验规则 + { required: true, message: '部门名称必填项' } + ], + component: { + span: 12, + props: { + clearable: true + }, + placeholder: '请输入部门名称' + }, + } + }, + key: { + title: '部门标识', + sortable: true, + form: { + component: { + props: { + clearable: true + }, + placeholder: '请输入标识字符' + }, + } + }, + owner: { + title: '负责人', + sortable: true, + form: { + component: { + span: 12, + props: { + clearable: true + }, + placeholder: '请输入负责人' + } + } + }, + phone: { + title: '联系电话', + sortable: true, + form: { + component: { + span: 12, + props: { + clearable: true + }, + placeholder: '请输入联系电话' + } + } + }, + email: { + title: '邮箱', + sortable: true, + form: { + component: { + span: 12, + props: { + clearable: true + }, + placeholder: '请输入邮箱' + }, + rules: [ + { + type: 'email', + message: '请输入正确的邮箱地址', + trigger: ['blur', 'change'] + } + ] + } + }, + sort: { + title: '排序', + sortable: true, + width: 80, + type: 'number', + form: { + value: 1, + component: { + span: 12, + placeholder: '请选择序号' + } + } + }, + status: { + title: '状态', + sortable: true, + search: { + disabled: false + }, + type: 'dict-radio', + dict: dict({ + data: dictionary('button_status_bool') + }), + form: { + value: true, + component: { + span: 12, + placeholder: '请选择状态' + } + } + } + } + }, + } +} diff --git a/web/src/views/system/dept/index.vue b/web/src/views/system/dept/index.vue index 97dae42..1fa8634 100644 --- a/web/src/views/system/dept/index.vue +++ b/web/src/views/system/dept/index.vue @@ -1,163 +1,26 @@ -