Explorar el Código

瑞恒看板库存模块

yanghao hace 2 semanas
padre
commit
3e71cd5e7a

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.86:48080  https://iot.deepoil.cc:5443  http://172.26.0.56:48080  http://192.168.188.198:48080
-VITE_BASE_URL='https://iot.deepoil.cc:5443'
+VITE_BASE_URL='http://172.30.41.105:48080'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 5 - 0
src/api/pms/stat/index.ts

@@ -208,6 +208,11 @@ export const IotStatApi = {
     return await request.get({ url: `rq/stat/rd/device/teamUtilizationRate`, params })
   },
 
+  // 瑞恒看板-存货分布、积压趋势
+  getInventoryDistribution: async (params: any) => {
+    return await request.get({ url: `/pms/iot-prod-inventory-aging/inventoryStatus`, params })
+  },
+
   getMaintainCount: async (params?: any) => {
     return await request.get({ url: `/rq/stat/home/maintain/count/` + params })
   },

+ 36 - 0
src/views/pms/stat/rhkb.vue

@@ -1,5 +1,6 @@
 <script lang="ts" setup>
 import { DESIGN_HEIGHT, DESIGN_WIDTH } from '@/utils/kb'
+import dayjs from 'dayjs'
 
 import rhsummary from './rhkb/rhsummary.vue'
 import deviceType from './rhkb/deviceType.vue'
@@ -25,6 +26,8 @@ const pageTabs = [
   { label: '生产日报', value: 'device' }
 ] as const
 
+const selectedDate = ref(dayjs().subtract(1, 'day').format('YYYY-MM-DD'))
+
 const wrapperRef = ref<HTMLDivElement>()
 const scale = ref(1)
 
@@ -32,6 +35,7 @@ let resizeObserver: ResizeObserver | null = null
 let resizeRaf = 0
 
 provide('rhKbScale', scale)
+provide('rhKbInventoryDate', selectedDate)
 
 const targetWrapperStyle = computed(() => ({
   width: `${DESIGN_WIDTH * scale.value}px`,
@@ -102,6 +106,15 @@ onUnmounted(() => {
               {{ tab.label }}
             </button>
           </div>
+          <div v-if="activePage === 'home'" class="page-filters">
+            <el-date-picker
+              v-model="selectedDate"
+              value-format="YYYY-MM-DD"
+              type="date"
+              placeholder="选择日期"
+              :clearable="false"
+              class="page-date-picker" />
+          </div>
 
           <div v-if="activePage === 'home'" class="kb-home-page">
             <rhsummary class="kb-stage-card kb-stage-card--1" />
@@ -152,6 +165,29 @@ onUnmounted(() => {
   gap: calc(12px * var(--kb-scale));
 }
 
+.page-filters {
+  position: absolute;
+  top: calc(10px * var(--kb-scale));
+  right: calc(20px * var(--kb-scale));
+  z-index: 3;
+}
+
+.page-date-picker {
+  width: calc(132px * var(--kb-scale));
+
+  :deep(.el-input__wrapper) {
+    min-height: calc(28px * var(--kb-scale));
+    padding: 0 calc(8px * var(--kb-scale));
+    background: rgb(255 255 255 / 88%);
+    border-radius: calc(5px * var(--kb-scale));
+    box-shadow: 0 0 0 1px rgb(31 91 184 / 28%) inset;
+  }
+
+  :deep(.el-input__inner) {
+    font-size: calc(13px * var(--kb-scale));
+  }
+}
+
 .page-tab {
   height: calc(28px * var(--kb-scale));
   min-width: calc(82px * var(--kb-scale));

+ 31 - 0
src/views/pms/stat/rhkb/inventorySituation.vue

@@ -9,6 +9,10 @@ import {
   THEME
 } from '@/utils/kb'
 
+import { IotStatApi } from '@/api/pms/stat'
+import dayjs from 'dayjs'
+import { getUserProfile } from '@/api/system/user/profile'
+
 type ActivePanel = 'distribution' | 'trend'
 
 type InventoryItem = {
@@ -19,6 +23,8 @@ type InventoryItem = {
 }
 
 const activePanel = ref<ActivePanel>('distribution')
+const DEFAULT_DATE = dayjs().subtract(1, 'day').format('YYYY-MM-DD')
+const selectedDate = inject<Ref<string>>('rhKbInventoryDate', ref(DEFAULT_DATE))
 const distributionChartRef = ref<HTMLDivElement>()
 const trendChartRef = ref<HTMLDivElement>()
 
@@ -430,6 +436,19 @@ function destroyCharts() {
   trendChart = null
 }
 
+async function requestInventoryDistribution() {
+  if (deptId.value === null || !selectedDate.value) return
+
+  try {
+    await IotStatApi.getInventoryDistribution({
+      fdate: selectedDate.value,
+      dept: 157
+    })
+  } catch (error) {
+    console.error('获取库存分布数据失败', error)
+  }
+}
+
 watch(activePanel, (value) => {
   nextTick(() => {
     if (value === 'distribution') {
@@ -449,6 +468,18 @@ onMounted(() => {
   window.addEventListener('rhkb:resize', resizeCharts)
 })
 
+let deptId = ref<number | null>(null)
+
+onMounted(async () => {
+  const users = await getUserProfile()
+  deptId.value = users.dept.id
+  await requestInventoryDistribution()
+})
+
+watch(selectedDate, () => {
+  requestInventoryDistribution()
+})
+
 onUnmounted(() => {
   window.removeEventListener('resize', resizeCharts)
   window.removeEventListener('rhkb:resize', resizeCharts)