diff --git a/src/api/shop/shop.ts b/src/api/shop/shop.ts index 857ef13..1e77278 100644 --- a/src/api/shop/shop.ts +++ b/src/api/shop/shop.ts @@ -8,6 +8,8 @@ export interface ShopQuery extends BasePageQuery { belongType?: number; /** 运行模式(0-支付模式 1-审批模式 2-借还模式 3-会员模式 4-耗材模式 5-暂存模式) */ mode?: number; + /** 运行模式列表 */ + modeList?: number[]; /** 借呗支付(1-正常使用 0-禁止使用) */ balanceEnable?: number; } diff --git a/src/store/modules/btnPermission.ts b/src/store/modules/btnPermission.ts index 8e980a5..0dc3bb3 100644 --- a/src/store/modules/btnPermission.ts +++ b/src/store/modules/btnPermission.ts @@ -15,10 +15,25 @@ export const useBtnPermissionStore = defineStore("btnPermission", () => { 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 { btnPermissions, fetchPermissions, hasPermission, + getShopModeList, }; }); diff --git a/src/views/cabinet/shop/card.vue b/src/views/cabinet/shop/card.vue index 751a8f1..dc99418 100644 --- a/src/views/cabinet/shop/card.vue +++ b/src/views/cabinet/shop/card.vue @@ -5,6 +5,7 @@ import { getShopList, type ShopDTO, ShopQuery, getModeText, getBalanceEnableText import { type PaginationProps } from "@pureadmin/table"; import { useRouter } from "vue-router"; import { useWxStore } from "@/store/modules/wx"; +import { useBtnPermissionStoreOutside } from "@/store/modules/btnPermission"; import Search from "@iconify-icons/ep/search"; import Refresh from "@iconify-icons/ep/refresh"; @@ -46,11 +47,13 @@ async function onSearch() { async function getList() { try { pageLoading.value = true; + const btnPermissionStore = useBtnPermissionStoreOutside(); const { data } = await getShopList({ ...searchFormParams.value, corpid: wxStore.corpid, pageSize: pagination.value.pageSize, - pageNum: pagination.value.currentPage + pageNum: pagination.value.currentPage, + modeList: btnPermissionStore.getShopModeList() }); dataList.value = data.rows; pagination.value.total = data.total; @@ -152,8 +155,8 @@ function getPaymentMethods(mode: number): Array<{ label: string; type: string }> 运行模式:{{ - getModeText(item.mode) }} - 机柜数量:{{ item.cabinetCount }} + getModeText(item.mode) }} + 机柜数量:{{ item.cabinetCount }} + diff --git a/src/views/cabinet/shop/shop-form-modal.vue b/src/views/cabinet/shop/shop-form-modal.vue index 61d8c17..a615fc2 100644 --- a/src/views/cabinet/shop/shop-form-modal.vue +++ b/src/views/cabinet/shop/shop-form-modal.vue @@ -9,6 +9,7 @@ import { useSysConfigStoreHook } from "@/store/modules/sysConfig"; import { beforeImageUpload } from "@/utils/imageCompressor"; import ReQrcode from "@/components/ReQrcode"; import { copyTextToClipboard } from "@pureadmin/utils"; +import { useBtnPermissionStoreOutside } from "@/store/modules/btnPermission"; const { VITE_APP_BASE_API } = import.meta.env; const props = defineProps({ @@ -39,6 +40,20 @@ const formData = ref({ 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 = { shopName: [{ required: true, message: "请输入地址名称", trigger: "blur" }], belongType: [{ required: true, message: "请选择商品模式", trigger: "change" }], @@ -195,12 +210,7 @@ const cancelDelete = () => { --> - - - - - - + - + 确定要删除地址 "{{ formData.shopName }}" 吗?此操作不可恢复。