添加按钮权限

This commit is contained in:
ctw committed 2025-01-19 13:37:13 +08:00
1 parent 0fa67d4d02
commit 1beb70d4aa
9 files changed
+239 -143

No files matched your search

+70 -36
View File
@@ -7,17 +7,32 @@
<el-input placeholder="请输入分类名称" v-model="state.queryForm.name" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
<el-button icon="search" type="primary" @click="getDataList" v-auth="'canteen_canteenCategory_view'">
查询
</el-button>
<el-button icon="Refresh" @click="resetQuery" v-auth="'canteen_canteenCategory_view'">重置</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'canteen_canteenCategory_add'">
<el-button
icon="folder-add"
type="primary"
class="ml10"
@click="formDialogRef.openDialog()"
v-auth="'canteen_canteenCategory_add'"
>
新 增
</el-button>
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'canteen_canteenCategory_del'" @click="handleDelete(selectObjs)">
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'canteen_canteenCategory_del'"
@click="handleDelete(selectObjs)"
>
删 除
</el-button>
<right-toolbar
@@ -27,7 +42,7 @@
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
/>
</div>
</el-row>
<el-table
@@ -57,10 +72,24 @@
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip min-width="160" />
<el-table-column label="操作" width="150" fixed="right">
<template #default="scope">
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenCategory_edit'" @click="formDialogRef.openDialog(scope.row.id)">
<el-button
icon="edit-pen"
text
type="primary"
v-auth="'canteen_canteenCategory_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
>
编辑
</el-button>
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenCategory_del'" @click="handleDelete([scope.row.id])">删除</el-button>
<el-button
icon="delete"
text
type="primary"
v-auth="'canteen_canteenCategory_del'"
@click="handleDelete([scope.row.id])"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
@@ -73,66 +102,71 @@
</template>
<script setup lang="ts" name="systemCanteenCategory">
import { BasicTableProps, useTable } from '/@/hooks/table';
import { fetchList, delObjs } from '/@/api/canteen/canteenCategory';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { useDict } from '/@/hooks/dict';
import { BasicTableProps, useTable } from "/@/hooks/table"
import { fetchList, delObjs } from "/@/api/canteen/canteenCategory"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
const { daily_menu } = useDict('daily_menu');
const { daily_menu } = useDict("daily_menu")
// 定义变量内容
const formDialogRef = ref();
const formDialogRef = ref()
// 搜索变量
const queryRef = ref();
const showSearch = ref(true);
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any;
const multiple = ref(true);
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList,
});
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields();
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = [];
getDataList();
};
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile('/canteen/canteenCategory/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenCategory.xlsx');
};
downBlobFile(
"/canteen/canteenCategory/export",
Object.assign(state.queryForm, { ids: selectObjs }),
"canteenCategory.xlsx",
)
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id);
multiple.value = !objs.length;
};
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除');
await useMessageBox().confirm("此操作将永久删除")
} catch {
return;
return
}
try {
await delObjs(ids);
getDataList();
useMessage().success('删除成功');
await delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg);
useMessage().error(err.msg)
}
};
}
</script>
@@ -85,6 +85,7 @@ import { getAllSimple as getCanteenCategory } from "/@/api/canteen/canteenCatego
import { useMessage } from "/@/hooks/message"
import { pageJoin } from "/@/api/wallet/mch-manage"
import { displayPrice } from "/@/utils/formatMoney"
import { auth } from "/@/utils/authFunction"
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH
@@ -110,6 +111,7 @@ const merchantId = ref() // 商户Id
const merchantInfo = ref<any>([])
const addFood = async (hourType: number) => {
if (!auth("canteen_canteenDailyMenu_add")) return
if (!merchantId.value) {
useMessage().error("请选择商户再进行新增")
return
@@ -182,6 +184,7 @@ const selectTimeFood = async () => {
// 删除菜品
const delteData = async (tid: number) => {
if (!auth("canteen_canteenDailyMenu_del")) return
ElMessageBox.confirm("确定删除菜品吗?", "删除菜品", {
confirmButtonText: "确定",
cancelButtonText: "取消",
@@ -7,14 +7,22 @@
<el-input placeholder="请输入分类名称" v-model="state.queryForm.name" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
<el-button icon="search" type="primary" @click="getDataList" v-auth="'canteen_canteenOnlineCategory_view'">
查询
</el-button>
<el-button icon="Refresh" @click="resetQuery" v-auth="'canteen_canteenOnlineCategory_view'">重置</el-button>
</el-form-item>
</el-form>
</el-row>
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'canteen_canteenOnlineCategory_add'">
<el-button
icon="folder-add"
type="primary"
class="ml10"
@click="formDialogRef.openDialog()"
v-auth="'canteen_canteenOnlineCategory_add'"
>
新 增
</el-button>
<el-button
@@ -34,7 +42,7 @@
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
/>
</div>
</el-row>
<el-table
@@ -67,7 +75,13 @@
>
编辑
</el-button>
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenOnlineCategory_del'" @click="handleDelete([scope.row.id])">
<el-button
icon="delete"
text
type="primary"
v-auth="'canteen_canteenOnlineCategory_del'"
@click="handleDelete([scope.row.id])"
>
删除
</el-button>
</template>
@@ -82,64 +96,69 @@
</template>
<script setup lang="ts" name="systemCanteenOnlineCategory">
import { BasicTableProps, useTable } from '/@/hooks/table';
import { fetchList, delObjs } from '/@/api/canteen/canteenOnlineCategory';
import { useMessage, useMessageBox } from '/@/hooks/message';
import { BasicTableProps, useTable } from "/@/hooks/table"
import { fetchList, delObjs } from "/@/api/canteen/canteenOnlineCategory"
import { useMessage, useMessageBox } from "/@/hooks/message"
// 引入组件
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义变量内容
const formDialogRef = ref();
const formDialogRef = ref()
// 搜索变量
const queryRef = ref();
const showSearch = ref(true);
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any;
const multiple = ref(true);
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: fetchList,
});
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } =
useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields();
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = [];
getDataList();
};
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile('/canteen/canteenOnlineCategory/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenOnlineCategory.xlsx');
};
downBlobFile(
"/canteen/canteenOnlineCategory/export",
Object.assign(state.queryForm, { ids: selectObjs }),
"canteenOnlineCategory.xlsx",
)
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id);
multiple.value = !objs.length;
};
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm('此操作将永久删除');
await useMessageBox().confirm("此操作将永久删除")
} catch {
return;
return
}
try {
await delObjs(ids);
getDataList();
useMessage().success('删除成功');
await delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg);
useMessage().error(err.msg)
}
};
}
</script>
+5 -3
View File
@@ -10,8 +10,10 @@
<select-ctcgol v-model="state.queryForm.categoryId" style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
<el-button icon="search" type="primary" @click="getDataList" v-auth="'canteen_canteenOnlineSpu_view'">
查询
</el-button>
<el-button icon="Refresh" @click="resetQuery" v-auth="'canteen_canteenOnlineSpu_view'">重置</el-button>
</el-form-item>
</el-form>
</el-row>
@@ -43,7 +45,7 @@
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
/>
</div>
</el-row>
<el-table
+6 -3
View File
@@ -10,8 +10,10 @@
<select-ctcg v-model="state.queryForm.categoryId" style="width: 200px" />
</el-form-item>
<el-form-item>
<el-button icon="search" type="primary" @click="getDataList">查询</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
<el-button icon="search" type="primary" @click="getDataList" v-auth="'canteen_canteenSpu_view'">
查询
</el-button>
<el-button icon="Refresh" @click="resetQuery" v-auth="'canteen_canteenSpu_view'">重置</el-button>
</el-form-item>
</el-form>
</el-row>
@@ -108,8 +110,9 @@
type="primary"
v-auth="'canteen_canteenSpu_del'"
@click="handleDelete([scope.row.id])"
>删除</el-button
>
删除
</el-button>
</template>
</el-table-column>
</el-table>