增加菜单页面,增加小程序管理页面,增加店铺员工页面

This commit is contained in:
2025-02-17 10:03:35 +08:00
parent 4adee9121e
commit 960bbada59
29 changed files with 2508 additions and 280 deletions

View File

@@ -1 +0,0 @@
<template></template>

View File

@@ -0,0 +1,14 @@
<template>
<h3>{{ title }}</h3>
</template>
<script setup>
const props = defineProps({
title: {
type: String,
default: "",
},
});
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,177 @@
import ShopStaffApi, { type addRequest } from "@/api/account/shopStaff";
import type { IModalConfig } from "@/components/CURD/types";
import { discountTypeOptions } from './config'
const modalConfig: IModalConfig<addRequest> = {
pageName: "sys:user",
dialog: {
title: "添加员工",
width: 800,
draggable: true,
},
form: {
labelWidth: 140,
},
formAction: function (data) {
return ShopStaffApi.add(data);
},
beforeSubmit(data) {
console.log("提交之前处理", data);
},
formItems: [
{
label: "基本信息设置",
prop: "",
type: "title",
slotName: "title",
},
{
label: "角色",
prop: "roleId",
rules: [{ required: true, message: "请选择角色", trigger: "blur" }],
type: "select",
attrs: {
placeholder: "请选择角色",
},
col: {
xs: 24,
sm: 12,
},
options: []
},
{
label: "员工姓名",
prop: "name",
rules: [{ required: false, message: "请输入员工姓名", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入员工姓名",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "员工编号",
prop: "code",
rules: [{ required: true, message: "请输入员工编号", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入员工编号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "手机号",
prop: "phone",
rules: [{
required: true,
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur",
}],
type: "input",
attrs: {
placeholder: "请输入手机号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "登录账号",
prop: "accountName",
rules: [{ required: true, message: "请输入登录账号", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入登录账号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "登录密码",
prop: "accountPwd",
rules: [{ required: true, message: "请输入登录密码", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入登录密码",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "优惠类型",
prop: "discountType",
rules: [{ required: false, message: "请选择优惠类型", trigger: "blur" }],
type: "radio-button",
col: {
xs: 24,
sm: 12,
},
options: discountTypeOptions,
},
{
label: "最大优惠金额",
prop: "maxDiscountAmount",
rules: [{ required: false, message: "请输入最大优惠金额", trigger: "blur" }],
col: {
xs: 24,
sm: 12,
},
},
{
label: "是否启用",
prop: "status",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
col: {
xs: 24,
sm: 12,
},
},
{
label: "员工权限设置",
prop: "",
type: "title",
slotName: "title",
},
{
label: "是否允许管理端登录",
prop: "isManage",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
},
{
label: "是否允许pc登录",
prop: "isPc",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
},
],
};
// 如果有异步数据会修改配置的推荐用reactive包裹而纯静态配置的可以直接导出
export default reactive(modalConfig);

View File

@@ -0,0 +1,29 @@
export const discountTypeOptions: options[] = [
{ label: "金额", value: "0" },
{ label: "折扣", value: "1" },
];
export type optionsType = "discountType" | "";
export function returnOptions(type: optionsType) {
if (type === "discountType") {
return discountTypeOptions;
}
}
export function returnOptionsLabel(optionsType: optionsType, value: string | number) {
const options = returnOptions(optionsType);
if (!options) {
return "";
}
const option = options.find((item) => item.value === value);
return option ? option.label : "";
}
export interface options {
label: string;
value: string | number;
[property: string]: any;
}

View File

@@ -0,0 +1,62 @@
import ShopStaffApi, { type getListRequest } from "@/api/account/shopStaff";
import type { PageShopStaff } from "@/api/account/shopStaff";
import type { IContentConfig } from "@/components/CURD/types";
const contentConfig = {
pageName: "sys:user",
table: {
border: true,
highlightCurrentRow: true,
},
pagination: {
background: true,
layout: "prev,pager,next,jumper,total,sizes",
pageSize: 20,
pageSizes: [10, 20, 30, 50],
},
deleteAction: function (id: string) {
return ShopStaffApi.delete(id);
},
indexAction: function (params: getListRequest) {
return ShopStaffApi.getList(params);
},
// modifyAction: function (data) {
// // return ShopStaffApi.edit(data);
// },
pk: "id",
toolbar: ["add"],
defaultToolbar: ["refresh", "filter", "search"],
cols: [
{ type: "selection", width: 50, align: "center" },
{ prop: "id", width: 50, align: "center", show: false },
{
label: "员工名称",
align: "center",
prop: "name",
},
{
label: "员工编号",
align: "center",
prop: "code",
},
{
label: "最大优惠金额",
align: "center",
prop: "maxDiscountAmount",
},
{
label: "优惠类型",
align: "center",
prop: "discountType",
},
{
label: "操作",
align: "center",
fixed: "right",
templet: "tool",
operat: ["edit", "delete"],
},
],
};
export default contentConfig;

View File

@@ -0,0 +1,177 @@
import ShopStaffApi, { type editRequest } from "@/api/account/shopStaff";
import type { IModalConfig } from "@/components/CURD/types";
import { discountTypeOptions } from './config'
const modalConfig: IModalConfig<editRequest> = {
pageName: "sys:user",
dialog: {
title: "编辑员工",
width: 800,
draggable: true,
},
form: {
labelWidth: 140,
},
formAction: function (data) {
return ShopStaffApi.edit(data);
},
beforeSubmit(data) {
console.log("提交之前处理", data);
},
formItems: [
{
label: "基本信息设置",
prop: "",
type: "title",
slotName: "title",
},
{
label: "角色",
prop: "roleId",
rules: [{ required: true, message: "请选择角色", trigger: "blur" }],
type: "select",
attrs: {
placeholder: "请选择角色",
},
col: {
xs: 24,
sm: 12,
},
options: []
},
{
label: "员工姓名",
prop: "name",
rules: [{ required: false, message: "请输入员工姓名", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入员工姓名",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "员工编号",
prop: "code",
rules: [{ required: true, message: "请输入员工编号", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入员工编号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "手机号",
prop: "phone",
rules: [{
required: true,
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur",
}],
type: "input",
attrs: {
placeholder: "请输入手机号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "登录账号",
prop: "accountName",
rules: [{ required: true, message: "请输入登录账号", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入登录账号",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "登录密码",
prop: "accountPwd",
rules: [{ required: true, message: "请输入登录密码", trigger: "blur" }],
type: "input",
attrs: {
placeholder: "请输入登录密码",
},
col: {
xs: 24,
sm: 12,
},
},
{
label: "优惠类型",
prop: "discountType",
rules: [{ required: false, message: "请选择优惠类型", trigger: "blur" }],
type: "radio-button",
col: {
xs: 24,
sm: 12,
},
options: discountTypeOptions,
},
{
label: "最大优惠金额",
prop: "maxDiscountAmount",
rules: [{ required: false, message: "请输入最大优惠金额", trigger: "blur" }],
col: {
xs: 24,
sm: 12,
},
},
{
label: "是否启用",
prop: "status",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
col: {
xs: 24,
sm: 12,
},
},
{
label: "员工权限设置",
prop: "",
type: "title",
slotName: "title",
},
{
label: "是否允许管理端登录",
prop: "isManage",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
},
{
label: "是否允许pc登录",
prop: "isPc",
type: "radio",
options: [
{ label: "正常", value: 1 },
{ label: "禁用", value: 0 },
],
initialValue: 1,
},
],
};
// 如果有异步数据会修改配置的推荐用reactive包裹而纯静态配置的可以直接导出
export default reactive(modalConfig);

View File

@@ -0,0 +1,34 @@
import type { ISearchConfig } from "@/components/CURD/types";
import { paramTypeOptions } from './config'
const searchConfig: ISearchConfig = {
pageName: "sys:user",
formItems: [
{
type: "input",
label: "账号名",
prop: "name",
attrs: {
placeholder: "请输入账号名",
clearable: true,
style: {
width: "200px",
},
},
},
{
type: "input",
label: "员工编号",
prop: "code",
attrs: {
placeholder: "请输入员工编号",
clearable: true,
style: {
width: "200px",
},
},
},
],
};
export default searchConfig;

View File

@@ -0,0 +1,133 @@
<template>
<div class="app-container">
<!-- 列表 -->
<!-- 搜索 -->
<page-search
ref="searchRef"
:search-config="searchConfig"
@query-click="handleQueryClick"
@reset-click="handleResetClick"
/>
<!-- 列表 -->
<page-content
ref="contentRef"
:content-config="contentConfig"
@add-click="handleAddClick"
@edit-click="handleEditClick"
@export-click="handleExportClick"
@search-click="handleSearchClick"
@toolbar-click="handleToolbarClick"
@operat-click="handleOperatClick"
@filter-change="handleFilterChange"
>
<template #status="scope">
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
</el-tag>
</template>
<template #options="scope">
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
</template>
<template #gender="scope">
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
</template>
<template #mobile="scope">
<el-text>{{ scope.row[scope.prop] }}</el-text>
<copy-button
v-if="scope.row[scope.prop]"
:text="scope.row[scope.prop]"
style="margin-left: 2px"
/>
</template>
</page-content>
<!-- 新增 -->
<page-modal ref="addModalRef" :modal-config="addModalConfig" @submit-click="handleSubmitClick">
<template #url="scope">
<FileUpload v-model="scope.formData[scope.prop]" :limit="1" v-bind="scope.attrs" />
<!-- <Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" /> -->
</template>
</page-modal>
<!-- 编辑 -->
<page-modal
ref="editModalRef"
:modal-config="editModalConfig"
@submit-click="handleSubmitClick"
>
<template #url="scope">
<FileUpload v-model="scope.formData[scope.prop]" :limit="1" v-bind="scope.attrs" />
<!-- <Dict v-model="scope.formData[scope.prop]" code="gender" v-bind="scope.attrs" /> -->
</template>
</page-modal>
</div>
</template>
<script setup lang="ts">
import type { IObject, IOperatData } from "@/components/CURD/types";
import usePage from "@/components/CURD/usePage";
import addModalConfig from "./config/add";
import contentConfig from "./config/content";
import editModalConfig from "./config/edit";
import searchConfig from "./config/search";
import { returnOptionsLabel } from "./config/config";
import RoleApi, { type SysRole } from "@/api/account/role";
import ShopStaffApi from "@/api/account/shopStaff";
const {
searchRef,
contentRef,
addModalRef,
editModalRef,
handleQueryClick,
handleResetClick,
// handleAddClick,
// handleEditClick,
handleSubmitClick,
handleExportClick,
handleSearchClick,
handleFilterChange,
} = usePage();
// 数据初始化
async function init() {
const res = await RoleApi.getList({ page: 1, size: 100 });
const roleArr = res.records.map((item: SysRole) => {
return {
...item,
label: item.name,
value: item.id,
};
});
addModalConfig.formItems[1]!.options = roleArr;
editModalConfig.formItems[1]!.options = roleArr;
}
init();
// 新增
async function handleAddClick() {
addModalRef.value?.setModalVisible();
}
// 编辑
async function handleEditClick(row: IObject) {
editModalRef.value?.handleDisabled(false);
editModalRef.value?.setModalVisible();
// 根据id获取数据进行填充
await ShopStaffApi.get(row.id).then((res) => {
console.log(res);
editModalRef.value?.setFormData({ ...res });
});
}
1;
// 其他工具栏
function handleToolbarClick(name: string) {
console.log(name);
if (name === "custom1") {
ElMessage.success("点击了自定义1按钮");
}
}
// 其他操作列
async function handleOperatClick(data: IOperatData) {}
// 切换示例
</script>