|
|
@@ -0,0 +1,217 @@
|
|
|
+import type {
|
|
|
+ OnActionClickFn,
|
|
|
+ VbenFormSchema,
|
|
|
+ VxeTableGridOptions,
|
|
|
+} from '#/adapter';
|
|
|
+
|
|
|
+import { z } from '#/adapter';
|
|
|
+import { EnumApi } from '#/api';
|
|
|
+import { ShopUserApi, UserGradeApi } from '#/api/shop';
|
|
|
+
|
|
|
+export const useSearchSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'account',
|
|
|
+ label: '账号',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ fieldName: 'name',
|
|
|
+ label: '姓名',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'ApiSelect',
|
|
|
+ componentProps: {
|
|
|
+ api: UserGradeApi.getOptions,
|
|
|
+ showSearch: true,
|
|
|
+ optionFilterProp: 'label',
|
|
|
+ },
|
|
|
+ fieldName: 'grade',
|
|
|
+ label: '会员等级',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+};
|
|
|
+
|
|
|
+export function useColumns(
|
|
|
+ onActionClick?: OnActionClickFn<ShopUserApi.RecordItem>,
|
|
|
+): VxeTableGridOptions<ShopUserApi.RecordItem>['columns'] {
|
|
|
+ return [
|
|
|
+ { title: '序号', type: 'seq', width: 50 },
|
|
|
+ {
|
|
|
+ align: 'left',
|
|
|
+ field: 'user.account',
|
|
|
+ title: '账号',
|
|
|
+ width: 200,
|
|
|
+ },
|
|
|
+ { align: 'left', field: 'user.realName', title: '姓名', width: 120 },
|
|
|
+ { align: 'left', field: 'gradeName', title: '用户等级', width: 120 },
|
|
|
+ { align: 'right', field: 'point', title: '积分', width: 100 },
|
|
|
+ { align: 'right', field: 'balance', title: '余额', width: 100 },
|
|
|
+ {
|
|
|
+ field: 'user.status',
|
|
|
+ title: '状态',
|
|
|
+ width: 82,
|
|
|
+ cellRender: { name: 'CellTag' },
|
|
|
+ },
|
|
|
+ { align: 'left', field: 'user.remark', title: '备注' },
|
|
|
+ {
|
|
|
+ align: 'right',
|
|
|
+ field: 'user.sort',
|
|
|
+ title: '排序',
|
|
|
+ width: 82,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ align: 'right',
|
|
|
+ cellRender: {
|
|
|
+ attrs: {
|
|
|
+ nameField: 'user.account',
|
|
|
+ nameTitle: '账号',
|
|
|
+ onClick: onActionClick,
|
|
|
+ },
|
|
|
+ name: 'CellAction',
|
|
|
+ options: [
|
|
|
+ {
|
|
|
+ code: 'edit',
|
|
|
+ auth: ['shop-user:edit'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'resetPwd',
|
|
|
+ label: '重置密码',
|
|
|
+ auth: ['shop-user:resetPwd'],
|
|
|
+ confirm: {
|
|
|
+ title: '重置密码提示',
|
|
|
+ content: `确定要重置选择的记录吗?`,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'delete',
|
|
|
+ auth: ['shop-user:delete'],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ code: 'setStatus',
|
|
|
+ label: (row: ShopUserApi.RecordItem) => {
|
|
|
+ return row.user.status === 1 ? '禁用' : '启用';
|
|
|
+ },
|
|
|
+ auth: ['shop-user:setStatus'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ field: 'operation',
|
|
|
+ fixed: 'right',
|
|
|
+ headerAlign: 'center',
|
|
|
+ showOverflow: false,
|
|
|
+ title: '操作',
|
|
|
+ width: 160,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+}
|
|
|
+
|
|
|
+export const useSchema = (): VbenFormSchema[] => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ component: 'ApiSelect',
|
|
|
+ componentProps: {
|
|
|
+ api: UserGradeApi.getOptions,
|
|
|
+ showSearch: true,
|
|
|
+ optionFilterProp: 'label',
|
|
|
+ autoSelect: 'first',
|
|
|
+ },
|
|
|
+ fieldName: 'grade',
|
|
|
+ label: '会员等级',
|
|
|
+ rules: 'required',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入账号',
|
|
|
+ },
|
|
|
+ fieldName: 'account',
|
|
|
+ label: '账号',
|
|
|
+ rules: z
|
|
|
+ .string()
|
|
|
+ // .min(3, '账号至少需要3个字符')
|
|
|
+ .regex(
|
|
|
+ /^[a-z]\w{2,}$/i,
|
|
|
+ '账号只能由字母、数字、下划线组成并以字母开头',
|
|
|
+ ),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'InputPassword',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入密码',
|
|
|
+ },
|
|
|
+ fieldName: 'password',
|
|
|
+ label: '密码',
|
|
|
+ // rules: 'required',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入姓名',
|
|
|
+ },
|
|
|
+ fieldName: 'realName',
|
|
|
+ label: '姓名',
|
|
|
+ rules: 'required',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入昵称',
|
|
|
+ },
|
|
|
+ fieldName: 'nickName',
|
|
|
+ label: '昵称',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'ApiRadio',
|
|
|
+ componentProps: {
|
|
|
+ api: EnumApi.getList,
|
|
|
+ params: { name: EnumApi.EnumType.Gender },
|
|
|
+ optionType: 'button',
|
|
|
+ buttonStyle: 'solid',
|
|
|
+ autoSelect: 'last',
|
|
|
+ },
|
|
|
+ fieldName: 'sex',
|
|
|
+ label: '性别',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'DatePicker',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ valueFormat: 'YYYY-MM-DD',
|
|
|
+ },
|
|
|
+ fieldName: 'birthday',
|
|
|
+ label: '生日',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入电话',
|
|
|
+ },
|
|
|
+ fieldName: 'phone',
|
|
|
+ label: '电话',
|
|
|
+ rules: z
|
|
|
+ .string()
|
|
|
+ .regex(/^1[3-9]\d{9}$/, '电话格式错误')
|
|
|
+ .optional(),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入邮箱',
|
|
|
+ },
|
|
|
+ fieldName: 'email',
|
|
|
+ label: '邮箱',
|
|
|
+ rules: z.string().email('邮箱格式错误').optional(),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ placeholder: '请输入',
|
|
|
+ },
|
|
|
+ fieldName: 'remark',
|
|
|
+ label: '备注',
|
|
|
+ formItemClass: 'col-span-2 items-baseline',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+};
|