<template>
|
<div class="adjustment">
|
<div class="box">
|
<div class="adjustment_item" @click="showList.show = true">
|
<span>单据类型</span>
|
<div class="adjustment_item_xz">
|
<span :style="dataValue.documentTypeName ? 'color: #000' : ''">{{dataValue.documentTypeName ? dataValue.documentTypeName : '点击选择'}}</span>
|
<van-icon name="arrow" size="20" color="#999999" />
|
</div>
|
</div>
|
<div class="adjustment_item" @click="showList.show1 = true">
|
<span>入库仓库</span>
|
<div class="adjustment_item_xz">
|
<span :style="dataValue.warehouseName ? 'color: #000' : ''">{{dataValue.warehouseName ? dataValue.warehouseName : '点击选择'}}</span>
|
<van-icon name="arrow" size="20" color="#999999" />
|
</div>
|
</div>
|
</div>
|
<div class="adjustment_title">入库物料清单</div>
|
<van-swipe-cell v-for="(item, index) in list" :key="item.code">
|
<div class="box">
|
<div class="adjustment_item">
|
<span>工装器具</span>
|
<div class="adjustment_item_xz">
|
<span class="black">{{ item.code }}</span>
|
</div>
|
</div>
|
<div class="adjustment_item" @click="openWL(index)">
|
<span>入库物料</span>
|
<div class="adjustment_item_xz">
|
<span :style="item.wlName ? 'color: #000;' : ''">{{item.wlName ? item.wlName : '点击选择入库物料'}}</span>
|
<van-icon name="arrow" size="20" color="#999999" />
|
</div>
|
</div>
|
<div class="sweep">
|
<div class="sweep_box" @click="openCode('请扫描物料码', index)">
|
<img src="@/assets/icon/jianyan_ic_saoma@2x.png" alt="" />
|
<span>扫描物料</span>
|
</div>
|
</div>
|
<div class="adjustment_item" @click="openGX(index)" v-if="item.wlName && item.type">
|
<span>生产工序</span>
|
<div class="adjustment_item_xz">
|
<span :style="item.gxName ? 'color: #000;' : ''">{{item.gxName ? item.gxName : '点击选择'}}</span>
|
<van-icon name="arrow" size="20" color="#999999" />
|
</div>
|
</div>
|
<div class="adjustment_item" @click="openSX(index)" v-if="item.wlName">
|
<span>质量属性</span>
|
<div class="adjustment_item_xz">
|
<span :style="item.sxName ? 'color: #000;' : ''">{{item.sxName ? item.sxName : '点击选择'}}</span>
|
<van-icon name="arrow" size="20" color="#999999" />
|
</div>
|
</div>
|
<div class="adjustment_item" v-if="item.wlName">
|
<span>批次号</span>
|
<div class="adjustment_item_xz">
|
<input type="text" v-model="item.pch" placeholder="请输入" />
|
</div>
|
</div>
|
<div class="adjustment_item" v-if="item.wlName">
|
<span>入库数量({{ item.dw }})</span>
|
<div class="adjustment_item_xz">
|
<input type="text" @blur="numBlur(index)" v-model="item.num" placeholder="0" />
|
</div>
|
</div>
|
</div>
|
<template #right>
|
<van-button style="height: 100%;" square type="danger" text="删除" @click="dele(index)" />
|
</template>
|
</van-swipe-cell>
|
<div class="zw"></div>
|
<div class="footer">
|
<div class="footer_jx" @click="openCode('请扫描工装码')">继续扫码</div>
|
<div class="footer_w"></div>
|
<button class="footer_tj" v-preventReClick @click="submit">提交入库</button>
|
</div>
|
</div>
|
<!-- 单据类型 -->
|
<van-popup v-model:show="showList.show" position="bottom" round :style="{ height: '45%' }">
|
<van-picker
|
title="请选择单据类型"
|
:columns="showList.columns"
|
@confirm="onConfirm"
|
@cancel="onCancel"
|
/>
|
</van-popup>
|
<!-- 选择仓库 -->
|
<Warehouse :show="showList.show1" @close="close" @value="getValue" />
|
<!-- 入库物料 -->
|
<Material :show="showList.show2" @close="close1" @value="getValue1" />
|
<!-- 生产工序 -->
|
<van-popup v-model:show="showList.show3" position="bottom" round :style="{ height: '45%' }">
|
<van-picker
|
title="请选择生产工序"
|
:columns="showList.columns3"
|
@confirm="onConfirm3"
|
@cancel="onCancel3"
|
/>
|
</van-popup>
|
<!-- 质量属性 -->
|
<van-popup v-model:show="showList.show4" position="bottom" round :style="{ height: '45%' }">
|
<van-picker
|
title="请选择质量属性"
|
:columns="showList.columns4"
|
@confirm="onConfirm4"
|
@cancel="onCancel4"
|
/>
|
</van-popup>
|
<!-- 扫码 -->
|
<v-ScanCode
|
:openCode="showList.openCode"
|
:infos="showList.info"
|
@closePopup="closePopup"
|
@onDecode="onDecode" />
|
</template>
|
|
<script setup lang="ts">
|
import { ref, reactive, onMounted } from 'vue'
|
import { useRoute, useRouter } from "vue-router"
|
import { getBarcodeContent, getListByCondition } from "@/apis/WorkOrderAPI"
|
import { wOutBoundForStockUp, getMaterialItem, getListByMaterialId } from '@/apis/ExWarehouse'
|
import { QRCodeType, Attribute } from '@/enum'
|
import { REGULAR } from '@/utils/utils'
|
import { Toast } from 'vant'
|
import Warehouse from '@/components/common/Warehouse.vue'
|
import Material from '@/components/common/Material.vue'
|
|
const route = useRoute()
|
const router = useRouter()
|
|
// 控制页面数据验证
|
interface verification {
|
info: Array<string>,
|
openCode: boolean,
|
show: boolean,
|
columns: Array<any>,
|
show1: boolean,
|
show2: boolean,
|
show3: boolean,
|
columns3: Array<any>,
|
show4: boolean,
|
columns4: Array<any>
|
}
|
|
// 清单数据验证
|
interface list {
|
id: string | number,
|
code: string,
|
attribute: string,
|
dw: string,
|
wlId: string,
|
wlName: string,
|
wlCompany: string,
|
gxId: string,
|
gxName: string,
|
sxId: string,
|
sxName: string,
|
pch: string,
|
num: string,
|
type: boolean // 判断有没有工序
|
}
|
|
// 单据类型/入库仓库数据验证
|
interface ckVerification {
|
warehouseName: string,
|
warehouseId: string,
|
documentTypeName: string,
|
documentTypeId: string,
|
warehouseAttribute: string
|
}
|
|
// 单据类型/入库仓库
|
let dataValue = ref<ckVerification>({
|
warehouseName: '',
|
warehouseId: '',
|
warehouseAttribute: '',
|
documentTypeName: '库存调整',
|
documentTypeId: '28'
|
})
|
|
// 插入物料详细索引
|
let index = ref<number>()
|
|
// 入库清单
|
let list = ref<Array<list>>([])
|
|
// 控制下拉显示/隐藏/数据
|
let showList = reactive<verification>({
|
info: [],
|
openCode: false,
|
show: false,
|
// 13 客返返修入库
|
// 17 客退返修入库
|
// 28 库存调整
|
columns: [{ text: '库存调整', id: '28' }],
|
// ,{ text: '客返检验入库', id: '1' },{ text: '客退检验入库', id: '2' }],
|
show1: false,
|
show2: false,
|
show3: false,
|
columns3: [],
|
show4: false,
|
columns4: []
|
})
|
|
// 删除对应的工装
|
const dele = (i: number): void => {
|
if (list.value.length === 1) {
|
Toast.fail({ message: "至少保留一个工装" })
|
return
|
}
|
list.value.splice(i, 1)
|
}
|
|
// 提交调整入库
|
const submit = () => {
|
let isOpen: boolean = true
|
if (!dataValue.value.documentTypeId) return Toast.fail({ message: '单据类型不能为空' })
|
if (!dataValue.value.warehouseId) return Toast.fail({ message: '入库仓库不能为空' })
|
list.value.forEach((element: any) => {
|
if (element.type && !element.gxId) {
|
isOpen = false
|
return Toast.fail({message: `请完善[${element.code}]的生产工序`})
|
}
|
if (!element.wlId) {
|
isOpen = false
|
return Toast.fail({message: `请完善[${element.code}]的入库物料`})
|
}
|
if (!element.sxId) {
|
isOpen = false
|
return Toast.fail({message: `请完善[${element.code}]的质量属性`})
|
}
|
if (!element.num) {
|
isOpen = false
|
return Toast.fail({message: `请完善[${element.code}]的入库数量`})
|
}
|
})
|
if (isOpen) {
|
let woutboundInBodyBeanList: Array<any> = []
|
list.value.forEach((element: any) => {
|
woutboundInBodyBeanList.push({
|
appliancesId: element.id,
|
batch: element.pch,
|
materialId: element.wlId,
|
num: Number(element.num),
|
procedureId: element.gxId,
|
qualityType: Number(element.sxId),
|
unitId: element.wlCompany
|
})
|
})
|
wOutBoundForStockUp({
|
type: Number(dataValue.value.documentTypeId),
|
warehouseId: Number(dataValue.value.warehouseId),
|
woutboundInBodyBeanList
|
}).then(res => {
|
if (res.code === 200) {
|
Toast.success({ message: '创建成功', forbidClick: true, duration: 2000 })
|
setTimeout(() => {
|
router.go(-1)
|
}, 2000)
|
}
|
})
|
}
|
}
|
|
// 输入数量失去焦点校验单位
|
const numBlur = (i: number): void => {
|
if (Number(list.value[i].wlCompany) === 0) {
|
if (!REGULAR.positiveInteger.test(list.value[i].num)) {
|
list.value[i].num = ''
|
Toast.fail({ message: `物料[${list.value[i].code}]只能输入正整数` })
|
}
|
} else if (Number(list.value[i].wlCompany) === 1) {
|
if (!REGULAR.number.test(list.value[i].num)) {
|
list.value[i].num = ''
|
Toast.fail({ message: `物料[${list.value[i].code}]只能输入整数或小数(四位)` })
|
}
|
}
|
}
|
|
// 打开质量属性选择
|
const openSX = (i: number) => {
|
setIndexes(i)
|
if (list.value[i].attribute === Attribute.HH) { // 混合
|
showList.columns4 = [{ text: '合格', id: '0' },{ text: '不良', id: '1' },{ text: '报废', id: '2' }]
|
} else if (list.value[i].attribute === Attribute.HG) { // 合格
|
showList.columns4 = [{ text: '合格', id: '0' }]
|
} else if (list.value[i].attribute === Attribute.BL) { // 不良
|
showList.columns4 = [{ text: '不良', id: '1' }]
|
} else if (list.value[i].attribute === Attribute.BF) { // 报废
|
showList.columns4 = [{ text: '报废', id: '2' }]
|
}
|
showList.show4 = true
|
}
|
|
// 打开工序选择
|
const openGX = async (i: number) => {
|
setIndexes(i)
|
let res = await getListByMaterialId({
|
materialId: list.value[i].wlId
|
})
|
if (res.code === 200) {
|
showList.columns3 = []
|
res.data.forEach((element: any) => {
|
showList.columns3.push({ text: element.name, id: element.id })
|
})
|
showList.show3 = true
|
}
|
}
|
|
const openWL = (i: number) => {
|
setIndexes(i)
|
showList.show2 = true
|
}
|
|
// 设置插入索引
|
const setIndexes = (i: number): void => {
|
index.value = i
|
}
|
|
// 打开扫码
|
const openCode = (type: string, i: number): void => {
|
if (type === '请扫描工装码' && !dataValue.value.warehouseId) {
|
Toast.fail({ message: '请先选择入库仓库' })
|
return
|
}
|
setIndexes(i)
|
showList.info = [type]
|
showList.openCode = true
|
}
|
|
// 获取扫码回调
|
const onDecode = async (data: string[]): Promise<void> => {
|
showList.openCode = false
|
let res = await getBarcodeContent({
|
barcode: data[0]
|
})
|
if (showList.info[0] === '请扫描物料码') {
|
if (res.data.barcodeType === QRCodeType.WL) {
|
let wl = await getMaterialItem({ materialId: res.data.id })
|
if (wl.code === 200) {
|
list.value[index.value as number].wlName = wl.data.mmodelUnionName
|
list.value[index.value as number].wlId = wl.data.id
|
list.value[index.value as number].wlCompany = wl.data.umodelAttributeData
|
let gx = await getListByMaterialId({
|
materialId: wl.data.id
|
})
|
if (gx.code === 200) {
|
list.value[index.value as number].type = gx.code === 200 && gx.data.length > 0
|
if (gx.data && gx.data.length > 0) {
|
list.value[index.value as number].gxId = gx.data[0].id
|
list.value[index.value as number].gxName = gx.data[0].name
|
}
|
}
|
}
|
} else {
|
Toast.fail({ message: '请扫描正确的物料码' })
|
}
|
} else if (showList.info[0] === '请扫描工装码') {
|
if (res.data.barcodeType === QRCodeType.GZ) {
|
let gz = await getListByCondition({ id: res.data.id })
|
if (gz.code === 200) {
|
let isOpen: boolean = true
|
list.value.forEach((element: any) => {
|
if (element.id === gz.data[0].id) {
|
isOpen = false
|
Toast.fail({ message: '工装不能重复添加' })
|
}
|
})
|
if (isOpen) {
|
if (gz.data[0].status === 1) {
|
if (dataValue.value.warehouseAttribute === Attribute.HH) {
|
setData(gz.data[0], gz.data[0].smodelLabel)
|
return
|
} else if (dataValue.value.warehouseAttribute === Attribute.HG) {
|
if (gz.data[0].smodelLabel !== Attribute.HG) {
|
Toast.fail({ message: '工装属性必须和仓库属性一致' })
|
return
|
}
|
setData(gz.data[0], gz.data[0].smodelLabel)
|
} else if (dataValue.value.warehouseAttribute === Attribute.BL) {
|
if (gz.data[0].smodelLabel !== Attribute.BL) {
|
Toast.fail({ message: '工装属性必须和仓库属性一致' })
|
return
|
}
|
setData(gz.data[0], gz.data[0].smodelLabel)
|
} else if (dataValue.value.warehouseAttribute === Attribute.BF) {
|
if (gz.data[0].smodelLabel !== Attribute.BF) {
|
Toast.fail({ message: '工装属性必须和仓库属性一致' })
|
return
|
}
|
setData(gz.data[0], gz.data[0].smodelLabel)
|
}
|
} else {
|
Toast.fail({ message: '请扫描空的工装' })
|
}
|
}
|
}
|
} else {
|
Toast.fail({ message: '请扫描正确的工装码' })
|
}
|
}
|
}
|
|
// 插入物料清单
|
const setData = async (element: any, type: string): Promise<void> => {
|
let item = {
|
id: element.id,
|
code: element.code,
|
attribute: element.smodelLabel,
|
dw: list.value[list.value.length - 1].dw,
|
wlId: list.value[list.value.length - 1].wlId,
|
wlName: list.value[list.value.length - 1].wlName,
|
gxId: list.value[list.value.length - 1].gxId,
|
gxName: list.value[list.value.length - 1].gxName,
|
sxId: '',
|
sxName: '',
|
pch: list.value[list.value.length - 1].pch,
|
num: list.value[list.value.length - 1].num,
|
type: list.value[list.value.length - 1].type
|
}
|
if (type === Attribute.HH) {
|
item.sxId = '0'
|
item.sxName = '合格'
|
} else if (type === Attribute.HG) {
|
item.sxId = '0'
|
item.sxName = '合格'
|
} else if (type === Attribute.BL) {
|
item.sxId = '1'
|
item.sxName = '不良'
|
} else if (type === Attribute.BF) {
|
item.sxId = '2'
|
item.sxName = '报废'
|
}
|
list.value.unshift(item as never)
|
}
|
|
// 关闭扫码
|
const closePopup = () => {
|
showList.openCode = false
|
}
|
|
// 单据类型确认
|
const onConfirm = (val: any): void => {
|
dataValue.value.documentTypeId = val.id
|
dataValue.value.documentTypeName = val.text
|
showList.show = false
|
}
|
|
const onCancel = (val: any): void => {
|
showList.show = false
|
}
|
|
const close = (val: any): void => {
|
showList.show1 = false
|
}
|
|
// 仓库确认
|
const getValue = (val: any): void => {
|
if (val.tmodel.label === Attribute.HH) {
|
console.log('仓库是混合')
|
dataValue.value.warehouseId = val.id
|
dataValue.value.warehouseName = val.name
|
dataValue.value.warehouseAttribute = val.tmodel.label
|
} else if (list.value[0].attribute === Attribute.HG && val.tmodel.label === Attribute.HG) {
|
console.log('都是合格')
|
dataValue.value.warehouseId = val.id
|
dataValue.value.warehouseName = val.name
|
dataValue.value.warehouseAttribute = val.tmodel.label
|
} else if (list.value[0].attribute === Attribute.BL && val.tmodel.label === Attribute.BL) {
|
console.log('都是不良')
|
dataValue.value.warehouseId = val.id
|
dataValue.value.warehouseName = val.name
|
dataValue.value.warehouseAttribute = val.tmodel.label
|
} else if (list.value[0].attribute === Attribute.BF && val.tmodel.label === Attribute.BF) {
|
console.log('都是报废')
|
dataValue.value.warehouseId = val.id
|
dataValue.value.warehouseName = val.name
|
dataValue.value.warehouseAttribute = val.tmodel.label
|
} else {
|
Toast.fail({ message: '工装属性和仓库属性不一致' })
|
}
|
showList.show1 = false
|
}
|
|
const close1 = (val: any): void => {
|
showList.show2 = false
|
}
|
|
// 物料确认
|
const getValue1 = async (val: any): Promise<void> => {
|
let res = await getListByMaterialId({
|
materialId: val.id
|
})
|
if (res.code === 200) {
|
list.value[index.value as number].type = res.code === 200 && res.data.length > 0
|
list.value[index.value as number].wlId = val.id
|
list.value[index.value as number].wlName = val.mmodelUnionName
|
list.value[index.value as number].wlCompany = val.umodelAttributeData
|
list.value[index.value as number].dw = val.umodelName
|
showList.columns4 = []
|
if (list.value[index.value as number].attribute === Attribute.HH) { // 混合
|
showList.columns4 = [{ text: '合格', id: '0' },{ text: '不良', id: '1' },{ text: '报废', id: '2' }]
|
} else if (list.value[index.value as number].attribute === Attribute.HG) { // 合格
|
showList.columns4 = [{ text: '合格', id: '0' }]
|
} else if (list.value[index.value as number].attribute === Attribute.BL) { // 不良
|
showList.columns4 = [{ text: '不良', id: '1' }]
|
} else if (list.value[index.value as number].attribute === Attribute.BF) { // 报废
|
showList.columns4 = [{ text: '报废', id: '2' }]
|
}
|
if (showList.columns4.length > 0) {
|
list.value[index.value as number].sxId = showList.columns4[0].id
|
list.value[index.value as number].sxName = showList.columns4[0].text
|
}
|
let gx = await getListByMaterialId({
|
materialId: val.id
|
})
|
if (gx.code === 200) {
|
if (gx.data && gx.data.length > 0) {
|
list.value[index.value as number].gxId = gx.data[0].id
|
list.value[index.value as number].gxName = gx.data[0].name
|
}
|
}
|
}
|
showList.show2 = false
|
}
|
|
const onConfirm2 = (val: any): void => {
|
showList.show2 = false
|
}
|
|
const onCancel2 = (val: any): void => {
|
showList.show2 = false
|
}
|
|
// 工序确认
|
const onConfirm3 = (val: any): void => {
|
list.value[index.value as number].gxId = val.id
|
list.value[index.value as number].gxName = val.text
|
showList.show3 = false
|
}
|
|
const onCancel3 = (val: any): void => {
|
showList.show3 = false
|
}
|
|
// 质量属性确认
|
const onConfirm4 = (val: any): void => {
|
list.value[index.value as number].sxId = val.id
|
list.value[index.value as number].sxName = val.text
|
showList.show4 = false
|
}
|
|
const onCancel4 = (val: any): void => {
|
showList.show4 = false
|
}
|
|
// 获取工装信息
|
const getLKLKInfo = (id: string): void => {
|
getListByCondition({ id })
|
.then(res => {
|
if (res.code === 200) {
|
if (res.data[0].status === 1) {
|
let obj = {
|
id: res.data[0].id,
|
code: res.data[0].code,
|
attribute: res.data[0].smodelLabel,
|
dw: res.data[0].umodelName,
|
wlId: '',
|
wlName: '',
|
gxId: '',
|
gxName: '',
|
sxId: '',
|
sxName: '',
|
pch: '',
|
num: ''
|
}
|
list.value.push(obj as never)
|
} else {
|
Toast.fail({ message: '请扫描空的工装' })
|
}
|
}
|
})
|
}
|
|
onMounted(() => {
|
getLKLKInfo(route.query.id as string)
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.adjustment {
|
position: absolute;
|
top: 0;
|
left: 0;
|
width: 100%;
|
height: 100%;
|
.box {
|
padding: 0 30px;
|
background: #ffffff;
|
margin-bottom: 30px;
|
&:last-child {
|
margin-bottom: 0 !important;
|
}
|
.sweep {
|
padding: 20px 0 30px 0;
|
.sweep_box {
|
display: flex;
|
align-items: center;
|
justify-content: flex-end;
|
img {
|
width: 28px;
|
height: 28px;
|
margin-right: 12px;
|
}
|
span {
|
font-size: 28px;
|
font-weight: 400;
|
color: $nav-color;
|
}
|
}
|
}
|
.adjustment_item {
|
height: 98px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
border-bottom: 1PX solid #E5E5E5;
|
&:last-child {
|
border-bottom: 0 !important;
|
}
|
span {
|
font-size: 30px;
|
font-weight: 400;
|
color: #222222;
|
}
|
.adjustment_item_xz {
|
display: flex;
|
align-items: center;
|
input {
|
text-align: right;
|
padding: 0 30px;
|
box-sizing: border-box;
|
width: 400px;
|
height: 60px;
|
border-radius: 8px;
|
font-size: 28px;
|
border: 1PX solid #CCCCCC;
|
}
|
input::-webkit-input-placeholder {
|
font-size: 28px;
|
font-weight: 400;
|
color: #999999;
|
}
|
.black {
|
color: black !important;
|
}
|
span {
|
font-size: 28px;
|
font-weight: 400;
|
color: #999999;
|
margin-right: 10px;
|
}
|
}
|
}
|
}
|
.adjustment_title {
|
padding: 40px 30px 30px 30px;
|
font-size: 32px;
|
font-weight: 500;
|
color: #222222;
|
}
|
.zw {
|
height: 168px;
|
}
|
.footer {
|
position: fixed;
|
bottom: 0;
|
left: 30px;
|
width: calc(100% - 60px);
|
padding-bottom: 68px;
|
display: flex;
|
align-items: center;
|
.footer_jx {
|
flex: 1;
|
height: 88px;
|
background: #FFFFFF;
|
box-shadow: 0 0 12px 0 rgba(0,0,0,0.0800);
|
border-radius: 8px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 30px;
|
font-weight: 500;
|
color: $nav-color;
|
}
|
.footer_w {
|
width: 22px;
|
}
|
.footer_tj {
|
border: none;
|
flex: 1;
|
height: 88px;
|
background: $nav-color;
|
box-shadow: 0 0 12px 0 rgba(0,0,0,0.0800);
|
border-radius: 8px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 30px;
|
font-weight: 500;
|
color: #ffffff;
|
}
|
}
|
}
|
</style>
|