diff --git a/src/api/system/user.ts b/src/api/system/user.ts index 223ad79..4cbd9df 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -246,6 +246,7 @@ export interface UserInfo { * 用户分页查询对象 */ export interface UserPageQuery extends PageQuery { + times: any; /** 搜索关键字 */ keywords?: string; diff --git a/src/components/CURD/PageContent.vue b/src/components/CURD/PageContent.vue index 39e58bf..2a81b02 100644 --- a/src/components/CURD/PageContent.vue +++ b/src/components/CURD/PageContent.vue @@ -55,6 +55,7 @@ diff --git a/src/components/CURD/types.ts b/src/components/CURD/types.ts index 6086710..d1f97b4 100644 --- a/src/components/CURD/types.ts +++ b/src/components/CURD/types.ts @@ -148,6 +148,7 @@ export interface IContentConfig { icon?: string; name: string; text: string; + hidden?: boolean; type?: "primary" | "success" | "warning" | "danger" | "info"; } >; @@ -215,6 +216,7 @@ export interface IContentConfig { name: string; text: string; isBtn?: boolean; + hidden?: boolean; type?: "primary" | "success" | "warning" | "danger" | "info"; render?: (row: IObject) => boolean; options?: { diff --git a/src/layout/components/Sidebar/components/SidebarLogo.vue b/src/layout/components/Sidebar/components/SidebarLogo.vue index 8a8bd70..9878d02 100644 --- a/src/layout/components/Sidebar/components/SidebarLogo.vue +++ b/src/layout/components/Sidebar/components/SidebarLogo.vue @@ -43,7 +43,7 @@ async function geiShopList() { state.branchList = res; if (!localStorage.getItem("shopName")) { state.shopName = state.branchList[0].shopName - localStorage.setItem("branch_shopId", data.shopInfo.id) + localStorage.setItem("branch_shopId", state.branchList[0].id) localStorage.setItem("shopName", state.branchList[0].shopName) } else { state.shopName = localStorage.getItem("shopName") diff --git a/src/utils/index.ts b/src/utils/index.ts index f17566b..3697fb7 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -129,3 +129,16 @@ export function isSyncStatus() { return false } } + +/** + * 判断是否有某权限 + */ +export function hasPermission(params: any) { + let $PermissionObj = JSON.parse(localStorage.getItem("permission") || '[]' ) + const obj = $PermissionObj.find((v: any) => v == params || v == params) + if (obj) { + return obj + } + return false +} + diff --git a/src/views/application/marketing/coupon/list.vue b/src/views/application/marketing/coupon/list.vue index 4ae2c6f..7990a2c 100644 --- a/src/views/application/marketing/coupon/list.vue +++ b/src/views/application/marketing/coupon/list.vue @@ -81,6 +81,7 @@ import couponEnum from "./couponEnum"; import couponDetails from "./components/coupon_details.vue"; import couponAdd from "./components/add.vue"; import couponApi from "@/api/account/coupon"; +import { hasPermission } from "@/utils/index"; export default { // eslint-disable-next-line vue/no-unused-components @@ -100,6 +101,9 @@ export default { }, mounted() { this.getTableData(); + console.log(hasPermission('coupon:add')) + console.log(hasPermission('coupon:edit')) + // coupon:add shopStaff:add }, methods: { toAdd(data) { diff --git a/src/views/inventory/classification/config/content.ts b/src/views/inventory/classification/config/content.ts index f1a4aed..51e900a 100644 --- a/src/views/inventory/classification/config/content.ts +++ b/src/views/inventory/classification/config/content.ts @@ -20,7 +20,15 @@ const contentConfig: IContentConfig = { return Api.edit(data); }, pk: "id", - toolbar: ["add"], + toolbar: [ + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, + ], defaultToolbar: ["refresh", "filter", "search"], cols: [ // { type: "selection", width: 50, align: "center" }, @@ -49,7 +57,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: ["edit"], + operat: [{ text: "编辑", icon: 'edit', name: "edit"}], }, ], }; diff --git a/src/views/inventory/classification/index.vue b/src/views/inventory/classification/index.vue index 565a1ea..7550184 100644 --- a/src/views/inventory/classification/index.vue +++ b/src/views/inventory/classification/index.vue @@ -71,6 +71,7 @@ import contentConfig from "./config/content"; import editModalConfig from "./config/edit"; import searchConfig from "./config/search"; import { returnOptionsLabel } from "./config/config"; +import { isSyncStatus } from "@/utils/index"; const { searchRef, @@ -87,6 +88,14 @@ const { handleFilterChange, } = usePage(); +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false +} + // 新增 async function handleAddClick() { addModalRef.value?.setModalVisible(); diff --git a/src/views/inventory/consumables/config/content.ts b/src/views/inventory/consumables/config/content.ts index 3ffef60..8b18d62 100644 --- a/src/views/inventory/consumables/config/content.ts +++ b/src/views/inventory/consumables/config/content.ts @@ -28,7 +28,20 @@ const contentConfig: IContentConfig = { indexActionData: {}, pk: "id", toolbar: [ - "add", + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, + { + icon: "refresh", + text: "同步", + type: "danger", + name: "sync", + auth: "import", + }, { text: "入库", name: "ruku", diff --git a/src/views/inventory/consumables/index.vue b/src/views/inventory/consumables/index.vue index 114b26d..9e5954d 100644 --- a/src/views/inventory/consumables/index.vue +++ b/src/views/inventory/consumables/index.vue @@ -64,7 +64,7 @@ justify-content: center; align-items: center; "> - 编辑 + 编辑 耗材盘点 @@ -89,12 +89,16 @@ import addHaocai from "./components/add-haocai.vue"; import dataTongji from "./components/DataStatistics.vue"; import addConsTakin from "./components/addConsTakin.vue"; import consApi from "@/api/product/cons"; +import UserAPI from "@/api/product/index"; + import type { IObject, IOperatData } from "@/components/CURD/types"; import usePage from "@/components/CURD/usePage"; import contentConfig from "./config/content"; import editModalConfig from "./config/edit"; import searchConfig from "./config/search"; import { returnOptionsLabel } from "./config/config"; +import { isSyncStatus } from "@/utils/index"; + const router = useRouter(); const { searchRef, @@ -122,6 +126,15 @@ if (conName) { } } +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.toolbar[1].hidden = false +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.toolbar[1].hidden = true +} + + //统计数据 const gongjiData = reactive({ totalRow: 0 }); function getTongji(params: IObject | undefined) { @@ -189,8 +202,13 @@ async function handleEditClick(row: IObject) { editModalRef.value?.setFormData({ ...row, url: [row.url] }); } // 其他工具栏 -function handleToolbarClick(name: string) { +async function handleToolbarClick(name: string) { console.log(name); + if (name === 'sync') { + let res = await UserAPI.sync() + ElMessage.success('操作成功,数据正在后台同步中...') + return; + } if (name === "category") { router.push({ path: "/inventory/classification" }); return; diff --git a/src/views/inventory/supplier/config/content.ts b/src/views/inventory/supplier/config/content.ts index 81ac465..f2c3d1d 100644 --- a/src/views/inventory/supplier/config/content.ts +++ b/src/views/inventory/supplier/config/content.ts @@ -23,7 +23,15 @@ const contentConfig: IContentConfig = { return Api.edit(data); }, pk: "id", - toolbar: ["add"], + toolbar: [ + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, + ], defaultToolbar: ["refresh", "filter", "search"], cols: [ // { type: "selection", width: 50, align: "center" }, @@ -71,7 +79,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: ["edit", "delete"], + operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}], }, ], }; diff --git a/src/views/inventory/supplier/index.vue b/src/views/inventory/supplier/index.vue index 565a1ea..990c84a 100644 --- a/src/views/inventory/supplier/index.vue +++ b/src/views/inventory/supplier/index.vue @@ -71,6 +71,7 @@ import contentConfig from "./config/content"; import editModalConfig from "./config/edit"; import searchConfig from "./config/search"; import { returnOptionsLabel } from "./config/config"; +import { isSyncStatus } from "@/utils/index"; const { searchRef, @@ -87,6 +88,16 @@ const { handleFilterChange, } = usePage(); +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = true +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false +} + // 新增 async function handleAddClick() { addModalRef.value?.setModalVisible(); diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 5b1a3f2..43b9beb 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -172,7 +172,8 @@ function handleLogin() { setDouyinToken(checkInfo.userInfo.token); }); localStorage.removeItem("shopName") - + let resData = await $API_login.getPermission() + localStorage.setItem("permission",JSON.stringify(resData)) const { path, queryParams } = parseRedirect(); console.log(path, queryParams); diff --git a/src/views/online-shop/goods-group.vue b/src/views/online-shop/goods-group.vue index 9e8e0b6..6ffa921 100644 --- a/src/views/online-shop/goods-group.vue +++ b/src/views/online-shop/goods-group.vue @@ -176,6 +176,8 @@ import searchConfig from "./goodsGroupconfig/search"; import searchConfig2 from "./goodsGroupconfig/search2"; import myDialog from '@/components/mycomponents/myDialog.vue' import selectGoodslist from "./goodsGroupconfig/selectGoodslist.vue" +import { isSyncStatus } from "@/utils/index"; + const { searchRef, searchRefs, @@ -194,6 +196,18 @@ const { handleFilterChange, } = usePage(); +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = true + contentConfig.cols[3].templet = "custom" +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.cols[3].templet = "switch" + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false +} + let switchref = ref(false) // 新增 diff --git a/src/views/online-shop/goodsGroupconfig/content.ts b/src/views/online-shop/goodsGroupconfig/content.ts index d17c42e..5d7d7c1 100644 --- a/src/views/online-shop/goodsGroupconfig/content.ts +++ b/src/views/online-shop/goodsGroupconfig/content.ts @@ -73,7 +73,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: ["edit", "delete"], + operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}], }, ], }; diff --git a/src/views/product/category.vue b/src/views/product/category.vue index 6546862..0666d76 100644 --- a/src/views/product/category.vue +++ b/src/views/product/category.vue @@ -95,6 +95,7 @@ import contentConfig from "./categoryconfig/content"; import contentConfig2 from "./categoryconfig/content2"; import editModalConfig from "./categoryconfig/edit"; import searchConfig from "./categoryconfig/search"; +import { isSyncStatus } from "@/utils/index"; const { searchRef, @@ -111,6 +112,17 @@ const { handleFilterChange, } = usePage(); +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = true + contentConfig.cols[2].templet = "custom" +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.cols[2].templet = "switch" + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false +} // 新增 async function handleAddClick() { addModalRef.value?.setModalVisible(); diff --git a/src/views/product/categoryconfig/content.ts b/src/views/product/categoryconfig/content.ts index 4740b7a..a563187 100644 --- a/src/views/product/categoryconfig/content.ts +++ b/src/views/product/categoryconfig/content.ts @@ -44,7 +44,15 @@ const contentConfig: IContentConfig = { // return res.list; // }, pk: "id", - toolbar: ["add"], + toolbar: [ + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, + ], cols: [ // { type: "selection", width: 50, align: "center" }, { label: "分类名称", align: "center", prop: "name" }, @@ -68,7 +76,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: ["edit", "delete"], + operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}], }, ], }; diff --git a/src/views/product/index.vue b/src/views/product/index.vue index f700cab..60b0a14 100644 --- a/src/views/product/index.vue +++ b/src/views/product/index.vue @@ -200,17 +200,15 @@ let datas = reactive({ remark: "", images: [] }); + if (isSyncStatus()) { - if( JSON.stringify(contentConfig.toolbar)?.indexOf("add") != -1){ - contentConfig.toolbar?.splice(0, 1) - } - if( JSON.stringify(contentConfig.cols[contentConfig.cols.length-1].operat)?.indexOf("delete") != -1){ - contentConfig.cols[contentConfig.cols.length-1].operat?.splice(2, 1) - } -}else { - if( JSON.stringify(contentConfig.toolbar)?.indexOf("custom2") != -1){ - contentConfig.toolbar?.splice(1, 1) - } + contentConfig.toolbar[0].hidden = true + contentConfig.toolbar[1].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = true +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.toolbar[1].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[2].hidden = false } onMounted(() => { @@ -220,7 +218,7 @@ onMounted(() => { } // 获取耗材列表 gethaocaiList() - + }); function newHandleQueryClick(e: IObject | undefined) { const filterParams = contentRef.value?.getFilterParams(); @@ -324,14 +322,13 @@ async function handleEditClick(row: IObject) { // 其他工具栏 async function handleToolbarClick(name: string) { console.log(name); - if ( name === "custom1" ) { + if (name === "custom1") { // ElMessage.success("点击了自定义1按钮"); myDialogRef.value.open(); } - if ( name === "custom2" ) { //商品同步 + if (name === "sync") { //商品同步 let res = await UserAPI.sync() ElMessage.success('操作成功,数据正在后台同步中...') - console.log(res) } } async function confirm() { diff --git a/src/views/product/indexconfig/SpecificationAttribute.vue b/src/views/product/indexconfig/SpecificationAttribute.vue index 2b1b71f..a5ce69b 100644 --- a/src/views/product/indexconfig/SpecificationAttribute.vue +++ b/src/views/product/indexconfig/SpecificationAttribute.vue @@ -14,7 +14,7 @@ @@ -26,7 +26,7 @@ @@ -38,7 +38,7 @@ @@ -51,7 +51,7 @@ @@ -64,9 +64,9 @@ @@ -77,7 +77,7 @@ + controls-position="right" style="width: 100%" :disabled="isSyncStatus()"> \ No newline at end of file + diff --git a/src/views/product/indexconfig/addgoods.vue b/src/views/product/indexconfig/addgoods.vue index 8951c69..25139c0 100644 --- a/src/views/product/indexconfig/addgoods.vue +++ b/src/views/product/indexconfig/addgoods.vue @@ -4,21 +4,21 @@ - + - + - + @@ -27,7 +27,7 @@ - + @@ -54,7 +54,7 @@ - + 单规格商品 多规格商品 套餐商品 @@ -65,7 +65,7 @@
- + 固定套餐 可选套餐 @@ -82,13 +82,13 @@ @@ -97,13 +97,13 @@
- + - + - 删除 + 删除
@@ -113,29 +113,29 @@
- 添加套餐组 + 添加套餐组
- + @@ -157,7 +157,7 @@
- + @@ -165,7 +165,7 @@ - + 允许 不允许 @@ -198,7 +198,7 @@
- +
注:关闭则不计算出入库数据
@@ -211,7 +211,7 @@
- +
单份商品打包费。注:店铺开启外卖模式下该数据才生效
@@ -251,6 +251,7 @@ import { reactive, ref } from 'vue' import type { FormInstance, FormRules } from 'element-plus' // 规格属性 import SpecificationAttribute from './SpecificationAttribute.vue' +import { isSyncStatus } from "@/utils/index"; import UserAPI from "@/api/product/productclassification"; import UserAPI2 from "@/api/product/commonUnits"; import UserAPI3 from "@/api/product/index"; @@ -492,6 +493,10 @@ function selectSkuHandle(item: any, index: number) { // } } function addimgEvent() { + if( isSyncStatus() ){ + ElMessage.error('当前同步启用状态下不可修改') + return + } (addImg.value as any)?.show() } // 确认套餐商品设置规格 @@ -521,6 +526,10 @@ function addgoods(index: number = -1) { (shopListRef.value as any)?.opens() } function deleteEvent(d: any) { + if( isSyncStatus() ){ + ElMessage.error('当前同步启用状态下不可修改') + return + } let index = ruleForm.images.findIndex((ele) => ele == d); ruleForm.images.splice(index, 1); } @@ -915,4 +924,4 @@ const resetForm = (formEl: FormInstance | undefined) => { top: -10px; z-index: 10; } - \ No newline at end of file + diff --git a/src/views/product/indexconfig/content.ts b/src/views/product/indexconfig/content.ts index 9598603..af20a78 100644 --- a/src/views/product/indexconfig/content.ts +++ b/src/views/product/indexconfig/content.ts @@ -58,12 +58,18 @@ const contentConfig: IContentConfig = { }, pk: "id", toolbar: [ - "add", + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, { icon: "refresh", text: "同步", type: "danger", - name: "custom2", + name: "sync", auth: "import", }, { @@ -114,7 +120,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: [{ text: "报损" }, "edit", "delete"], + operat: [{ text: "报损", name: ''}, { text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}], }, ], }; diff --git a/src/views/product/specifications.vue b/src/views/product/specifications.vue index 6f9ae41..f907128 100644 --- a/src/views/product/specifications.vue +++ b/src/views/product/specifications.vue @@ -29,10 +29,10 @@ @@ -123,6 +123,8 @@ import contentConfig2 from "./specificationsconfig/content2"; import editModalConfig from "./specificationsconfig/edit"; import searchConfig from "./specificationsconfig/search"; import { pid } from "process"; +import { isSyncStatus } from "@/utils/index"; + const validateSku1 = (rule, value, callback) => { if (!datas.skuForm.label) { callback(new Error(' ')) @@ -190,6 +192,12 @@ let datas = reactive({ addchilderinfo: {} }) let myDialogRef = ref(null) +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true +} else { + contentConfig.toolbar[0].hidden = false +} + function subitgood() { skuForm.value.validate(async valid => { if (valid) { @@ -381,4 +389,4 @@ const isA = ref(true); margin-left: 10px; vertical-align: bottom; } - \ No newline at end of file + diff --git a/src/views/product/specificationsconfig/content.ts b/src/views/product/specificationsconfig/content.ts index ebdba47..a3e646e 100644 --- a/src/views/product/specificationsconfig/content.ts +++ b/src/views/product/specificationsconfig/content.ts @@ -41,7 +41,13 @@ const contentConfig: IContentConfig = { // }, pk: "id", toolbar: [ - "add", + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, ], cols: [ // { type: "selection", width: 50, align: "center" }, diff --git a/src/views/product/unit.vue b/src/views/product/unit.vue index e545093..0118650 100644 --- a/src/views/product/unit.vue +++ b/src/views/product/unit.vue @@ -61,6 +61,7 @@ import contentConfig from "./unitconfig/content"; import contentConfig2 from "./unitconfig/content2"; import editModalConfig from "./unitconfig/edit"; import searchConfig from "./unitconfig/search"; +import { isSyncStatus } from "@/utils/index"; const { searchRef, @@ -77,6 +78,16 @@ const { handleFilterChange, } = usePage(); +if (isSyncStatus()) { + contentConfig.toolbar[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = true + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = true +} else { + contentConfig.toolbar[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[0].hidden = false + contentConfig.cols[contentConfig.cols.length - 1].operat[1].hidden = false +} + // 新增 async function handleAddClick() { addModalRef.value?.setModalVisible(); diff --git a/src/views/product/unitconfig/content.ts b/src/views/product/unitconfig/content.ts index 035d12a..0a5c63c 100644 --- a/src/views/product/unitconfig/content.ts +++ b/src/views/product/unitconfig/content.ts @@ -38,7 +38,13 @@ const contentConfig: IContentConfig = { }, pk: "id", toolbar: [ - "add", + { + icon: "plus", + text: "新增", + type: "primary", + name: "add", + auth: "import", + }, ], cols: [ // { type: "selection", width: 50, align: "center" }, @@ -50,7 +56,7 @@ const contentConfig: IContentConfig = { fixed: "right", width: 280, templet: "tool", - operat: ["edit", "delete"], + operat: [{ text: "编辑", icon: 'edit', name: "edit"}, { text: "删除", icon: 'delete', type: 'danger', name: "delete"}], }, ], };