feat(shop): 添加基于权限的店铺模式过滤功能
在店铺查询接口中添加 modeList 字段支持多模式查询 新增 getShopModeList 方法从权限中提取可用模式 修改店铺列表和表单页面,根据用户权限过滤可用的运行模式
This commit is contained in:
parent
11d835ca43
commit
db9128ec3a
|
|
@ -8,6 +8,8 @@ export interface ShopQuery extends BasePageQuery {
|
||||||
belongType?: number;
|
belongType?: number;
|
||||||
/** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式 5-暂存模式) */
|
/** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式 5-暂存模式) */
|
||||||
mode?: number;
|
mode?: number;
|
||||||
|
/** 运行模式列表 */
|
||||||
|
modeList?: number[];
|
||||||
/** 借呗支付(1-正常使用 0-禁止使用) */
|
/** 借呗支付(1-正常使用 0-禁止使用) */
|
||||||
balanceEnable?: number;
|
balanceEnable?: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,25 @@ export const useBtnPermissionStore = defineStore("btnPermission", () => {
|
||||||
return btnPermissions.value.includes(permission);
|
return btnPermissions.value.includes(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 从权限列表中解析出所有 shop:mode:数字 格式的权限,返回对应的数字列表
|
||||||
|
* @returns 拥有 shopMode 权限的数字数组
|
||||||
|
*/
|
||||||
|
const getShopModeList = () => {
|
||||||
|
const pattern = /^shop:mode:(\d+)$/;
|
||||||
|
return btnPermissions.value
|
||||||
|
.map((permission) => {
|
||||||
|
const match = permission.match(pattern);
|
||||||
|
return match ? Number(match[1]) : null;
|
||||||
|
})
|
||||||
|
.filter((num): num is number => num !== null);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
btnPermissions,
|
btnPermissions,
|
||||||
fetchPermissions,
|
fetchPermissions,
|
||||||
hasPermission,
|
hasPermission,
|
||||||
|
getShopModeList,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { getShopList, type ShopDTO, ShopQuery, getModeText, getBalanceEnableText
|
||||||
import { type PaginationProps } from "@pureadmin/table";
|
import { type PaginationProps } from "@pureadmin/table";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import { useWxStore } from "@/store/modules/wx";
|
import { useWxStore } from "@/store/modules/wx";
|
||||||
|
import { useBtnPermissionStoreOutside } from "@/store/modules/btnPermission";
|
||||||
|
|
||||||
import Search from "@iconify-icons/ep/search";
|
import Search from "@iconify-icons/ep/search";
|
||||||
import Refresh from "@iconify-icons/ep/refresh";
|
import Refresh from "@iconify-icons/ep/refresh";
|
||||||
|
|
@ -46,11 +47,13 @@ async function onSearch() {
|
||||||
async function getList() {
|
async function getList() {
|
||||||
try {
|
try {
|
||||||
pageLoading.value = true;
|
pageLoading.value = true;
|
||||||
|
const btnPermissionStore = useBtnPermissionStoreOutside();
|
||||||
const { data } = await getShopList({
|
const { data } = await getShopList({
|
||||||
...searchFormParams.value,
|
...searchFormParams.value,
|
||||||
corpid: wxStore.corpid,
|
corpid: wxStore.corpid,
|
||||||
pageSize: pagination.value.pageSize,
|
pageSize: pagination.value.pageSize,
|
||||||
pageNum: pagination.value.currentPage
|
pageNum: pagination.value.currentPage,
|
||||||
|
modeList: btnPermissionStore.getShopModeList()
|
||||||
});
|
});
|
||||||
dataList.value = data.rows;
|
dataList.value = data.rows;
|
||||||
pagination.value.total = data.total;
|
pagination.value.total = data.total;
|
||||||
|
|
@ -152,8 +155,8 @@ function getPaymentMethods(mode: number): Array<{ label: string; type: string }>
|
||||||
<el-descriptions class="cabinet-info" :column="1">
|
<el-descriptions class="cabinet-info" :column="1">
|
||||||
<!-- <el-descriptions-item class="type">模式:{{ item.belongType === 0 ? '借还模式' : '固资模式' }}</el-descriptions-item> -->
|
<!-- <el-descriptions-item class="type">模式:{{ item.belongType === 0 ? '借还模式' : '固资模式' }}</el-descriptions-item> -->
|
||||||
<el-descriptions-item class="mode">运行模式:<el-tag :type="getModeType(item.mode)">{{
|
<el-descriptions-item class="mode">运行模式:<el-tag :type="getModeType(item.mode)">{{
|
||||||
getModeText(item.mode) }}</el-tag></el-descriptions-item>
|
getModeText(item.mode) }}</el-tag></el-descriptions-item>
|
||||||
<el-descriptions-item class="mode" >机柜数量:{{ item.cabinetCount }}</el-descriptions-item>
|
<el-descriptions-item class="mode">机柜数量:{{ item.cabinetCount }}</el-descriptions-item>
|
||||||
<!-- <el-descriptions-item class="payment-methods">支付方式:
|
<!-- <el-descriptions-item class="payment-methods">支付方式:
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item v-for="method in getPaymentMethods(item.mode)" class="payment-methods">
|
<el-descriptions-item v-for="method in getPaymentMethods(item.mode)" class="payment-methods">
|
||||||
|
|
@ -178,7 +181,7 @@ function getPaymentMethods(mode: number): Array<{ label: string; type: string }>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- <shop-form-modal v-model:visible="modalVisible" :row="currentRow" @refresh="getList" /> -->
|
<shop-form-modal v-model:visible="modalVisible" :row="currentRow" @refresh="getList" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { useSysConfigStoreHook } from "@/store/modules/sysConfig";
|
||||||
import { beforeImageUpload } from "@/utils/imageCompressor";
|
import { beforeImageUpload } from "@/utils/imageCompressor";
|
||||||
import ReQrcode from "@/components/ReQrcode";
|
import ReQrcode from "@/components/ReQrcode";
|
||||||
import { copyTextToClipboard } from "@pureadmin/utils";
|
import { copyTextToClipboard } from "@pureadmin/utils";
|
||||||
|
import { useBtnPermissionStoreOutside } from "@/store/modules/btnPermission";
|
||||||
const { VITE_APP_BASE_API } = import.meta.env;
|
const { VITE_APP_BASE_API } = import.meta.env;
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
@ -39,6 +40,20 @@ const formData = ref<UpdateShopCommand>({
|
||||||
coverImg: ""
|
coverImg: ""
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const btnPermissionStore = useBtnPermissionStoreOutside();
|
||||||
|
const modeOptions = [
|
||||||
|
{ label: '支付模式', value: 0 },
|
||||||
|
{ label: '审批模式', value: 1 },
|
||||||
|
{ label: '借还模式', value: 2 },
|
||||||
|
{ label: '会员模式', value: 3 },
|
||||||
|
{ label: '耗材模式', value: 4 },
|
||||||
|
{ label: '暂存模式', value: 5 }
|
||||||
|
];
|
||||||
|
const allowedModeOptions = computed(() => {
|
||||||
|
const allowedModes = btnPermissionStore.getShopModeList();
|
||||||
|
return modeOptions.filter(option => allowedModes.includes(option.value));
|
||||||
|
});
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
shopName: [{ required: true, message: "请输入地址名称", trigger: "blur" }],
|
shopName: [{ required: true, message: "请输入地址名称", trigger: "blur" }],
|
||||||
belongType: [{ required: true, message: "请选择商品模式", trigger: "change" }],
|
belongType: [{ required: true, message: "请选择商品模式", trigger: "change" }],
|
||||||
|
|
@ -195,12 +210,7 @@ const cancelDelete = () => {
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
<el-form-item label="运行模式" prop="mode">
|
<el-form-item label="运行模式" prop="mode">
|
||||||
<el-select v-model="formData.mode" placeholder="请选择运行模式">
|
<el-select v-model="formData.mode" placeholder="请选择运行模式">
|
||||||
<el-option label="支付模式" :value="0" />
|
<el-option v-for="option in allowedModeOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||||
<el-option label="审批模式" :value="1" />
|
|
||||||
<el-option label="借还模式" :value="2" />
|
|
||||||
<el-option label="会员模式" :value="3" />
|
|
||||||
<el-option label="耗材模式" :value="4" />
|
|
||||||
<el-option label="暂存模式" :value="5" />
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="借呗支付" prop="balanceEnable">
|
<!-- <el-form-item label="借呗支付" prop="balanceEnable">
|
||||||
|
|
@ -221,7 +231,7 @@ const cancelDelete = () => {
|
||||||
<el-form-item label="二维码">
|
<el-form-item label="二维码">
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<ReQrcode :text="`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${formData.shopId}`"
|
<ReQrcode :text="`${sysConfigStore.serverHost}/shop-api/api/shop/wechatAuth?shopId=${formData.shopId}`"
|
||||||
:options="{ width: 150 }" :width="150"/>
|
:options="{ width: 150 }" :width="150" />
|
||||||
<el-button type="primary" size="small" @click="copyLink" style="margin-left: 10px;">
|
<el-button type="primary" size="small" @click="copyLink" style="margin-left: 10px;">
|
||||||
复制链接
|
复制链接
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -230,10 +240,7 @@ const cancelDelete = () => {
|
||||||
</el-form>
|
</el-form>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="handleClose" style="margin-right: 5px;">取消</el-button>
|
<el-button @click="handleClose" style="margin-right: 5px;">取消</el-button>
|
||||||
<el-button
|
<el-button v-if="formData.shopId && (props.row?.cabinetCount || 0) === 0" type="danger" @click="handleDelete"
|
||||||
v-if="formData.shopId && (props.row?.cabinetCount || 0) === 0"
|
|
||||||
type="danger"
|
|
||||||
@click="handleDelete"
|
|
||||||
style="margin-right: 5px;">
|
style="margin-right: 5px;">
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
|
|
@ -242,11 +249,7 @@ const cancelDelete = () => {
|
||||||
</el-drawer>
|
</el-drawer>
|
||||||
|
|
||||||
<!-- 删除确认对话框 -->
|
<!-- 删除确认对话框 -->
|
||||||
<el-dialog
|
<el-dialog v-model="deleteDialogVisible" title="确认删除" width="400px" :close-on-click-modal="false">
|
||||||
v-model="deleteDialogVisible"
|
|
||||||
title="确认删除"
|
|
||||||
width="400px"
|
|
||||||
:close-on-click-modal="false">
|
|
||||||
<span>确定要删除地址 "{{ formData.shopName }}" 吗?此操作不可恢复。</span>
|
<span>确定要删除地址 "{{ formData.shopName }}" 吗?此操作不可恢复。</span>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue