Răsfoiți Sursa

添加误排除文件

skyline 2 luni în urmă
părinte
comite
5c2b741004

+ 177 - 0
haha-admin-web/src/views/inventory/logs/index.vue

@@ -0,0 +1,177 @@
+<script setup lang="ts">
+import { ref } from "vue";
+import { PureTableBar } from "@/components/RePureTableBar";
+import { useRenderIcon } from "@/components/ReIcon/src/hooks";
+import Refresh from "~icons/ep/refresh";
+
+defineOptions({
+  name: "InventoryLogs"
+});
+
+const formRef = ref();
+const tableRef = ref();
+
+const loading = ref(false);
+const dataList = ref([]);
+const pagination = ref({
+  total: 0,
+  pageSize: 10,
+  currentPage: 1
+});
+
+const form = ref({
+  deviceId: "",
+  productId: ""
+});
+
+const columns = [
+  {
+    label: "设备名称",
+    prop: "deviceName",
+    minWidth: 120
+  },
+  {
+    label: "商品名称",
+    prop: "productName",
+    minWidth: 120
+  },
+  {
+    label: "变动类型",
+    prop: "changeType",
+    minWidth: 100
+  },
+  {
+    label: "变动数量",
+    prop: "quantity",
+    minWidth: 100
+  },
+  {
+    label: "变动前库存",
+    prop: "beforeStock",
+    minWidth: 100
+  },
+  {
+    label: "变动后库存",
+    prop: "afterStock",
+    minWidth: 100
+  },
+  {
+    label: "操作人",
+    prop: "operator",
+    minWidth: 100
+  },
+  {
+    label: "变动时间",
+    prop: "createTime",
+    minWidth: 160
+  }
+];
+
+const onSearch = () => {
+  loading.value = true;
+  setTimeout(() => {
+    dataList.value = [];
+    loading.value = false;
+  }, 500);
+};
+
+const resetForm = (formEl: any) => {
+  if (!formEl) return;
+  formEl.resetFields();
+  onSearch();
+};
+
+const handleSizeChange = (val: number) => {
+  pagination.value.pageSize = val;
+  onSearch();
+};
+
+const handleCurrentChange = (val: number) => {
+  pagination.value.currentPage = val;
+  onSearch();
+};
+
+onSearch();
+</script>
+
+<template>
+  <div class="main">
+    <el-form
+      ref="formRef"
+      :inline="true"
+      :model="form"
+      class="search-form bg-bg_color w-full pl-8 pt-[12px] overflow-auto"
+    >
+      <el-form-item label="设备:" prop="deviceId">
+        <el-select
+          v-model="form.deviceId"
+          placeholder="请选择设备"
+          clearable
+          filterable
+          class="w-[180px]!"
+        >
+        </el-select>
+      </el-form-item>
+      <el-form-item label="商品:" prop="productId">
+        <el-select
+          v-model="form.productId"
+          placeholder="请选择商品"
+          clearable
+          filterable
+          class="w-[180px]!"
+        >
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          type="primary"
+          :icon="useRenderIcon('ri/search-line')"
+          :loading="loading"
+          @click="onSearch"
+        >
+          搜索
+        </el-button>
+        <el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)">
+          重置
+        </el-button>
+      </el-form-item>
+    </el-form>
+
+    <PureTableBar
+      title="库存变动"
+      :columns="columns"
+      @refresh="onSearch"
+    >
+      <template v-slot="{ size, dynamic_columns }">
+        <pure-table
+          ref="tableRef"
+          row-key="id"
+          adaptive
+          :adaptiveConfig="{ offsetBottom: 108 }"
+          align-whole="center"
+          table-layout="auto"
+          :loading="loading"
+          :size="size"
+          :data="dataList"
+          :columns="dynamic_columns"
+          :pagination="{ ...pagination, size }"
+          :header-cell-style="{
+            background: 'var(--el-fill-color-light)',
+            color: 'var(--el-text-color-primary)'
+          }"
+          @page-size-change="handleSizeChange"
+          @page-current-change="handleCurrentChange"
+        >
+        </pure-table>
+      </template>
+    </PureTableBar>
+  </div>
+</template>
+
+<style lang="scss" scoped>
+.search-form {
+  :deep(.el-form-item) {
+    margin-bottom: 12px;
+  }
+}
+</style>

+ 146 - 0
haha-admin-web/src/views/inventory/logs/utils/hook.tsx

