提交 19b7c5c0 编写于 作者: 刘英杰's avatar 刘英杰

V1.0.2.250415-250529

上级 10d4763a
# 设备出库频率计算说明
## 基本概念
**频率**是指单位时间内事件发生的次数。在设备管理中,出库频率表示设备在一定时间周期内的出库次数。
## 计算公式
```
频率 = 出库次数 ÷ 时间周期
```
## 您的例子:30天出库5次
### 计算过程
- **出库次数**:5次
- **时间周期**:30天
- **频率计算**:5 ÷ 30 = 0.167次/天
### 不同单位的表示
- **每天频率**:0.167次/天
- **每周频率**:0.167 × 7 = 1.17次/周
- **每月频率**:0.167 × 30 = 5次/月
## 频率等级分类
| 等级 | 频率范围 | 说明 | 建议 |
|------|----------|------|------|
| 高频 | ≥1次/天 | 设备使用频率很高 | 建议加强维护 |
| 中频 | 1次/周 - 1次/天 | 设备使用频率适中 | 正常维护即可 |
| 低频 | 1次/月 - 1次/周 | 设备使用频率较低 | 可考虑共享使用 |
| 极低频 | <1次/月 | 设备使用频率很低 | 建议重新评估需求 |
## 在系统中的应用
### 1. 频率计算工具函数
```javascript
import { calculateFrequency, formatFrequency } from '@/utils/frequencyCalculator';
// 计算频率
const frequency = calculateFrequency(5, 30, 'day'); // 0.167
// 格式化显示
const display = formatFrequency(frequency, 'day'); // "0.167 次/天"
```
### 2. 在表格中显示频率
在借用记录表格中添加了"出库频率"列,自动计算并显示每个设备的出库频率。
### 3. 频率统计组件
提供了专门的频率计算器组件,可以:
- 输入出库次数和时间周期
- 选择不同的计算单位(天/周/月/年)
- 实时显示计算结果
- 查看频率等级说明
## 实际应用场景
### 1. 设备使用效率分析
通过频率分析可以了解:
- 哪些设备使用频率高,需要加强维护
- 哪些设备使用频率低,可以考虑共享或重新分配
### 2. 维护计划制定
- 高频设备:需要更频繁的维护检查
- 低频设备:可以减少维护频率
### 3. 采购决策支持
- 高频设备:可能需要增加库存或采购新设备
- 极低频设备:可能需要重新评估采购需求
## 技术实现
### 工具函数位置
```
src/utils/frequencyCalculator.js
```
### 主要功能
- `calculateFrequency()`: 基础频率计算
- `formatFrequency()`: 频率格式化显示
- `getFrequencyLevel()`: 获取频率等级
- `calculateFrequencyFromHistory()`: 基于历史记录计算频率
### 组件位置
```
src/components/frequencyCalculator.vue
src/pages/equipmentManagement/components/frequencyDemo.vue
```
## 使用示例
```javascript
// 基础计算
const frequency = calculateFrequency(5, 30, 'day');
console.log(frequency); // 0.16666666666666666
// 格式化显示
const display = formatFrequency(frequency, 'day');
console.log(display); // "0.167 次/天"
// 获取等级
const level = getFrequencyLevel(frequency);
console.log(level); // "低频"
```
## 注意事项
1. **时间周期**:建议使用天数作为基础单位进行计算
2. **数据准确性**:确保出库记录的时间戳准确
3. **历史数据**:频率计算需要足够的历史数据才能准确反映使用模式
4. **季节性考虑**:某些设备可能存在季节性使用差异,需要分时段分析
\ No newline at end of file
<template>
<div class="frequency-calculator">
<Card title="设备出库频率统计" :bordered="false">
<!-- 频率计算器 -->
<div class="calculator-section">
<h3>频率计算器</h3>
<Row :gutter="16">
<Col span="8">
<FormItem label="出库次数">
<InputNumber
v-model="calculator.outboundCount"
:min="1"
:max="1000"
placeholder="请输入出库次数"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="时间周期(天)">
<InputNumber
v-model="calculator.timePeriod"
:min="1"
:max="3650"
placeholder="请输入时间周期"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="计算单位">
<Select v-model="calculator.unit" style="width: 100%">
<Option value="day">次/天</Option>
<Option value="week">次/周</Option>
<Option value="month">次/月</Option>
<Option value="year">次/年</Option>
</Select>
</FormItem>
</Col>
</Row>
<div class="result-section">
<Alert type="info" show-icon>
<template #message>
<strong>计算结果:</strong>
<span class="frequency-result">{{ calculatedFrequency }}</span>
</template>
</Alert>
</div>
</div>
<!-- 频率统计表格 -->
<div class="statistics-section">
<h3>频率统计</h3>
<Table :columns="frequencyColumns" :data="frequencyData" border>
<template #frequency="{ row }">
<Tag :color="getFrequencyColor(row.frequency)">
{{ row.frequency }}
</Tag>
</template>
</Table>
</div>
</Card>
</div>
</template>
<script setup>
import { ref, reactive, computed } from 'vue';
import { Card, Row, Col, FormItem, InputNumber, Select, Option, Alert, Table, Tag } from 'view-ui-plus';
// 计算器数据
const calculator = reactive({
outboundCount: 5,
timePeriod: 30,
unit: 'day'
});
// 计算频率
const calculatedFrequency = computed(() => {
if (!calculator.outboundCount || !calculator.timePeriod) {
return '请输入数据';
}
const frequencyPerDay = calculator.outboundCount / calculator.timePeriod;
switch (calculator.unit) {
case 'day':
return `${frequencyPerDay.toFixed(3)} 次/天`;
case 'week':
return `${(frequencyPerDay * 7).toFixed(3)} 次/周`;
case 'month':
return `${(frequencyPerDay * 30).toFixed(3)} 次/月`;
case 'year':
return `${(frequencyPerDay * 365).toFixed(3)} 次/年`;
default:
return `${frequencyPerDay.toFixed(3)} 次/天`;
}
});
// 频率统计表格列定义
const frequencyColumns = [
{
title: '频率范围',
key: 'range',
minWidth: 120
},
{
title: '频率值',
key: 'frequency',
minWidth: 120,
slot: 'frequency'
},
{
title: '说明',
key: 'description',
minWidth: 200
}
];
// 频率数据
const frequencyData = ref([
{
range: '高频',
frequency: '≥1次/天',
description: '设备使用频率很高,建议加强维护'
},
{
range: '中频',
frequency: '1次/周 - 1次/天',
description: '设备使用频率适中,正常维护即可'
},
{
range: '低频',
frequency: '1次/月 - 1次/周',
description: '设备使用频率较低,可考虑共享使用'
},
{
range: '极低频',
frequency: '<1次/月',
description: '设备使用频率很低,建议重新评估需求'
}
]);
// 获取频率颜色
const getFrequencyColor = (frequency) => {
if (frequency.includes('≥1次/天')) return 'red';
if (frequency.includes('1次/周')) return 'orange';
if (frequency.includes('1次/月')) return 'blue';
return 'green';
};
// 导出频率计算函数供其他组件使用
const calculateFrequency = (outboundCount, timePeriod, unit = 'day') => {
const frequencyPerDay = outboundCount / timePeriod;
switch (unit) {
case 'day':
return frequencyPerDay;
case 'week':
return frequencyPerDay * 7;
case 'month':
return frequencyPerDay * 30;
case 'year':
return frequencyPerDay * 365;
default:
return frequencyPerDay;
}
};
// 获取频率等级
const getFrequencyLevel = (frequency) => {
if (frequency >= 1) return '高频';
if (frequency >= 1/7) return '中频';
if (frequency >= 1/30) return '低频';
return '极低频';
};
// 暴露方法供父组件调用
defineExpose({
calculateFrequency,
getFrequencyLevel
});
</script>
<style scoped>
.frequency-calculator {
padding: 16px;
}
.calculator-section {
margin-bottom: 24px;
}
.calculator-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
.result-section {
margin-top: 16px;
}
.frequency-result {
color: #2d8cf0;
font-weight: bold;
font-size: 16px;
}
.statistics-section {
margin-top: 24px;
}
.statistics-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
</style>
\ No newline at end of file
<template>
<div class="frequency-calculator">
<Card title="设备出库频率统计" :bordered="false">
<!-- 频率计算器 -->
<div class="calculator-section">
<h3>频率计算器</h3>
<Row :gutter="16">
<Col span="8">
<FormItem label="出库次数">
<InputNumber
v-model="calculator.outboundCount"
:min="1"
:max="1000"
placeholder="请输入出库次数"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="时间周期(天)">
<InputNumber
v-model="calculator.timePeriod"
:min="1"
:max="3650"
placeholder="请输入时间周期"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="计算单位">
<Select v-model="calculator.unit" style="width: 100%">
<Option value="day">次/天</Option>
<Option value="week">次/周</Option>
<Option value="month">次/月</Option>
<Option value="year">次/年</Option>
</Select>
</FormItem>
</Col>
</Row>
<div class="result-section">
<Alert type="info" show-icon>
<template #message>
<strong>计算结果:</strong>
<span class="frequency-result">{{ calculatedFrequency }}</span>
</template>
</Alert>
</div>
</div>
<!-- 频率统计表格 -->
<div class="statistics-section">
<h3>频率统计</h3>
<Table :columns="frequencyColumns" :data="frequencyData" border>
<template #frequency="{ row }">
<Tag :color="getFrequencyColor(row.frequency)">
{{ row.frequency }}
</Tag>
</template>
</Table>
</div>
</Card>
</div>
</template>
<script setup>
import { ref, reactive, computed } from 'vue';
import { Card, Row, Col, FormItem, InputNumber, Select, Option, Alert, Table, Tag } from 'view-ui-plus';
// 计算器数据
const calculator = reactive({
outboundCount: 5,
timePeriod: 30,
unit: 'day'
});
// 计算频率
const calculatedFrequency = computed(() => {
if (!calculator.outboundCount || !calculator.timePeriod) {
return '请输入数据';
}
const frequencyPerDay = calculator.outboundCount / calculator.timePeriod;
switch (calculator.unit) {
case 'day':
return `${frequencyPerDay.toFixed(3)} 次/天`;
case 'week':
return `${(frequencyPerDay * 7).toFixed(3)} 次/周`;
case 'month':
return `${(frequencyPerDay * 30).toFixed(3)} 次/月`;
case 'year':
return `${(frequencyPerDay * 365).toFixed(3)} 次/年`;
default:
return `${frequencyPerDay.toFixed(3)} 次/天`;
}
});
// 频率统计表格列定义
const frequencyColumns = [
{
title: '频率范围',
key: 'range',
minWidth: 120
},
{
title: '频率值',
key: 'frequency',
minWidth: 120,
slot: 'frequency'
},
{
title: '说明',
key: 'description',
minWidth: 200
}
];
// 频率数据
const frequencyData = ref([
{
range: '高频',
frequency: '≥1次/天',
description: '设备使用频率很高,建议加强维护'
},
{
range: '中频',
frequency: '1次/周 - 1次/天',
description: '设备使用频率适中,正常维护即可'
},
{
range: '低频',
frequency: '1次/月 - 1次/周',
description: '设备使用频率较低,可考虑共享使用'
},
{
range: '极低频',
frequency: '<1次/月',
description: '设备使用频率很低,建议重新评估需求'
}
]);
// 获取频率颜色
const getFrequencyColor = (frequency) => {
if (frequency.includes('≥1次/天')) return 'red';
if (frequency.includes('1次/周')) return 'orange';
if (frequency.includes('1次/月')) return 'blue';
return 'green';
};
// 导出频率计算函数供其他组件使用
const calculateFrequency = (outboundCount, timePeriod, unit = 'day') => {
const frequencyPerDay = outboundCount / timePeriod;
switch (unit) {
case 'day':
return frequencyPerDay;
case 'week':
return frequencyPerDay * 7;
case 'month':
return frequencyPerDay * 30;
case 'year':
return frequencyPerDay * 365;
default:
return frequencyPerDay;
}
};
// 获取频率等级
const getFrequencyLevel = (frequency) => {
if (frequency >= 1) return '高频';
if (frequency >= 1/7) return '中频';
if (frequency >= 1/30) return '低频';
return '极低频';
};
// 暴露方法供父组件调用
defineExpose({
calculateFrequency,
getFrequencyLevel
});
</script>
<style scoped>
.frequency-calculator {
padding: 16px;
}
.calculator-section {
margin-bottom: 24px;
}
.calculator-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
.result-section {
margin-top: 16px;
}
.frequency-result {
color: #2d8cf0;
font-weight: bold;
font-size: 16px;
}
.statistics-section {
margin-top: 24px;
}
.statistics-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
</style>
\ No newline at end of file
/***
超管》0
普通用户》1
部门管理员》2
**/
export default [
{
path: '/homePage',
title: '首页',
auth: [0,1,2],
icon: 'md-home',
},
{
path: '/applicationClaim',
title: '申请申领',
auth: [0,1,2],
icon: 'md-document',
},
{
path: '/reviewApproval',
title: '审核审批',
auth: [0,2],
icon: 'md-checkmark-circle',
},
// {
// path: '/statusQuery',
// title: '状态查询',
// auth: [0,1],
// icon: 'md-search',
// },
{
path: '/alertManagement',
title: '预警管理',
auth: [0],
icon: 'md-alert',
},
{
path: '/equipmentManagement',
title: '设备管理',
auth: [0],
icon: 'md-build',
},
{
path: '/consumablesManagement',
title: '耗材管理',
auth: [0],
icon: 'md-cube',
},
{
path: '/categoryManagement',
title: '分类管理',
auth: [0],
icon: 'md-folder',
},
{
path: '/systemConfiguration',
title: '系统配置',
auth: [0],
icon: 'md-settings',
children: [
{
path: '/messagePushTemplate',
title: '消息推送模版',
auth: [0],
icon: 'md-mail',
},
{
path: '/userPermission',
title: '用户权限',
auth: [0],
icon: 'md-lock',
},
{
path: '/operationLog',
title: '操作日志',
auth: [0],
icon: 'md-list-box',
}
]
}
]
<template>
<div class="frequency-demo">
<Card title="设备出库频率计算演示" :bordered="false">
<!-- 您的例子演示 -->
<div class="example-section">
<h3>您的例子:30天出库5次</h3>
<Row :gutter="16">
<Col span="6">
<Statistic title="出库次数" :value="5" suffix="次" />
</Col>
<Col span="6">
<Statistic title="时间周期" :value="30" suffix="天" />
</Col>
<Col span="6">
<Statistic title="频率(次/天)" :value="0.167" :precision="3" />
</Col>
<Col span="6">
<Statistic title="频率等级" :value="'低频'" />
</Col>
</Row>
<Alert type="success" show-icon style="margin-top: 16px">
<template #message>
<strong>计算公式:</strong> 频率 = 出库次数 ÷ 时间周期 = 5 ÷ 30 = 0.167次/天
</template>
</Alert>
</div>
<!-- 频率计算器 -->
<div class="calculator-section">
<h3>频率计算器</h3>
<Row :gutter="16">
<Col span="8">
<FormItem label="出库次数">
<InputNumber
v-model="calculator.outboundCount"
:min="1"
:max="1000"
placeholder="请输入出库次数"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="时间周期(天)">
<InputNumber
v-model="calculator.timePeriod"
:min="1"
:max="3650"
placeholder="请输入时间周期"
style="width: 100%"
/>
</FormItem>
</Col>
<Col span="8">
<FormItem label="计算单位">
<Select v-model="calculator.unit" style="width: 100%">
<Option value="day">次/天</Option>
<Option value="week">次/周</Option>
<Option value="month">次/月</Option>
<Option value="year">次/年</Option>
</Select>
</FormItem>
</Col>
</Row>
<div class="result-section">
<Alert type="info" show-icon>
<template #message>
<strong>计算结果:</strong>
<span class="frequency-result">{{ calculatedFrequency }}</span>
</template>
</Alert>
</div>
</div>
<!-- 频率等级说明 -->
<div class="level-section">
<h3>频率等级说明</h3>
<Table :columns="levelColumns" :data="levelData" border>
<template #level="{ row }">
<Tag :color="row.color">{{ row.level }}</Tag>
</template>
</Table>
</div>
</Card>
</div>
</template>
<script setup>
import { ref, reactive, computed } from 'vue';
import { Card, Row, Col, FormItem, InputNumber, Select, Option, Alert, Table, Tag, Statistic } from 'view-ui-plus';
import { calculateFrequency, formatFrequency, getFrequencyLevel, getFrequencyColor } from '@/utils/frequencyCalculator';
// 计算器数据
const calculator = reactive({
outboundCount: 5,
timePeriod: 30,
unit: 'day'
});
// 计算频率
const calculatedFrequency = computed(() => {
if (!calculator.outboundCount || !calculator.timePeriod) {
return '请输入数据';
}
const frequency = calculateFrequency(calculator.outboundCount, calculator.timePeriod, calculator.unit);
return formatFrequency(frequency, calculator.unit);
});
// 频率等级表格列定义
const levelColumns = [
{
title: '频率等级',
key: 'level',
minWidth: 100,
slot: 'level'
},
{
title: '频率范围',
key: 'range',
minWidth: 150
},
{
title: '说明',
key: 'description',
minWidth: 200
}
];
// 频率等级数据
const levelData = ref([
{
level: '高频',
range: '≥1次/天',
description: '设备使用频率很高,建议加强维护',
color: 'red'
},
{
level: '中频',
range: '1次/周 - 1次/天',
description: '设备使用频率适中,正常维护即可',
color: 'orange'
},
{
level: '低频',
range: '1次/月 - 1次/周',
description: '设备使用频率较低,可考虑共享使用',
color: 'blue'
},
{
level: '极低频',
range: '<1次/月',
description: '设备使用频率很低,建议重新评估需求',
color: 'green'
}
]);
</script>
<style scoped>
.frequency-demo {
padding: 16px;
}
.example-section {
margin-bottom: 32px;
}
.example-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
.calculator-section {
margin-bottom: 32px;
}
.calculator-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
.result-section {
margin-top: 16px;
}
.frequency-result {
color: #2d8cf0;
font-weight: bold;
font-size: 16px;
}
.level-section h3 {
margin-bottom: 16px;
color: #17233d;
font-weight: 500;
}
</style>
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown 格式
0% or
您添加了 0 人 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册 或