🚀 feat(新增): 模板生成内容
This commit is contained in:
parent
a609bb1dd4
commit
c097849f63
|
@ -29,10 +29,6 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="WebTemplate\"/>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Bunny.WebApi\Bunny.WebApi.csproj"/>
|
<ProjectReference Include="..\Bunny.WebApi\Bunny.WebApi.csproj"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { reactive } from 'vue';
|
||||||
|
import type { FormRules } from 'element-plus';
|
||||||
|
import { ColumnsEnum } from '@/enum/columnsEnum';
|
||||||
|
|
||||||
|
// 字段
|
||||||
|
export const columns = [
|
||||||
|
{ type: 'selection' },
|
||||||
|
{ label: ColumnsEnum.tableId, prop: 'id' },
|
||||||
|
|
||||||
|
{ label: ColumnsEnum.tableCreateTime, prop: 'createTime', sortable: true, width: 160 },
|
||||||
|
{ label: ColumnsEnum.tableUpdateTime, prop: 'updateTime', sortable: true, width: 160 },
|
||||||
|
{ label: ColumnsEnum.tableCreateUser, prop: 'createUser', width: 100, slot: 'createUser' },
|
||||||
|
{ label: ColumnsEnum.tableUpdateUser, prop: 'updateUser', width: 100, slot: 'updateUser' },
|
||||||
|
{ label: ColumnsEnum.tableOperation, prop: 'operation', slot: 'operation', width: 150, fixed: 'right' },
|
||||||
|
];
|
||||||
|
|
||||||
|
// 规则
|
||||||
|
export const rules = reactive<FormRules>({
|
||||||
|
nickName: [{ required: true, message: '昵称不能为空', trigger: 'blur' }],
|
||||||
|
email: [
|
||||||
|
{ required: true, message: '邮件不能为空', trigger: 'blur' },
|
||||||
|
{ type: 'email', message: '邮箱格式错误' },
|
||||||
|
],
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
export enum ColumnsEnum {
|
||||||
|
tableId = '主键',
|
||||||
|
tableCreateTime = '创建时间',
|
||||||
|
tableUpdateTime = '更新时间',
|
||||||
|
tableCreateUser = '创建用户',
|
||||||
|
tableUpdateUser = '更新用户',
|
||||||
|
tableOperation = '操作',
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
import { useWebUserStore } from '@/store/user/webUser';
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import type { WebUser, WebUserUpdateForm } from '../../../../../../types/store/user/webUser';
|
||||||
|
import { messageBox } from '@/utils/message';
|
||||||
|
|
||||||
|
const webUserStore = useWebUserStore();
|
||||||
|
export const ids = ref<string[]>([]);
|
||||||
|
export const updateForm = reactive<WebUserUpdateForm>({
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取用户数据
|
||||||
|
*/
|
||||||
|
export const getDataList = async () => {
|
||||||
|
webUserStore.loading = true;
|
||||||
|
await webUserStore.getUserinfoList();
|
||||||
|
webUserStore.loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 当前页改变时
|
||||||
|
*/
|
||||||
|
export const onCurrentPageChange = async (value: number) => {
|
||||||
|
webUserStore.pagination.currentPage = value;
|
||||||
|
await getDataList();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 当分页发生变化
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
export const onPageSizeChange = (value: number) => {
|
||||||
|
webUserStore.pagination.pageSize = value;
|
||||||
|
getDataList().then();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 选择行
|
||||||
|
* @param itemList
|
||||||
|
*/
|
||||||
|
export const handleSelectionChange = (itemList: WebUser[]) => {
|
||||||
|
ids.value = itemList.map(item => item.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 添加操作
|
||||||
|
*/
|
||||||
|
export const onAdd = () => {
|
||||||
|
webUserStore.addDialogVisible = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 当更新时
|
||||||
|
*/
|
||||||
|
export const onUpdate = ({ row }): void => {
|
||||||
|
// 合并数据
|
||||||
|
Object.assign(updateForm, row);
|
||||||
|
// 设置基础数据格式
|
||||||
|
updateForm.sex = row.sex === '女' ? 0 : 1;
|
||||||
|
// 打开弹窗
|
||||||
|
webUserStore.updateDialogVisible = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 当删除时
|
||||||
|
*/
|
||||||
|
export const onDelete = async ({ row }) => {
|
||||||
|
const result = await webUserStore.deleteUserinfo([row.id]).then();
|
||||||
|
// 成功刷新数据
|
||||||
|
result && (await webUserStore.getUserinfoList());
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 批量删除
|
||||||
|
*/
|
||||||
|
export const onDeleteBatch = async () => {
|
||||||
|
const isConfirm = await messageBox({
|
||||||
|
message: '是否确认批量删除',
|
||||||
|
title: '删除警告',
|
||||||
|
showMessage: false,
|
||||||
|
confirmMessage: '删除成功',
|
||||||
|
cancelMessage: '取消删除',
|
||||||
|
});
|
||||||
|
// 确认删除时执行
|
||||||
|
if (isConfirm) {
|
||||||
|
const result = await webUserStore.deleteUserinfo(ids.value);
|
||||||
|
|
||||||
|
// 成功刷新数据
|
||||||
|
result && (await webUserStore.getUserinfoList());
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue