报表申报智能运输页面完成

This commit is contained in:
zx
2026-04-23 14:35:54 +08:00
parent 6f1db0f92e
commit 5ca85c1f0d
53 changed files with 3659 additions and 292 deletions

View File

@@ -1,6 +1,6 @@
<!-- 仓库/存储区选择 -->
<template>
<navigation :title="isWarehousing.value ? '仓库选择' : '存储区选择'" :back-url="backUrl"></navigation>
<navigation :title="title" :back-url="backUrl"></navigation>
<view class="contentBox">
<view class="topSearch">
@@ -11,7 +11,7 @@
<!-- 仓库/存储列表 -->
<z-paging ref="pagingRef" class="containerBox" v-model="infoList" @query="getList">
<uni-list class="listBox">
<uni-list-item v-for="item in infoList" :key="item.id" clickable @click="onChecked(item)">
<uni-list-item v-for="item in infoList" :key="item.id" clickable @tap="onChecked(item)">
<template v-slot:body>
<view style="display: flex; flex-direction: column; width: 100%;" v-if="isWarehousing">
<view class="line title">
@@ -34,8 +34,8 @@
<view class="line content">
<p>备注</p>
<p>
<span v-if="item?.remark"></span>
<span v-else class="empty">未填写</span>
<text v-if="item?.remark"></text>
<text v-else class="empty">未填写</text>
</p>
</view>
@@ -46,8 +46,8 @@
</view>
<view class="line content">
<p>
<span v-if="item?.remark">{{ item?.remark }}</span>
<span v-else class="empty">未填写</span>
<text v-if="item?.remark">{{ item?.remark }}</text>
<text v-else class="empty">未填写</text>
</p>
</view>
</view>
@@ -58,14 +58,36 @@
</view>
</template>
<script setup>
import { computed, ref, toRefs } from 'vue';
import { ref, toRefs } from 'vue';
import { onShow } from "@dcloudio/uni-app";
import { getWarehousingInfo } from '@/api/system';
import getRepository from "@/api/getRepository";
import { objectToQuery } from '../until';
import Navigation from '../components/Navigation.vue';
import { watch } from 'vue';
const OPERATE_CONFIG = {
materialQuery: {
toCheckUrl: '/pages/warehousing/Declaration/components/materialQueryDetail',
title: '请选择物资查询仓库',
},
inventoryAgeView: {
toCheckUrl: '/pages/warehousing/InventoryInfo/components/inventoryAgeDetail',
title: '请选择物资库龄查询仓库'
},
dailyReport: {
toCheckUrl: '/pages/warehousing/Report/components/dailyDetail',
title: '请选择查看日报表的仓库'
},
monthlyReport: {
toCheckUrl: '/pages/warehousing/Report/components/monthlyDetail',
title: '请选择查看月报表的仓库'
},
warehouseReport: {
toCheckUrl: '/pages/warehousing/Report/components/warehouseDetail',
title: '请选择查看库存的仓库'
},
}
const props = defineProps({
// 是否为仓库查询
isWarehousing: {
@@ -85,9 +107,8 @@ const { isWarehousing, pathParams } = toRefs(props)
const queryParams = ref({
keyword: ''
})
const title = ref('')
const backUrl = ref('')
// stockIn 入库单开单 stockIn_Detail入库单编辑 issueUniqueCode唯一码 issueUniqueCode_inbound入库生成唯一码
const keyType = computed(() => pathParams.value.type || pathParams.value.back)
// 绑定:加载屏
const pagingRef = ref(null)
// 数据:仓库/存储区
@@ -115,6 +136,7 @@ const getWarehousing = () => {
res.data.forEach(e => {
e.showMore = false;
});
infoList.value = res.data
pagingRef.value.complete(res.data)
}).catch(res => {
pagingRef.value.complete(false)
@@ -126,6 +148,7 @@ const getRepositoryInfo = async () => {
res.data.forEach(e => {
e.showMore = false;
});
infoList.value = res.data
pagingRef.value.complete(res.data)
}).catch(res => {
pagingRef.value.complete(false)
@@ -136,10 +159,12 @@ const getRepositoryInfo = async () => {
const toBack = (keyType) => {
console.log('监听', keyType);
let url = ''
let query = objectToQuery(pathParams.value)
switch (keyType) {
case 'stockIn':
// 入库单开单
url = '/pages/warehousing/stockIn/create'
break;
case 'stockOut':
// 出库单开单
@@ -149,45 +174,75 @@ const toBack = (keyType) => {
// 出库单出库
url = '/pages/warehousing/stockOut/components/outAway'
break;
case 'my':
// 出库单出库
url = '/pages/warehousing/stockIn/create'
break;
case 'materialQuery':
// 物资查询
url = 'pages/warehousing/index'
query = ''
break;
case 'inventoryAgeView':
// 库龄
url = 'pages/warehousing/index'
query = ''
break;
case 'dailyReport':
// 日报
query = ''
url = 'pages/warehousing/index'
break;
case 'monthlyReport':
// 月报
query = ''
url = 'pages/warehousing/index'
break;
default:
url = 'pages/warehousing/index';
query = '';
break;
}
const query = objectToQuery(pathParams.value)
backUrl.value = `${url}${query}`
backUrl.value = query ? `${url}${query}` : url
}
// 选择:仓库/存储区
const onChecked = (val) => {
const flag = isWarehousing.value ? 'app_warehousing' : 'app_storageArea'
let infoChecked = uni.getStorageSync(flag);
if (!Array.isArray(infoChecked)) {
infoChecked = [];
const toUrl = OPERATE_CONFIG?.[pathParams.value?.type]?.toCheckUrl;
let params = val.materialId ? { warehouseCode: val.deptId, materialId: val.materialId } : { warehouseCode: val.deptId }
if (pathParams.value.type === 'warehouseReport') {
params.title = val.deptName
}
const query = objectToQuery(params);
if (toUrl) {
uni.navigateTo({ url: toUrl + query });
return;
}
const flag = isWarehousing.value ? "app_warehousing" : "app_storageArea";
let infoChecked = uni.getStorageSync(flag) || [];
if (!Array.isArray(infoChecked)) infoChecked = [];
if (val) {
infoChecked = [{ ...val }]
infoChecked = [{ ...val }];
uni.setStorageSync(flag, infoChecked);
}
// 返回list
uni.navigateTo({
url: backUrl.value
})
}
// 监听:确保 pathParams 变化时一定执行 toBack()
uni.navigateTo({ url: backUrl.value });
};
watch(
() => pathParams.value,
(d) => {
console.log('pathParams 变化:', d);
if (!d) return
if (!d) return;
const type = d.type || d.back;
console.log(type, 'eeeeeee');
toBack(type)
const titleStr = OPERATE_CONFIG?.[d.type]?.title;
if (titleStr) {
title.value = titleStr;
} else {
title.value = isWarehousing.value ? "仓库选择" : "存储区选择";
}
toBack(type);
},
{ deep: true, immediate: true }
)
);
onShow(() => {
pagingRef.value?.reload?.()
})

View File

@@ -4,29 +4,29 @@
<view class="detailInfo mb-2">
<view class="line title">
<p> {{ typeName + '单号' }}{{ detailInfo?.billNo }}</p>
<span :style="getColor(detailInfo?.billType)">
<text :style="getColor(detailInfo?.billType)">
{{ getBillType(detailInfo?.billType, detailInfo?.status, flag) }}
</span>
</text>
</view>
<p class="line content">仓库
<span> {{ detailInfo?.warehouseName }}</span>
<text> {{ detailInfo?.warehouseName }}</text>
</p>
<p class="line content">存储区
<span> {{ detailInfo?.areaName }}</span>
<text> {{ detailInfo?.areaName }}</text>
</p>
<p class="line content">开单时间
<span>{{ formatDate(detailInfo?.createTime) }}</span>
<text>{{ formatDate(detailInfo?.createTime) }}</text>
</p>
<p class="line content" v-if="detailInfo?.inboundTime">{{ typeName + '时间' }}
<span>{{ formatDate(detailInfo?.inboundTime) }}</span>
<text>{{ formatDate(detailInfo?.inboundTime) }}</text>
</p>
</view>
<view class="detailInfo mb-6">
<p class="line content">
<span class="grey" style="font-weight: 600;">详细备注</span>
<text class="grey" style="font-weight: 600;">详细备注</text>
<span>{{ detailInfo?.billRemark || '-' }}</span>
<text>{{ detailInfo?.billRemark || '-' }}</text>
</p>
</view>
</view>

View File

@@ -0,0 +1,844 @@
<template>
<navigation :title="title" back-url="pages/intelligent/index"> </navigation>
<view class="warehouse-page contentBox">
<view class="warehouse-hero">
<view>
<text class="hero-sub">{{ projectName || '项目仓库' }}</text>
<view class="hero-title">{{ warehouseName || '仓库传感器看板' }}</view>
</view>
<view class="hero-meta ">
<view class="warehouse-hero-box">
<div class="summary-card mr-16 total">
<span class="label">设备总数</span>
<strong class="value">{{ sensorCards.length }}</strong>
</div>
<div class="summary-card mr-16 online">
<span class="label">在线设备</span>
<strong class="value">{{ onlineCount }}</strong>
</div>
<div class="summary-card offline">
<span class="label">离线设备</span>
<strong class="value">{{ offlineCount }}</strong>
</div>
</view>
<view class="report"> 最近上报:{{ latestReportTime || '--' }} </view>
</view>
</view>
<view class="sensor-grid">
<view v-if="loading" class="loading-view">加载中...</view>
<view v-else-if="sensorCards.length === 0" class="empty-state">
当前仓库暂无传感器设备
</view>
<view v-for="item in sensorCards" :key="item.cardKey" :class="['sensor-card', item.statusClass]">
<view class="sensor-content">
<view class="sensor-main">
<view class="sensor-top">
<view :class="['sensor-icon', item.type]">
<text>{{ item.icon }}</text>
</view>
<view class="sensor-state">
<text class="dot"></text>
{{ item.onlineText }}
</view>
</view>
<view class="sensor-body">
<text class="location">{{ item.locationName }}</text>
<view class="type-name">{{ item.typeName }}</view>
<text class="summary">{{ item.summary }}</text>
<view v-if="isSocketControlType(item.type)" class="socket-actions">
<button class="control-btn on" :disabled="!!controlLoadingMap[item.cardKey]"
@tap="handleSocketControl(item, 'on')">
{{ getSocketActionText(item.type, 'on', !!controlLoadingMap[item.cardKey]) }}
</button>
<button class="control-btn off" :disabled="!!controlLoadingMap[item.cardKey]"
@tap="handleSocketControl(item, 'off')">
{{ getSocketActionText(item.type, 'off', !!controlLoadingMap[item.cardKey]) }}
</button>
</view>
<view v-else-if="item.type === 'switch'" class="switch-actions">
<view v-for="channel in [1, 2, 3]" :key="channel" class="switch-row">
<text class="ch-label">开关{{ channel }}</text>
<button class="control-btn on"
:disabled="!!controlLoadingMap[`${item.cardKey}-ch-${channel}`]"
@tap="handleLightSwitchControl(item, channel, 'on')">
{{ !!controlLoadingMap[`${item.cardKey}-ch-${channel}`] ? '发送中...' : '' }}
</button>
<button class="control-btn off"
:disabled="!!controlLoadingMap[`${item.cardKey}-ch-${channel}`]"
@tap="handleLightSwitchControl(item, channel, 'off')">
{{ !!controlLoadingMap[`${item.cardKey}-ch-${channel}`] ? '发送中...' : '' }}
</button>
</view>
</view>
</view>
</view>
<view class="metric-panel">
<text class="panel-title">实时指标</text>
<view class="metric-list">
<view v-for="metric in item.metrics" :key="metric.label" class="metric-item">
<text class="label">{{ metric.label }}</text>
<text class="value">{{ metric.value }}</text>
</view>
<view v-if="item.metrics.length === 0" class="metric-item muted">
<text class="label">状态</text>
<text class="value">等待数据</text>
</view>
</view>
</view>
</view>
<view class="sensor-footer">
<text>DevEUI{{ item.devEui || '--' }}</text>
<text>{{ item.reportTime || '暂无上报' }}</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
import { controlLightSwitch, controlSocket, listMqttDevice, listMqttData, listMqttEvent } from '@/api/home'
import { closeWs, connectWs } from '../utils/ws'
import { onLoad } from "@dcloudio/uni-app";
import Navigation from './Navigation.vue';
const loading = ref(false)
const devices = ref([])
const title = ref('')
const latestDataMap = reactive({})
const controlLoadingMap = reactive({})
const ENV_CARD_TYPES = ['tempHum', 'toxicGas', 'hydrogenSulfide']
const deptId = ref('')
const projectName = ref('')
const warehouseName = ref('')
onLoad((options) => {
deptId.value = options?.deptId
projectName.value = options?.projectName
warehouseName.value = options?.warehouseName
title.value = options?.warehouseName
})
const sensorCards = computed(() => devices.value.flatMap((device) => expandDeviceCards(device)))
const onlineCount = computed(() => sensorCards.value.filter(i => i.isOnline).length)
const offlineCount = computed(() => Math.max(sensorCards.value.length - onlineCount.value, 0))
const latestReportTime = computed(() => {
const times = sensorCards.value.map(i => i.reportTime).filter(Boolean)
return times[0] || ''
})
function goBack() {
uni.navigateBack()
}
function loadDevices() {
if (!deptId.value) {
devices.value = []
return
}
loading.value = true
listMqttDevice({
pageNum: 1,
pageSize: 100,
deptId: deptId.value
}).then(res => {
devices.value = res.rows || []
return loadLatestData()
}).finally(() => {
loading.value = false
})
}
function loadLatestData() {
const tasks = devices.value.map(device => {
if (!device.id) return Promise.resolve()
const reqs = [
listMqttData({ pageNum: 1, pageSize: 1, deviceId: device.id }).then(res => {
const row = (res.rows || [])[0]
if (row) {
const key = getDeviceKey(device)
latestDataMap[key] = normalizePayload({ ...latestDataMap[key] || {}, ...row })
}
}).catch(() => { })
]
if (isStateDevice(device)) {
reqs.push(listMqttEvent({ pageNum: 1, pageSize: 1, deviceId: device.id }).then(res => {
const row = (res.rows || [])[0]
if (row) {
const key = getDeviceKey(device)
latestDataMap[key] = normalizePayload({ ...latestDataMap[key] || {}, ...row, ...deriveStateFromEvent(row) })
}
}).catch(() => { }))
}
return Promise.all(reqs)
})
return Promise.all(tasks)
}
function handleWsMessage(data) {
if (!data || String(data.deptId || '') !== String(deptId.value || '')) return
const runtimeStatus = data.deviceStatus != null ? String(data.deviceStatus) : null
const index = devices.value.findIndex(device =>
String(device.id || '') === String(data.deviceId || '') ||
String(device.devEui || '').toLowerCase() === String(data.devEui || '').toLowerCase()
)
if (index > -1) {
const device = devices.value[index]
const key = getDeviceKey(device)
const patched = patchRealtimeState(latestDataMap[key] || {}, data)
latestDataMap[key] = normalizePayload({ ...latestDataMap[key] || {}, ...patched })
devices.value[index] = { ...device, status: runtimeStatus ?? '0' }
return
}
const key = getDeviceKey(data)
const patched = patchRealtimeState(latestDataMap[key] || {}, data)
latestDataMap[key] = normalizePayload({ ...latestDataMap[key] || {}, ...patched })
}
function patchRealtimeState(prev, next) {
const res = { ...next }
const s1 = next.switch_1 ?? next.switch1
const s2 = next.switch_2 ?? next.switch2
const s3 = next.switch_3 ?? next.switch3
if (s1 != null) res.switch_1 = res.switch1 = s1
if (s2 != null) res.switch_2 = res.switch2 = s2
if (s3 != null) res.switch_3 = res.switch3 = s3
const water = deriveWaterStatus({ ...prev, ...next })
if (water != null) res.waterStatus = res.water_status = water
const door = deriveDoorStatus({ ...prev, ...next })
if (door != null) res.doorStatus = res.door_status = door
const socket = deriveSocketStatus({ ...prev, ...next })
if (socket != null) res.switchStatus = res.socket_status = res.socketStatus = socket
return res
}
async function handleSocketControl(item, action) {
const deviceId = item.id || item.deviceId
const devEui = item.devEui || item.devEUI || item.dev_eui
if (!devEui) return uni.showToast({ title: '未找到设备', icon: 'none' })
const k = item.cardKey || String(deviceId)
if (controlLoadingMap[k]) return
controlLoadingMap[k] = true
try {
const status = action === 'on' ? 1 : 0
await controlSocket({ devEui, deviceId, status })
syncSocketLocalState(item, status)
uni.showToast({ title: '指令已发送', icon: 'success' })
} finally {
controlLoadingMap[k] = false
}
}
async function handleLightSwitchControl(item, ch, action) {
const devEui = item.devEui || item.devEUI || item.dev_eui
if (!devEui) return uni.showToast({ title: '未找到设备', icon: 'none' })
const k = `${item.cardKey}-ch-${ch}`
if (controlLoadingMap[k]) return
controlLoadingMap[k] = true
try {
const status = action === 'on' ? 1 : 0
await controlLightSwitch({ devEui, channel: ch, status })
syncLightSwitchLocalState(item, ch, status)
uni.showToast({ title: '指令已发送', icon: 'success' })
} finally {
controlLoadingMap[k] = false
}
}
function syncSocketLocalState(item, status) {
const key = getDeviceKey(item)
if (!key) return
const now = new Date().toISOString()
latestDataMap[key] = normalizePayload({
...latestDataMap[key] || {},
socket_status: status, socketStatus: status, switchStatus: status,
gatewayTime: now, createTime: now
})
}
function syncLightSwitchLocalState(item, ch, status) {
const key = getDeviceKey(item)
if (!key) return
const now = new Date().toISOString()
latestDataMap[key] = normalizePayload({
...latestDataMap[key] || {},
deviceId: item.deviceId || item.id,
devEui: item.devEui || item.devEUI || item.dev_eui,
deviceName: item.deviceName,
[`switch_${ch}`]: status, [`switch${ch}`]: status,
gatewayTime: now, createTime: now
})
}
function expandDeviceCards(device) {
const data = latestDataMap[getDeviceKey(device)] || {}
const type = getSensorType(device, data)
if (type === 'env') return ENV_CARD_TYPES.map(t => buildSensorCard(device, t))
return [buildSensorCard(device)]
}
function buildSensorCard(device, displayType) {
const data = latestDataMap[getDeviceKey(device)] || {}
const type = displayType || getSensorType(device, data)
const metrics = buildDisplayMetrics(data, type)
const reportTime = formatTime(data.createTime || data.gatewayTime)
const isOnline = String(device.status) === '0'
return {
...device,
cardKey: `${getDeviceKey(device) || 's'}-${type}`,
type,
icon: getDisplayIcon(type),
typeName: getDisplayTypeName(type),
locationName: getLocationName(device, data),
summary: getDisplaySummary(data, type),
metrics,
reportTime,
isOnline,
onlineText: isOnline ? '在线' : '离线',
statusClass: isOnline ? 'online' : 'offline'
}
}
function isSocketControlType(type) {
return type === 'socket' || type === 'acSocket'
}
function getSocketActionText(type, action, loading) {
if (loading) return '发送中...'
if (type === 'acSocket') return action === 'on' ? '开启空调' : '关闭空调'
return action === 'on' ? '开启排风' : '关闭排风'
}
function getDisplayIcon(type) {
return type === 'acSocket' ? '空' : getSensorIcon(type)
}
function getDisplayTypeName(type) {
return type === 'acSocket' ? '智能空调插座' : getSensorTypeName(type)
}
function getDisplaySummary(data, type) {
if (type === 'acSocket') return `空调状态:${translateSwitch(data.switchStatus)}`
return getSensorSummary(data, type)
}
function buildDisplayMetrics(data, type) {
const m = buildMetrics(data, type === 'acSocket' ? 'socket' : type)
if (type === 'acSocket') {
return m.map(i => i.label === '插座状态' ? { ...i, label: '空调状态' } : i)
}
return m
}
function getDeviceKey(d) {
return d.deviceId || d.id || d.devEui || d.devEUI || d.dev_eui
}
function normalizePayload(row) {
const json = parseJson(row.dataJson) || parseJson(row.payload) || {}
const nested = parseJson(row.data) || {}
const water = deriveWaterStatus({ ...json, ...nested, ...row })
return {
...json, ...nested, ...row,
devEui: row.devEui || row.devEUI || json.devEui,
waterStatus: row.waterStatus ?? row.water_status ?? water,
water_status: row.water_status ?? row.waterStatus ?? water,
socket_status: row.socket_status ?? row.socketStatus,
switchStatus: row.switchStatus ?? row.socket_status,
switch_1: row.switch_1 ?? row.switch1, switch1: row.switch1 ?? row.switch_1,
switch_2: row.switch_2 ?? row.switch2, switch2: row.switch2 ?? row.switch_2,
switch_3: row.switch_3 ?? row.switch3, switch3: row.switch3 ?? row.switch_3,
doorStatus: row.doorStatus ?? row.door_status
}
}
function parseJson(v) {
if (typeof v !== 'string') return null
try { return JSON.parse(v) } catch { return null }
}
function deriveStateFromEvent(row) {
const evt = (row.eventType || row.event || '').toLowerCase()
const desc = (row.eventDesc || row.statusDesc || '').toLowerCase()
const res = {}
if (evt.includes('open') || desc.includes('打开')) res.doorStatus = 1
if (evt.includes('close') || desc.includes('关闭')) res.doorStatus = 0
if (evt.includes('on') || desc.includes('通电')) res.socket_status = res.switchStatus = 1
if (evt.includes('off') || desc.includes('断电')) res.socket_status = res.switchStatus = 0
const water = deriveWaterStatus(row)
if (water != null) res.waterStatus = res.water_status = water
return res
}
function deriveWaterStatus(data) {
const evt = (data.eventType || data.status || '').toLowerCase()
const desc = (data.eventDesc || data.statusDesc || '').toLowerCase()
if (evt === 'alarm' || desc.includes('浸水') || desc.includes('水浸')) return 1
if (evt === 'normal' || desc.includes('正常')) return 0
return data.waterStatus ?? data.water_status
}
function deriveDoorStatus(data) {
return data.doorStatus ?? data.door_status
}
function deriveSocketStatus(data) {
return data.switchStatus ?? data.socket_status ?? data.socketStatus
}
function getSensorType(device, data) {
const t = (device.deviceType || '').toLowerCase()
const name = (device.deviceName || '').toLowerCase()
if (t === 'smoke') return 'smoke'
if (t === 'water') return 'water'
if (t === 'door') return 'door'
if (t === 'env') return 'env'
if (t === 'switch') return 'switch'
if (t === 'socket') return name.includes('空调') ? 'acSocket' : 'socket'
if (name.includes('smoke')) return 'smoke'
if (name.includes('water')) return 'water'
if (name.includes('空调')) return 'acSocket'
if (name.includes('socket')) return 'socket'
if (name.includes('switch')) return 'switch'
if (name.includes('door')) return 'door'
if (name.includes('temp') || name.includes('hum')) return 'env'
return 'sensor'
}
function isStateDevice(device) {
const s = `${device.deviceType} ${device.deviceName}`.toLowerCase()
return s.includes('door') || s.includes('socket') || s.includes('switch')
}
function getSensorIcon(type) {
const map = { smoke: '烟', water: '水', socket: '电', switch: '灯', door: '门', env: '温', tempHum: '温', toxicGas: '氨', hydrogenSulfide: '硫' }
return map[type] || '测'
}
function getSensorTypeName(type) {
const map = { smoke: '烟雾传感器', water: '水浸传感器', socket: '智能排风', switch: '智慧照明', door: '门禁状态', env: '环境传感器', tempHum: '温湿度', toxicGas: '有毒气体', hydrogenSulfide: '硫化氢' }
return map[type] || '传感器'
}
function getLocationName(device) {
return device.deptName || warehouseName.value || '仓库'
}
function getSensorSummary(data, type) {
if (!Object.keys(data).length) return '等待上报'
if (type === 'water') return `水浸:${translateNormalAlarm(data.waterStatus)}`
if (type === 'smoke') return `烟雾:${translateSmokeStatus(data.status)}`
if (type === 'socket') return `插座:${translateSwitch(data.switchStatus)}`
if (type === 'switch') {
const arr = []
if (data.switch_1 != null) arr.push(`1${translateSwitchShort(data.switch_1)}`)
if (data.switch_2 != null) arr.push(`2${translateSwitchShort(data.switch_2)}`)
if (data.switch_3 != null) arr.push(`3${translateSwitchShort(data.switch_3)}`)
return arr.length ? `开关:${arr.join(' ')}` : '开关状态'
}
if (type === 'door') return `门禁:${translateSwitch(data.doorStatus)}`
if (type === 'tempHum') return `${data.temperature || '--'}℃/${data.humidity || '--'}%`
if (type === 'toxicGas') return `氨气:${data.nh3 || '--'}ppm`
if (type === 'hydrogenSulfide') return `硫化氢:${data.h2s || '--'}ppm`
if (type === 'env') return `${data.temperature || '--'}℃/${data.humidity || '--'}%`
return '已上报'
}
function buildMetrics(data, type) {
if (type === 'tempHum') return [{ label: '温度', value: data.temperature + '℃' }, { label: '湿度', value: data.humidity + '%' }, { label: '电量', value: data.battery + '%' }].filter(i => i.value)
if (type === 'toxicGas') return [{ label: '氨气', value: data.nh3 + 'ppm' }, { label: '电量', value: data.battery + '%' }].filter(i => i.value)
if (type === 'hydrogenSulfide') return [{ label: '硫化氢', value: data.h2s + 'ppm' }, { label: '电量', value: data.battery + '%' }].filter(i => i.value)
const list = []
if (data.temperature != null) list.push({ label: '温度', value: data.temperature + '℃' })
if (data.humidity != null) list.push({ label: '湿度', value: data.humidity + '%' })
if (data.nh3 != null) list.push({ label: '氨气', value: data.nh3 + 'ppm' })
if (data.h2s != null) list.push({ label: '硫化氢', value: data.h2s + 'ppm' })
if (data.battery != null) list.push({ label: '电量', value: data.battery + '%' })
if (type === 'water' && data.waterStatus != null) list.unshift({ label: '水浸', value: translateNormalAlarm(data.waterStatus) })
if (type === 'socket' && data.switchStatus != null) list.unshift({ label: '插座', value: translateSwitch(data.switchStatus) })
if (type === 'door' && data.doorStatus != null) list.unshift({ label: '门禁', value: translateSwitch(data.doorStatus) })
if (type === 'switch') {
const sw = []
if (data.switch_1 != null) sw.push({ label: '开关1', value: translateSwitchShort(data.switch_1) })
if (data.switch_2 != null) sw.push({ label: '开关2', value: translateSwitchShort(data.switch_2) })
if (data.switch_3 != null) sw.push({ label: '开关3', value: translateSwitchShort(data.switch_3) })
return [...sw, ...list].slice(0, 6)
}
return list.slice(0, 6)
}
function translateNormalAlarm(v) {
const s = String(v)
return s === '0' ? '正常' : s === '1' ? '告警' : '未知'
}
function translateSmokeStatus(v) {
const s = String(v).toLowerCase()
return s === '0' || s === 'normal' ? '正常' : s === '1' || s === 'alarm' ? '告警' : '正常'
}
function translateSwitch(v) {
const s = String(v).toLowerCase()
return s === '0' || s === 'off' ? '关闭' : s === '1' || s === 'on' ? '开启' : '--'
}
function translateSwitchShort(v) {
const s = String(v).toLowerCase()
return s === '0' || s === 'off' ? '关' : s === '1' || s === 'on' ? '开' : '-'
}
function formatTime(t) {
if (!t) return ''
return t.replace('T', ' ').substring(5, 16)
}
onMounted(() => {
loadDevices()
connectWs(handleWsMessage)
})
onBeforeUnmount(() => {
closeWs(handleWsMessage)
})
</script>
<style scoped lang="scss">
.warehouse-page {
padding: 20rpx;
background: #f5f7fa;
min-height: 100vh;
}
.warehouse-hero {
background: linear-gradient(135deg, #085f52, #0a7c70);
color: #fff;
padding: 30rpx;
border-radius: 24rpx;
margin-bottom: 20rpx;
position: relative;
}
.warehouse-hero-box {
display: flex;
justify-content: space-between;
}
.back-btn {
background: rgba(255, 255, 255, 0.2);
color: #fff;
border-radius: 100rpx;
font-size: 24rpx;
padding: 10rpx 20rpx;
border: none;
margin-bottom: 16rpx;
}
.hero-sub {
font-size: 24rpx;
opacity: 0.8;
}
.hero-title {
font-size: 40rpx;
font-weight: bold;
margin: 8rpx 0;
}
.hero-desc {
font-size: 24rpx;
opacity: 0.8;
}
.meta-num {
font-size: 40rpx;
font-weight: bold;
display: block;
}
.meta-label {
font-size: 24rpx;
opacity: 0.9;
}
.num {
font-size: 36rpx;
font-weight: bold;
color: #111;
margin-top: 8rpx;
display: block;
}
.online .num {
color: #07a186;
}
.offline .num {
color: #999;
}
.sensor-card {
background: #fff;
border-radius: 24rpx;
padding: 24rpx;
margin-bottom: 20rpx;
position: relative;
overflow: hidden;
}
.sensor-card::before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 8rpx;
background: #08a089;
}
.sensor-card.offline {
opacity: 0.6;
filter: grayscale(0.5);
}
.sensor-content {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.sensor-main {
background: #f9f9f9;
border-radius: 20rpx;
padding: 20rpx;
}
.sensor-top {
display: flex;
justify-content: space-between;
align-items: center;
}
.sensor-icon {
width: 70rpx;
height: 70rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: bold;
background: #e6f7f5;
color: #088a77;
}
.sensor-state {
font-size: 24rpx;
padding: 8rpx 16rpx;
background: #e6f7f5;
color: #088a77;
border-radius: 100rpx;
display: flex;
align-items: center;
}
.dot {
width: 12rpx;
height: 12rpx;
background: #09a089;
border-radius: 50%;
margin-right: 8rpx;
}
.sensor-body {
margin-top: 20rpx;
}
.location {
font-size: 24rpx;
color: #666;
}
.type-name {
font-size: 32rpx;
font-weight: bold;
margin: 8rpx 0;
}
.summary {
font-size: 26rpx;
background: #f0f0f0;
padding: 8rpx 16rpx;
border-radius: 100rpx;
display: inline-block;
margin-top: 8rpx;
}
.socket-actions {
display: flex;
gap: 16rpx;
margin-top: 20rpx;
}
.switch-actions {
margin-top: 20rpx;
}
.switch-row {
display: flex;
align-items: center;
gap: 12rpx;
margin-bottom: 12rpx;
}
.ch-label {
width: 80rpx;
font-size: 24rpx;
}
.control-btn {
padding: 12rpx 24rpx;
border-radius: 100rpx;
font-size: 24rpx;
font-weight: bold;
border: none;
}
.control-btn.on {
background: #d1fae5;
color: #065f46;
}
.control-btn.off {
background: #ffedd5;
color: #9a3412;
}
.metric-panel {
background: #f9f9f9;
border-radius: 20rpx;
padding: 20rpx;
}
.panel-title {
font-size: 26rpx;
color: #666;
margin-bottom: 16rpx;
display: block;
}
.metric-list {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
}
.metric-item {
flex: 1;
min-width: 200rpx;
background: #fff;
padding: 16rpx;
border-radius: 16rpx;
}
.label {
font-size: 22rpx;
color: #666;
display: block;
}
.value {
font-size: 28rpx;
font-weight: bold;
color: #088a77;
margin-top: 4rpx;
}
.muted {
background: #f1f1f1;
color: #999;
}
.sensor-footer {
margin-top: 20rpx;
padding-top: 16rpx;
border-top: 1rpx dashed #eee;
font-size: 22rpx;
color: #999;
display: flex;
justify-content: space-between;
}
.empty-state {
text-align: center;
padding: 60rpx;
color: #999;
font-size: 28rpx;
}
.summary-card {
padding: 18px 20px;
border-radius: 18px;
position: relative;
overflow: hidden;
width: 30%;
.label {
display: block;
font-size: 13px;
font-weight: 500;
color: #334155;
margin-bottom: 6px;
}
.value {
font-size: 28px;
font-weight: 700;
line-height: 1.2;
}
}
// 设备总数
.summary-card.total {
background: #eef2ff;
color: #6366f1;
}
// 在线设备
.summary-card.online {
background: #ecfdf5;
color: #059669;
}
// 离线设备
.summary-card.offline {
background: #F5F5F5;
color: #64748b;
}
// 最近上报
.summary-card.report {
background: #f0f9ff;
color: #0ea5e9;
}
.loading-view {
text-align: center;
padding: 40rpx;
font-size: 28rpx;
color: #666;
}
.hero-meta {
// background-color: #F8FAFC;
border-color: #CBD5E1;
border-radius: 16rpx;
margin-top: 16rpx;
// padding: 24rpx;
}
.report {
margin-top: 8rpx;
font-size: 14px;
color: #fff;
}
</style>

View File

@@ -4,16 +4,16 @@
<view class="remarkLine">
<text>物料列表</text>
<uv-button type="primary" v-if="isAddMaterial" :plain="true" size="small" text="添加物料"
@click="toMaterial"></uv-button>
@tap="toMaterial"></uv-button>
<view v-if="isShowRqCode" class="flex align-center justify-between">
<span class="f-12 mr-16 grey" style="font-size: 12px;" v-if="num > 0">
剩余<span style="color: red;">
<text class="f-12 mr-16 grey" style="font-size: 12px;" v-if="num > 0">
剩余<text style="color: red;">
{{ num }}
</span>种物料未生成唯一码
</span>
</text>种物料未生成唯一码
</text>
<uv-button type="primary" :plain="true" size="small" text="快速生成唯一码"
@click="toGenerateUniqueCodeQuickly"></uv-button>
@tap="toGenerateUniqueCodeQuickly"></uv-button>
</view>
</view>
@@ -30,18 +30,18 @@
</view>
<!-- 副标题简称/型号/规格/类型 -->
<view class="subTitle mb-2">
<span v-if="item.materialShortName">{{ item.materialShortName }} / </span>
<span v-if="item.model">{{ item.model }} / </span>
<span v-if="item.specification">{{ item.specification }} / </span>
<span v-if="item.typeName">{{ item.typeName }}</span>
<text v-if="item.materialShortName">{{ item.materialShortName }} / </text>
<text v-if="item.model">{{ item.model }} / </text>
<text v-if="item.specification">{{ item.specification }} / </text>
<text v-if="item.typeName">{{ item.typeName }}</text>
</view>
<!-- uniqueCode -->
<view class="uniqueCode mb-2">
<span class="f-12 " v-if="item.uniqueCode">唯一码{{ item?.uniqueCode }}</span>
<text class="f-12 " v-if="item.uniqueCode">唯一码{{ item?.uniqueCode }}</text>
</view>
<!-- 数量 + 单位 -->
<view class="tag-row mb-2">
<span class="tag-error">{{ getTypeParentNames(item.typeParentNames) }}</span>
<text class="tag-error">{{ getTypeParentNames(item.typeParentNames) }}</text>
<view class="quantity-form">
<uni-forms-item :name="`material[${idx}].quantity`" label-width="0">
<uni-easyinput :disabled="!edit || isEdit == '5'"
@@ -52,24 +52,24 @@
</view>
</view>
<!-- 库存状态 -->
<view class="flex justify-between mb-2 " v-if="isEdit == 3 && isStockIn">
<view class="flex justify-between mb-2 " v-if="isEdit == 3 && includes(keyType, 'stockIn')">
<p style="font-size: 13px;">
已入库
<span style="color:green">{{ getStockQuantity(item, 'complete') }}</span>
<text style="color:green">{{ getStockQuantity(item, 'complete') }}</text>
</p>
<p style="font-size: 13px;">
剩余
<span style="color:red">{{ getStockQuantity(item, 'remaining') }}</span>
<text style="color:red">{{ getStockQuantity(item, 'remaining') }}</text>
</p>
</view>
<view class="flex justify-between mb-2 " v-if="isEdit == 3 && !isStockIn">
<view class="flex justify-between mb-2 " v-if="isEdit == 3 && includes(keyType, 'stockOut')">
<p style="font-size: 13px;">
已出库
<span style="color:green">{{ getStockQuantity(item, 'complete') }}</span>
<text style="color:green">{{ getStockQuantity(item, 'complete') }}</text>
</p>
<p style="font-size: 13px;">
剩余
<span style="color:red">{{ getStockQuantity(item, 'remaining') }}</span>
<text style="color:red">{{ getStockQuantity(item, 'remaining') }}</text>
</p>
</view>
<!-- 备注 -->
@@ -92,8 +92,9 @@
<!-- 选择物料 -->
<uv-modal ref="modalRef" class="chooseModal" :title="none" :showConfirmButton="false" :showCancelButton="false">
<p class="title">请选择称重来源</p>
<p class="link" @click="toMaterialSelection('0')">无线液位计</p>
<p class="link" @click="toMaterialSelection('1')">手动输入</p>
<p class="link" v-if="includes(keyType, 'declaration')" @tap="toMaterialSelection('2')">蓝牙电子秤</p>
<p class="link" @tap="toMaterialSelection('0')">无线液位计</p>
<p class="link" @tap="toMaterialSelection('1')">手动输入</p>
</uv-modal>
@@ -123,71 +124,84 @@ const OPERATE_CONFIG = {
toMaterialUrl: '/pages/warehousing/uniqueCode/issueUniqueCode/index',
title: '入库单开单'
},
// 申报单开单
declaration: {
toMaterialUrl: '/pages/warehousing/uniqueCode/issueUniqueCode/materialSelection',
title: '申报单开单'
},
my: {
toMaterialUrl: '/pages/warehousing/uniqueCode/issueUniqueCode/index',
title: '申报单开单'
},
}
const props = defineProps({
formData: { type: Object, default: () => ({ material: [], remark: '' }), required: true },//物料信息
isEdit: { type: Boolean, default: true, required: true }, //编辑1 / 物料只读2 / 入库单只读3 /入库生成唯一码编辑4 /5数量不可编辑 备注可编辑
isEdit: { type: Boolean, default: true, required: true }, //编辑1 / 物料只读2 / 入/出库单只读3 /入库生成唯一码编辑4 /5数量不可编辑 备注可编辑
pathParams: { type: Object, default: {} }, //只读时传入对应的code、id
extendData: { type: Object, default: {} }, //其他额外参数
})
const emit = defineEmits(["setStorage"]); //申报开单 选择物料存储所填数据
const { formData, isEdit, pathParams, extendData } = toRefs(props)
// 标识:页面
const keyType = computed(() => pathParams.value.type)
//是否为编辑状态
// 标识:是否为编辑状态
const edit = computed(() => includes(['1', '4', '5'], `${isEdit.value}`))
// 显示添加物料按钮 isEdit编辑、
const isAddMaterial = computed(() => `${isEdit.value}` === '1' && keyType != 'issueUniqueCode_inbound' && !includes(keyType.value, 'stockOut'))
// 显示快速生成唯一码 isShowRqCode
// 标识:显示添加物料按钮 编辑1且非开单页面以及非出库相关页面
const isAddMaterial = computed(() => `${isEdit.value}` === '1' && keyType.value != 'stockIn_inbound' && !includes(keyType.value, 'stockOut'))
// 标识:显示快速生成唯一码 编辑5数量不可编辑 备注可编辑且非出库相关页面
const isShowRqCode = computed(() => `${isEdit.value}` === '5' && !includes(keyType.value, 'stockOut'))
const isStockIn = computed(() => includes(keyType.value, 'stockIn'))
// 删除:数据
const delItem = ref(null)
// 删除:开关
const alertDialog = ref(null)
// 删除:开关
const isDialog = ref(false)
// 数据:开单-可选择的物料列表
const selectMaterialList = computed(() => extendData.value?.selectMaterialList)
const num = computed(() => selectMaterialList.value?.length || 0)
// 弹窗开关:入库单开单
// 弹窗:入库单开单
const modalRef = ref()
// 按钮:添加物料
const toMaterial = () => {
if (keyType.value == 'stockIn') { // 入库单开单 - 添加物料可选择手输入/无线液位计
if (keyType.value == 'stockIn' || includes(keyType.value, 'declaration')) { // 入库单开单 - 添加物料可选择手输入/无线液位计
modalRef.value.open()
} else {
const path = objectToQuery(pathParams.value)
// 唯一码 - 编辑/新增
const value = uni.getStorageSync('app_material');
uni.setStorageSync('app_material', [{ ...value[0], uniqueCodeRemark: formData.value?.remark }]); // 将最新的唯一码备注写入缓存
uni.navigateTo({
url: `${OPERATE_CONFIG.issueUniqueCode.toMaterialUrl}${path}`
})
}
}
// 添加物料弹窗: 入库单入库 时可选择手动/无线液
// 添加物料弹窗: 入库单入库、申报开单 时可选择手动/无线液
const toMaterialSelection = (type) => {
// 0无线液 1手动输入
// 0无线液 1手动输入 2蓝牙
let url = ''
const path = objectToQuery(pathParams.value)
if (type === '1') {
emit("setStorage");
url = `${OPERATE_CONFIG.issueUniqueCode.toMaterialUrl}`
}
uni.navigateTo({
url: `${url}${path}`
})
}
// 快速生成唯一码 -
// 快速生成唯一码 -
const toGenerateUniqueCodeQuickly = () => {
const path = objectToQuery(pathParams.value)
console.log(path, 'path==>');
uni.navigateTo({
url: `${OPERATE_CONFIG.stockIn.toMaterialUrl}${path}`
})
}
// 删除弹窗:显示 长按事件
const handleItemLongPress = (val) => {
alertDialog.value.open()
@@ -204,7 +218,6 @@ const dialogConfirm = () => {
const idx = findIndex(formData.value.material, (i) => `${i.id}` === `${delItem.value.id}`)
assign(formData.value.material[idx], { isDelete: '1' });
uni.setStorageSync('app_material', formData.value.material)
}
@@ -251,7 +264,7 @@ defineExpose({
}
span {
text {
font-size: 14px;
}

View File

@@ -3,7 +3,7 @@
<!-- <view class="nav-placeholder" :style="{ height: 35 + 'px' }"></view> -->
<view class="navbar" :style="{ height: navHeight + 'rpx' }">
<view class="left" @click="goBack">
<view class="left" @tap="goBack">
<uni-icons type="left" size="18" v-if="showBack" />
</view>

View File

@@ -0,0 +1,55 @@
<script setup>
import { warehouseList } from '@/api/home';
import { ref } from 'vue';
import { transformData, objectToQuery } from '../until'
const myWarehouseList = ref([])
const onChecked = (item) => {
if (!item.deptId) return
uni.navigateTo({
url: `/pages/components/EquipmentInfo?deptId=${item.deptId}&warehouseName=${item.warehouseName || ''}&projectName=${item.parentName || ''}`
})
}
const getMyWarehouseList = () => {
warehouseList().then((res) => {
myWarehouseList.value = transformData(res.data)
console.log('我的仓库===>', res, transformData(res.data));
})
}
getMyWarehouseList()
</script>
<template>
<uv-list v-for="(item, index) in myWarehouseList" :key="index" class="list">
<view class="title line">{{ item.parentName }}</view>
<uv-list-item v-for="(i, idx) in item.items" :key="idx" link clickable @tap="onChecked(i)"
:title="i.warehouseName">
<template v-slot:footer>
<view :style="i?.onlineRate > 0 ? 'color :#9CCC65;font-size: 14px;' : 'color :#000;font-size: 14px;'">
<text>在线率</text>
<text>{{ i?.onlineRate }}%</text>
</view>
</template>
</uv-list-item>
</uv-list>
</template>
<style scoped>
.list {
background-color: #fff;
margin-bottom: 8px;
}
.title {
padding: 8px 30rpx;
}
</style>

View File

@@ -0,0 +1,399 @@
<template>
<navigation :title="typeInfo?.title" :back-url="typeInfo?.backUrl"></navigation>
<view class="report-page contentBox">
<uv-form v-if="typeInfo?.mode" labelPosition="top" labelWidth="100" class="form" :model="formData"
ref="formRef">
<uv-form-item prop="beginDate">
<view class="carPickerText" :style="formData.beginDate ? 'color: #303133;' : ''"
@tap="openCalendar('start')">
<text class="mr-16"> {{ formData.beginDate || '请选择开始月份' }}</text>
<uv-icon name="arrow-down-fill" />
</view>
</uv-form-item>
<text style="width: 20%; text-align: center;"></text>
<uv-form-item prop="endDate ">
<view class="carPickerText" :style="formData.endDate ? 'color: #303133;' : ''"
@tap=" openCalendar('end')">
<text class="mr-16">{{ formData.endDate || '请选择结束月份' }}</text>
<uv-icon name="arrow-down-fill" />
</view>
</uv-form-item>
</uv-form>
<view class="topSearch " v-if="!typeInfo?.mode">
<uni-easyinput type="text" v-model="formData.keyword" prefixIcon="search" :inputBorder="false"
@iconClick="getReport" placeholder="请输入搜索内容" />
</view>
<!-- 表格 -->
<scroll-view class="table-scroll containerBox" scroll-x>
<view class="table-box">
<view class="table-header" border>
<view class="th key-col"></view>
<view class="th">A</view>
<view class="th">B</view>
<view class="th">C</view>
<view class="th">D</view>
<view class="th">E</view>
<view class="th">F</view>
<view class="th">G</view>
<view class="th">H</view>
</view>
<view class="table-header" v-if="keyType === 'dailyReport' || keyType === 'monthlyReport'">
<view class="th key-col"></view>
<view class="th">物料编码</view>
<view class="th">物料名称</view>
<view class="th">物料规格</view>
<view class="th">计量单位</view>
<view v-if="keyType === 'dailyReport'" class="th">上日结余</view>
<view v-if="keyType === 'dailyReport'" class="th">日入库</view>
<view v-if="keyType === 'dailyReport'" class="th">日出库</view>
<view v-if="keyType === 'dailyReport'" class="th">日结余</view>
<view v-if="keyType === 'monthlyReport'" class="th">上月结余</view>
<view v-if="keyType === 'monthlyReport'" class="th">月入库</view>
<view v-if="keyType === 'monthlyReport'" class="th">月出库</view>
<view v-if="keyType === 'monthlyReport'" class="th">日结余</view>
</view>
<view class="table-header" v-if="keyType === 'companyReport' || keyType === 'warehouseReport'">
<view class="th key-col"></view>
<view class="th">物料编码</view>
<view class="th">物料名称</view>
<view class="th">库存量</view>
<view class="th">计量单位</view>
<view class="th">物料类别</view>
<view class="th">物料分类</view>
<view class="th">物料规格</view>
<view class="th">物料型号</view>
</view>
<view class="table-body" v-if="keyType === 'dailyReport' || keyType === 'monthlyReport'">
<view class="tr" v-for="(item, index) in list" :key="item.materialId">
<view class="td key-col">{{ index + 1 }}</view>
<view class="td">{{ item.materialCode }}</view>
<view class="td">{{ item.materialName }}</view>
<view class="td">{{ item.specification || '-' }}</view>
<view class="td">{{ item.unitName }}</view>
<view>
</view>
<view class="td">{{ item.previousBalance }}</view>
<view class="td">{{ item.dailyInbound }}</view>
<view class="td">{{ item.dailyOutbound }}</view>
<view class="td">{{ item.dailyBalance }}</view>
</view>
<view class="empty" v-if="list.length === 0">暂无数据</view>
</view>
<view class="table-body" v-if="keyType === 'companyReport' || keyType === 'warehouseReport'">
<view class="tr" v-for="(item, index) in list" :key="item.materialId">
<view class="td key-col">{{ index + 1 }}</view>
<view class="td">{{ item.materialCode }}</view>
<view class="td">{{ item.materialName }}</view>
<view class="td">{{ item?.stockQty || item?.quantity }}</view>
<view class="td">{{ item.unitName }}</view>
<view class="td">{{ item.typeName }}</view>
<view class="td">{{ item.materialShortName }}</view>
<view class="td">{{ item.specification }}</view>
<view class="td">{{ item.model }}</view>
</view>
<view class="empty" v-if="list.length === 0">暂无数据</view>
</view>
</view>
</scroll-view>
<uv-datetime-picker :mode="typeInfo?.mode" v-model="pickerValue" ref="calendarRef"
@confirm="confirm"></uv-datetime-picker>
</view>
</template>
<script setup>
import { dailyReportList, companyStockReportList } from "@/api/report";
import { onLoad } from "@dcloudio/uni-app";
import { ref, reactive, toRefs, watch } from 'vue';
import { formatDate } from "../until";
import dayjs from "dayjs";
import Navigation from '../components/Navigation.vue';
import { onMounted } from "vue";
import { inventoryList } from '@/api/inventoryInfo';
const OPERATE_CONFIG = {
dailyReport: {
mode: 'date',
title: '库存日报',
format: 'YYYY-MM-DD',
backUrl: '/pages/warehousing/Report/daily'
},
monthlyReport: {
mode: 'year-month',
title: '库存月报',
format: 'YYYY-MM',
backUrl: '/pages/warehousing/Report/monthly'
},
companyReport: {
mode: '',
title: '公司库存报表',
format: '',
backUrl: 'pages/warehousing/index'
},
warehouseReport: {
mode: '',
title: '',
format: '',
backUrl: 'pages/warehousing/Report/warehouse'
},
}
const props = defineProps({
keyType: { //报表:日、月
type: String,
default: ''
}
})
const { keyType } = toRefs(props)
let currentType = '' // start / end
const pickerValue = ref('')
const calendarRef = ref(null)
const list = ref([])
const pathParams = ref({})
const typeInfo = ref({
mode: '',
title: '库存日报',
format: 'YYYY-MM-DD',
backUrl: '/pages/warehousing/report/daily'
})
const formData = reactive({
beginDate: formatDate(dayjs(), typeInfo.value.format),
endDate: formatDate(dayjs(), typeInfo.value.format),
keyword: '',
})
// 获取数据
const getReport = () => {
let params = {}
if (keyType.value == 'monthlyReport') {
params.warehouseCode = pathParams.value.warehouseCode
params.beginDate = dayjs(formData.beginDate).startOf('month').format('YYYY-MM-DD')
params.endDate = dayjs(params.endDate).endOf('month').format('YYYY-MM-DD')
}
if (keyType.value == 'dailyReport') {
params.warehouseCode = pathParams.value.warehouseCode
params.beginDate = formData.beginDate
params.endDate = formData.endDate
}
if (keyType.value == 'companyReport') {
params.keyword = formData.keyword
}
if (keyType.value == 'warehouseReport') {
params.keyword = formData.keyword
params.warehouseCode = pathParams.value.warehouseCode
}
console.log(params, '参数===》');
if (keyType.value == 'companyReport') {
companyStockReportList(params).then(res => {
if (res && res.code == 200) {
list.value = res.data || []
}
})
} else if (keyType.value == 'monthlyReport' || keyType.value == 'dailyReport') {
dailyReportList(params).then(res => {
if (res && res.code == 200) {
list.value = res.data || []
}
})
}
else if (keyType.value == 'warehouseReport') {
inventoryList(params).then(res => {
if (res && res.code == 200) {
list.value = res.data || []
}
})
}
}
onMounted(() => {
getReport()
if (keyType.value == 'monthlyReport' || keyType.value == 'dailyReport') {
formData.beginDate = formatDate(dayjs(), typeInfo.value.format)
formData.endDate = formatDate(dayjs(), typeInfo.value.format)
}
if (keyType.value == 'companyReport') {
formData.keyword = ''
}
})
// 确定选择
const confirm = (val) => {
console.log('确定按钮');
if (currentType === 'start') {
formData.beginDate = formatDate(val.value, typeInfo.value.format)
} else {
formData.endDate = formatDate(val.value, typeInfo.value.format)
}
getReport()
}
// 开始、结束日期选择器
const openCalendar = (val) => {
if (val == 'start') pickerValue.value = formData.beginDate
else pickerValue.value = formData.endDate
currentType = val
calendarRef.value.open()
}
onLoad((options) => {
pathParams.value = options || {}
})
watch(() => keyType.value,
(d) => {
if (!d) return;
typeInfo.value = OPERATE_CONFIG[d]
if (pathParams.value.title) {
typeInfo.value.title = pathParams.value.title + '库存报表'
}
}, { deep: true, immediate: true })
</script>
<style scoped lang="scss">
.report-page {
padding: 20rpx;
background: #fff;
min-height: 100vh;
}
.date-item {
flex: 1;
padding: 20rpx;
background: #fff;
border-radius: 12rpx;
display: flex;
align-items: center;
font-size: 26rpx;
}
.table-scroll {
background: #fff;
border-radius: 16rpx;
}
.table-box {
width: 1000rpx;
margin-bottom: 20px;
}
.table-header {
display: flex;
}
.th,
.td {
flex: 1;
min-width: 120rpx;
text-align: center;
font-size: 14px;
}
.th {
color: #333;
border: 1rpx solid #f0f0f0;
border-bottom: 0;
}
.td {
color: #666;
border: 1rpx solid #f0f0f0;
border-bottom: 0;
}
.tr:last-child {
border-bottom: 1rpx solid #f0f0f0;
}
.key-col {
width: 40px;
background: #f8f9fa;
font-weight: bold;
}
.tr {
display: flex;
border-bottom: 0;
}
.empty {
padding: 80rpx 0;
text-align: center;
color: #999;
}
::v-deep.form {
display: flex;
justify-content: center;
align-items: center;
.uv-form-item {
width: 45%;
.uv-form-item__body {
text-align: center;
padding: 0;
}
}
margin-bottom: 16px;
}
.carPickerText {
border-bottom: 1px solid #D3D3D3;
width: 100%;
font-size: 14px;
display: flex;
justify-content: center;
align-items: center;
padding-bottom: 4px;
}
.topSearch {
position: fixed;
top: 65rpx;
left: 0;
right: 0;
z-index: 999;
padding: 4rpx;
background-color: #fff;
border-bottom: 1px solid #eee;
box-sizing: border-box;
}
</style>

View File

@@ -12,24 +12,24 @@
<!-- 列表 -->
<z-paging ref="pagingRef" class="containerBox" v-model="list" @query="getList">
<uni-list class="listBox">
<uni-list-item v-for="item in list" :key="item.id" clickable @click="onDetail(item)">
<uni-list-item v-for="item in list" :key="item.id" clickable @tap="onDetail(item)">
<template v-slot:body>
<view style="display: flex; flex-direction: column; width: 100%;">
<view class="line title">
<p> {{ typeName }}编号{{ item.billNo }}</p>
<span :style="getColor(item?.billType)">
<text :style="getColor(item?.billType)">
{{ getBillType(item?.billType, item?.status, flag) }}
</span>
</text>
</view>
<p class="line content">{{ typeName }}类型
<span>{{ getOrderType(item.status) }}</span>
<text>{{ getOrderType(item.status) }}</text>
</p>
<p class="line content">库位
<span v-if="item.warehouseName">{{ item.warehouseName }}/</span>
<span v-if="item.areaName"> {{ item.areaName }}</span>
<text v-if="item.warehouseName">{{ item.warehouseName }}/</text>
<text v-if="item.areaName"> {{ item.areaName }}</text>
</p>
<p class="line content">开单时间
<span>{{ item.createTime }}</span>
<text>{{ item.createTime }}</text>
</p>
</view>
</template>

View File

@@ -1,10 +1,11 @@
<!-- 获取仓库数据 -->
<template>
<view>
<uv-form ref="formRef" class="form" :model="formData" label-width="150rpx">
<!-- 仓库 -->
<uv-form-item label="仓库" prop="warehouse">
<u-cell @click="onClick('warehouse')">
<u-cell @tap="onClick('warehouse')">
<view slot="title" class="u-slot-title">
<text class="u-cell-text" v-if="formData?.warehousing?.[0]?.deptName">
{{ formData?.warehousing?.[0].deptName }}
@@ -16,7 +17,18 @@
</uv-form-item>
<!-- 存储区 -->
<uv-form-item label="存储区" prop="storageArea">
<u-cell @click="onClick('storageArea')">
<u-cell @tap="onClick('storageArea')">
<view slot="title" class="u-slot-title">
<text class="u-cell-text" v-if="formData?.storageArea?.[0]?.deptName">
{{ formData?.storageArea?.[0].deptName }}
</text>
<text class="placeholder" v-else> 请选择运输单元</text>
<uni-icons type="right" size="10" />
</view>
</u-cell>
</uv-form-item>
<uv-form-item v-if="pathParams.type === 'transport'" label="运输单元" prop="storageArea">
<u-cell @tap="onClick('storageArea')">
<view slot="title" class="u-slot-title">
<text class="u-cell-text" v-if="formData?.storageArea?.[0]?.deptName">
{{ formData?.storageArea?.[0].deptName }}
@@ -26,6 +38,12 @@
</view>
</u-cell>
</uv-form-item>
<!-- 打卡图片 -->
<uv-form-item v-if="pathParams.type === 'transport'" label="打卡图片" prop="fileList" class="topLabel">
<uv-upload :fileList="formData?.fileList" name="1" multiple :maxCount="6" @afterRead="afterRead"
@delete="deleteImg" :previewFullImage="true"></uv-upload>
</uv-form-item>
<!-- 备注 -->
<uv-form-item label="备注">
<uv-input v-model="formData.remark" placeholder="请输入备注" align="right" border="none" />
@@ -57,6 +75,7 @@ const { warehouseInfo, pathParams } = toRefs(props)
// 表单数据
const formData = ref({ remark: '', warehousing: '', storageArea: '' })
// 赋值:更新列表值
const setFormData = (d) => {
if (!d) return;
@@ -101,6 +120,21 @@ defineExpose({
}
}
.topLabel {
.uv-form-item__body {
display: block;
}
.uv-textarea {
padding-left: 0;
}
.uv-upload {
margin-top: 8px;
}
}
.uv-form-item__body {
background-color: #fff;
padding: 12rpx;