<template>
|
<div class="menu">
|
<div class="menu_header">
|
<div class="menu_header_title"><span>{{props.title}}</span></div>
|
<div class="menu_header_icon" v-if="props.isShow">
|
<img src="@/assets/icon/work_ic_guanli@2x.png" alt="" />
|
<span>管理</span>
|
</div>
|
</div>
|
<div class="menu_list">
|
<div class="menu_list_item" v-for="item in list" :key="item.id" @click="jump(item)">
|
<img :src="item.icon" alt="" />
|
<span>{{item.label}}</span>
|
</div>
|
<div class="menu_list_zw"></div>
|
<div class="menu_list_zw"></div>
|
<div class="menu_list_zw"></div>
|
</div>
|
<v-ScanCode
|
:openCode="openCodea"
|
:infos="infosa"
|
@closePopup="closePopupa"
|
@onDecode="onDecodea" />
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { defineProps, nextTick, ref } from 'vue'
|
import { useRouter } from "vue-router"
|
import { Toast } from 'vant'
|
import { QRCodeType } from '@/enum'
|
import { getBarcodeContent, getListByCondition, queryById } from '@/apis/WorkOrderAPI'
|
import { outScanAppliances } from '@/apis/ExWarehouse'
|
|
const router = useRouter()
|
|
// 控制扫码显示隐藏
|
const openCodea = ref<boolean>(false)
|
|
// 扫码提示
|
let infosa: any = ref([])
|
|
// 判断条件
|
let type: any = ref('')
|
|
// 关闭扫码组件
|
const closePopupa = (): void => {
|
openCodea.value = false
|
}
|
|
const props = defineProps({
|
title: {
|
type: String,
|
required: false,
|
default: ''
|
},
|
isShow: {
|
type: Boolean,
|
required: false,
|
default: false
|
},
|
list: {
|
type: Array,
|
required: false,
|
default: []
|
}
|
})
|
|
// 获取扫码值
|
const onDecodea = async (data: string[]): Promise<void> => {
|
|
await nextTick(() => {
|
openCodea.value = false
|
})
|
|
let info: any = ref([]) // 二维码类型
|
|
for (let i = 0; i < data.length; i++) {
|
let res = await getBarcodeContent({ // 扫码请求返回类型和id
|
barcode: data[i]
|
})
|
if (res.code === 200) {
|
info.value.push(res.data)
|
}
|
}
|
switch (type.value.trim()) {
|
|
case '/needToBeDealtWith/issueOperation': // 出库
|
if (info.value[0].barcodeType === QRCodeType.ZKD || info.value[0].barcodeType === QRCodeType.CKD) {
|
await router.push({name: 'issueOperation', query: { id: info.value[0].id, type: info.value[0].barcodeType }})
|
} else {
|
Toast.fail({ message: '请扫描正确的单据码', duration: 2000 })
|
}
|
break
|
case '/needToBeDealtWith/warehousing': // 入库
|
if (info.value[0].barcodeType === QRCodeType.ZKD || info.value[0].barcodeType === QRCodeType.RKD) {
|
await router.push({ path: '/needToBeDealtWith/warehousing', query: { id: info.value[0].id, type: info.value[0].barcodeType } })
|
} else {
|
Toast.fail({ message: '请扫描正确的入库单码', duration: 2000 })
|
}
|
break
|
case '/productionInspection/test/1': // 巡线
|
if (info.value[0].barcodeType !== QRCodeType.GD) {
|
Toast.fail({ message: '请扫描正确的工单码' })
|
} else if (info.value[1].barcodeType !== QRCodeType.GZ) {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
} else {
|
await router.push({ path: '/productionInspection/test', query: { gdId: info.value[0].id, gzId: info.value[1].id, type: 1 }} )
|
}
|
break
|
case '/productionInspection/test/2': // 巡检
|
if (info.value[0].barcodeType !== QRCodeType.GD) {
|
Toast.fail({ message: '请扫描正确的工单码' })
|
} else if (info.value[1].barcodeType !== QRCodeType.GZ) {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
} else {
|
await router.push({ path: '/productionInspection/test', query: { gdId: info.value[0].id, gzId: info.value[1].id, type: 2 }} )
|
}
|
break
|
case '/workOrder/bindingDevice': // 用户绑定设备
|
if (info.value[0].barcodeType === QRCodeType.SB) {
|
await router.push({ path: '/workOrder/bindingDevice', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描正确的设备码', duration: 2000 })
|
}
|
break
|
case '/workOrder/codeScanningFeeding': // 生产投料
|
if (info.value[0].barcodeType !== QRCodeType.GD) {
|
Toast.fail({ message: '请扫描正确的工单码' })
|
} else if (info.value[1].barcodeType !== QRCodeType.GZ) {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
} else {
|
await router.push({ path: '/workOrder/codeScanningFeeding', query: { id: info.value[0].id, gzId: info.value[1].id } })
|
}
|
break
|
case '/workOrder/codeScanningOutput': // 生产报工
|
if (info.value[0].barcodeType !== QRCodeType.GD) {
|
Toast.fail({ message: '请扫描正确的工单码' })
|
} else if (info.value[1].barcodeType !== QRCodeType.GZ) {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
} else {
|
await router.push({ path: '/workOrder/codeScanningOutput', query: { id: info.value[0].id, gzId: info.value[1].id } })
|
}
|
break
|
case '/workOrder/details-front': // 查工单
|
if (info.value[0].barcodeType === QRCodeType.GD) {
|
let res = await queryById(info.value[0].id)
|
if (res.code === 200) {
|
if (res.data.status === 4 || res.data.status === 6 || res.data.paused === 1) {
|
await router.push({ name: 'afterWorkReport', query: { id: info.value[0].id } })
|
} else {
|
await router.push({ name: 'workOrderDetails-front', query: { id: info.value[0].id } })
|
}
|
}
|
// if (info.value[0].id) {
|
// await router.push({ path: '/workOrder/details-front', query: { id: info.value[0].id } })
|
// } else {
|
// Toast.fail({ message: '暂未查找到工单', duration: 2000 })
|
// }
|
} else {
|
Toast.fail({ message: '请扫描正确的工单码', duration: 2000 })
|
}
|
break
|
case '/productionInspection/finalInspection': // 生产终检
|
if (info.value[0].barcodeType !== QRCodeType.GD) {
|
Toast.fail({ message: '请扫描正确的工单码' })
|
} else if (info.value[1].barcodeType !== QRCodeType.GZ) {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
} else {
|
// let gz = await getListByCondition({ id: info.value[1].id }) // 获取工装详情
|
let res = await queryById(info.value[0].id) // 获取工单详情,判断此工单是否是已完工或已取消
|
if (res.code === 200) {
|
// if (gz.data[0].workorderId !== res.data.id) {
|
// Toast.fail({ message: '此工装不在当前工单下', duration: 2000 })
|
// return
|
// }
|
if (res.data.status === 4 || res.data.status === 6) {
|
Toast.fail({ message: '工单状态为已报工或已取消不能检验', duration: 2000 })
|
return
|
}
|
}
|
await router.push({ path: '/productionInspection/finalInspection', query: { gdId: info.value[0].id, gzId: info.value[1].id } })
|
}
|
break
|
case '/workOrder/basketChange': // 换篮筐
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
await router.push({ path: '/workOrder/basketChange', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
case '/requisition/rework': // 返工返修申请
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
let res = await getListByCondition({ id: info.value[0].id })
|
if (res.code === 200 && res.data[0].qualityType === 1) {
|
await router.push({ path: '/requisition/rework', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描质量属性为不良的工装', duration: 2000 })
|
}
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
case '/requisition/scrapped': // 工序报废申请
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
let res = await getListByCondition({ id: info.value[0].id })
|
if (res.code === 200 && res.data[0].qualityType === 2) {
|
await router.push({ path: '/requisition/scrapped', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描质量属性为报废的工装', duration: 2000 })
|
}
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
case '/needToBeDealtWith/adjustReceipt': // 调整入库
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
let res = await getListByCondition({ id: info.value[0].id })
|
if (res.code === 200) {
|
if (res.data[0].status === 1) {
|
await router.push({ path: '/needToBeDealtWith/adjustReceipt', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描空的工装', duration: 2000 })
|
}
|
}
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
case '/workOrder/InspectTooling': // 查工装
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
await router.push({ path: '/workOrder/InspectTooling', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
case '/workOrder/location': // 查货位
|
if (info.value[0].barcodeType === QRCodeType.HW) {
|
await router.push({ path: '/workOrder/location', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '请扫描正确的货位码', duration: 2000 })
|
}
|
break
|
case '/needToBeDealtWith/scanning': // 扫码转库
|
if (info.value[0].barcodeType === QRCodeType.GZ) {
|
getListByCondition({ id: info.value[0].id })
|
.then(res => {
|
if (res.code === 200) {
|
if (res.data && res.data.length > 0) {
|
if (res.data[0].warehouseId) {
|
if (res.data[0].status !== 1) {
|
router.push({ path: '/needToBeDealtWith/scanning', query: { id: info.value[0].id } })
|
} else {
|
Toast.fail({ message: '该工装状态为空', duration: 2000 })
|
}
|
} else {
|
Toast.fail({ message: '该工装不在仓库', duration: 2000 })
|
}
|
} else {
|
Toast.fail({ message: '未查询到工装', duration: 2000 })
|
}
|
}
|
})
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码', duration: 2000 })
|
}
|
break
|
default:
|
Toast.fail({ message: '操作异常' })
|
}
|
}
|
|
// 跳转路由
|
const jump = (item: any) => {
|
debugger;
|
type.value = item.url
|
switch (item.url.trim()) {
|
case '/needToBeDealtWith/issueOperation': // 出库
|
infosa.value = ['请扫描出库单码']
|
openCodea.value = true
|
break
|
case '/needToBeDealtWith/warehousing': // 入库
|
infosa.value = ['请扫描入库单码']
|
openCodea.value = true
|
break
|
case '/productionInspection/test/1': // 巡线
|
infosa.value = ['请扫描工单码', '请扫描工装码']
|
openCodea.value = true
|
break
|
case '/productionInspection/test/2': // 巡检
|
infosa.value = ['请扫描工单码', '请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/bindingDevice': // 用户绑定设备
|
infosa.value = ['请扫描设备码']
|
openCodea.value = true
|
break
|
case '/workOrder/codeScanningFeeding': // 生产投料
|
infosa.value = ['请扫描工单码', '请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/codeScanningOutput': // 生产报工
|
infosa.value = ['请扫描工单码', '请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/details-front': // 查工单
|
infosa.value = ['请扫描工单码']
|
openCodea.value = true
|
break
|
case '/productionInspection/finalInspection': // 生产终检
|
infosa.value = ['请扫描工单码', '请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/basketChange': // 换篮筐
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/requisition/rework': // 返工返修申请
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/requisition/scrapped': // 工序报废申请
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/requisition/test': // 检验申请
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/needToBeDealtWith/adjustReceipt': // 调整入库
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/InspectTooling': // 查工装
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
case '/workOrder/location': // 查货位
|
infosa.value = ['请扫描货位码']
|
openCodea.value = true
|
break
|
case '/needToBeDealtWith/scanning': // 扫码转库
|
infosa.value = ['请扫描工装码']
|
openCodea.value = true
|
break
|
default:
|
router.push({ path: String(item.url).trim() })
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.menu {
|
padding: 30px;
|
box-sizing: border-box;
|
display: flex;
|
flex-direction: column;
|
background: white;
|
.menu_header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
.menu_header_title {
|
span {
|
font-size: 32px;
|
font-weight: 500;
|
color: #222222;
|
}
|
}
|
.menu_header_icon {
|
display: flex;
|
align-items: center;
|
img {
|
width: 26px;
|
height: 26px;
|
margin-right: 8px;
|
}
|
span {
|
font-size: 26px;
|
font-weight: 400;
|
color: #666666;
|
}
|
}
|
}
|
.menu_list {
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: space-between;
|
.menu_list_zw {
|
width: 20%;
|
height: 0;
|
}
|
.menu_list_item {
|
width: 20%;
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
justify-content: center;
|
margin-top: 40px;
|
img {
|
width: 88px;
|
height: 88px;
|
border-radius: 24px;
|
overflow: hidden;
|
}
|
span {
|
font-size: 24px;
|
font-weight: 400;
|
color: #333333;
|
margin-top: 16px;
|
}
|
}
|
}
|
}
|
</style>
|