<template>
|
<view class='main'>
|
|
<view class="flex-item title_main">
|
<uni-section class='title_section' title="" >
|
<template v-slot:right>
|
<button @click="scannerCode" class='scanner_code' size='mini'>再次扫码</button>
|
<button @click="saveReportForWork" v-if="reportworkList.length>0" class="reporting_work" size='mini'>审核报工</button>
|
</template>
|
</uni-section>
|
|
|
|
</view>
|
<view class="flex-item table_main">
|
<template v-for="(items,index1) in reportworkList">
|
<uni-section :title="'流程卡号:'+items.processTitle.processId" type="line" >
|
<template v-slot:right>
|
<button @click="deleteProcess(index1)" v-if="reportworkList.length>1" size='mini'>移除</button>
|
</template>
|
</uni-section>
|
<uni-table border stripe style='width:100%;overflow-y: auto;margin-bottom: 1rem;'>
|
<uni-tr>
|
<uni-th width='48' align="center">序号</uni-th>
|
<uni-th width='48' align="center">小片</uni-th>
|
<uni-th width='50' align="center">宽</uni-th>
|
<uni-th width='50' align="center">高</uni-th>
|
<uni-th width='50' align="center">总数</uni-th>
|
<uni-th
|
@click="cleanAllFinish(index1)"
|
width='50'
|
align="center"
|
style="background-color: #409eff;color: black;"
|
>完工</uni-th>
|
<uni-th width='50' align="center">次破</uni-th>
|
</uni-tr>
|
|
<uni-tr v-for="(item,index) in items.processList">
|
<uni-td>{{item.order_number}}</uni-td>
|
<uni-td>{{item.technology_number}}</uni-td>
|
<uni-td>{{item.child_width}}</uni-td>
|
<uni-td>{{item.child_height}}</uni-td>
|
<uni-td>{{item.quantity}}</uni-td>
|
<uni-td>
|
<!-- @keyboardheightchange @blur-->
|
<input type="number" v-model='item.completedQuantity'
|
@confirm="changeFinishNum(item)"
|
@blur="changeFinishNum(item)"
|
/>
|
</uni-td>
|
<uni-td>
|
<input type="number" v-model='item.breakageQuantity'
|
@confirm='changeBreakNum(item,index,index1)'
|
@blur="changeBreakNum(item,index,index1)"
|
/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</template>
|
</view>
|
<!-- <view class="flex-item uni-bg-blue">C</view> -->
|
|
</view>
|
|
<!-- 次破弹出层 -->
|
<uni-popup class='breakInfo' ref="popup" :mask-click="false" >
|
<view class="flex-item foot_main">
|
<uni-row>
|
<uni-col class='break_col' :span='24' >第{{damageShowRow}}行</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >次破类型:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<uni-data-select
|
v-model="damageDetail.breakageType"
|
:localdata="breakageType"
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >次破原因:</uni-col>
|
<uni-col class='break_col' :span='16' >
|
<uni-data-select
|
v-model="damageDetail.breakageReason"
|
:localdata="breakageReason"
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >责任工序:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<uni-data-select
|
v-model="damageDetail.responsibleProcess"
|
:localdata="responsibleProcess"
|
@change='changeResponsibleProcess'
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >责任设备:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<uni-data-select
|
v-model="damageDetail.responsibleEquipment"
|
:localdata="responsibleEquipment"
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >责任班组:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<uni-data-select
|
v-model="damageDetail.responsibleTeam"
|
:localdata="responsibleTeam"
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >可利用:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<checkbox-group @change='changeAvailable($event)'>
|
<checkbox :value="1" />
|
</checkbox-group>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >返回工序:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<uni-data-select
|
v-model="damageDetail.returnProcess"
|
:localdata="backProcess"
|
/>
|
</uni-col>
|
</uni-row>
|
<uni-row>
|
<uni-col class='break_col' :span='8' >责任信息:</uni-col>
|
<uni-col class='break_col' :span='16'>
|
<input v-model="damageDetail.responsiblePersonnel" />
|
</uni-col>
|
</uni-row>
|
</view>
|
<view>
|
|
<uni-row>
|
<uni-col :span='12'>
|
<button @click="close(0)">取消</button>
|
</uni-col>
|
<uni-col :span='12'>
|
<button type="primary" @click="close(1)">确定</button>
|
</uni-col>
|
</uni-row>
|
</view>
|
</uni-popup>
|
|
<!-- 提示弹窗 -->
|
<view>
|
<!-- 提示窗示例 -->
|
<uni-popup ref="alertDialog" type="dialog">
|
<uni-popup-dialog type="warn"
|
cancelText="再次报工"
|
confirmText="确认完成"
|
title="通知"
|
content="流程卡数量还未全部报完!"
|
@confirm="dialogConfirm"
|
@close="dialogClose" />
|
</uni-popup>
|
</view>
|
<view>
|
<!-- 提示信息弹窗 -->
|
<uni-popup ref="message" type="message">
|
<uni-popup-message :type="msgType" :message="messageText" :duration="3000"></uni-popup-message>
|
</uni-popup>
|
</view>
|
</template>
|
|
<script setup>
|
import { computed, onMounted,ref, watch } from 'vue'
|
import { onLoad } from '@dcloudio/uni-app'
|
import userInfo from '@/stores/userInfo'
|
import request from '@/utils/request'
|
import mpaasScan from '@/utils/scanner.js'
|
const store=userInfo()
|
let processId = ref(null)
|
let process = ref(null)
|
let damageShowFlag = ref(false)
|
let damageShowProcessIndex = ref(-1)
|
let damageShowRow = ref(0)
|
let processTitle = ref(null)
|
let processList = ref([])
|
let buttonLoading = ref(true)
|
const alertDialog = ref(null)
|
const message = ref(null)
|
const popup = ref(null)
|
const type=ref('center')
|
const msgType=ref('success')
|
const messageText=ref('')
|
|
const reportworkList = ref([])
|
|
//定义接收加载表头下拉数据
|
const titleSelectJson = ref({
|
historyDevice:[],
|
historyTeams:[],
|
historyProcess:[],
|
breakageType:[],
|
breakageReason:[]
|
})
|
|
//定义破损明细
|
const damageDetail = ref({
|
breakageQuantity: null,//破损数量
|
available: null,//可利用
|
returnProcess: null,//返回工序
|
breakageType: null,//破损类型
|
breakageReason: null,//原因
|
responsibleProcess: null,//责任工序
|
responsibleEquipment: null,//责任设备
|
responsibleTeam: null,//责任班组
|
responsiblePersonnel: null//责任信息
|
})
|
|
const messageToggle = (type,msg) => {
|
msgType.value = type
|
messageText.value = msg
|
message.value.open()
|
}
|
|
|
onLoad(async (option)=>{
|
|
processId.value = option.processId
|
process.value = option.process
|
await getProcessCardList(option.processId,option.process)
|
buttonLoading.value = false
|
|
|
})
|
//查询流程卡
|
const getProcessCardList = (processId1,process1) => {
|
|
if(processId1.indexOf('/')!==14){
|
uni.showModal({
|
title: '提示',
|
content: "请输入正确格式的流程卡",
|
showCancel:false
|
});
|
return
|
}
|
const processIdList = processId1.split('/')
|
if(processIdList[1].length>1){
|
uni.showModal({
|
title: '提示',
|
content: "app不支持多层合并二维码",
|
showCancel:false
|
});
|
return
|
}
|
|
const reportType = 2//报工是否查询样品订单2查询,1不查询
|
request.post(`/reportingWork/addSelectLastWork/${processIdList[0]}/${processIdList[1]}/${process1}/${reportType}`)
|
.then((res) => {
|
if (res.code == 200) {
|
const reportData = {}
|
reportData.processList = res.data.Detail
|
res.data.data.processId = processId1
|
reportData.processTitle = res.data.data
|
reportworkList.value.push(reportData)
|
const index = reportworkList.value.length-1
|
|
//历史班组
|
res.data.historyTeams.unshift(
|
{
|
basic_name:store.user.userName,
|
process:process.value
|
}
|
)
|
titleSelectJson.value.historyTeams= res.data.historyTeams
|
|
//历史设备
|
titleSelectJson.value.historyDevice = res.data.historyDevice
|
//历史工序
|
titleSelectJson.value.historyProcess = res.data.historyProcess
|
//次破类型
|
titleSelectJson.value.breakageType = res.data.breakageType
|
//次破原因
|
titleSelectJson.value.breakageReason = res.data.breakageReason
|
}
|
}).catch(err => {
|
uni.showModal({
|
title: '提示',
|
content: err,
|
showCancel:false
|
});
|
})
|
}
|
//报工保存
|
const saveReportForWork = () => {
|
for (let item of reportworkList.value) {
|
const finishNumVal = finishNum(item.processList)
|
if(finishNumVal===0){
|
messageToggle('error',`${item.processTitle.processId}完工数量或次破数量至少大于0`)
|
return
|
}
|
|
let notSame = null
|
|
for(let i in item.processList){
|
if(item.processList[i].breakageQuantity!== undefined && item.processList[i].breakageQuantity!==null && item.processList[i].breakageQuantity!==''){
|
if(item.processList[i].damageDetails === undefined){
|
messageToggle('error',`序号'${item.processList[i].order_number}'未检测到次破数据`)
|
return
|
}else{
|
if(item.processList[i].damageDetails[0].breakageQuantity*1!==item.processList[i].breakageQuantity*1){
|
messageToggle('error',`序号'${item.processList[i].order_number}'次破数量不匹配`)
|
return
|
}
|
}
|
}else{
|
delete item.processList[i].breakageQuantity
|
}
|
|
|
}
|
|
|
const hasConflict = item.processList.some((item1, index) => {
|
// 检查当前元素之后是否有相同 id 但不同 num 的对象
|
return item.processList.slice(index + 1).some(other => {
|
if(other.order_number === item1.order_number
|
&& other.completedQuantity !== item1.completedQuantity
|
|| other.quantity<other.completedQuantity){
|
|
notSame = other
|
return true
|
}
|
}
|
)
|
})
|
if(hasConflict){
|
messageToggle('error',`流程卡${item.processTitle.processId} 序号'${notSame.order_number}'同序号完工不相同或数量超过总数`)
|
return
|
}
|
|
|
|
item.processTitle.teamsGroupsName = store.user.userName
|
item.processTitle.deviceName =store.choiceDevice.text ||'phone'
|
item.processTitle.deviceId =store.choiceDevice.value ||''
|
item.processTitle.creatorId = store.user.userId
|
item.processTitle.creator = store.user.userName
|
item.processTitle.classes = store.user.class
|
|
}
|
buttonLoading.value = true
|
const requestData = {
|
reportingWorks:reportworkList.value,
|
type:0,//审核状态
|
userId:store.user.userId,
|
userName:store.user.userName,
|
qualityInsStatus:2//跨工序质检审核,1不需要,2需要
|
}
|
request.post(`/app/addWorkInProgress`,requestData).then(res =>{
|
if(res.code == 200){
|
if(allQuantity(reportworkList.value[0].processList)>finishNum(reportworkList.value[0].processList) && reportworkList.value.length===1){
|
alertDialog.value.open()
|
}else{
|
uni.reLaunch({
|
url: `/pages/mainView/mainView?state=success`
|
})
|
}
|
|
}else{
|
const errorObj = JSON.parse(res.msg)
|
const msg = t('reportingWorks.pleaseNumber1')+":"+errorObj.orderNumber+'\n'
|
+t('reportingWorks.pleaseNumber2')+':'+errorObj.technologyNumber+'\n'
|
+t('reportingWorks.pleaseNumber3')+':'+errorObj.processNum+'<'+
|
+t('reportingWorks.pleaseNumber4')+':'+errorObj.sumNum+'\n'
|
+t('reportingWorks.pleaseNumber5')
|
messageToggle('error',msg)
|
}
|
}).catch(err => {
|
uni.showModal({
|
title: '提示',
|
content: err,
|
showCancel:false
|
});
|
}).finally(() => {
|
buttonLoading.value = false
|
})
|
}
|
|
//弹出框确认
|
const dialogConfirm = () => {
|
uni.reLaunch({
|
url: `/pages/mainView/mainView?state=success`
|
})
|
}
|
const dialogClose = () => {
|
uni.redirectTo({
|
url: `/pages/reportingWork/reportingWork?processId=${processId.value}`
|
});
|
}
|
|
//下工序审核
|
const reviewReportForWork = () => {
|
const reportWork = {
|
process: processTitle.value.previousProcess,
|
processId:processId.value,
|
thisProcess:processTitle.value.thisProcess,
|
technologyStr:processId.value.split('/')[1],
|
userName:store.user.userName
|
}
|
request.post("/reportingWork/reviewReportingWork",reportWork).then((res) =>{
|
if(res.code === '200'){
|
uni.redirectTo({
|
url: `/pages/reportingWork/reportingWork?processId=${processId.value}`
|
})
|
}
|
}).catch(err => {
|
uni.showModal({
|
title: '提示',
|
content: err,
|
showCancel:false
|
});
|
})
|
}
|
//此流程卡目前总数量
|
const allQuantity = (processList) =>{
|
let sum = 0
|
processList.forEach( item => {
|
let quantity = item.quantity*1 || 0
|
sum += quantity
|
})
|
return sum
|
}
|
// 完工次破总数量
|
const finishNum = (processList) => {
|
let sum = 0
|
processList.forEach( item => {
|
let finish = item.completedQuantity*1 || 0
|
let breakNum = item.breakageQuantity*1 || 0
|
sum += finish
|
sum += breakNum
|
})
|
return sum
|
}
|
//打开提示框
|
|
//判断可利用
|
const backProcess = ref([])
|
const changeAvailable = (e) => {
|
backProcess.value = []
|
if(e.detail.value.length){
|
damageDetail.value.available = 1
|
titleSelectJson.value.historyProcess.forEach( item => {
|
backProcess.value.push({
|
value:item.basic_category,
|
text:item.basic_category
|
})
|
})
|
}else{
|
damageDetail.value.available = null
|
damageDetail.value.returnProcess = null
|
}
|
}
|
//责任工序
|
const responsibleProcess = computed(()=>{
|
let list = []
|
titleSelectJson.value.historyProcess.forEach( item => {
|
list.push({
|
value:item.basic_category,
|
text:item.basic_category
|
})
|
})
|
return list
|
})
|
//计算属性 次破类型
|
const breakageType = computed(()=>{
|
let list = []
|
titleSelectJson.value.breakageType.forEach( item => {
|
list.push({
|
value:item.basic_name,
|
text:item.basic_name
|
})
|
})
|
return list
|
})
|
|
//计算属性 次破原因
|
const breakageReason = computed(()=>{
|
let list = []
|
titleSelectJson.value.breakageReason.forEach( item => {
|
list.push({
|
value:item.basic_name,
|
text:item.basic_name
|
})
|
})
|
return list
|
})
|
|
//责任设备 responsibleEquipment
|
const responsibleEquipment = ref([])
|
const responsibleTeam = ref([])
|
const changeResponsibleProcess = () =>{
|
responsibleEquipment.value = []
|
responsibleTeam.value = []
|
damageDetail.value.responsibleEquipment = null
|
damageDetail.value.responsibleTeam = null
|
titleSelectJson.value.historyDevice.forEach( item => {
|
if(item.basic_category===damageDetail.value.responsibleProcess){
|
responsibleEquipment.value.push({
|
value:item.basic_name,
|
text:item.basic_name
|
})
|
}
|
})
|
titleSelectJson.value.historyTeams.forEach( item => {
|
if(item.process===damageDetail.value.responsibleProcess){
|
responsibleTeam.value.push({
|
value:item.basic_name,
|
text:item.basic_name
|
})
|
}
|
})
|
}
|
|
|
|
// 完工改变
|
const changeFinishNum = (row) => {
|
damageShowFlag.value = false
|
const finishNum = row.completedQuantity*1 || 0
|
const breakNum = row.breakageQuantity*1 || 0
|
if((row.quantity-finishNum-breakNum)<0){
|
row.completedQuantity = null
|
return
|
}
|
reportworkList.value.forEach(items => {
|
items.processList.forEach(item => {
|
if(item.order_number == row.order_number && finishNum<=item.quantity){
|
item.completedQuantity = finishNum
|
}
|
})
|
})
|
|
}
|
const changeBreakNum = (row,index,index1) => {
|
const finishNum = row.completedQuantity*1 || 0
|
const breakNum = row.breakageQuantity*1 || 0
|
if((row.quantity-breakNum)<0){
|
row.breakageQuantity = null
|
return
|
}
|
row.completedQuantity = row.quantity-breakNum
|
if(reportworkList.value[index1].processList[index].damageDetails){
|
damageDetail.value = reportworkList.value[index1].processList[index].damageDetails[0]
|
}else{
|
for(let index in damageDetail.value){
|
damageDetail.value[index] = null
|
}
|
}
|
|
if(breakNum*1>0){
|
damageDetail.value.breakageQuantity = breakNum*1
|
damageShowRow.value = index+1
|
damageShowProcessIndex = index1
|
popup.value.open()
|
}else{
|
delete reportworkList.value[index1].processList[index].damageDetails
|
for(let index in damageDetail.value){
|
damageDetail.value[index] = null
|
}
|
}
|
|
}
|
|
const rules = {
|
breakageType: '请选择次破类型',
|
breakageReason:'请选择次破原因',
|
responsibleProcess:'请选择责任工序',
|
responsibleEquipment:'请选择责任设备',
|
responsibleTeam:'请选择责任班组',
|
returnProcess:'可利用已勾选,请选择返回工序'
|
}
|
|
const close = (type) => {
|
//判断是否是确定
|
if(type===1){
|
for(let item in rules){
|
//判断选中可利用和下拉框是否为空
|
if(!damageDetail.value[item] && item!=='returnProcess'){
|
messageToggle('error',rules[item])
|
return
|
}else if(item==='returnProcess' && !damageDetail.value[item] && damageDetail.value['available']){
|
messageToggle('error',rules[item])
|
return
|
}
|
}
|
//每行破损赋值
|
reportworkList.value[damageShowProcessIndex].processList[damageShowRow.value-1].damageDetails = [
|
JSON.parse(JSON.stringify(damageDetail.value))
|
]
|
}else{
|
delete reportworkList.value[damageShowProcessIndex].processList[damageShowRow.value-1].breakageQuantity
|
delete reportworkList.value[damageShowProcessIndex].processList[damageShowRow.value-1].damageDetails
|
}
|
popup.value.close()
|
}
|
|
const cleanAllFinish = (index) => {
|
try{
|
reportworkList.value[index].processList.forEach(item => {
|
item.completedQuantity = 0
|
})
|
}catch(e){
|
|
}
|
|
}
|
|
const scannerCode = () => {
|
if(reportworkList.length>6){
|
messageToggle('error','最多支持6个流程卡同时报工')
|
}
|
mpaasScan().then(val => {
|
for (let items of reportworkList.value) {
|
for(let item of items.processList){
|
const prcoessCard = items.processTitle.flowCard.processId+"/"+item.technology_number
|
if(prcoessCard === val){
|
messageToggle('error','此流程卡已存在列表当中')
|
return
|
}
|
}
|
}
|
|
getProcessCardList(val,process.value)
|
})
|
}
|
|
//移除流程卡
|
const deleteProcess = (indexVal) => {
|
reportworkList.value.splice(indexVal, 1)
|
}
|
|
</script>
|
|
<style>
|
.main{
|
width: 100vw;
|
height: 93.5vh
|
}
|
.flex-item{
|
/* flex-direction: column;
|
background-color: aliceblue; */
|
}
|
.title_main{
|
width: 100vw;
|
height: 12vh;
|
}
|
.table_main{
|
width: 100vw;
|
height: 80vh;
|
margin: 0 auto;
|
}
|
.foot_main{
|
width: 96vw;
|
margin: 0 auto;
|
background-color: white;
|
}
|
|
.uni-row{
|
text-align: center;
|
}
|
.break_col{
|
height: 35px;
|
border:1px solid black;
|
}
|
.breakInfo{
|
width: 96vw;
|
}
|
.title_section .uni-section-header__slot-right{
|
width: 100%;
|
}
|
.reporting_work{
|
float: right;
|
}
|
</style>
|