From ef754c4844cdd88949117ef6cdc43325dd38d557 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 08 一月 2026 17:21:02 +0800
Subject: [PATCH] 代码调整11

---
 src/views/financialManagement/inventoryAccounting/index.vue |  390 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 390 insertions(+), 0 deletions(-)

diff --git a/src/views/financialManagement/inventoryAccounting/index.vue b/src/views/financialManagement/inventoryAccounting/index.vue
new file mode 100644
index 0000000..3acf5d9
--- /dev/null
+++ b/src/views/financialManagement/inventoryAccounting/index.vue
@@ -0,0 +1,390 @@
+<template>
+  <div class="inventory-statistics">
+    <!-- 绛涢�夎〃鍗� -->
+    <div class="filter-form">
+      <el-form :model="filterForm" inline>
+<!--        <el-form-item label="鏃堕棿鑼冨洿">-->
+<!--          <el-date-picker-->
+<!--            v-model="filterForm.dateRange"-->
+<!--            type="daterange"-->
+<!--            range-separator="鑷�"-->
+<!--            start-placeholder="寮�濮嬫棩鏈�"-->
+<!--            end-placeholder="缁撴潫鏃ユ湡"-->
+<!--          />-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="渚涘簲鍟嗗悕绉�">-->
+<!--          <el-input v-model="filterForm.supplierName" style="width: 240px" placeholder="璇疯緭鍏�" clearable prefix-icon="Search" />-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="浜у搧鍚嶇О">-->
+<!--          <el-input v-model="filterForm.productCategory" style="width: 240px" placeholder="璇疯緭鍏�" clearable prefix-icon="Search" />-->
+<!--        </el-form-item>-->
+        <el-form-item>
+          <el-button type="primary" @click="handleSearch">鏌ヨ</el-button>
+<!--          <el-button @click="handleReset">閲嶇疆</el-button>-->
+<!--          <el-button type="success" @click="handleExport">瀵煎嚭</el-button>-->
+        </el-form-item>
+      </el-form>
+    </div>
+
+    <!-- 缁熻姹囨�诲崱鐗� -->
+    <div class="summary-cards">
+      <el-row :gutter="20">
+        <el-col :span="6">
+          <el-card class="summary-card">
+            <div class="summary-item">
+              <p class="summary-title">鎬诲簱瀛樻暟閲�</p>
+              <p class="summary-value">{{ summaryData.totalInventoryCount }}</p>
+            </div>
+          </el-card>
+        </el-col>
+        <el-col :span="6">
+          <el-card class="summary-card">
+            <div class="summary-item">
+              <p class="summary-title">鎬诲簱瀛橀噾棰�</p>
+              <p class="summary-value">楼{{ summaryData.totalInventoryValue }}</p>
+            </div>
+          </el-card>
+        </el-col>
+        <el-col :span="6">
+          <el-card class="summary-card">
+            <div class="summary-item">
+              <p class="summary-title">搴撳瓨鍙樺姩鏁伴噺</p>
+              <p class="summary-value">{{ summaryData.inventoryChangeCount }}</p>
+            </div>
+          </el-card>
+        </el-col>
+        <el-col :span="6">
+          <el-card class="summary-card">
+            <div class="summary-item">
+              <p class="summary-title">搴撳瓨鍙樺姩閲戦</p>
+              <p class="summary-value">楼{{ summaryData.inventoryChangeValue }}</p>
+            </div>
+          </el-card>
+        </el-col>
+      </el-row>
+    </div>
+
+    <!-- 鍥捐〃鍖哄煙 -->
+    <div class="chart-section">
+      <el-row :gutter="20">
+        <el-col :span="12">
+          <el-card class="chart-card">
+            <template #header>
+              <div class="card-header">
+                <span>搴撳瓨鍒嗙被鍗犳瘮</span>
+              </div>
+            </template>
+            <div id="category-pie-chart" style="height: 400px;"></div>
+          </el-card>
+        </el-col>
+        <el-col :span="12">
+          <el-card class="chart-card">
+            <template #header>
+              <div class="card-header">
+                <span>搴撳瓨閲戦瓒嬪娍</span>
+              </div>
+            </template>
+            <div id="amount-trend-chart" style="height: 400px;"></div>
+          </el-card>
+        </el-col>
+      </el-row>
+    </div>
+
+    <!-- 鏁版嵁琛ㄦ牸 -->
+    <div class="table_list">
+      <el-table
+        :data="tableData"
+        v-loading="loading"
+        border
+        style="width: 100%"
+        :header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
+      >
+        <el-table-column align="center" type="selection" width="55" />
+        <el-table-column align="center" label="搴忓彿" type="index" width="60" />
+        <el-table-column label="渚涘簲鍟嗗悕绉�" prop="supplierName" width="240" show-overflow-tooltip />
+        <el-table-column label="浜у搧" prop="productCategory" min-width="100" show-overflow-tooltip />
+        <el-table-column label="瑙勬牸鍨嬪彿" prop="specificationModel" min-width="200" show-overflow-tooltip />
+        <el-table-column label="鍗曚綅" prop="unit" width="70" show-overflow-tooltip />
+        <el-table-column label="鍏ュ簱鏁伴噺" prop="inboundNum" width="90" show-overflow-tooltip />
+        <el-table-column label="搴撳瓨鏁伴噺" prop="inboundNum0" width="90" show-overflow-tooltip />
+        <el-table-column label="鍚◣鍗曚环" prop="taxInclusiveUnitPrice" width="100" show-overflow-tooltip />
+        <el-table-column label="鍚◣鎬讳环" prop="taxInclusiveTotalPrice" width="100" show-overflow-tooltip />
+        <el-table-column label="绋庣巼(%)" prop="taxRate" width="80" show-overflow-tooltip />
+        <el-table-column label="涓嶅惈绋庢�讳环" prop="taxExclusiveTotalPrice" width="100" show-overflow-tooltip />
+        <el-table-column label="鍏ュ簱浜�" prop="createBy" width="100" show-overflow-tooltip />
+      </el-table>
+      <pagination v-show="total > 0" :total="total" layout="total, sizes, prev, pager, next, jumper" :page="page.current" :limit="page.size" @pagination="paginationChange" />
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, reactive, onMounted, nextTick } from 'vue'
+import * as echarts from 'echarts'
+import {getStockInChartData, getStockInPage} from "@/api/inventoryManagement/stockIn.js";
+
+// 鐘舵�佸彉閲�
+const loading = ref(false)
+const total = ref(0)
+const tableData = ref([])
+const summaryData = ref({})
+const page = reactive({
+  current: 1,
+  size: 100,
+})
+
+// 鍥捐〃瀹炰緥
+const categoryPieChart = ref(null)
+const amountTrendChart = ref(null)
+
+// 绛涢�夎〃鍗�
+const filterForm = reactive({
+  dateRange: [],
+  supplierName: '',
+  productCategory: ''
+})
+
+const paginationChange = (obj) => {
+  page.current = obj.page;
+  page.size = obj.limit;
+  loadData()
+}
+
+// 鍒濆鍖栨暟鎹�
+onMounted(() => {
+  loadSummaryData()
+  loadData()
+})
+
+// 鍔犺浇缁熻姹囨�绘暟鎹�
+const loadSummaryData = () => {
+  getStockInChartData().then(res => {
+    summaryData.value = res.data
+  })
+}
+
+// 鍔犺浇搴撳瓨鏁版嵁
+const loadData = () => {
+  loading.value = true
+  getStockInPage({ ...filterForm, ...page }).then(res => {
+    loading.value = false
+    tableData.value = res.data.records
+    total.value = res.data.total
+    console.log('res', res.data.records)
+
+    // 鏁版嵁鍔犺浇瀹屾垚鍚庢覆鏌撳浘琛�
+    nextTick(() => {
+      renderCategoryPieChart()
+      renderAmountTrendChart()
+    })
+  }).catch(() => {
+    loading.value = false
+  })
+}
+
+// 娓叉煋鍒嗙被鍗犳瘮楗煎浘
+const renderCategoryPieChart = () => {
+  if (!categoryPieChart.value) {
+    categoryPieChart.value = echarts.init(document.getElementById('category-pie-chart'))
+  }
+  // 鏍规嵁 tableData 鎸� productCategory 鍒嗙被骞惰绠� inboundNum0 鏁伴噺鎬诲拰
+  const categoryMap = tableData.value.reduce((acc, cur) => {
+    acc[cur.productCategory] = (acc[cur.productCategory] || 0) + cur.inboundNum0
+    return acc
+  }, {})
+
+  // 灏嗗垎绫荤粨鏋滆浆鎹负 ECharts 楗煎浘鎵�闇�鐨勬暟鎹牸寮�
+  const categoryData = Object.entries(categoryMap).map(([name, value]) => ({
+    name: name,
+    value: value
+  }))
+  const option = {
+    title: {
+      text: '搴撳瓨鍒嗙被鍗犳瘮',
+      left: 'center'
+    },
+    tooltip: {
+      trigger: 'item',
+      formatter: '{a} <br/>{b}: {c} ({d}%)'
+    },
+    legend: {
+      orient: 'vertical',
+      left: 'left'
+    },
+    series: [
+      {
+        name: '搴撳瓨鍒嗙被',
+        type: 'pie',
+        radius: ['40%', '70%'],
+        avoidLabelOverlap: false,
+        itemStyle: {
+          borderRadius: 10,
+          borderColor: '#fff',
+          borderWidth: 2
+        },
+        label: {
+          show: true,
+          formatter: '{b}: {d}%'
+        },
+        emphasis: {
+          label: {
+            show: true,
+            fontSize: '16',
+            fontWeight: 'bold'
+          }
+        },
+        data: categoryData
+      }
+    ]
+  }
+
+  categoryPieChart.value.setOption(option)
+}
+// 娓叉煋閲戦瓒嬪娍鎶樼嚎鍥�
+const renderAmountTrendChart = () => {
+  if (!amountTrendChart.value) {
+    amountTrendChart.value = echarts.init(document.getElementById('amount-trend-chart'))
+  }
+  // 鎸夋湀浠藉垎缁勫苟璁$畻taxInclusiveTotalPrice鎬诲拰
+  const monthlyAmounts = tableData.value.reduce((acc, cur) => {
+    const date = new Date(cur.createTime);
+    const month = date.getMonth() + 1;
+
+    // 纭繚month鍦�1-12鑼冨洿鍐�
+    if (month >= 1 && month <= 12) {
+      acc[month] = (acc[month] || 0) + cur.taxInclusiveTotalPrice;
+    }
+    return acc;
+  }, {});
+
+  // 鐢熸垚12涓湀鐨勬暟鎹紝缂哄け鏈堜唤鐢�0浠f浛
+  const amounts = [];
+  for (let i = 1; i <= 12; i++) {
+    amounts.push(monthlyAmounts[i] || 0);
+  }
+  const dates = ['1鏈�', '2鏈�', '3鏈�', '4鏈�', '5鏈�', '6鏈�', '7鏈�', '8鏈�', '9鏈�', '10鏈�', '11鏈�', '12鏈�']
+
+  const option = {
+    title: {
+      text: '搴撳瓨閲戦瓒嬪娍',
+      left: 'center'
+    },
+    tooltip: {
+      trigger: 'axis',
+      formatter: '{b}: 楼{c}'
+    },
+    xAxis: {
+      type: 'category',
+      data: dates
+    },
+    yAxis: {
+      type: 'value',
+      axisLabel: {
+        formatter: '楼{value}'
+      }
+    },
+    series: [
+      {
+        name: '搴撳瓨閲戦',
+        type: 'line',
+        data: amounts,
+        smooth: true,
+        areaStyle: {}
+      }
+    ]
+  }
+
+  amountTrendChart.value.setOption(option)
+}
+
+// 鏌ヨ鎿嶄綔
+const handleSearch = () => {
+  loadData()
+}
+
+// 閲嶇疆鎿嶄綔
+const handleReset = () => {
+  filterForm.dateRange = []
+  filterForm.supplierName = ''
+  filterForm.productCategory = ''
+  loadData()
+}
+
+// 瀵煎嚭鎿嶄綔
+const handleExport = () => {
+  console.log('瀵煎嚭鏁版嵁')
+}
+
+// 绐楀彛澶у皬鏀瑰彉鏃讹紝閲嶆柊璋冩暣鍥捐〃澶у皬
+window.addEventListener('resize', () => {
+  if (categoryPieChart.value) categoryPieChart.value.resize()
+  if (amountTrendChart.value) amountTrendChart.value.resize()
+})
+</script>
+
+<style scoped>
+.inventory-statistics {
+  padding: 20px;
+}
+
+.filter-form {
+  margin-bottom: 20px;
+}
+
+.summary-cards {
+  margin-bottom: 20px;
+}
+
+.summary-card {
+  text-align: center;
+  height: 100px;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+}
+
+.summary-item {
+  width: 100%;
+}
+
+.summary-title {
+  font-size: 14px;
+  color: #606266;
+  margin-bottom: 5px;
+}
+
+.summary-value {
+  font-size: 24px;
+  font-weight: bold;
+  color: #303133;
+}
+
+.summary-value.warning {
+  color: #e6a23c;
+}
+
+.summary-value.danger {
+  color: #f56c6c;
+}
+
+.chart-section {
+  margin-bottom: 20px;
+}
+
+.chart-card {
+  height: 460px;
+}
+
+.card-header {
+  font-weight: bold;
+}
+
+.table_list {
+  margin-top: 20px;
+}
+
+.pagination {
+  text-align: right;
+  margin-top: 20px;
+}
+</style>

--
Gitblit v1.9.3