|
|
@@ -3,7 +3,7 @@ import { message } from "@/utils/message";
|
|
|
import { getStockRecords, getStockRecordDetail, cancelStockRecord } from "@/api/inventory";
|
|
|
import type { PaginationProps } from "@pureadmin/table";
|
|
|
import type { SearchFormProps } from "./types";
|
|
|
-import { onMounted, reactive, ref, toRaw } from "vue";
|
|
|
+import { onMounted, reactive, ref } from "vue";
|
|
|
|
|
|
export function useStockRecords() {
|
|
|
const form = reactive<SearchFormProps>({
|
|
|
@@ -19,6 +19,10 @@ export function useStockRecords() {
|
|
|
currentPage: 1,
|
|
|
background: true
|
|
|
});
|
|
|
+ const detailVisible = ref(false);
|
|
|
+ const detailLoading = ref(false);
|
|
|
+ const detailRecord = ref<any>({});
|
|
|
+ const detailItems = ref<any[]>([]);
|
|
|
|
|
|
const statusMap = {
|
|
|
1: { text: "进行中", type: "primary" },
|
|
|
@@ -41,66 +45,66 @@ export function useStockRecords() {
|
|
|
{
|
|
|
label: "设备ID",
|
|
|
prop: "deviceId",
|
|
|
- minWidth: 120
|
|
|
+ width: 120
|
|
|
},
|
|
|
{
|
|
|
label: "设备名称",
|
|
|
prop: "deviceName",
|
|
|
- minWidth: 120
|
|
|
+ minWidth: 130
|
|
|
},
|
|
|
{
|
|
|
label: "上货类型",
|
|
|
prop: "stockType",
|
|
|
- minWidth: 100,
|
|
|
+ width: 90,
|
|
|
formatter: ({ stockType }) => stockTypeMap[stockType] || "未知"
|
|
|
},
|
|
|
{
|
|
|
label: "上货员",
|
|
|
prop: "stockerName",
|
|
|
- minWidth: 100
|
|
|
+ width: 90
|
|
|
},
|
|
|
{
|
|
|
- label: "上货员电话",
|
|
|
+ label: "电话",
|
|
|
prop: "stockerPhone",
|
|
|
- minWidth: 120
|
|
|
+ width: 120
|
|
|
},
|
|
|
{
|
|
|
- label: "商品种类",
|
|
|
+ label: "种类",
|
|
|
prop: "totalItems",
|
|
|
- minWidth: 90
|
|
|
+ width: 60
|
|
|
},
|
|
|
{
|
|
|
- label: "总数量",
|
|
|
+ label: "数量",
|
|
|
prop: "totalQuantity",
|
|
|
- minWidth: 90
|
|
|
+ width: 60
|
|
|
},
|
|
|
{
|
|
|
label: "状态",
|
|
|
prop: "status",
|
|
|
- minWidth: 100,
|
|
|
+ width: 80,
|
|
|
cellRenderer: ({ row }) => {
|
|
|
const item = statusMap[row.status] || { text: "未知", type: "info" };
|
|
|
- return <el-tag type={item.type}>{item.text}</el-tag>;
|
|
|
+ return <el-tag type={item.type} size="small">{item.text}</el-tag>;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
label: "创建时间",
|
|
|
prop: "createTime",
|
|
|
- minWidth: 160,
|
|
|
+ width: 160,
|
|
|
formatter: ({ createTime }) =>
|
|
|
createTime ? dayjs(createTime).format("YYYY-MM-DD HH:mm:ss") : ""
|
|
|
},
|
|
|
{
|
|
|
label: "完成时间",
|
|
|
- prop: "completeTime",
|
|
|
- minWidth: 160,
|
|
|
- formatter: ({ completeTime }) =>
|
|
|
- completeTime ? dayjs(completeTime).format("YYYY-MM-DD HH:mm:ss") : "-"
|
|
|
+ prop: "endTime",
|
|
|
+ width: 160,
|
|
|
+ formatter: ({ endTime }) =>
|
|
|
+ endTime ? dayjs(endTime).format("YYYY-MM-DD HH:mm:ss") : "-"
|
|
|
},
|
|
|
{
|
|
|
label: "操作",
|
|
|
fixed: "right",
|
|
|
- width: 150,
|
|
|
+ width: 120,
|
|
|
slot: "operation"
|
|
|
}
|
|
|
];
|
|
|
@@ -112,12 +116,11 @@ export function useStockRecords() {
|
|
|
page: pagination.currentPage,
|
|
|
pageSize: pagination.pageSize
|
|
|
};
|
|
|
-
|
|
|
- // 只添加非空的搜索条件
|
|
|
+
|
|
|
if (form.deviceId) searchParams.deviceId = form.deviceId;
|
|
|
if (form.stockerId !== undefined) searchParams.stockerId = form.stockerId;
|
|
|
if (form.status !== undefined) searchParams.status = form.status;
|
|
|
-
|
|
|
+
|
|
|
const { data } = await getStockRecords(searchParams);
|
|
|
if (data) {
|
|
|
dataList.value = data.list || [];
|
|
|
@@ -144,8 +147,21 @@ export function useStockRecords() {
|
|
|
}
|
|
|
|
|
|
async function handleViewDetail(row) {
|
|
|
- const { data } = await getStockRecordDetail(row.id);
|
|
|
- console.log("详情:", data);
|
|
|
+ detailVisible.value = true;
|
|
|
+ detailLoading.value = true;
|
|
|
+ detailRecord.value = row;
|
|
|
+ detailItems.value = [];
|
|
|
+ try {
|
|
|
+ const { data } = await getStockRecordDetail(row.id);
|
|
|
+ if (data) {
|
|
|
+ detailRecord.value = data;
|
|
|
+ detailItems.value = data.items || [];
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ message("加载详情失败", { type: "error" });
|
|
|
+ } finally {
|
|
|
+ detailLoading.value = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
function handleSizeChange(val: number) {
|
|
|
@@ -169,6 +185,11 @@ export function useStockRecords() {
|
|
|
dataList,
|
|
|
pagination,
|
|
|
statusMap,
|
|
|
+ stockTypeMap,
|
|
|
+ detailVisible,
|
|
|
+ detailLoading,
|
|
|
+ detailRecord,
|
|
|
+ detailItems,
|
|
|
onSearch,
|
|
|
resetForm,
|
|
|
handleCancel,
|