Compare commits
No commits in common. "d70ee43c295e0fbe600fc0228aaaa4ed8fe53526" and "d8ae565b4ae8c536396d74e9473e3726083c3c84" have entirely different histories.
d70ee43c29
...
d8ae565b4a
|
@ -15,10 +15,6 @@ export interface CabinetCellDTO {
|
||||||
usageStatus: number;
|
usageStatus: number;
|
||||||
availableStatus: number;
|
availableStatus: number;
|
||||||
operator?: string;
|
operator?: string;
|
||||||
goodsId?: number;
|
|
||||||
goodsName?: string;
|
|
||||||
price?: number;
|
|
||||||
coverImg?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddCabinetCellCommand {
|
export interface AddCabinetCellCommand {
|
||||||
|
@ -64,7 +60,4 @@ export interface ConfigureGoodsCellsCommand {
|
||||||
|
|
||||||
export const configureGoodsCells = (cellId: number, goodsId: number) => {
|
export const configureGoodsCells = (cellId: number, goodsId: number) => {
|
||||||
return http.request<ResponseData<void>>('put', `/cabinet/cell/configureGoodsCells/${cellId}/${goodsId}`);
|
return http.request<ResponseData<void>>('put', `/cabinet/cell/configureGoodsCells/${cellId}/${goodsId}`);
|
||||||
};
|
|
||||||
export const configureGoodsCellsStock = (cellId: number, goodsId: number, stock: number) => {
|
|
||||||
return http.request<ResponseData<void>>('put', `/cabinet/cell/configureGoodsCellsStock/${cellId}/${goodsId}/${stock}`);
|
|
||||||
};
|
};
|
|
@ -58,7 +58,3 @@ export const deleteSmartCabinet = (ids: string) => {
|
||||||
export const getAllCabinetsWithCells = () => {
|
export const getAllCabinetsWithCells = () => {
|
||||||
return http.request<ResponseData<AllCabinetDataDTO>>('get', '/cabinet/smartCabinet/all');
|
return http.request<ResponseData<AllCabinetDataDTO>>('get', '/cabinet/smartCabinet/all');
|
||||||
};
|
};
|
||||||
|
|
||||||
export const allCabinets = () => {
|
|
||||||
return http.request<ResponseData<Array<SmartCabinetDTO>>>('get', '/cabinet/smartCabinet/allCabinets');
|
|
||||||
};
|
|
|
@ -1,102 +0,0 @@
|
||||||
import { http } from '@/utils/http';
|
|
||||||
|
|
||||||
export interface SearchReturnApprovalQuery extends BasePageQuery {
|
|
||||||
approvalId?: number;
|
|
||||||
orderId?: number;
|
|
||||||
goodsId?: number;
|
|
||||||
status?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 退货审批DTO */
|
|
||||||
/** 退货审批DTO */
|
|
||||||
export interface ReturnApprovalDTO {
|
|
||||||
/** 审批编号 */
|
|
||||||
approvalId?: number;
|
|
||||||
/** 关联订单ID */
|
|
||||||
orderId: number;
|
|
||||||
/** 关联商品ID */
|
|
||||||
goodsId: number;
|
|
||||||
/** 归还数量 */
|
|
||||||
returnQuantity: number;
|
|
||||||
/** 商品单价 */
|
|
||||||
goodsPrice: number;
|
|
||||||
/** 退还金额 */
|
|
||||||
returnAmount: number;
|
|
||||||
/** 归还图片路径数组 */
|
|
||||||
returnImages: string[];
|
|
||||||
/** 审核图片路径数组 */
|
|
||||||
auditImages: string[];
|
|
||||||
/** 归还说明 */
|
|
||||||
returnRemark?: string;
|
|
||||||
/** 审核说明 */
|
|
||||||
auditRemark?: string;
|
|
||||||
/** 审批状态(1待审核 2已通过 3已驳回) */
|
|
||||||
status: number;
|
|
||||||
statusStr: string;
|
|
||||||
creatorId?: number;
|
|
||||||
createTime?: Date;
|
|
||||||
updaterId?: number;
|
|
||||||
updateTime?: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AddReturnApprovalCommand {
|
|
||||||
/** 关联订单ID */
|
|
||||||
orderId: number;
|
|
||||||
/** 关联商品ID */
|
|
||||||
goodsId: number;
|
|
||||||
/** 归还数量 */
|
|
||||||
returnQuantity: number;
|
|
||||||
/** 归还图片路径数组 */
|
|
||||||
returnImages: string[];
|
|
||||||
/** 归还说明 */
|
|
||||||
returnRemark?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UpdateReturnApprovalCommand {
|
|
||||||
/** 审批编号 */
|
|
||||||
approvalId: number;
|
|
||||||
/** 归还数量 */
|
|
||||||
returnQuantity: number;
|
|
||||||
/** 审核图片路径数组 */
|
|
||||||
auditImages: string[];
|
|
||||||
/** 审核说明 */
|
|
||||||
auditRemark?: string;
|
|
||||||
/** 审批状态(1待审核 2已通过 3已驳回) */
|
|
||||||
status: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 获取退货审批列表 */
|
|
||||||
export const getReturnApprovalListApi = (params?: SearchReturnApprovalQuery) => {
|
|
||||||
return http.request<ResponseData<PageDTO<ReturnApprovalDTO>>>(
|
|
||||||
'get',
|
|
||||||
'/shop/returnApproval',
|
|
||||||
{ params }
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 新增退货审批 */
|
|
||||||
export const addReturnApprovalApi = (data: AddReturnApprovalCommand) => {
|
|
||||||
return http.request<ResponseData<void>>('post', '/shop/returnApproval', {
|
|
||||||
data
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 修改退货审批 */
|
|
||||||
export const updateReturnApprovalApi = (
|
|
||||||
approvalId: number,
|
|
||||||
data: UpdateReturnApprovalCommand
|
|
||||||
) => {
|
|
||||||
return http.request<ResponseData<void>>(
|
|
||||||
'put',
|
|
||||||
`/shop/returnApproval/${approvalId}`,
|
|
||||||
{ data }
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** 批量删除退货审批 */
|
|
||||||
export const deleteReturnApprovalApi = (approvalIds: (number | string)[]) => {
|
|
||||||
return http.request<ResponseData<void>>(
|
|
||||||
'delete',
|
|
||||||
`/shop/returnApproval/${approvalIds.join(',')}`
|
|
||||||
);
|
|
||||||
};
|
|
|
@ -25,7 +25,6 @@ export interface GoodsDTO {
|
||||||
deleted?: number;
|
deleted?: number;
|
||||||
cabinetName?: string;
|
cabinetName?: string;
|
||||||
cellNo?: number;
|
cellNo?: number;
|
||||||
totalStock?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 商品请求参数 */
|
/** 商品请求参数 */
|
||||||
|
|
|
@ -1,199 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { PureTableBar } from "@/components/RePureTableBar";
|
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
||||||
import { getReturnApprovalListApi, deleteReturnApprovalApi, ReturnApprovalDTO } from "@/api/shop/approval";
|
|
||||||
import Delete from "@iconify-icons/ep/delete";
|
|
||||||
import Search from "@iconify-icons/ep/search";
|
|
||||||
import Refresh from "@iconify-icons/ep/refresh";
|
|
||||||
import View from "@iconify-icons/ep/view";
|
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
|
||||||
|
|
||||||
const formRef = ref();
|
|
||||||
const tableRef = ref();
|
|
||||||
|
|
||||||
// 搜索表单
|
|
||||||
const searchFormParams = ref({
|
|
||||||
approvalId: null,
|
|
||||||
orderId: null,
|
|
||||||
goodsId: null,
|
|
||||||
status: null
|
|
||||||
});
|
|
||||||
|
|
||||||
// 分页参数
|
|
||||||
const pagination = ref({
|
|
||||||
pageSize: 10,
|
|
||||||
currentPage: 1,
|
|
||||||
total: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const dataList = ref<ReturnApprovalDTO[]>([]);
|
|
||||||
const multipleSelection = ref<number[]>([]);
|
|
||||||
const detailVisible = ref(false);
|
|
||||||
const currentDetail = ref<ReturnApprovalDTO>();
|
|
||||||
|
|
||||||
// 获取审批列表
|
|
||||||
const getList = async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
const { data } = await getReturnApprovalListApi({
|
|
||||||
...searchFormParams.value,
|
|
||||||
pageSize: pagination.value.pageSize,
|
|
||||||
pageNum: pagination.value.currentPage
|
|
||||||
});
|
|
||||||
dataList.value = data.rows.map(item => ({
|
|
||||||
...item,
|
|
||||||
statusStr: { 1: '待审核', 2: '已通过', 3: '已驳回' }[item.status]
|
|
||||||
}));
|
|
||||||
pagination.value.total = data.total;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 搜索
|
|
||||||
const onSearch = () => {
|
|
||||||
pagination.value.currentPage = 1;
|
|
||||||
getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 重置
|
|
||||||
const resetForm = () => {
|
|
||||||
formRef.value.resetFields();
|
|
||||||
onSearch();
|
|
||||||
};
|
|
||||||
|
|
||||||
// 分页变化
|
|
||||||
const handlePaginationChange = () => getList();
|
|
||||||
|
|
||||||
// 批量删除
|
|
||||||
const handleBulkDelete = async () => {
|
|
||||||
if (multipleSelection.value.length === 0) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确认删除选中的${multipleSelection.value.length}项审批记录?`,
|
|
||||||
"警告",
|
|
||||||
{ confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }
|
|
||||||
);
|
|
||||||
|
|
||||||
await deleteReturnApprovalApi(multipleSelection.value);
|
|
||||||
ElMessage.success("批量删除成功");
|
|
||||||
multipleSelection.value = [];
|
|
||||||
getList();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("删除取消或失败", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 查看详情
|
|
||||||
const showDetail = (row: ReturnApprovalDTO) => {
|
|
||||||
currentDetail.value = row;
|
|
||||||
detailVisible.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
getList();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="main">
|
|
||||||
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
|
||||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
|
||||||
<el-form-item label="审批ID:" prop="approvalId">
|
|
||||||
<el-input v-model.number="searchFormParams.approvalId" placeholder="请输入审批ID" clearable class="!w-[180px]" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="订单ID:" prop="orderId">
|
|
||||||
<el-input v-model.number="searchFormParams.orderId" placeholder="请输入订单ID" clearable class="!w-[180px]" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="商品ID:" prop="goodsId">
|
|
||||||
<el-input v-model.number="searchFormParams.goodsId" placeholder="请输入商品ID" clearable class="!w-[180px]" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态:" prop="status">
|
|
||||||
<el-select v-model="searchFormParams.status" placeholder="请选择状态" clearable class="!w-[180px]">
|
|
||||||
<el-option label="待审核" :value="1" />
|
|
||||||
<el-option label="已通过" :value="2" />
|
|
||||||
<el-option label="已驳回" :value="3" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
|
||||||
搜索
|
|
||||||
</el-button>
|
|
||||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
|
||||||
重置
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<PureTableBar title="退货审批列表" @refresh="getList">
|
|
||||||
<template #buttons>
|
|
||||||
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
|
||||||
@click="handleBulkDelete">
|
|
||||||
批量删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="approvalId"
|
|
||||||
@selection-change="rows => multipleSelection = rows.map(r => r.approvalId)" border>
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
<el-table-column label="审批ID" prop="approvalId" width="120" />
|
|
||||||
<el-table-column label="订单ID" prop="orderId" width="120" />
|
|
||||||
<el-table-column label="商品ID" prop="goodsId" width="120" />
|
|
||||||
<el-table-column label="退货数量" prop="returnQuantity" width="100" />
|
|
||||||
<el-table-column label="状态" prop="status" width="100">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="{ 1: 'warning', 2: 'success', 3: 'danger' }[row.status]">
|
|
||||||
{{ row.statusStr }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button type="primary" link :icon="useRenderIcon(View)" @click="showDetail(row)">
|
|
||||||
详情
|
|
||||||
</el-button>
|
|
||||||
<el-popconfirm :title="`确认删除审批记录#${row.approvalId}?`"
|
|
||||||
@confirm="() => deleteReturnApprovalApi([row.approvalId])">
|
|
||||||
<template #reference>
|
|
||||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-popconfirm>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
|
||||||
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
|
|
||||||
@size-change="handlePaginationChange" @current-change="handlePaginationChange" />
|
|
||||||
</PureTableBar>
|
|
||||||
|
|
||||||
<!-- 详情弹窗 -->
|
|
||||||
<el-dialog v-model="detailVisible" title="审批详情" width="50%">
|
|
||||||
<el-descriptions :column="2" border>
|
|
||||||
<el-descriptions-item label="退货图片">
|
|
||||||
<div class="flex flex-wrap gap-2">
|
|
||||||
<el-image v-for="(img, index) in currentDetail?.returnImages" :key="index" :src="img"
|
|
||||||
:preview-src-list="currentDetail?.returnImages" :initial-index="index" fit="cover"
|
|
||||||
class="w-20 h-20 rounded" />
|
|
||||||
</div>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="审核图片">
|
|
||||||
<div class="flex flex-wrap gap-2">
|
|
||||||
<el-image v-for="(img, index) in currentDetail?.auditImages" :key="index" :src="img"
|
|
||||||
:preview-src-list="currentDetail?.auditImages" :initial-index="index" fit="cover"
|
|
||||||
class="w-20 h-20 rounded" />
|
|
||||||
</div>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="退货说明">{{ currentDetail?.returnRemark || '无' }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="审核说明">{{ currentDetail?.auditRemark || '无' }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
:deep(.el-image-viewer__wrapper) {
|
|
||||||
z-index: 9999 !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,140 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
||||||
import { getGoodsListApi, type GoodsDTO } from "@/api/shop/goods";
|
|
||||||
import { configureGoodsCellsStock } from "@/api/cabinet/cabinet-cell";
|
|
||||||
import Search from "@iconify-icons/ep/search";
|
|
||||||
import Refresh from "@iconify-icons/ep/refresh";
|
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
cellId: {
|
|
||||||
type: Number,
|
|
||||||
required: true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const emit = defineEmits(['refresh', 'update:modelValue']);
|
|
||||||
const closeModal = () => {
|
|
||||||
emit('update:modelValue', false);
|
|
||||||
};
|
|
||||||
|
|
||||||
const searchFormParams = ref({
|
|
||||||
goodsName: "",
|
|
||||||
status: null
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagination = ref({
|
|
||||||
pageSize: 10,
|
|
||||||
currentPage: 1,
|
|
||||||
total: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const dataList = ref<GoodsDTO[]>([]);
|
|
||||||
|
|
||||||
const getList = async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
const { data } = await getGoodsListApi({
|
|
||||||
...searchFormParams.value,
|
|
||||||
pageSize: pagination.value.pageSize,
|
|
||||||
pageNum: pagination.value.currentPage
|
|
||||||
});
|
|
||||||
dataList.value = data.rows;
|
|
||||||
pagination.value.total = data.total;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleConfigure = async (row: GoodsDTO) => {
|
|
||||||
try {
|
|
||||||
const { value } = await ElMessageBox.prompt(
|
|
||||||
'请输入商品库存数量',
|
|
||||||
'配置库存',
|
|
||||||
{
|
|
||||||
inputPattern: /^[1-9]\d*$/,
|
|
||||||
inputErrorMessage: '请输入有效的正整数库存'
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
await configureGoodsCellsStock(props.cellId, row.goodsId!, Number(value));
|
|
||||||
ElMessage.success('配置成功');
|
|
||||||
emit('refresh');
|
|
||||||
closeModal();
|
|
||||||
} catch (error) {
|
|
||||||
console.error('配置取消或失败', error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({ getList });
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="config-modal">
|
|
||||||
<el-form :inline="true" :model="searchFormParams" class="search-form">
|
|
||||||
<el-form-item label="商品名称:">
|
|
||||||
<el-input v-model="searchFormParams.goodsName" placeholder="请输入商品名称" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="状态:">
|
|
||||||
<el-select v-model="searchFormParams.status" placeholder="请选择状态" clearable>
|
|
||||||
<el-option label="已上架" :value="1" />
|
|
||||||
<el-option label="已下架" :value="2" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="getList">
|
|
||||||
搜索
|
|
||||||
</el-button>
|
|
||||||
<el-button :icon="useRenderIcon(Refresh)"
|
|
||||||
@click="searchFormParams = { goodsName: '', status: null }; getList()">
|
|
||||||
重置
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="dataList" border>
|
|
||||||
<el-table-column label="商品图片" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-image :src="row.coverImg" fit="cover" class="rounded" width="60" height="60" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品名称" prop="goodsName" />
|
|
||||||
<el-table-column label="价格" prop="price" width="120" />
|
|
||||||
<el-table-column label="库存" prop="stock" width="120" />
|
|
||||||
<el-table-column label="已分配库存" prop="totalStock" width="120" />
|
|
||||||
<el-table-column label="状态" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.status === 1 ? 'success' : 'danger'">
|
|
||||||
{{ row.status === 1 ? '已上架' : '已下架' }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button type="primary" link @click="handleConfigure(row)">
|
|
||||||
配置
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<div class="dialog-footer" style="margin-top: 20px; text-align: right">
|
|
||||||
<el-button @click="closeModal">取消</el-button>
|
|
||||||
</div>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
|
||||||
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next" :total="pagination.total"
|
|
||||||
@size-change="getList" @current-change="getList" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.config-modal {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-form {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,245 +0,0 @@
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref, onMounted } from "vue";
|
|
||||||
import { PureTableBar } from "@/components/RePureTableBar";
|
|
||||||
import { onBeforeRouteUpdate, useRoute } from "vue-router";
|
|
||||||
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
||||||
import { getCabinetCellList, deleteCabinetCell, CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
|
|
||||||
import { allCabinets, SmartCabinetDTO } from "@/api/cabinet/smart-cabinet";
|
|
||||||
import EditPen from "@iconify-icons/ep/edit-pen";
|
|
||||||
import Delete from "@iconify-icons/ep/delete";
|
|
||||||
import AddFill from "@iconify-icons/ri/add-circle-line";
|
|
||||||
import Search from "@iconify-icons/ep/search";
|
|
||||||
import Refresh from "@iconify-icons/ep/refresh";
|
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
|
||||||
import { on } from "events";
|
|
||||||
import CabinetGoodsConfigModal from "./cabinet-goods-config-modal.vue";
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: "CabinetGoods"
|
|
||||||
});
|
|
||||||
|
|
||||||
const formRef = ref();
|
|
||||||
const tableRef = ref();
|
|
||||||
|
|
||||||
const searchFormParams = ref({
|
|
||||||
cabinetId: null,
|
|
||||||
cellNo: null,
|
|
||||||
cellType: null
|
|
||||||
});
|
|
||||||
|
|
||||||
const pagination = ref({
|
|
||||||
pageSize: 10,
|
|
||||||
currentPage: 1,
|
|
||||||
total: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
const loading = ref(false);
|
|
||||||
const dataList = ref([]);
|
|
||||||
const multipleSelection = ref<number[]>([]);
|
|
||||||
const currentRow = ref<CabinetCellDTO>();
|
|
||||||
const configVisible = ref(false);
|
|
||||||
const currentCellId = ref<number>();
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
|
|
||||||
const cabinets = ref<SmartCabinetDTO[]>([]);
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const { data } = await allCabinets();
|
|
||||||
cabinets.value = data;
|
|
||||||
if (data.length > 0) {
|
|
||||||
searchFormParams.value.cabinetId = data[0].cabinetId;
|
|
||||||
getList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeRouteUpdate(async () => {
|
|
||||||
const { data } = await allCabinets();
|
|
||||||
cabinets.value = data;
|
|
||||||
if (data.length > 0) {
|
|
||||||
searchFormParams.value.cabinetId = data[0].cabinetId;
|
|
||||||
getList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const getList = async () => {
|
|
||||||
try {
|
|
||||||
loading.value = true;
|
|
||||||
const { data } = await getCabinetCellList({
|
|
||||||
...searchFormParams.value,
|
|
||||||
pageSize: pagination.value.pageSize,
|
|
||||||
pageNum: pagination.value.currentPage
|
|
||||||
});
|
|
||||||
dataList.value = data.rows;
|
|
||||||
pagination.value.total = data.total;
|
|
||||||
} finally {
|
|
||||||
loading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSearch = () => {
|
|
||||||
pagination.value.currentPage = 1;
|
|
||||||
getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
const resetForm = () => {
|
|
||||||
formRef.value.resetFields();
|
|
||||||
onSearch();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onSizeChange = (val: number) => {
|
|
||||||
pagination.value.pageSize = val;
|
|
||||||
getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
const onCurrentChange = (val: number) => {
|
|
||||||
pagination.value.currentPage = val;
|
|
||||||
getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDelete = async (row: CabinetCellDTO) => {
|
|
||||||
try {
|
|
||||||
await deleteCabinetCell(row.cellId!.toString());
|
|
||||||
ElMessage.success("删除成功");
|
|
||||||
getList();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("删除失败", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleBulkDelete = async () => {
|
|
||||||
if (multipleSelection.value.length === 0) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(
|
|
||||||
`确认删除选中的${multipleSelection.value.length}项单元格吗?`,
|
|
||||||
"警告",
|
|
||||||
{ confirmButtonText: "确定", cancelButtonText: "取消", type: "warning" }
|
|
||||||
);
|
|
||||||
|
|
||||||
await deleteCabinetCell(multipleSelection.value.join(","));
|
|
||||||
ElMessage.success("批量删除成功");
|
|
||||||
multipleSelection.value = [];
|
|
||||||
getList();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("删除取消或失败", error);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSelectionChange = (rows: CabinetCellDTO[]) => {
|
|
||||||
multipleSelection.value = rows.map(row => row.cellId!);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEdit = (row: CabinetCellDTO) => {
|
|
||||||
currentRow.value = row;
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleConfigure = (row: CabinetCellDTO) => {
|
|
||||||
currentCellId.value = row.cellId;
|
|
||||||
configVisible.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const switchCellType = (cellType: number) => {
|
|
||||||
switch (cellType) {
|
|
||||||
case 1:
|
|
||||||
return "小格";
|
|
||||||
case 2:
|
|
||||||
return "中格";
|
|
||||||
case 3:
|
|
||||||
return "大格";
|
|
||||||
case 4:
|
|
||||||
return "超大格";
|
|
||||||
default:
|
|
||||||
return "未知";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="main">
|
|
||||||
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
|
||||||
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
|
||||||
<el-form-item label="柜机:" prop="cabinetId">
|
|
||||||
<el-select v-model.number="searchFormParams.cabinetId" placeholder="请选择柜机" clearable class="!w-[200px]">
|
|
||||||
<el-option v-for="cabinet in cabinets" :key="cabinet.cabinetId" :label="cabinet.cabinetName"
|
|
||||||
:value="cabinet.cabinetId" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="单元格号:" prop="cellNo">
|
|
||||||
<el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="单元格类型:" prop="cellType">
|
|
||||||
<el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]">
|
|
||||||
<el-option label="小格" :value="1" />
|
|
||||||
<el-option label="中格" :value="2" />
|
|
||||||
<el-option label="大格" :value="3" />
|
|
||||||
<el-option label="超大格" :value="4" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
|
||||||
搜索
|
|
||||||
</el-button>
|
|
||||||
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
|
||||||
重置
|
|
||||||
</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<PureTableBar title="柜体单元格管理" @refresh="getList">
|
|
||||||
<template #buttons>
|
|
||||||
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
|
||||||
@click="handleBulkDelete">
|
|
||||||
批量删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
|
|
||||||
@selection-change="handleSelectionChange" border>
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
<el-table-column label="商品图片" width="120">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-image :src="row.coverImg" :preview-src-list="[row.coverImg]" :z-index="9999" :preview-teleported="true"
|
|
||||||
:hide-on-click-modal="true" fit="cover" class="rounded" width="60" height="60" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="商品名称">
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ row.goodsId ? row.goodsName : '未配置商品' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="价格" prop="price" width="120" />
|
|
||||||
<el-table-column label="库存" prop="stock" width="120" />
|
|
||||||
<el-table-column label="单元格号" prop="cellNo" width="120" />
|
|
||||||
<el-table-column label="单元格类型" prop="cellType">
|
|
||||||
<template #default="{ row }">
|
|
||||||
{{ switchCellType(row.cellType) }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="150" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
|
||||||
编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button type="success" link :icon="useRenderIcon(AddFill)" @click="handleConfigure(row)">
|
|
||||||
配置商品
|
|
||||||
</el-button>
|
|
||||||
<el-popconfirm :title="`确认删除【${row.cellNo}】号单元格?`" @confirm="handleDelete(row)">
|
|
||||||
<template #reference>
|
|
||||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-popconfirm>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
|
|
||||||
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
|
|
||||||
@size-change="onSizeChange" @current-change="onCurrentChange" />
|
|
||||||
</PureTableBar>
|
|
||||||
<CabinetGoodsConfigModal v-model="configVisible" :cell-id="currentCellId" @refresh="getList" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
Loading…
Reference in New Issue