添加用户模块

This commit is contained in:
icssoa 2023-04-17 02:25:38 +08:00
parent c623674b9b
commit 105f2b5f58
5 changed files with 535 additions and 1111 deletions

1159
build/cool/temp/eps.d.ts vendored

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
[["/admin/base/comm","",[["/personUpdate","post"],["/uploadMode","get"],["/permmenu","get"],["/person","get"],["/upload","post"],["/logout","post"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/open","",[["/refreshToken","get"],["/captcha","get"],["/login","post"],["/html","get"],["/eps","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/department","BaseSysDepartmentEntity",[["/delete","post"],["/update","post"],["/order","post"],["/list","post"],["/add","post"],["/page"],["/info"]]],["/admin/base/sys/log","BaseSysLogEntity",[["/setKeep","post"],["/getKeep","get"],["/clear","post"],["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/menu","BaseSysMenuEntity",[["/create","post"],["/delete","post"],["/update","post"],["/parse","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/param","BaseSysParamEntity",[["/delete","post"],["/update","post"],["/html","get"],["/info","get"],["/page","post"],["/add","post"],["/list"]]],["/admin/base/sys/role","BaseSysRoleEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/user","BaseSysUserEntity",[["/delete","post"],["/update","post"],["/move","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/db","CloudDBEntity",[["/initEntity","post"],["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/info","CloudFuncInfoEntity",[["/invoke","post"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/log","CloudFuncLogEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/demo/goods","DemoGoodsEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/info","DictInfoEntity",[["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/type","DictTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/device","IotDeviceEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/message","IotMessageEntity",[["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/iot/mqtt","",[["/publish","post"],["/config","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/recycle/data","RecycleDataEntity",[["/restore","post"],["/info","get"],["/page","post"],["/list"],["/update"],["/delete"],["/add"]]],["/admin/space/info","SpaceInfoEntity",[["/getConfig","get"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/space/type","SpaceTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/task/info","TaskInfoEntity",[["/delete","post"],["/update","post"],["/start","post"],["/once","post"],["/stop","post"],["/info","get"],["/page","post"],["/log","get"],["/add","post"],["/list"]]],["/admin/user/address","UserAddressEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/chat/message","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/chat/session","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/test","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]]]
[["/admin/ai/limit","AiLimitEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/ai/order","AiOrderEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/ai/vip","AiVipEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/comm","",[["/personUpdate","post"],["/uploadMode","get"],["/permmenu","get"],["/person","get"],["/upload","post"],["/logout","post"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/open","",[["/refreshToken","get"],["/captcha","get"],["/login","post"],["/html","get"],["/eps","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/department","BaseSysDepartmentEntity",[["/delete","post"],["/update","post"],["/order","post"],["/list","post"],["/add","post"],["/page"],["/info"]]],["/admin/base/sys/log","BaseSysLogEntity",[["/setKeep","post"],["/getKeep","get"],["/clear","post"],["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/base/sys/menu","BaseSysMenuEntity",[["/create","post"],["/delete","post"],["/update","post"],["/parse","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/param","BaseSysParamEntity",[["/delete","post"],["/update","post"],["/html","get"],["/info","get"],["/page","post"],["/add","post"],["/list"]]],["/admin/base/sys/role","BaseSysRoleEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/base/sys/user","BaseSysUserEntity",[["/delete","post"],["/update","post"],["/move","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/db","CloudDBEntity",[["/initEntity","post"],["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/info","CloudFuncInfoEntity",[["/invoke","post"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/cloud/func/log","CloudFuncLogEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/demo/goods","DemoGoodsEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/info","DictInfoEntity",[["/delete","post"],["/update","post"],["/data","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/dict/type","DictTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/device","IotDeviceEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/iot/message","IotMessageEntity",[["/page","post"],["/list"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/iot/mqtt","",[["/publish","post"],["/config","get"],["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/admin/recycle/data","RecycleDataEntity",[["/restore","post"],["/info","get"],["/page","post"],["/list"],["/update"],["/delete"],["/add"]]],["/admin/space/info","SpaceInfoEntity",[["/getConfig","get"],["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/space/type","SpaceTypeEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/admin/task/info","TaskInfoEntity",[["/delete","post"],["/update","post"],["/start","post"],["/once","post"],["/stop","post"],["/info","get"],["/page","post"],["/log","get"],["/add","post"],["/list"]]],["/admin/user/info","UserInfoEntity",[["/delete","post"],["/update","post"],["/info","get"],["/list","post"],["/page","post"],["/add","post"]]],["/chat/message","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/chat/session","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]],["/test","",[["/list"],["/page"],["/info"],["/update"],["/delete"],["/add"]]]]

View File

@ -1,6 +1,6 @@
{
"name": "front-next",
"version": "6.1.0",
"version": "6.2.0",
"scripts": {
"dev": "vite --host",
"build": "vite build",

View File

@ -1,276 +0,0 @@
<template>
<cl-crud ref="Crud">
<cl-row>
<!-- 刷新按钮 -->
<cl-refresh-btn />
<!-- 新增按钮 -->
<cl-add-btn />
<!-- 删除按钮 -->
<cl-multi-delete-btn />
<cl-query field="loginType" :list="[
{ label: '小程序', value: 0 },
{ label: '公众号', value: 1 },
{ label: 'H5', value: 2 },
{ label: 'App', value: 3 }
]" />
<cl-flex1 />
<!-- 关键字搜索 -->
<cl-search-key />
</cl-row>
<cl-row>
<!-- 数据表格 -->
<cl-table ref="Table">
<template #column-avatarUrl="{ scope }">
<cl-avatar class="cover" :src="scope.row.avatarUrl" :style="{ margin: 'auto' }" />
</template>
<template #column-status="{ scope }">
<el-switch v-model="scope.row._status" active-color=" #ff4949" inactive-color=" #13ce66"
@change="onStatusChange($event, scope.row)" />
</template>
<template #column-labels="{ scope }">
<el-tag v-for="(item, index) in scope.row.labels" :key="index" size="small" style="margin: 5px 5px 0 0"
disable-transitions>
{{ item }}</el-tag>
</template>
<template #slot-up-labels="{ scope }">
<el-button type="text" size="small" @click="updateLabels(scope.row)">编辑标签</el-button>
</template>
</cl-table>
</cl-row>
<cl-row>
<cl-flex1 />
<!-- 分页控件 -->
<cl-pagination />
</cl-row>
<!-- 新增编辑 -->
<!-- <cl-upsert ref="Upsert" /> -->
<cl-form ref="Form" />
</cl-crud>
</template>
<script lang="ts" name="user-info" setup>
import { useCrud, useTable, useForm } from "@cool-vue/crud";
import { useCool } from "/@/cool";
import { ElMessage } from "element-plus";
const { service } = useCool();
// cl-form
const Form = useForm();
// cl-table
const Table = useTable({
contextMenu: ["refresh", "delete"],
columns: [
{
type: "selection",
width: 60
},
{
label: "昵称",
prop: "nickName",
align: "center",
minWidth: 150
},
{
label: "头像",
prop: "avatarUrl",
align: "center",
minWidth: 100
},
{
label: "手机",
prop: "phone",
align: "center",
minWidth: 120
},
{
label: "标签",
prop: "labels",
align: "center",
minWidth: 120
},
{
label: "性别",
prop: "sex",
align: "center",
dict: [
{
label: "未知",
value: 0
},
{
label: "男",
value: 1
},
{
label: "女",
value: 2
}
],
minWidth: 100
},
{
label: "状态",
prop: "status",
align: "center",
minWidth: 100,
dict: [
{
label: "启用",
value: 1,
type: "success"
},
{
label: "禁用",
value: 0,
type: "danger"
}
]
},
{
label: "来源",
prop: "loginType",
dict: [
{
label: "小程序",
value: 0,
type: "danger"
},
{
label: "公众号",
value: 1,
type: "success"
},
{
label: "小程序",
value: 2,
type: "primary"
},
{
label: "App",
value: 3,
type: "warning"
}
]
},
{
label: "创建时间",
prop: "createTime",
align: "center",
sortable: "custom",
minWidth: 150
},
{
label: "更新时间",
prop: "updateTime",
align: "center",
minWidth: 150
},
{
label: "操作",
type: "op",
buttons: ["slot-up-labels", "delete"]
}
]
});
//
function onStatusChange(val: string | number | boolean, item: any) {
item.status = val ? 0 : 1;
service.user.info
.update({ id: item.id, status: item.status })
.then(() => {
ElMessage.success(val ? "禁用成功" : "启用成功");
})
.catch((err: string) => {
ElMessage.error(err);
});
}
function updateLabels(row: any) {
Form.value?.open({
items: [
{
label: "标签",
prop: "labels",
hook: {
bind: ["split"],
submit: ["join"]
},
component: {
name: "el-select",
props: {
multiple: true,
filterable: true,
allowCreate: true
},
options: [
{
value: "优质用户",
label: "优质用户"
},
{
value: "普通用户",
label: "普通用户"
},
{
value: "劣质用户",
label: "劣质用户"
}
]
}
}
],
on: {
open(data) {
data.labels = row.labels;
},
submit: (data: any, { close, done }: any) => {
service.user.info
.update({
id: row.id,
labels: data.labels
})
.then(() => {
ElMessage.success("编辑成功");
Crud.value?.refresh();
close();
})
.catch((err: any) => {
ElMessage.error(err);
done();
});
}
}
});
}
// cl-crud
const Crud = useCrud(
{
service: service.user.info,
async onRefresh(params, { next, done, render }) {
const { list } = await next(params);
render(
list.map((e: any) => {
e._status = e.status == 0 ? true : false;
e.labels = (e.labels || "").split(",").filter(Boolean);
return e;
})
);
}
},
(app) => {
app.refresh();
}
);
</script>

View File

@ -0,0 +1,207 @@
<template>
<cl-crud ref="Crud">
<cl-row>
<!-- 刷新按钮 -->
<cl-refresh-btn />
<!-- 删除按钮 -->
<cl-multi-delete-btn />
<!-- 登录方式 -->
<cl-filter label="登录方式">
<cl-select :options="options.loginType" prop="loginType" style="width: 120px" />
</cl-filter>
<!-- 性别 -->
<cl-filter label="性别">
<cl-select :options="options.gender" prop="gender" style="width: 120px" />
</cl-filter>
<cl-flex1 />
<!-- 关键字搜索 -->
<cl-search-key placeholder="请输入昵称、手机号" />
</cl-row>
<cl-row>
<!-- 数据表格 -->
<cl-table ref="Table" />
</cl-row>
<cl-row>
<cl-flex1 />
<!-- 分页控件 -->
<cl-pagination />
</cl-row>
<!-- 新增编辑 -->
<cl-upsert ref="Upsert" />
</cl-crud>
</template>
<script lang="ts" name="user-list" setup>
import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
import { useCool } from "/@/cool";
import { reactive } from "vue";
const { service } = useCool();
//
const options = reactive({
loginType: [
{
label: "小程序",
value: 0,
type: "danger"
},
{
label: "公众号",
value: 1,
type: "success"
},
{
label: "H5",
value: 2
}
],
gender: [
{
label: "未知",
value: 0,
type: "info"
},
{
label: "男",
value: 1,
type: "success"
},
{
label: "女",
value: 2,
type: "danger"
}
],
status: [
{
label: "启用",
value: 1
},
{
label: "禁用",
value: 0
}
]
});
// cl-table
const Table = useTable({
columns: [
{
type: "selection",
width: 60
},
{
label: "昵称",
prop: "nickName",
minWidth: 150
},
{
label: "头像",
prop: "avatarUrl",
minWidth: 100,
component: {
name: "cl-avatar"
}
},
{
label: "手机",
prop: "phone",
minWidth: 120
},
{
label: "性别",
prop: "gender",
dict: options.gender,
minWidth: 100
},
{
label: "登录方式",
prop: "loginType",
dict: options.loginType,
minWidth: 100
},
{
label: "状态",
prop: "status",
minWidth: 100,
component: {
name: "cl-switch"
}
},
{
label: "创建时间",
prop: "createTime",
sortable: "desc",
minWidth: 150
},
{
label: "操作",
type: "op",
buttons: ["edit", "delete"]
}
]
});
// cl-upsert
const Upsert = useUpsert({
dialog: {
width: "600px"
},
items: [
{
prop: "avatarUrl",
label: "头像",
component: { name: "cl-upload" }
},
{
prop: "nickName",
label: "昵称",
component: { name: "el-input" },
required: true
},
{
prop: "phone",
label: "手机号",
component: {
name: "el-input",
props: {
maxlength: 11
}
}
},
{
prop: "gender",
label: "性别",
value: 1,
component: {
name: "el-radio-group",
options: options.gender
}
},
{
prop: "status",
label: "状态",
value: 1,
component: {
name: "el-radio-group",
options: options.status
}
}
]
});
// cl-crud
const Crud = useCrud(
{
service: service.user.info
},
(app) => {
app.refresh();
}
);
</script>