优化
This commit is contained in:
@@ -5,7 +5,8 @@ const BASE_URL = '/materialType/materialType'
|
||||
export interface MaterialTypeResp {
|
||||
id: string
|
||||
typeName: string
|
||||
floatRatio: string
|
||||
upFloatRatio: string
|
||||
downFloatRatio: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
createUser: string
|
||||
@@ -26,6 +27,11 @@ export function listMaterialType(query: MaterialTypePageQuery) {
|
||||
}
|
||||
|
||||
/** @desc 新增物料品类 */
|
||||
export function addMaterialType(data: any) {
|
||||
return http.post(`${BASE_URL}`, data)
|
||||
}
|
||||
|
||||
/** @desc 查询物料品类 */
|
||||
export function selectList() {
|
||||
return http.get(`${BASE_URL}/selectList`)
|
||||
}
|
||||
|
||||
BIN
src/assets/wav/tooLess.wav
Normal file
BIN
src/assets/wav/tooLess.wav
Normal file
Binary file not shown.
BIN
src/assets/wav/tooMany.wav
Normal file
BIN
src/assets/wav/tooMany.wav
Normal file
Binary file not shown.
@@ -17,7 +17,6 @@
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import {
|
||||
getMaterialProcess,
|
||||
addMaterialProcess,
|
||||
updateMaterialProcess,
|
||||
type MaterialProcessResp
|
||||
|
||||
@@ -75,7 +75,6 @@ const {
|
||||
handleDelete
|
||||
} = useTable((page) => listMaterialProcess({ ...queryForm, ...page }), { immediate: true })
|
||||
const columns = ref<TableInstanceColumns[]>([
|
||||
{ title: '主键ID', dataIndex: 'id', slotName: 'id' },
|
||||
{ title: '流程名称', dataIndex: 'processName', slotName: 'processName' },
|
||||
{ title: '流程编码', dataIndex: 'processCode', slotName: 'processCode' },
|
||||
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
|
||||
|
||||
@@ -9,14 +9,38 @@
|
||||
@before-ok="save"
|
||||
@close="reset"
|
||||
>
|
||||
<GiForm ref="formRef" v-model="form" :columns="columns" />
|
||||
<GiForm ref="formRef" v-model="form" :columns="columns">
|
||||
<template #floatRatio>
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<a-input-number
|
||||
v-model="form.downFloatRatio"
|
||||
style="width: 45%"
|
||||
:min="-100"
|
||||
:max="100"
|
||||
:mode="'button'"
|
||||
placeholder="最小值"
|
||||
required: true,
|
||||
/>
|
||||
<span style="color: #999;">至</span>
|
||||
<a-input-number
|
||||
v-model="form.upFloatRatio"
|
||||
style="width: 45%"
|
||||
:min="0"
|
||||
:max="100"
|
||||
:mode="'button'"
|
||||
placeholder="最大值"
|
||||
required: true,
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</GiForm>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from '@arco-design/web-vue'
|
||||
import { useWindowSize } from '@vueuse/core'
|
||||
import {addMaterialType, type MaterialTypeResp, updateMaterialType} from '@/apis/materialType/materialType'
|
||||
import { addMaterialType, type MaterialTypeResp, updateMaterialType} from '@/apis/materialType/materialType'
|
||||
import { type ColumnItem, GiForm } from '@/components/GiForm'
|
||||
import { useResetReactive } from '@/hooks'
|
||||
|
||||
@@ -45,11 +69,10 @@ const columns: ColumnItem[] = reactive([
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '品类浮动比',
|
||||
label: '浮动范围(%)',
|
||||
field: 'floatRatio',
|
||||
type: 'input-number',
|
||||
type: 'custom',
|
||||
span: 24,
|
||||
required: true,
|
||||
},
|
||||
])
|
||||
|
||||
@@ -96,4 +119,4 @@ const onUpdate = async (data: MaterialTypeResp) => {
|
||||
defineExpose({ onAdd, onUpdate })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -33,6 +33,11 @@
|
||||
<template #default>导出</template>
|
||||
</a-button>
|
||||
</template>
|
||||
|
||||
<template #floatRatio="{ record }">
|
||||
{{ record.downFloatRatio + '% ~ ' + record.upFloatRatio + '%' }}
|
||||
</template>
|
||||
|
||||
<template #action="{ record }">
|
||||
<a-space>
|
||||
<a-link v-permission="['materialType:materialType:update']" title="修改" @click="onUpdate(record)">修改</a-link>
|
||||
@@ -79,13 +84,12 @@ const {
|
||||
handleDelete
|
||||
} = useTable((page) => listMaterialType({ ...queryForm, ...page }), { immediate: true })
|
||||
const columns = ref<TableInstanceColumns[]>([
|
||||
{ title: '主键ID', dataIndex: 'id', slotName: 'id' },
|
||||
{ title: '品类名称', dataIndex: 'typeName', slotName: 'typeName' },
|
||||
{
|
||||
{
|
||||
title: h('span', null, [
|
||||
'品类浮动比',
|
||||
'品类上下浮动范围(%)',
|
||||
h('a-tooltip', {
|
||||
title: '计算公式:电子称称重重量/(物料单位克重*物料数量)- 1'
|
||||
title: '领取物料重量不得超出此百分比范围'
|
||||
}, [
|
||||
h('span', {
|
||||
style: {
|
||||
@@ -95,9 +99,9 @@ const columns = ref<TableInstanceColumns[]>([
|
||||
}
|
||||
}, '?')
|
||||
])
|
||||
]),
|
||||
dataIndex: 'floatRatio',
|
||||
slotName: 'floatRatio'
|
||||
]),
|
||||
dataIndex: 'upFloatRatio',
|
||||
slotName: 'floatRatio'
|
||||
},
|
||||
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
|
||||
{ title: '更新时间', dataIndex: 'updateTime', slotName: 'updateTime', show: false },
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
<div class="form-row">
|
||||
<div class="form-item">
|
||||
<label>输入数量:</label>
|
||||
<a-input v-model="inputQuantity" placeholder="请输入数量" @change="calculateWeight" />
|
||||
<a-input-number :min="1" mode="button" v-model="inputQuantity" placeholder="请输入数量" @change="calculateWeight" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
@@ -139,13 +139,17 @@
|
||||
<label>计算重量(g):</label>
|
||||
<a-input v-model="calculatedWeight" placeholder="-" disabled />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-item">
|
||||
<label>对应重量(g):</label>
|
||||
<a-input v-model="ahDeviceWeight" placeholder="-" disabled />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-item">
|
||||
<label>该物料重量范围:</label>
|
||||
<a-input v-model="formData.materialName" placeholder="该物料重量范围" disabled />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 这里是摄像头画面 - 替换成FLV播放器 -->
|
||||
<div class="video-container large-image">
|
||||
@@ -463,30 +467,30 @@ const checkCameraStatus = () => {
|
||||
let statusCheckTimer: any = null
|
||||
|
||||
// 监听步骤变化
|
||||
watch(activeStep, (newVal) => {
|
||||
if (newVal === 2) {
|
||||
// 进入称重登记页面,启动摄像头
|
||||
reconnectCount.value = 1 // 重置重连计数
|
||||
nextTick(() => {
|
||||
initCamera()
|
||||
})
|
||||
|
||||
// 启动状态检查(每30秒检查一次)
|
||||
statusCheckTimer = setInterval(checkCameraStatus, 30000)
|
||||
} else {
|
||||
// 离开称重登记页面,停止摄像头和定时器
|
||||
stopCamera()
|
||||
if (statusCheckTimer) {
|
||||
clearInterval(statusCheckTimer)
|
||||
statusCheckTimer = null
|
||||
}
|
||||
if (reconnectTimer.value) {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
reconnectCount.value = 1
|
||||
}
|
||||
})
|
||||
// watch(activeStep, (newVal) => {
|
||||
// if (newVal === 2) {
|
||||
// // 进入称重登记页面,启动摄像头
|
||||
// reconnectCount.value = 1 // 重置重连计数
|
||||
// nextTick(() => {
|
||||
// initCamera()
|
||||
// })
|
||||
//
|
||||
// // 启动状态检查(每30秒检查一次)
|
||||
// statusCheckTimer = setInterval(checkCameraStatus, 30000)
|
||||
// } else {
|
||||
// // 离开称重登记页面,停止摄像头和定时器
|
||||
// stopCamera()
|
||||
// if (statusCheckTimer) {
|
||||
// clearInterval(statusCheckTimer)
|
||||
// statusCheckTimer = null
|
||||
// }
|
||||
// if (reconnectTimer.value) {
|
||||
// clearTimeout(reconnectTimer.value)
|
||||
// reconnectTimer.value = null
|
||||
// }
|
||||
// reconnectCount.value = 1
|
||||
// }
|
||||
// })
|
||||
|
||||
// 组件卸载时清理所有定时器
|
||||
onBeforeUnmount(() => {
|
||||
@@ -594,9 +598,9 @@ const workOrderResp = ref<WorkOrderResp>({
|
||||
})
|
||||
|
||||
// 称重登记页面数据
|
||||
const inputQuantity = ref('')
|
||||
const inputQuantity = ref()
|
||||
// todo
|
||||
const ahDeviceWeight = ref('10.1')
|
||||
const ahDeviceWeight = ref('100')
|
||||
const calculatedWeight = ref('')
|
||||
const weighingCount = ref(1)
|
||||
|
||||
@@ -871,7 +875,7 @@ const handleBackToFirst = () => {
|
||||
// 重置称重登记页面数据
|
||||
inputQuantity.value = ''
|
||||
// todo
|
||||
ahDeviceWeight.value = '10.1'
|
||||
ahDeviceWeight.value = '100'
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = 1
|
||||
// 清空称重列表
|
||||
@@ -908,8 +912,8 @@ const calculateWeight = () => {
|
||||
//处理确定
|
||||
const handleConfirm = async () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
Message.error('请输入数量')
|
||||
if (!inputQuantity.value || inputQuantity.value <= 0) {
|
||||
Message.error('数量需大于0!')
|
||||
return
|
||||
}
|
||||
if (!ahDeviceWeight.value || ahDeviceWeight.value.trim() === '') {
|
||||
@@ -919,15 +923,27 @@ const handleConfirm = async () => {
|
||||
|
||||
const data = {
|
||||
calculatedWeight: calculatedWeight.value,
|
||||
materialId: formData.id,
|
||||
inputQuantity: inputQuantity.value,
|
||||
ahDeviceWeight: ahDeviceWeight.value,
|
||||
}
|
||||
|
||||
const res = await validateWeighing(data);
|
||||
if (res.code != '0') {
|
||||
Message.error(res.msg || '系统异常!');
|
||||
// 然后处理错误信息
|
||||
if (!res || !res.code) {
|
||||
return;
|
||||
}
|
||||
if (res.data.code !== '200') {
|
||||
if (res.data.code !== '501') {
|
||||
playAudio('tooMany')
|
||||
}
|
||||
if (res.data.code !== '502') {
|
||||
playAudio('tooLess')
|
||||
}
|
||||
Message.error(res.data.msg || '系统异常!');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 立即创建一个新项的基本数据
|
||||
const newItem = {
|
||||
@@ -946,7 +962,7 @@ const handleConfirm = async () => {
|
||||
// 重置输入(让用户能继续输入)
|
||||
inputQuantity.value = ''
|
||||
// todo
|
||||
ahDeviceWeight.value = '10.1'
|
||||
ahDeviceWeight.value = '100'
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
|
||||
@@ -1098,6 +1114,20 @@ const closeWebSocket = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 播放音频文件
|
||||
const playAudio = (filename: string) => {
|
||||
console.log(filename)
|
||||
try {
|
||||
// 创建音频对象并播放
|
||||
const audio = new Audio(`/src/assets/wav/${filename}.wav`)
|
||||
audio.play().catch(error => {
|
||||
console.error('音频播放失败:', error)
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('播放音频时出错:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 组件卸载时关闭WebSocket连接
|
||||
onUnmounted(() => {
|
||||
closeWebSocket()
|
||||
|
||||
Reference in New Issue
Block a user