每日菜谱修改,商户引入
This commit is contained in:
1 parent
aea4f8d23a
commit
a912f3006a
9 files changed
+604
-32
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/admin/foodToday/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/admin/foodToday',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/admin/foodToday/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/admin/foodToday',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/admin/foodToday',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function selectFoodList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectFoodList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
//时间生成
|
||||
export function selectWeekInfo(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectWeekInfo',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// //获取当前选中的菜品信息
|
||||
export function selectTimeFoodApi(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenDailyMenu/selectTimeFood',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
@@ -40,11 +40,3 @@ export function putObj(obj?: Object) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function selectFoodList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/canteenSpu/selectFoodList',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function fetchList(query?: Object) {
|
||||
return request({
|
||||
url: '/canteen/merchantInfo/page',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/merchantInfo',
|
||||
method: 'post',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
export function getObj(id?: string) {
|
||||
return request({
|
||||
url: '/canteen/merchantInfo/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function delObjs(ids?: Object) {
|
||||
return request({
|
||||
url: '/canteen/merchantInfo',
|
||||
method: 'delete',
|
||||
data: ids
|
||||
})
|
||||
}
|
||||
|
||||
export function putObj(obj?: Object) {
|
||||
return request({
|
||||
url: '/canteen/merchantInfo',
|
||||
method: 'put',
|
||||
data: obj
|
||||
})
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ interface MessageImplements {
|
||||
warning(title: string): void;
|
||||
success(title: string): void;
|
||||
error(title: string): void;
|
||||
delConfirm(content?: string, tip?: string): void;
|
||||
}
|
||||
|
||||
export function useMessage() {
|
||||
@@ -54,6 +55,18 @@ export function useMessage() {
|
||||
duration: 2000, // 错误提示显示时间延长到5秒
|
||||
});
|
||||
}
|
||||
|
||||
delConfirm(content?: string, tip?: string) {
|
||||
return ElMessageBox.confirm(
|
||||
content ? content : t('common.delMessage'),
|
||||
tip ? tip : t('common.confirmTitle'),
|
||||
{
|
||||
confirmButtonText: t('common.ok'),
|
||||
cancelButtonText: t('common.cancel'),
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return new MessageClass();
|
||||
@@ -97,6 +110,19 @@ export function useMessageBox() {
|
||||
type: 'warning',
|
||||
});
|
||||
}
|
||||
|
||||
// 删除窗体
|
||||
delConfirm(content?: string, tip?: string) {
|
||||
return ElMessageBox.confirm(
|
||||
content ? content : t('common.delMessage'),
|
||||
tip ? tip : t('common.confirmTitle'),
|
||||
{
|
||||
confirmButtonText: t('common.ok'),
|
||||
cancelButtonText: t('common.cancel'),
|
||||
type: 'warning'
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return new MessageBoxClass();
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
import {useDict} from '/@/hooks/dict';
|
||||
import {useMessage} from "/@/hooks/message";
|
||||
import {getObj, addObj, putObj} from '/@/api/canteen/canteenDailyMenu'
|
||||
import {selectFoodList} from "/@/api/canteen/canteenSpu";
|
||||
import {selectFoodList} from "/@/api/canteen/canteenDailyMenu";
|
||||
import {rule} from '/@/utils/validate';
|
||||
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<!-- <el-select-->
|
||||
<!-- v-model="merchantId"-->
|
||||
<!-- placeholder="请选择商户"-->
|
||||
<!-- size="large"-->
|
||||
<!-- style="width: 240px; display: inline-block"-->
|
||||
<!-- :disabled="merchantStatus"-->
|
||||
<!-- @change="merchantSelect"-->
|
||||
<!-- >-->
|
||||
<!-- <el-option v-for="item in merchantInfo" :key="item.id" :label="item.name" :value="item.id" />-->
|
||||
<!-- </el-select>-->
|
||||
<div style="margin-left: 4.5%;margin-top: 1.5%">
|
||||
<el-select
|
||||
v-model="merchantId"
|
||||
placeholder="请选择商户"
|
||||
size="large"
|
||||
style="width: 240px; display: inline-block"
|
||||
:disabled="merchantStatus"
|
||||
@change="merchantSelect"
|
||||
>
|
||||
<el-option v-for="item in merchantInfo" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
<h1 class="title">今日菜谱</h1>
|
||||
</div>
|
||||
<table width="100%" class="titleTable">
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
<script setup lang="ts" name="systemCanteenDailyMenu">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs } from "/@/api/canteen/canteenDailyMenu";
|
||||
import { fetchList, delObjs ,selectTimeFoodApi,selectWeekInfo,} from "/@/api/canteen/canteenDailyMenu";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
|
||||
@@ -72,10 +72,12 @@ const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
const list = ref([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchList
|
||||
@@ -151,7 +153,9 @@ const addClick = async (index: number) => {
|
||||
}
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
weekData.data = await TodayApi.selectWeekInfo(weekParams)
|
||||
let weekDataRes= await selectWeekInfo(weekParams);
|
||||
console.log(weekDataRes)
|
||||
weekData.data = weekDataRes.data
|
||||
isActive.value = 0
|
||||
timedata = weekData.data[0]
|
||||
//时间格式
|
||||
@@ -175,8 +179,8 @@ const selectTimeFood = async () => {
|
||||
}
|
||||
//最大长度
|
||||
let count = 0
|
||||
const result = await TodayApi.selectTimeFood(params)
|
||||
result.forEach((r) => {
|
||||
const result = await selectTimeFoodApi(params)
|
||||
result.data.forEach((r) => {
|
||||
if (r.dailyMenuVOS.length > count) {
|
||||
count = r.dailyMenuVOS.length
|
||||
}
|
||||
@@ -206,8 +210,8 @@ const selectTimeFood = async () => {
|
||||
const delteData = async (tid: number) => {
|
||||
try {
|
||||
await message.delConfirm('确定删除菜品吗?')
|
||||
await TodayApi.deleteToday(tid)
|
||||
message.success(t('common.delSuccess'))
|
||||
await delObjs(tid)
|
||||
message.success(('common.delSuccess'))
|
||||
selectTimeFood()
|
||||
} catch {}
|
||||
}
|
||||
@@ -221,10 +225,6 @@ const resetQuery = () => {
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/canteen/canteenDailyMenu/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenDailyMenu.xlsx')
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
@@ -247,5 +247,105 @@ const handleDelete = async (ids: string[]) => {
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
/** 查询列表 */
|
||||
// const getList = async () => {
|
||||
// loading.value = true
|
||||
// try {
|
||||
// const data = await fetchData(queryParams)
|
||||
// list.value = data.list
|
||||
// total.value = data.total
|
||||
// } finally {
|
||||
// loading.value = false
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 初始化下拉框 */
|
||||
const merchantInit = async () => {
|
||||
// 获取下拉框
|
||||
// merchantInfo.value = await ManageApi.selectMerchantList()
|
||||
// //默认选中第一个
|
||||
// if (merchantInfo.value) {
|
||||
// merchantId.value = merchantInfo.value[0].id
|
||||
// if (merchantInfo.value.length > 1) {
|
||||
// merchantStatus.value = false
|
||||
// }
|
||||
// getList()
|
||||
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
// merchantInit()
|
||||
})
|
||||
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.title {
|
||||
font-size: 28px;
|
||||
display: inline-block;
|
||||
margin-left: 25%;
|
||||
}
|
||||
|
||||
.titleTable {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
margin-top: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tdclass {
|
||||
border: 1px solid rgb(233, 233, 233);
|
||||
width: 13%;
|
||||
height: 36px;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.trclass > td:first-child {
|
||||
text-align: center;
|
||||
}
|
||||
.trclass > td:last-child {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.foodTable {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.food td {
|
||||
width: 250px;
|
||||
height: 200px;
|
||||
display: inline-block;
|
||||
background-color: white;
|
||||
margin-left: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.imageCss {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.food td:first-child {
|
||||
width: 60px;
|
||||
height: 200px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 4%;
|
||||
background-color: transparent;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
// text-decoration: blue underline;
|
||||
color: rgb(0, 118, 228);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dataDiv {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.selectedSpan {
|
||||
border: 1px solid rgb(255, 187, 0);
|
||||
color: rgb(255, 187, 0);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,180 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible"
|
||||
:close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="绑定部门" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="form.deptId"
|
||||
:data="parentData"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
class="w100"
|
||||
clearable
|
||||
check-strictly
|
||||
:render-after-expand="false"
|
||||
placeholder="请选择要绑定的部门"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户名" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入商户名"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户类型" prop="merchantType">
|
||||
<el-radio-group v-model="form.merchantType">
|
||||
<el-radio :label="item.value" v-for="(item, index) in merchant_type" border :key="index">{{ item.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户logog" prop="logo">
|
||||
<upload-img v-model="form.logo"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="商户收款二维码" prop="collectMoneyCode">
|
||||
<upload-img v-model="form.collectMoneyCode"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="轮播图" prop="swiper">
|
||||
<upload-img v-model="form.swiper"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入联系电话"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="营业时间" prop="businessTime">
|
||||
<el-input v-model="form.businessTime" placeholder="请输入结束营业时间"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="店铺地址" prop="address">
|
||||
<el-input type="textarea" v-model="form.address" placeholder="请输入店铺地址"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="MerchantInfoDialog">
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { useMessage } from "/@/hooks/message";
|
||||
import { getObj, addObj, putObj } from '/@/api/canteen/merchantInfo'
|
||||
import { rule } from '/@/utils/validate';
|
||||
import {deptTree} from "/@/api/admin/dept";
|
||||
const emit = defineEmits(['refresh']);
|
||||
|
||||
// 定义变量内容
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
//定义业务变量内容
|
||||
const parentData = ref<any[]>([]);
|
||||
// 定义字典
|
||||
const { merchant_type } = useDict('merchant_type')
|
||||
|
||||
// 提交表单数据
|
||||
const form = reactive({
|
||||
id:'',
|
||||
deptId: '',
|
||||
name: '',
|
||||
merchantType: '',
|
||||
logo: '',
|
||||
collectMoneyCode: '',
|
||||
swiper: '',
|
||||
phone: '',
|
||||
businessTime: '',
|
||||
address: '',
|
||||
});
|
||||
|
||||
// 定义校验规则
|
||||
const dataRules = ref({
|
||||
name: [{required: true, message: '商户名不能为空', trigger: 'blur'}],
|
||||
merchantType: [{required: true, message: '商户类型(字典,1食堂 2超时)不能为空', trigger: 'blur'}],
|
||||
logo: [{required: true, message: '商户logog不能为空', trigger: 'blur'}],
|
||||
swiper: [{required: true, message: '轮播图不能为空', trigger: 'blur'}],
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
visible.value = true
|
||||
form.id = ''
|
||||
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
});
|
||||
|
||||
// 获取merchantInfo信息
|
||||
if (id) {
|
||||
form.id = id
|
||||
getmerchantInfoData(id)
|
||||
}
|
||||
getDeptData()
|
||||
};
|
||||
|
||||
// 提交
|
||||
const onSubmit = async () => {
|
||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||
if (!valid) return false;
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
form.id ? await putObj(form) : await addObj(form);
|
||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||
visible.value = false;
|
||||
emit('refresh');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 初始化表单数据
|
||||
const getmerchantInfoData = (id: string) => {
|
||||
// 获取数据
|
||||
loading.value = true
|
||||
getObj(id).then((res: any) => {
|
||||
Object.assign(form, res.data)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
};
|
||||
|
||||
// 暴露变量
|
||||
defineExpose({
|
||||
openDialog
|
||||
});
|
||||
// 从后端获取菜单信息
|
||||
const getDeptData = async () => {
|
||||
deptTree().then((res) => {
|
||||
parentData.value=res.data;
|
||||
});
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<el-row>
|
||||
<div class="mb8" style="width: 100%">
|
||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||
v-auth="'canteen_merchantInfo_add'">
|
||||
新 增
|
||||
</el-button>
|
||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||
v-auth="'canteen_merchantInfo_del'" @click="handleDelete(selectObjs)">
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_merchantInfo_export'"
|
||||
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
||||
@queryTable="getDataList"></right-toolbar>
|
||||
</div>
|
||||
</el-row>
|
||||
<el-table :data="state.dataList" v-loading="state.loading" border
|
||||
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||
@selection-change="selectionChangHandle"
|
||||
@sort-change="sortChangeHandle">
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="deptName" label="部门" show-overflow-tooltip/>
|
||||
<el-table-column prop="name" label="商户名" show-overflow-tooltip/>
|
||||
<el-table-column prop="merchantType" label="商户类型" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="merchant_type" :value="scope.row.merchantType"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="logo" label="商户logog" show-overflow-tooltip/>
|
||||
<el-table-column prop="collectMoneyCode" label="商户收款二维码" show-overflow-tooltip/>
|
||||
<el-table-column prop="phone" label="联系电话" show-overflow-tooltip/>
|
||||
<el-table-column prop="businessTime" label="结束营业时间" show-overflow-tooltip/>
|
||||
<el-table-column prop="address" label="店铺地址" show-overflow-tooltip/>
|
||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip/>
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_merchantInfo_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'canteen_merchantInfo_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</div>
|
||||
|
||||
<!-- 编辑、新增 -->
|
||||
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemMerchantInfo">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs } from "/@/api/canteen/merchantInfo";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
// 定义查询字典
|
||||
|
||||
const { merchant_type } = useDict('merchant_type')
|
||||
// 定义变量内容
|
||||
const formDialogRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = 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 resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile('/canteen/merchantInfo/export', Object.assign(state.queryForm, { ids: selectObjs }), 'merchantInfo.xlsx')
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id);
|
||||
multiple.value = !objs.length;
|
||||
};
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm('此操作将永久删除');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids);
|
||||
getDataList();
|
||||
useMessage().success('删除成功');
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in new issue
Block a user