@@ -0,0 +1,146 @@
+import dayjs from "dayjs";
+import { message } from "@/utils/message";
+import { getInventoryLogs } from "@/api/inventory";
+import type { PaginationProps } from "@pureadmin/table";
+import { onMounted, reactive, ref, toRaw } from "vue";
+
+export function useInventoryLogs() {
+  const form = reactive<SearchFormProps>({
+    deviceId: "",
+    productId: undefined,
+    changeType: ""
+  });
+  const loading = ref(true);
+  const dataList = ref([]);
+  const pagination = reactive<PaginationProps>({
+    total: 0,
+    pageSize: 10,
+    currentPage: 1,
+    background: true
+  });
+
+  const columns: TableColumnList = [
+    {
+      label: "设备ID",
+      prop: "deviceId",
+      minWidth: 120
+    },
+    {
+      label: "设备名称",
+      prop: "deviceName",
+      minWidth: 120
+    },
+    {
+      label: "商品编码",
+      prop: "productCode",
+      minWidth: 120
+    },
+    {
+      label: "商品名称",
+      prop: "productName",
+      minWidth: 150
+    },
+    {
+      label: "变动类型",
+      prop: "changeType",
+      minWidth: 100,
+      cellRenderer: ({ row }) => {
+        const typeMap = {
+          increase: { text: "增加", type: "success" },
+          decrease: { text: "减少", type: "danger" },
+          adjust: { text: "调整", type: "warning" }
+        };
+        const item = typeMap[row.changeType] || { text: row.changeType, type: "info" };
+        return <el-tag type={item.type}>{item.text}</el-tag>;
+      }
+    },
+    {
+      label: "变动数量",
+      prop: "changeQuantity",
+      minWidth: 100,
+      cellRenderer: ({ row }) => (
+        <span class={row.changeQuantity > 0 ? "text-success" : "text-danger"}>
+          {row.changeQuantity > 0 ? "+" : ""}{row.changeQuantity}
+        </span>
+      )
+    },
+    {
+      label: "变动前库存",
+      prop: "beforeStock",
+      minWidth: 100
+    },
+    {
+      label: "变动后库存",
+      prop: "afterStock",
+      minWidth: 100
+    },
+    {
+      label: "操作人",
+      prop: "operatorName",
+      minWidth: 100
+    },
+    {
+      label: "备注",
+      prop: "remark",
+      minWidth: 150,
+      showOverflowTooltip: true
+    },
+    {
+      label: "操作时间",
+      prop: "createTime",
+      minWidth: 160,
+      formatter: ({ createTime }) =>
+        createTime ? dayjs(createTime).format("YYYY-MM-DD HH:mm:ss") : ""
+    }
+  ];
+
+  async function onSearch() {
+    loading.value = true;
+    try {
+      const { data } = await getInventoryLogs({
+        ...toRaw(form),
+        page: pagination.currentPage,
+        pageSize: pagination.pageSize
+      });
+      if (data) {
+        dataList.value = data.list || [];
+        pagination.total = data.total || 0;
+      }
+    } finally {
+      loading.value = false;
+    }
+  }
+
+  function resetForm(formEl) {
+    if (!formEl) return;
+    formEl.resetFields();
+    pagination.currentPage = 1;
+    onSearch();
+  }
+
+  function handleSizeChange(val: number) {
+    pagination.pageSize = val;
+    onSearch();
+  }
+
+  function handleCurrentChange(val: number) {
+    pagination.currentPage = val;
+    onSearch();
+  }
+
+  onMounted(() => {
+    onSearch();
+  });
+
+  return {
+    form,
+    loading,
+    columns,
+    dataList,
+    pagination,
+    onSearch,
+    resetForm,
+    handleSizeChange,
+    handleCurrentChange
+  };
+}

+ 26 - 0
haha-admin-web/src/views/inventory/logs/utils/types.ts

@@ -0,0 +1,26 @@
+interface SearchFormProps {
+  deviceId?: string;
+  productId?: number;
+  changeType?: string;
+  page?: number;
+  pageSize?: number;
+}
+
+interface LogItemProps {
+  id: number;
+  deviceId: string;
+  deviceName?: string;
+  productId: number;
+  productCode: string;
+  productName: string;
+  changeType: string;
+  changeQuantity: number;
+  beforeStock: number;
+  afterStock: number;
+  operatorId: number;
+  operatorName: string;
+  remark?: string;
+  createTime: string;
+}
+
+export type { SearchFormProps, LogItemProps };