From 0904d14fb18944b5cc209b44e48d25c8f5aed928 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 15 七月 2026 15:52:04 +0800
Subject: [PATCH] 银川 1.仓储物流添加库存事务流水页面

---
 src/api/mes/wm/transaction/index.ts |   52 ++++++++
 src/views/wls/transaction/data.ts   |  205 ++++++++++++++++++++++++++++++++++
 src/views/wls/transaction/index.vue |   71 +++++++++++
 3 files changed, 328 insertions(+), 0 deletions(-)

diff --git a/src/api/mes/wm/transaction/index.ts b/src/api/mes/wm/transaction/index.ts
new file mode 100644
index 0000000..8dd08f4
--- /dev/null
+++ b/src/api/mes/wm/transaction/index.ts
@@ -0,0 +1,52 @@
+import type { PageParam, PageResult } from '@vben/request';
+
+import { requestClient } from '#/api/request';
+
+export namespace MesWmTransactionApi {
+  /** 搴撳瓨浜嬪姟娴佹按 */
+  export interface Transaction {
+    id?: number;
+    type?: number; // 浜嬪姟绫诲瀷锛�1-鍏ュ簱 2-鍑哄簱锛�
+    typeName?: string; // 浜嬪姟绫诲瀷鍚嶇О
+    bizType?: number; // 涓氬姟绫诲瀷缂栫爜
+    bizTypeName?: string; // 涓氬姟绫诲瀷鍚嶇О
+    bizCode?: string; // 涓氬姟鍗曞彿
+    itemId?: number; // 鐗╂枡ID
+    itemCode?: string; // 鐗╂枡缂栫爜
+    itemName?: string; // 鐗╂枡鍚嶇О
+    quantity?: number; // 鍙樺姩鏁伴噺
+    batchId?: number; // 鎵规ID
+    batchCode?: string; // 鎵规鍙�
+    warehouseId?: number; // 浠撳簱ID
+    warehouseName?: string; // 浠撳簱鍚嶇О
+    locationId?: number; // 搴撳尯ID
+    locationName?: string; // 搴撳尯鍚嶇О
+    areaId?: number; // 搴撲綅ID
+    areaName?: string; // 搴撲綅鍚嶇О
+    transactionTime?: string; // 浜嬪姟鍙戠敓鏃堕棿
+    createTime?: string; // 鍒涘缓鏃堕棿
+  }
+
+  /** 鍒嗛〉鏌ヨ鍙傛暟 */
+  export interface PageParams extends PageParam {
+    itemId?: number;
+    batchCode?: string;
+    warehouseId?: number;
+    locationId?: number;
+    areaId?: number;
+    type?: number;
+    bizType?: number;
+    bizCode?: string;
+    materialStockId?: number;
+    startTime?: string;
+    endTime?: string;
+  }
+}
+
+/** 鍒嗛〉鏌ヨ搴撳瓨浜嬪姟娴佹按 */
+export function getTransactionPage(params: MesWmTransactionApi.PageParams) {
+  return requestClient.get<PageResult<MesWmTransactionApi.Transaction>>(
+    '/mes/wm/transaction/page',
+    { params },
+  );
+}
diff --git a/src/views/wls/transaction/data.ts b/src/views/wls/transaction/data.ts
new file mode 100644
index 0000000..59e50fc
--- /dev/null
+++ b/src/views/wls/transaction/data.ts
@@ -0,0 +1,205 @@
+import type { VbenFormSchema } from '#/adapter/form';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesWmTransactionApi } from '#/api/mes/wm/transaction';
+
+import { markRaw } from 'vue';
+
+import { MdmItemSelect } from '#/views/basicData/mdm/components';
+import {
+  WmWarehouseAreaSelect,
+  WmWarehouseLocationSelect,
+  WmWarehouseSelect,
+} from '#/views/wls/warehouse/components';
+
+/** 涓氬姟绫诲瀷閫夐」 */
+const bizTypeOptions = [
+  { label: '鑷畾涔夊叆搴�', value: 126 },
+  { label: '鑷畾涔夊嚭搴�', value: 127 },
+  { label: '閲囪喘鍏ュ簱', value: 110 },
+  { label: '閿�鍞嚭搴�', value: 119 },
+  { label: '璋冩嫧鍑哄簱', value: 112 },
+  { label: '璋冩嫧鍏ュ簱', value: 113 },
+  { label: '鍏朵粬鍏ュ簱', value: 115 },
+  { label: '鍏朵粬鍑哄簱', value: 114 },
+  { label: '鐢熶骇棰嗘枡', value: 116 },
+  { label: '鐢熶骇閫�鏂�', value: 117 },
+  { label: '鐢熶骇鍏ュ簱', value: 118 },
+  { label: '鐢熶骇娑堣��', value: 123 },
+  { label: '浜у搧浜у嚭', value: 124 },
+  { label: '渚涘簲鍟嗛��璐�', value: 125 },
+  { label: '閿�鍞��璐�', value: 120 },
+  { label: '澶栧崗鍙戞枡', value: 121 },
+  { label: '澶栧崗鍏ュ簱', value: 122 },
+];
+
+/** 鍒楄〃鐨勬悳绱㈣〃鍗� */
+export function useGridFormSchema(): VbenFormSchema[] {
+  return [
+    {
+      fieldName: 'itemId',
+      label: '鐗╂枡',
+      component: markRaw(MdmItemSelect),
+      componentProps: {
+        placeholder: '璇烽�夋嫨鐗╂枡',
+      },
+    },
+    {
+      fieldName: 'batchCode',
+      label: '鎵规鍙�',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ユ壒娆″彿',
+      },
+    },
+    {
+      fieldName: 'warehouseId',
+      label: '浠撳簱',
+      component: markRaw(WmWarehouseSelect),
+      componentProps: {
+        placeholder: '璇烽�夋嫨浠撳簱',
+      },
+    },
+    {
+      fieldName: 'locationId',
+      label: '搴撳尯',
+      component: markRaw(WmWarehouseLocationSelect),
+      dependencies: {
+        triggerFields: ['warehouseId'],
+        componentProps: (values) => ({
+          warehouseId: values.warehouseId,
+          placeholder: '璇烽�夋嫨搴撳尯',
+        }),
+        trigger: (values, formApi) => {
+          if (values.locationId !== undefined) {
+            void formApi.setFieldValue('locationId', undefined);
+          }
+        },
+      },
+    },
+    {
+      fieldName: 'areaId',
+      label: '搴撲綅',
+      component: markRaw(WmWarehouseAreaSelect),
+      dependencies: {
+        triggerFields: ['warehouseId', 'locationId'],
+        componentProps: (values) => ({
+          locationId: values.locationId,
+          placeholder: '璇烽�夋嫨搴撲綅',
+        }),
+        trigger: (values, formApi) => {
+          if (values.areaId !== undefined) {
+            void formApi.setFieldValue('areaId', undefined);
+          }
+        },
+      },
+    },
+    {
+      fieldName: 'type',
+      label: '浜嬪姟绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: [
+          { label: '鍏ュ簱', value: 1 },
+          { label: '鍑哄簱', value: 2 },
+        ],
+        placeholder: '璇烽�夋嫨浜嬪姟绫诲瀷',
+      },
+    },
+    {
+      fieldName: 'bizType',
+      label: '涓氬姟绫诲瀷',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: bizTypeOptions,
+        placeholder: '璇烽�夋嫨涓氬姟绫诲瀷',
+      },
+    },
+    {
+      fieldName: 'bizCode',
+      label: '涓氬姟鍗曞彿',
+      component: 'Input',
+      componentProps: {
+        allowClear: true,
+        placeholder: '璇疯緭鍏ヤ笟鍔″崟鍙�',
+      },
+    },
+    {
+      fieldName: 'transactionTime',
+      label: '浜嬪姟鏃堕棿',
+      component: 'RangePicker',
+      componentProps: {
+        allowClear: true,
+        format: 'YYYY-MM-DD HH:mm:ss',
+        showTime: true,
+        valueFormat: 'YYYY-MM-DD HH:mm:ss',
+      },
+    },
+  ];
+}
+
+/** 鍒楄〃鐨勫瓧娈� */
+export function useGridColumns(): VxeTableGridOptions<MesWmTransactionApi.Transaction>['columns'] {
+  return [
+    {
+      field: 'typeName',
+      title: '浜嬪姟绫诲瀷',
+      width: 80,
+      slots: { default: 'typeName' },
+    },
+    {
+      field: 'bizTypeName',
+      title: '涓氬姟绫诲瀷',
+      width: 100,
+    },
+    {
+      field: 'bizCode',
+      title: '涓氬姟鍗曞彿',
+      minWidth: 150,
+    },
+    {
+      field: 'itemCode',
+      title: '鐗╂枡缂栫爜',
+      width: 120,
+    },
+    {
+      field: 'itemName',
+      title: '鐗╂枡鍚嶇О',
+      minWidth: 150,
+    },
+    {
+      field: 'batchCode',
+      title: '鎵规鍙�',
+      width: 120,
+    },
+    {
+      field: 'quantity',
+      title: '鏁伴噺',
+      width: 100,
+      slots: { default: 'quantity' },
+    },
+    {
+      field: 'warehouseName',
+      title: '浠撳簱',
+      width: 100,
+    },
+    {
+      field: 'locationName',
+      title: '搴撳尯',
+      width: 100,
+    },
+    {
+      field: 'areaName',
+      title: '搴撲綅',
+      width: 100,
+    },
+    {
+      field: 'transactionTime',
+      title: '浜嬪姟鏃堕棿',
+      width: 160,
+      formatter: 'formatDateTime',
+    },
+  ];
+}
diff --git a/src/views/wls/transaction/index.vue b/src/views/wls/transaction/index.vue
new file mode 100644
index 0000000..8bd48e4
--- /dev/null
+++ b/src/views/wls/transaction/index.vue
@@ -0,0 +1,71 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { MesWmTransactionApi } from '#/api/mes/wm/transaction';
+
+import { Page } from '@vben/common-ui';
+
+import { Tag } from 'ant-design-vue';
+
+import { useVbenVxeGrid } from '#/adapter/vxe-table';
+import { getTransactionPage } from '#/api/mes/wm/transaction';
+
+import { useGridColumns, useGridFormSchema } from './data';
+
+const [Grid, gridApi] = useVbenVxeGrid({
+  formOptions: {
+    schema: useGridFormSchema(),
+  },
+  gridOptions: {
+    columns: useGridColumns(),
+    height: 'auto',
+    keepSource: true,
+    proxyConfig: {
+      ajax: {
+        query: async ({ page }, formValues) => {
+          const params: MesWmTransactionApi.PageParams = {
+            pageNo: page.currentPage,
+            pageSize: page.pageSize,
+            ...formValues,
+          };
+          if (formValues.transactionTime?.length === 2) {
+            params.startTime = formValues.transactionTime[0];
+            params.endTime = formValues.transactionTime[1];
+          }
+          delete (params as any).transactionTime;
+          return await getTransactionPage(params);
+        },
+      },
+    },
+    rowConfig: {
+      keyField: 'id',
+      isHover: true,
+    },
+    toolbarConfig: {
+      refresh: true,
+      search: true,
+    },
+  } as VxeTableGridOptions<MesWmTransactionApi.Transaction>,
+});
+</script>
+
+<template>
+  <Page auto-content-height>
+    <Grid table-title="搴撳瓨浜嬪姟娴佹按">
+      <template #typeName="{ row }">
+        <Tag :color="row.type === 1 ? 'green' : 'red'">
+          {{ row.typeName || '-' }}
+        </Tag>
+      </template>
+      <template #quantity="{ row }">
+        <span
+          :class="{
+            'text-green-600 font-bold': (row.quantity ?? 0) > 0,
+            'text-red-600 font-bold': (row.quantity ?? 0) < 0,
+          }"
+        >
+          {{ (row.quantity ?? 0).toFixed(2) }}
+        </span>
+      </template>
+    </Grid>
+  </Page>
+</template>

--
Gitblit v1.9.3