diff --git a/src/components/PageContent/index.vue b/src/components/PageContent/index.vue new file mode 100644 index 00000000..bfe6faae --- /dev/null +++ b/src/components/PageContent/index.vue @@ -0,0 +1,320 @@ + + + + + diff --git a/src/components/PageModal/index.vue b/src/components/PageModal/index.vue new file mode 100644 index 00000000..1890af16 --- /dev/null +++ b/src/components/PageModal/index.vue @@ -0,0 +1,128 @@ + + + + + diff --git a/src/components/PageSearch/index.vue b/src/components/PageSearch/index.vue new file mode 100644 index 00000000..1010f2b7 --- /dev/null +++ b/src/components/PageSearch/index.vue @@ -0,0 +1,97 @@ + + + + + diff --git a/src/router/index.ts b/src/router/index.ts index b67fdf5f..671765dd 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -54,6 +54,23 @@ export const constantRoutes: RouteRecordRaw[] = [ ], }, + { + path: "/curd", + component: Layout, + meta: { + alwaysShow: false, + }, + children: [ + { + path: "index", + component: () => import("@/views/demo/curd/index.vue"), + meta: { + title: "增删改查", + }, + }, + ], + }, + // 外部链接 // { // path: "/external-link", diff --git a/src/views/demo/curd/config/add.ts b/src/views/demo/curd/config/add.ts new file mode 100644 index 00000000..39cc1b6b --- /dev/null +++ b/src/views/demo/curd/config/add.ts @@ -0,0 +1,145 @@ +const modalConfig = { + pageName: "sys:user", + dialog: { + title: "新增用户", + width: 800, + "append-to-body": true, + }, + formAction: function (data: any) { + console.log("add", data); + return new Promise((resolve, reject) => { + resolve("新增成功"); + }); + }, + formItems: [ + { + type: "input", + label: "用户名", + prop: "username", + attrs: { + placeholder: "请输入用户名", + }, + }, + { + type: "input", + label: "用户昵称", + prop: "nickname", + attrs: { + placeholder: "请输入用户昵称", + }, + }, + { + type: "tree-select", + label: "所属部门", + prop: "deptId", + attrs: { + placeholder: "请选择所属部门", + data: [ + { + value: 1, + label: "有来技术", + children: [ + { + value: 2, + label: "研发部门", + }, + { + value: 3, + label: "测试部门", + }, + ], + }, + ], + filterable: true, + "check-strictly": true, + "render-after-expand": false, + }, + }, + { + type: "select", + label: "性别", + prop: "gender", + attrs: { + placeholder: "请选择", + }, + options: [ + { label: "男", value: 1 }, + { label: "女", value: 2 }, + { label: "未知", value: 0 }, + ], + }, + { + type: "select", + label: "角色", + prop: "roleIds", + attrs: { + placeholder: "请选择", + multiple: true, + }, + options: [ + { label: "系统管理员", value: 2 }, + { label: "系统管理员1", value: 4 }, + { label: "系统管理员2", value: 5 }, + { label: "系统管理员3", value: 6 }, + { label: "系统管理员4", value: 7 }, + { label: "系统管理员5", value: 8 }, + { label: "系统管理员6", value: 9 }, + { label: "系统管理员7", value: 10 }, + { label: "系统管理员8", value: 11 }, + { label: "访问游客", value: 3 }, + ], + }, + { + type: "input", + label: "手机号码", + prop: "mobile", + attrs: { + placeholder: "请输入手机号码", + maxlength: 11, + }, + }, + { + type: "input", + label: "邮箱", + prop: "email", + attrs: { + placeholder: "请输入邮箱", + maxlength: 50, + }, + }, + { + type: "radio", + label: "状态", + prop: "status", + options: [ + { label: "正常", value: 1 }, + { label: "禁用", value: 0 }, + ], + initialValue: 1, + }, + ], + formRules: { + username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], + nickname: [ + { required: true, message: "用户昵称不能为空", trigger: "blur" }, + ], + deptId: [{ required: true, message: "所属部门不能为空", trigger: "blur" }], + roleIds: [{ required: true, message: "用户角色不能为空", trigger: "blur" }], + email: [ + { + pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/, + message: "请输入正确的邮箱地址", + trigger: "blur", + }, + ], + mobile: [ + { + pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, + message: "请输入正确的手机号码", + trigger: "blur", + }, + ], + }, +}; + +export default modalConfig; diff --git a/src/views/demo/curd/config/content.ts b/src/views/demo/curd/config/content.ts new file mode 100644 index 00000000..8b538ec4 --- /dev/null +++ b/src/views/demo/curd/config/content.ts @@ -0,0 +1,95 @@ +const contentConfig = { + pageName: "sys:user", + indexAction: function (data: any) { + console.log("index", data); + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve({ + total: 2, + list: [ + { + id: 2, + username: "admin", + nickname: "系统管理员", + mobile: "17621210366", + genderLabel: "男", + avatar: + "https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif", + email: null, + status: 1, + deptName: "有来技术", + roleNames: "系统管理员", + createTime: "2019-10-10", + }, + { + id: 3, + username: "test", + nickname: "测试小用户", + mobile: "17621210366", + genderLabel: "男", + avatar: + "https://oss.youlai.tech/youlai-boot/2023/05/16/811270ef31f548af9cffc026dfc3777b.gif", + email: null, + status: 1, + deptName: "测试部门", + roleNames: "访问游客", + createTime: "2021-06-05", + }, + ], + }); + }, 800); + }); + }, + deleteAction: function (id: string) { + console.log("delete", id); + return new Promise((resolve, reject) => { + resolve("删除成功"); + }); + }, + pk: "id", + toolbar: [ + "refresh", + "add", + "delete", + "export", + { + name: "upload", + icon: "upload", + text: "导入", + }, + ], + cols: [ + { type: "selection", width: 50, align: "center" }, + { label: "编号", align: "center", prop: "id", width: 100 }, + { label: "用户名", align: "center", prop: "username" }, + { label: "用户昵称", align: "center", prop: "nickname", width: 120 }, + { label: "性别", align: "center", prop: "genderLabel", width: 100 }, + { label: "部门", align: "center", prop: "deptName", width: 120 }, + { label: "手机号码", align: "center", prop: "mobile", width: 120 }, + { + label: "状态", + align: "center", + prop: "status", + templet: "custom", + }, + { label: "创建时间", align: "center", prop: "createTime", width: 180 }, + { + label: "操作", + fixed: "right", + width: 220, + templet: "tool", + operat: [ + { + name: "reset_pwd", + auth: "reset_pwd", + icon: "refresh-left", + text: "重置密码", + }, + "edit", + "delete", + ], + }, + ], +}; + +export default contentConfig; diff --git a/src/views/demo/curd/config/edit.ts b/src/views/demo/curd/config/edit.ts new file mode 100644 index 00000000..2463d0d4 --- /dev/null +++ b/src/views/demo/curd/config/edit.ts @@ -0,0 +1,146 @@ +const modalConfig = { + pageName: "sys:user", + dialog: { + title: "修改用户", + width: 800, + "append-to-body": true, + }, + formAction: function (data: any) { + console.log("edit", data); + return new Promise((resolve, reject) => { + resolve("编辑成功"); + }); + }, + formItems: [ + { + type: "input", + label: "用户名", + prop: "username", + attrs: { + placeholder: "请输入用户名", + readonly: true, + }, + }, + { + type: "input", + label: "用户昵称", + prop: "nickname", + attrs: { + placeholder: "请输入用户昵称", + }, + }, + { + type: "tree-select", + label: "所属部门", + prop: "deptId", + attrs: { + placeholder: "请选择所属部门", + data: [ + { + value: 1, + label: "有来技术", + children: [ + { + value: 2, + label: "研发部门", + }, + { + value: 3, + label: "测试部门", + }, + ], + }, + ], + filterable: true, + "check-strictly": true, + "render-after-expand": false, + }, + }, + { + type: "select", + label: "性别", + prop: "gender", + attrs: { + placeholder: "请选择", + }, + options: [ + { label: "男", value: 1 }, + { label: "女", value: 2 }, + { label: "未知", value: 0 }, + ], + }, + { + type: "select", + label: "角色", + prop: "roleIds", + attrs: { + placeholder: "请选择", + multiple: true, + }, + options: [ + { label: "系统管理员", value: 2 }, + { label: "系统管理员1", value: 4 }, + { label: "系统管理员2", value: 5 }, + { label: "系统管理员3", value: 6 }, + { label: "系统管理员4", value: 7 }, + { label: "系统管理员5", value: 8 }, + { label: "系统管理员6", value: 9 }, + { label: "系统管理员7", value: 10 }, + { label: "系统管理员8", value: 11 }, + { label: "访问游客", value: 3 }, + ], + }, + { + type: "input", + label: "手机号码", + prop: "mobile", + attrs: { + placeholder: "请输入手机号码", + maxlength: 11, + }, + }, + { + type: "input", + label: "邮箱", + prop: "email", + attrs: { + placeholder: "请输入邮箱", + maxlength: 50, + }, + }, + { + type: "radio", + label: "状态", + prop: "status", + options: [ + { label: "正常", value: 1 }, + { label: "禁用", value: 0 }, + ], + initialValue: 1, + }, + ], + formRules: { + username: [{ required: true, message: "用户名不能为空", trigger: "blur" }], + nickname: [ + { required: true, message: "用户昵称不能为空", trigger: "blur" }, + ], + deptId: [{ required: true, message: "所属部门不能为空", trigger: "blur" }], + roleIds: [{ required: true, message: "用户角色不能为空", trigger: "blur" }], + email: [ + { + pattern: /\w[-\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\.)+[A-Za-z]{2,14}/, + message: "请输入正确的邮箱地址", + trigger: "blur", + }, + ], + mobile: [ + { + pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, + message: "请输入正确的手机号码", + trigger: "blur", + }, + ], + }, +}; + +export default modalConfig; diff --git a/src/views/demo/curd/config/search.ts b/src/views/demo/curd/config/search.ts new file mode 100644 index 00000000..fa6600e6 --- /dev/null +++ b/src/views/demo/curd/config/search.ts @@ -0,0 +1,50 @@ +const searchConfig = { + pageName: "sys:user", + formItems: [ + { + type: "input", + label: "关键字", + prop: "keywords", + attrs: { + placeholder: "用户名/昵称/手机号", + clearable: true, + style: { + width: "200px", + }, + }, + }, + { + type: "select", + label: "状态", + prop: "status", + attrs: { + placeholder: "全部", + clearable: true, + style: { + width: "100px", + }, + }, + options: [ + { label: "启用", value: 1 }, + { label: "禁用", value: 0 }, + ], + }, + { + type: "date-picker", + label: "创建时间", + prop: "createAt", + attrs: { + type: "daterange", + "range-separator": "~", + "start-placeholder": "开始时间", + "end-placeholder": "截止时间", + "value-format": "YYYY-MM-DD", + style: { + width: "240px", + }, + }, + }, + ], +}; + +export default searchConfig; diff --git a/src/views/demo/curd/index.vue b/src/views/demo/curd/index.vue new file mode 100644 index 00000000..f1a84d59 --- /dev/null +++ b/src/views/demo/curd/index.vue @@ -0,0 +1,107 @@ + + +