Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7fbce0d390
4 files changed
+243
-233
No files matched your search
@@ -11,5 +11,8 @@ ENV = 'development'
|
|||||||
VITE_ADMIN_PROXY_PATH = http://localhost:9999
|
VITE_ADMIN_PROXY_PATH = http://localhost:9999
|
||||||
#VITE_ADMIN_PROXY_PATH = http://192.168.110.156:9999
|
#VITE_ADMIN_PROXY_PATH = http://192.168.110.156:9999
|
||||||
|
|
||||||
|
# 图片访问基础地址
|
||||||
|
VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api
|
||||||
|
|
||||||
# 代码生成服务地址
|
# 代码生成服务地址
|
||||||
VITE_GEN_PROXY_PATH = http://192.168.110.156:5003
|
VITE_GEN_PROXY_PATH = http://192.168.110.156:5003
|
||||||
@@ -69,6 +69,7 @@ const dialogVisible = ref(false);
|
|||||||
const elUploadRef = ref();
|
const elUploadRef = ref();
|
||||||
// 获取 el-form 组件上下文
|
// 获取 el-form 组件上下文
|
||||||
const formContext = inject(formContextKey, void 0);
|
const formContext = inject(formContextKey, void 0);
|
||||||
|
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||||
|
|
||||||
// 上传
|
// 上传
|
||||||
const handleHttpUpload = async (options: UploadRequestOptions) => {
|
const handleHttpUpload = async (options: UploadRequestOptions) => {
|
||||||
@@ -99,7 +100,7 @@ const handleRemove = (uploadFile: any, uploadFiles: any[]) => {
|
|||||||
|
|
||||||
// 预览
|
// 预览
|
||||||
const handlePictureCardPreview = (uploadFile: any) => {
|
const handlePictureCardPreview = (uploadFile: any) => {
|
||||||
dialogImageUrl.value = 'http://123.156.230.15:8089/api' + uploadFile.response.data.url;
|
dialogImageUrl.value = imageBaseUrl + uploadFile.response.data.url;
|
||||||
dialogVisible.value = true;
|
dialogVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,159 +1,161 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible"
|
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
|
||||||
:close-on-click-modal="false" draggable>
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
<el-form-item label="日期" prop="hourType">
|
||||||
<!-- <el-row :gutter="24">-->
|
<p>{{ form.startTime }}</p>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="日期" prop="hourType">
|
<el-form-item label="时间" prop="hourType">
|
||||||
<p>{{ form.startTime }}</p>
|
<p v-if="form.hourType == 1">早餐</p>
|
||||||
</el-form-item>
|
<p v-else-if="form.hourType == 2">午餐</p>
|
||||||
|
<p v-else-if="form.hourType == 3">晚餐</p>
|
||||||
|
<p v-else>未知类型</p>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="时间" prop="hourType">
|
<el-form-item label="菜品" prop="spuId">
|
||||||
<p v-if="form.hourType == 1">早餐</p>
|
<el-select v-model="spuIds" placeholder="请选择菜品" multiple>
|
||||||
<p v-else-if="form.hourType == 2">午餐</p>
|
<el-option v-for="item in foodData" :key="item.id" :label="item.name" :value="item.id" />
|
||||||
<p v-else-if="form.hourType == 3">晚餐</p>
|
</el-select>
|
||||||
<p v-else>未知类型</p>
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
|
|
||||||
<el-form-item label="菜品" prop="spuId">
|
<!-- <el-col :span="12" class="mb20">
|
||||||
<el-select v-model="spuIds" placeholder="请选择菜品" multiple>
|
<el-form-item label="归属时间 1早餐 2午餐 3晚餐" prop="hourType">
|
||||||
<el-option v-for="item in foodData" :key="item.id" :label="item.name" :value="item.id"/>
|
<el-input v-model="form.hourType" placeholder="请输入归属时间 1早餐 2午餐 3晚餐" />
|
||||||
</el-select>
|
</el-form-item>
|
||||||
</el-form-item>
|
</el-col> -->
|
||||||
|
</el-form>
|
||||||
|
|
||||||
<!-- <el-col :span="12" class="mb20">
|
<h1 style="font-size: 16px; font-weight: bold; color: #000000; margin: 20px 0">预览图</h1>
|
||||||
<el-form-item label="归属时间 1早餐 2午餐 3晚餐" prop="hourType">
|
<div style="width: 100%; display: flex; flex-wrap: wrap">
|
||||||
<el-input v-model="form.hourType" placeholder="请输入归属时间 1早餐 2午餐 3晚餐"/>
|
<img style="width: 250px; height: 200px; margin: 10px" v-for="(image, index) in spuImages" :key="index" :src="image" />
|
||||||
</el-form-item>
|
</div>
|
||||||
</el-col>-->
|
|
||||||
<!-- </el-row>-->
|
<template #footer>
|
||||||
</el-form>
|
<span class="dialog-footer">
|
||||||
<template #footer>
|
<el-button @click="visible = false">取消</el-button>
|
||||||
<span class="dialog-footer">
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||||
<el-button @click="visible = false">取消</el-button>
|
</span>
|
||||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
</template>
|
||||||
</span>
|
</el-dialog>
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="CanteenDailyMenuDialog">
|
<script setup lang="ts" name="CanteenDailyMenuDialog">
|
||||||
import {useDict} from '/@/hooks/dict';
|
import { useDict } from '/@/hooks/dict';
|
||||||
import {useMessage} from "/@/hooks/message";
|
import { useMessage } from '/@/hooks/message';
|
||||||
import {getObj, addObj, putObj} from '/@/api/canteen/canteenDailyMenu'
|
import { getObj, addObj, putObj } from '/@/api/canteen/canteenDailyMenu';
|
||||||
import {selectFoodList} from "/@/api/canteen/canteenDailyMenu";
|
import { selectFoodList } from '/@/api/canteen/canteenDailyMenu';
|
||||||
import {rule} from '/@/utils/validate';
|
import { rule } from '/@/utils/validate';
|
||||||
|
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(['refresh']);
|
||||||
|
|
||||||
//业务变量
|
//业务变量
|
||||||
const foodData = ref([])
|
const foodData = ref<any>([]);
|
||||||
const spuIds = ref([])
|
const spuIds = ref([]);
|
||||||
const spuImages = ref([])
|
const spuImages = ref<string[]>([]);
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref();
|
||||||
const visible = ref(false)
|
const visible = ref(false);
|
||||||
const loading = ref(false)
|
const loading = ref(false);
|
||||||
// 定义字典
|
// 定义字典
|
||||||
const {daily_menu} = useDict('daily_menu')
|
const { daily_menu } = useDict('daily_menu');
|
||||||
|
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||||
|
|
||||||
// 提交表单数据
|
// 提交表单数据
|
||||||
const form = reactive({
|
const form = reactive<any>({
|
||||||
id: '',
|
id: '',
|
||||||
startTime: '',
|
startTime: '',
|
||||||
spuId: '',
|
spuId: '',
|
||||||
hourType: '',
|
hourType: '',
|
||||||
merchantId: '',
|
merchantId: '',
|
||||||
deptId: '',
|
deptId: '',
|
||||||
spuIds:''
|
spuIds: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 定义校验规则
|
// 定义校验规则
|
||||||
const dataRules = ref({})
|
const dataRules = ref({});
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = (id: string,time?: string, hourType?: number,merchantId?:number) => {
|
const openDialog = (id: string, time?: string, hourType?: number, merchantId?: number) => {
|
||||||
visible.value = true
|
visible.value = true;
|
||||||
form.id = ''
|
form.id = '';
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dataFormRef.value?.resetFields();
|
dataFormRef.value?.resetFields();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取canteenDailyMenu信息
|
|
||||||
if (id) {
|
|
||||||
form.id = id
|
|
||||||
getcanteenDailyMenuData(id)
|
|
||||||
}
|
|
||||||
if (time) {
|
|
||||||
form.startTime = time
|
|
||||||
}
|
|
||||||
if (hourType) {
|
|
||||||
form.hourType = hourType
|
|
||||||
}
|
|
||||||
form.merchantId = merchantId
|
|
||||||
|
|
||||||
|
// 获取canteenDailyMenu信息
|
||||||
|
if (id) {
|
||||||
|
form.id = id;
|
||||||
|
getcanteenDailyMenuData(id);
|
||||||
|
}
|
||||||
|
if (time) {
|
||||||
|
form.startTime = time;
|
||||||
|
}
|
||||||
|
if (hourType) {
|
||||||
|
form.hourType = hourType;
|
||||||
|
}
|
||||||
|
form.merchantId = merchantId;
|
||||||
};
|
};
|
||||||
watch(spuIds, (newValue, oldValue) => {
|
watch(spuIds, (newValue, oldValue) => {
|
||||||
spuImages.value = []
|
spuImages.value = [];
|
||||||
form.spuIds = newValue
|
form.spuIds = newValue;
|
||||||
//更新值
|
//更新值
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
const newValues = newValue.toString().split(',')
|
const newValues = newValue.toString().split(',');
|
||||||
for (let index = 0; index < newValues.length; index++) {
|
for (let index = 0; index < newValues.length; index++) {
|
||||||
const data = newValues[index]
|
const data = newValues[index];
|
||||||
foodData.value.forEach((sData) => {
|
foodData.value.forEach((sData: any) => {
|
||||||
if (sData.id?.toString() === data) {
|
if (sData.id?.toString() === data) {
|
||||||
spuImages.value.push(sData.picUrl?.toString())
|
spuImages.value.push(imageBaseUrl + sData.picUrl?.toString());
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
if (spuIds.value.length<=0){
|
if (spuIds.value.length <= 0) {
|
||||||
useMessage().warning("请选择菜品")
|
useMessage().warning('请选择菜品');
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {
|
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||||
});
|
if (!valid) return false;
|
||||||
if (!valid) return false;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
form.id ? await putObj(form) : await addObj(form);
|
form.id ? await putObj(form) : await addObj(form);
|
||||||
useMessage().success(form.id ? '修改成功' : '添加成功');
|
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||||
visible.value = false;
|
visible.value = false;
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error(err.msg);
|
useMessage().error(err.msg);
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 初始化表单数据
|
// 初始化表单数据
|
||||||
const getcanteenDailyMenuData = (id: string) => {
|
const getcanteenDailyMenuData = (id: string) => {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
loading.value = true
|
loading.value = true;
|
||||||
getObj(id).then((res: any) => {
|
getObj(id)
|
||||||
Object.assign(form, res.data)
|
.then((res: any) => {
|
||||||
}).finally(() => {
|
Object.assign(form, res.data);
|
||||||
loading.value = false
|
})
|
||||||
})
|
.finally(() => {
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog
|
openDialog,
|
||||||
});
|
});
|
||||||
/** 初始化 **/
|
/** 初始化 **/
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 获取菜品列表
|
// 获取菜品列表
|
||||||
let axiosResponse = await selectFoodList();
|
let axiosResponse = await selectFoodList();
|
||||||
foodData.value = axiosResponse.data
|
foodData.value = axiosResponse.data;
|
||||||
})
|
});
|
||||||
</script>
|
</script>
|
||||||
@@ -1,149 +1,153 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout-padding">
|
<div class="layout-padding">
|
||||||
<div class="layout-padding-auto layout-padding-view">
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
<el-row v-show="showSearch">
|
<el-row v-show="showSearch">
|
||||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||||
<el-form-item label="商品名称" prop="name" >
|
<el-form-item label="商品名称" prop="name">
|
||||||
<el-input placeholder="请输入商品名称" v-model="state.queryForm.name" />
|
<el-input placeholder="请输入商品名称" v-model="state.queryForm.name" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品分类编号" prop="categoryId">
|
<el-form-item label="商品分类编号" prop="categoryId">
|
||||||
<el-select v-model="state.queryForm.categoryId" placeholder="请选择商品分类编号">
|
<el-select v-model="state.queryForm.categoryId" placeholder="请选择商品分类编号">
|
||||||
<el-option label="请选择">0</el-option>
|
<el-option label="请选择">0</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button icon="search" type="primary" @click="getDataList">
|
<el-button icon="search" type="primary" @click="getDataList"> 查询 </el-button>
|
||||||
查询
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
</el-button>
|
</el-form-item>
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
</el-form>
|
||||||
</el-form-item>
|
</el-row>
|
||||||
</el-form>
|
<el-row>
|
||||||
</el-row>
|
<div class="mb8" style="width: 100%">
|
||||||
<el-row>
|
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'canteen_canteenSpu_add'">
|
||||||
<div class="mb8" style="width: 100%">
|
新 增
|
||||||
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
</el-button>
|
||||||
v-auth="'canteen_canteenSpu_add'">
|
<el-button plain :disabled="multiple" icon="Delete" type="primary" v-auth="'canteen_canteenSpu_del'" @click="handleDelete(selectObjs)">
|
||||||
新 增
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
<right-toolbar
|
||||||
v-auth="'canteen_canteenSpu_del'" @click="handleDelete(selectObjs)">
|
v-model:showSearch="showSearch"
|
||||||
删除
|
:export="'canteen_canteenSpu_export'"
|
||||||
</el-button>
|
@exportExcel="exportExcel"
|
||||||
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenSpu_export'"
|
class="ml10 mr20"
|
||||||
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
style="float: right"
|
||||||
@queryTable="getDataList"></right-toolbar>
|
@queryTable="getDataList"
|
||||||
</div>
|
></right-toolbar>
|
||||||
</el-row>
|
</div>
|
||||||
<el-table :data="state.dataList" v-loading="state.loading" border
|
</el-row>
|
||||||
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
<el-table
|
||||||
|
:data="state.dataList"
|
||||||
|
v-loading="state.loading"
|
||||||
|
border
|
||||||
|
:cell-style="tableStyle.cellStyle"
|
||||||
|
:header-cell-style="tableStyle.headerCellStyle"
|
||||||
@selection-change="selectionChangHandle"
|
@selection-change="selectionChangHandle"
|
||||||
@sort-change="sortChangeHandle">
|
@sort-change="sortChangeHandle"
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
>
|
||||||
<el-table-column type="index" label="#" width="40" />
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
<el-table-column prop="name" label="商品名称" show-overflow-tooltip/>
|
<el-table-column type="index" label="#" width="40" />
|
||||||
<el-table-column prop="categoryId" label="商品分类编号" show-overflow-tooltip/>
|
<el-table-column prop="name" label="商品名称" width="120px" show-overflow-tooltip />
|
||||||
<el-table-column prop="picUrl" label="商品封面图" show-overflow-tooltip/>
|
<el-table-column prop="categoryId" label="商品分类编号" width="120px" show-overflow-tooltip />
|
||||||
<!-- <el-table-column prop="sliderPicUrls" label="商品轮播图" show-overflow-tooltip/>-->
|
<el-table-column prop="picUrl" label="商品封面图" align="center" width="160px" show-overflow-tooltip>
|
||||||
<el-table-column prop="sort" label="排序字段" show-overflow-tooltip/>
|
<template #default="scope">
|
||||||
<el-table-column prop="status" label="上架状态" show-overflow-tooltip>
|
<el-image style="width: 100px; height: 100px" :src="imageBaseUrl + scope.row.picUrl" fit="cover" />
|
||||||
<template #default="scope">
|
</template>
|
||||||
<dict-tag :options="spu_status" :value="scope.row.status"></dict-tag>
|
</el-table-column>
|
||||||
</template>
|
<!-- <el-table-column prop="sliderPicUrls" label="商品轮播图" show-overflow-tooltip/>-->
|
||||||
</el-table-column>
|
<el-table-column prop="sort" label="排序字段" show-overflow-tooltip />
|
||||||
<el-table-column prop="price" label="商品价格,单位使用:分" show-overflow-tooltip/>
|
<el-table-column prop="status" label="上架状态" show-overflow-tooltip>
|
||||||
<el-table-column prop="marketPrice" label="市场价,单位使用:分" show-overflow-tooltip/>
|
<template #default="scope">
|
||||||
<el-table-column prop="costPrice" label="成本价,单位: 分" show-overflow-tooltip/>
|
<dict-tag :options="spu_status" :value="scope.row.status"></dict-tag>
|
||||||
<el-table-column prop="stock" label="库存" show-overflow-tooltip/>
|
</template>
|
||||||
<el-table-column prop="giveIntegral" label="赠送积分" show-overflow-tooltip/>
|
</el-table-column>
|
||||||
<el-table-column prop="salesCount" label="商品销量" show-overflow-tooltip/>
|
<el-table-column prop="price" label="商品价格,单位使用:分" show-overflow-tooltip />
|
||||||
<el-table-column prop="virtualSalesCount" label="虚拟销量" show-overflow-tooltip/>
|
<el-table-column prop="marketPrice" label="市场价,单位使用:分" show-overflow-tooltip />
|
||||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip/>
|
<el-table-column prop="costPrice" label="成本价,单位: 分" show-overflow-tooltip />
|
||||||
<el-table-column label="操作" width="150">
|
<el-table-column prop="stock" label="库存" show-overflow-tooltip />
|
||||||
<template #default="scope">
|
<el-table-column prop="giveIntegral" label="赠送积分" show-overflow-tooltip />
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenSpu_edit'"
|
<el-table-column prop="salesCount" label="商品销量" show-overflow-tooltip />
|
||||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
<el-table-column prop="virtualSalesCount" label="虚拟销量" show-overflow-tooltip />
|
||||||
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenSpu_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip />
|
||||||
</template>
|
<el-table-column label="操作" width="150" fixed="right">
|
||||||
</el-table-column>
|
<template #default="scope">
|
||||||
</el-table>
|
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenSpu_edit'" @click="formDialogRef.openDialog(scope.row.id)"
|
||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
>编辑</el-button
|
||||||
</div>
|
>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenSpu_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)" />
|
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||||
|
</div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="systemCanteenSpu">
|
<script setup lang="ts" name="systemCanteenSpu">
|
||||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
import { BasicTableProps, useTable } from '/@/hooks/table';
|
||||||
import { fetchList, delObjs } from "/@/api/canteen/canteenSpu";
|
import { fetchList, delObjs } from '/@/api/canteen/canteenSpu';
|
||||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
import { useMessage, useMessageBox } from '/@/hooks/message';
|
||||||
import { useDict } from '/@/hooks/dict';
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||||
// 定义查询字典
|
// 定义查询字典
|
||||||
|
|
||||||
const { spu_status } = useDict('spu_status')
|
const { spu_status } = useDict('spu_status');
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const formDialogRef = ref()
|
const formDialogRef = ref();
|
||||||
// 搜索变量
|
// 搜索变量
|
||||||
const queryRef = ref()
|
const queryRef = ref();
|
||||||
const showSearch = ref(true)
|
const showSearch = ref(true);
|
||||||
// 多选变量
|
// 多选变量
|
||||||
const selectObjs = ref([]) as any
|
const selectObjs = ref([]) as any;
|
||||||
const multiple = ref(true)
|
const multiple = ref(true);
|
||||||
|
const imageBaseUrl = import.meta.env.VITE_IMAGE_BASE_PATH;
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
queryForm: {},
|
queryForm: {},
|
||||||
pageList: fetchList
|
pageList: fetchList,
|
||||||
})
|
});
|
||||||
|
|
||||||
// table hook
|
// table hook
|
||||||
const {
|
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state);
|
||||||
getDataList,
|
|
||||||
currentChangeHandle,
|
|
||||||
sizeChangeHandle,
|
|
||||||
sortChangeHandle,
|
|
||||||
downBlobFile,
|
|
||||||
tableStyle
|
|
||||||
} = useTable(state)
|
|
||||||
|
|
||||||
// 清空搜索条件
|
// 清空搜索条件
|
||||||
const resetQuery = () => {
|
const resetQuery = () => {
|
||||||
// 清空搜索条件
|
// 清空搜索条件
|
||||||
queryRef.value?.resetFields()
|
queryRef.value?.resetFields();
|
||||||
// 清空多选
|
// 清空多选
|
||||||
selectObjs.value = []
|
selectObjs.value = [];
|
||||||
getDataList()
|
getDataList();
|
||||||
}
|
};
|
||||||
|
|
||||||
// 导出excel
|
// 导出excel
|
||||||
const exportExcel = () => {
|
const exportExcel = () => {
|
||||||
downBlobFile('/canteen/canteenSpu/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenSpu.xlsx')
|
downBlobFile('/canteen/canteenSpu/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenSpu.xlsx');
|
||||||
}
|
};
|
||||||
|
|
||||||
// 多选事件
|
// 多选事件
|
||||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
selectObjs.value = objs.map(({ id }) => id);
|
selectObjs.value = objs.map(({ id }) => id);
|
||||||
multiple.value = !objs.length;
|
multiple.value = !objs.length;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 删除操作
|
// 删除操作
|
||||||
const handleDelete = async (ids: string[]) => {
|
const handleDelete = async (ids: string[]) => {
|
||||||
try {
|
try {
|
||||||
await useMessageBox().confirm('此操作将永久删除');
|
await useMessageBox().confirm('此操作将永久删除');
|
||||||
} catch {
|
} catch {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await delObjs(ids);
|
await delObjs(ids);
|
||||||
getDataList();
|
getDataList();
|
||||||
useMessage().success('删除成功');
|
useMessage().success('删除成功');
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error(err.msg);
|
useMessage().error(err.msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user