触摸屏获取工序信息逻辑调整与优化
This commit is contained in:
parent
39d82514d5
commit
0a92ccd80e
@ -4,7 +4,7 @@
|
||||
@change="doInputChange">
|
||||
</el-input> -->
|
||||
<v-text-field prepend-inner-icon="mdi-line-scan" ref="inputRef" :type="passwordShow ? 'text' : 'password'"
|
||||
autofocus label="请扫码" v-model="input" variant="solo-inverted" @keydown="handleKeyPress">
|
||||
autofocus label="请扫码" v-model.trim="input" variant="solo-inverted" @keydown="handleKeyPress">
|
||||
<template v-slot:append>
|
||||
<div>
|
||||
<v-icon :icon="passwordShow ? 'mdi-eye' : 'mdi-eye-off'"
|
||||
@ -26,7 +26,7 @@
|
||||
import { getCurrentInstance, onMounted, onUnmounted, ref } from 'vue'
|
||||
const { proxy } = getCurrentInstance()
|
||||
const inputRef = ref(null)
|
||||
const passwordShow = ref(true)
|
||||
const passwordShow = ref(false)
|
||||
const input = ref('')
|
||||
// 自动重新聚焦
|
||||
function autoInputFocus() {
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
</v-btn> -->
|
||||
<el-row :gutter="5">
|
||||
<el-col :span="24" v-for="(value, key) in qualityOptions" :key="key">
|
||||
|
||||
<div class="card-box">
|
||||
<div class="card-header">
|
||||
<span>{{ key }}</span>
|
||||
|
||||
@ -31,6 +31,27 @@
|
||||
}}</v-btn>
|
||||
</div>
|
||||
</el-card>
|
||||
<el-row v-if="processId === 70 && formData.workorder" :gutter="5">
|
||||
<el-col :span="24" v-for="(value, key) in qualityOptions" :key="key">
|
||||
<div class="card-box">
|
||||
<div class="card-header">
|
||||
<span>{{ key }}</span>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col :span="2" v-for="(item, index) in value" :key="index">
|
||||
<div class="click-box" @mousedown="handleStart($event, item)"
|
||||
@mouseup="handleEnd(item)"
|
||||
@touchstart="handleStart($event, item)"
|
||||
@touchend="handleEnd(item)">
|
||||
<span class="click-title">{{ item.name }}</span>
|
||||
<span class="click-num">{{ getClickItemNum(item)
|
||||
}}</span>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item value="此工单工序记录">
|
||||
<el-card v-if="formData.workorder" class="mt-4">
|
||||
@ -123,6 +144,27 @@
|
||||
</template>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<!-- 修改缺陷项 -->
|
||||
<el-dialog class="dialogBox" v-model.sync="updateDialogShow" title="缺陷项修改" width="400px" append-to-body
|
||||
:close-on-click-modal="false">
|
||||
<el-form label-width="auto">
|
||||
<el-form-item label="工单号">
|
||||
<el-text class="number-text">{{ formData.workorder }}</el-text>
|
||||
</el-form-item>
|
||||
<el-form-item label="缺陷项">
|
||||
<el-text class="number-text">{{ updateName }}</el-text>
|
||||
</el-form-item>
|
||||
<el-form-item label="缺陷数">
|
||||
<el-input-number class="number-text" v-model="updateNum"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="updateDialogShow = false">取消</el-button>
|
||||
<button class="button-box" type="primary" @click="updateDefectNum"> 确认修改 </button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
@ -130,6 +172,7 @@
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
import * as ReportApi from '@/api/reportFlow/index'
|
||||
import * as FQCApi from '@/api/reportFlow/fqc'
|
||||
import scanInput from '../components/scanInput.vue'
|
||||
import ThePersonReportRecord from './components/ThePersonReportRecord.vue'
|
||||
import TheWorkOrderProcessRecord from './components/TheWorkOrderProcessRecord.vue'
|
||||
@ -176,6 +219,12 @@ const processOptions = [
|
||||
]
|
||||
const tab = ref('报工')
|
||||
const processId = ref(10)
|
||||
|
||||
watch(processId, (newVal, oldVal) => {
|
||||
if (newVal !== oldVal) {
|
||||
processChange()
|
||||
}
|
||||
})
|
||||
function getButtonName() {
|
||||
if (processId.value === 10) {
|
||||
return '确认领用'
|
||||
@ -233,29 +282,22 @@ function getFormData(workorder) {
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
formData.value = res.data
|
||||
ReportApi.GetProcessReportWorkDetail(params).then(res2 => {
|
||||
if (!res2.data) {
|
||||
formData.value.finishNum = formData.value.planNum;
|
||||
formData.value.badNum = 0;
|
||||
formData.value.worker = '';
|
||||
}
|
||||
else {
|
||||
formData.value.finishNum = res2.data.finishNum;
|
||||
formData.value.badNum = res2.data.badNum ?? 0;
|
||||
formData.value.worker = res2.data.worker;
|
||||
if (formData.value.finishNum > 0) {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-yellow'
|
||||
dialog.title = '提示'
|
||||
dialog.text = '工单此工序已报工过'
|
||||
}
|
||||
}
|
||||
})
|
||||
GetProcessReportWorkDetail(workorder)
|
||||
ReportApi.GetWorkOrderReportWorkList(params).then(res => {
|
||||
if (res.code == 200) {
|
||||
reportWorkerOrderList.value = res.data
|
||||
}
|
||||
})
|
||||
FQCApi.SearchDefectList({ WorkOrder: workorder }).then(res => {
|
||||
if (res.code === 200) {
|
||||
// 初始化数据
|
||||
clearGroupOptions()
|
||||
// 修改数据
|
||||
for (let item of res.data) {
|
||||
setDefectNum(item.defectCode, item.number)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
@ -265,6 +307,34 @@ function getFormData(workorder) {
|
||||
}
|
||||
})
|
||||
}
|
||||
// 获取此工序报工详情信息
|
||||
function GetProcessReportWorkDetail(workorder) {
|
||||
const params = { workorder, processId: processId.value }
|
||||
ReportApi.GetProcessReportWorkDetail(params).then(res => {
|
||||
if (!res.data) {
|
||||
formData.value.finishNum = formData.value.planNum ?? 20;
|
||||
formData.value.badNum = 0;
|
||||
formData.value.worker = '';
|
||||
}
|
||||
else {
|
||||
formData.value.finishNum = res.data.finishNum ?? 20;
|
||||
formData.value.badNum = res.data.badNum ?? 0;
|
||||
formData.value.worker = res.data.worker;
|
||||
if (formData.value.finishNum > 0) {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-yellow'
|
||||
dialog.title = '提示'
|
||||
dialog.text = '工单此工序已报工过'
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
// 工序修改
|
||||
function processChange() {
|
||||
if (formData.value.workorder !== '' && formData.value.workorder.length > 6) {
|
||||
GetProcessReportWorkDetail(formData.value.workorder)
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
proxy.$confirm('确定提交数据吗?').then(() => {
|
||||
@ -325,54 +395,205 @@ function showDialog(dialogJson = {}) {
|
||||
dialog.text = dialogJson.text
|
||||
}
|
||||
|
||||
const queryParams1 = reactive({
|
||||
name: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processId: null,
|
||||
})
|
||||
const queryParams2 = reactive({
|
||||
name: '',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
processId: null,
|
||||
})
|
||||
const loading = ref(false)
|
||||
const total1 = ref(0)
|
||||
const nowdayReportDataList = ref([])
|
||||
function nowdayReportOrderList() {
|
||||
loading.value = true
|
||||
queryParams1.processId = processId.value
|
||||
ReportApi.GetReportByProcessId(queryParams1).then(res => {
|
||||
const { code, data } = res
|
||||
if (code == 200) {
|
||||
nowdayReportDataList.value = data.result
|
||||
total1.value = data.totalNum
|
||||
loading.value = false
|
||||
/// ==================== 缺陷配置 =========================
|
||||
|
||||
const checkName = ref('')
|
||||
const qualityLoading = ref(false)
|
||||
const qualityOptionsClear = ref([])
|
||||
const qualityOptions = ref([])
|
||||
function getDefectConfigData(qcType = "") {
|
||||
qualityLoading.value = true
|
||||
const params = {
|
||||
status: 1,
|
||||
qcType
|
||||
}
|
||||
FQCApi.getDefectConfig(params).then(res => {
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
const _groupList = getGroupOptions(res.data)
|
||||
qualityOptions.value = _groupList
|
||||
qualityOptionsClear.value = _groupList
|
||||
qualityLoading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
const total2 = ref(0)
|
||||
const userReportDataList = ref([])
|
||||
function queryUserReport() {
|
||||
loading.value = true
|
||||
if (queryParams2.name === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '异常提示'
|
||||
dialog.text = '请输入姓名拼音'
|
||||
return
|
||||
}
|
||||
ReportApi.GetReportInfoByName(queryParams2).then(res => {
|
||||
const { code, data } = res
|
||||
if (code == 200) {
|
||||
userReportDataList.value = data.result
|
||||
total2.value = data.totalNum
|
||||
loading.value = false
|
||||
// 进行分组
|
||||
function getGroupOptions(list) {
|
||||
let groupedOptions = list.reduce((groups, item) => {
|
||||
if (!groups[item.group]) {
|
||||
groups[item.group] = []
|
||||
}
|
||||
})
|
||||
groups[item.group].push(item)
|
||||
return groups
|
||||
}, {})
|
||||
return groupedOptions
|
||||
}
|
||||
// 还原数据
|
||||
function clearGroupOptions() {
|
||||
qualityOptions.value = JSON.parse(JSON.stringify(qualityOptionsClear.value))
|
||||
}
|
||||
// 缺陷赋值
|
||||
function setDefectNum(code, num) {
|
||||
const _list = qualityOptions.value
|
||||
for (let category in _list) {
|
||||
if (Array.isArray(_list[category])) {
|
||||
let foundItem = _list[category].find((item) => item.code === code)
|
||||
if (foundItem) {
|
||||
// 更新找到的item的num属性
|
||||
foundItem.num = num
|
||||
return true // 可选返回true表示成功
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(`未找到code为${code}的缺陷项`)
|
||||
return false // 可选返回false表示未找到
|
||||
}
|
||||
|
||||
getDefectConfigData("入库检查")
|
||||
/// ======================================================
|
||||
/// ====================== 按钮操作 =====================
|
||||
const isLongPress = ref(false)
|
||||
const pressTimer = ref(null)
|
||||
const handleStart = (event, item) => {
|
||||
// 如果是触摸事件,阻止其默认行为(如滚动)
|
||||
if (event.type.startsWith('touch')) event.preventDefault()
|
||||
// 清除之前的定时器
|
||||
if (pressTimer.value) clearTimeout(pressTimer.value)
|
||||
// 设置新的定时器,用于判断长按
|
||||
pressTimer.value = setTimeout(() => {
|
||||
isLongPress.value = true
|
||||
console.log('长按')
|
||||
// 这里执行长按的逻辑
|
||||
showUpdateDialog(item)
|
||||
}, 500) // 长按的阈值设为500毫秒
|
||||
}
|
||||
|
||||
const handleEnd = (item) => {
|
||||
// 清除定时器
|
||||
if (pressTimer.value) clearTimeout(pressTimer.value)
|
||||
// 这里执行短按或长按结束的逻辑
|
||||
clickQualityIte(item)
|
||||
isLongPress.value = false
|
||||
}
|
||||
// 短按新增
|
||||
function clickQualityIte(item) {
|
||||
// 长按则跳过
|
||||
if (isLongPress.value) {
|
||||
return
|
||||
}
|
||||
const workOrder = formData.value.workorder
|
||||
if (workOrder === null || workOrder === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '工单未选择提示'
|
||||
dialog.text = '请先扫描工单!'
|
||||
return
|
||||
}
|
||||
if (formData.value.worker === null || formData.value.worker === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '作业员未填写提示'
|
||||
dialog.text = '请先扫描作业员!'
|
||||
return
|
||||
}
|
||||
const newNum = getClickItemNum(item) + 1
|
||||
const params = {
|
||||
WorkOrder: formData.value.workorder,
|
||||
DefectCode: item.code,
|
||||
num: item.num ?? 0,
|
||||
checkName: formData.value.worker
|
||||
}
|
||||
FQCApi.AddDefectNum(params).then((res) => {
|
||||
if (res.code != 200) {
|
||||
proxy.$message.error('添加缺陷项异常')
|
||||
return
|
||||
}
|
||||
})
|
||||
item.num = newNum
|
||||
formData.value.badNum = (formData.value.badNum * 1) + 1
|
||||
}
|
||||
// 长按弹出修改框
|
||||
const updateDialogShow = ref(false)
|
||||
const updateName = ref('')
|
||||
const updateCode = ref('')
|
||||
const updateNum = ref(0)
|
||||
function showUpdateDialog(item) {
|
||||
const workOrder = formData.value.workorder
|
||||
if (workOrder === null || workOrder === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '工单提示'
|
||||
dialog.text = '请先扫描或选择工单!'
|
||||
return
|
||||
}
|
||||
if (formData.value.worker === null || formData.value.worker === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '作业员未填写提示'
|
||||
dialog.text = '请先扫描作业员!'
|
||||
return
|
||||
}
|
||||
updateName.value = item.name
|
||||
updateCode.value = item.code
|
||||
updateNum.value = item.num ?? 0
|
||||
updateDialogShow.value = true
|
||||
}
|
||||
function updateDefectNum() {
|
||||
// 短按则跳过
|
||||
// if (!isLongPress.value) {
|
||||
// return
|
||||
// }
|
||||
const workOrder = formData.value.workorder
|
||||
if (workOrder === null || workOrder === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '工单提示'
|
||||
dialog.text = '请先扫描或选择工单!'
|
||||
return
|
||||
}
|
||||
if (formData.value.worker === null || formData.value.worker === '') {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-amber'
|
||||
dialog.title = '作业员未填写提示'
|
||||
dialog.text = '请先扫描作业员!'
|
||||
return
|
||||
}
|
||||
const params = {
|
||||
WorkOrder: formData.value.workorder,
|
||||
DefectCode: updateCode.value,
|
||||
num: updateNum.value,
|
||||
checkName: formData.value.worker
|
||||
}
|
||||
FQCApi.UpdateDefectNum(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-green'
|
||||
dialog.title = '修改提示'
|
||||
dialog.text = '修改缺陷项成功!'
|
||||
setDefectNum(params.DefectCode, params.num)
|
||||
updateDialogShow.value = false
|
||||
} else {
|
||||
dialog.show = true
|
||||
dialog.class = 'bg-red'
|
||||
dialog.title = '修改提示'
|
||||
dialog.text = '修改缺陷项异常!'
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
// 数据解析,错误数据排除
|
||||
function getClickItemNum(item) {
|
||||
if (!item.num) {
|
||||
return 0
|
||||
}
|
||||
return item.num * 1
|
||||
}
|
||||
// function updateFormReportNum(num) {
|
||||
// formData.value.planNum = (formData.value.planNum * 1) - 1
|
||||
// formData.value.badNum = (formData.value.badNum * 1) + 1
|
||||
// }
|
||||
/// =====================================================
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -414,4 +635,70 @@ function queryUserReport() {
|
||||
min-height: 88vh;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.card-box {
|
||||
margin-top: 10px;
|
||||
height: 100%;
|
||||
background-color: #000071;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
color: white;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.click-box {
|
||||
border-radius: 5%;
|
||||
margin: 5px;
|
||||
height: 100px;
|
||||
background-color: #1B5E20;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.click-title {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.click-num {
|
||||
height: 40px;
|
||||
font-size: 26px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.workorder-active {
|
||||
background-color: rgb(82.4, 155.2, 46.4);
|
||||
}
|
||||
|
||||
.button-left-top {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
.button-box {
|
||||
margin-left: 20px;
|
||||
width: 100px;
|
||||
height: 40px;
|
||||
border: 1px solid #eeeeee;
|
||||
border-radius: 10%;
|
||||
background: #0055ff;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
Loading…
x
Reference in New Issue
Block a user