<template>
|
<view class='main'>
|
|
<view class="flex-item title_main">
|
<uni-section :title="'流程卡号:'+processId" type="line">
|
<template v-slot:right>
|
<button @click='reviewReportForWork' v-if='!reportState' size='mini'>审核</button>
|
<button :loading="buttonLoading" @click="saveReportForWork" v-if='reportState' size='mini'>报工</button>
|
</template>
|
</uni-section>
|
|
|
|
</view>
|
<view class="flex-item table_main">
|
<uni-table border stripe style='width:100%;overflow-y: auto;'>
|
<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"
|
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 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'
|
:disabled="!reportState"
|
@confirm="changeFinishNum(item)"
|
@blur="changeFinishNum(item)"
|
/>
|
</uni-td>
|
<uni-td>
|
<input type="number" v-model='item.breakageQuantity'
|
@confirm='changeBreakNum(item,index)'
|
@blur="changeBreakNum(item,index)"
|
:disabled="!reportState"
|
/>
|
</uni-td>
|
</uni-tr>
|
</uni-table>
|
</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'
|
const store=userInfo()
|
let processId = ref(null)
|
let process = ref(null)
|
let reportState = ref(false)
|
let damageShowFlag = ref(false)
|
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 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//责任信息
|
})
|
|
|
|
onLoad(async (option)=>{
|
processId.value = option.processId
|
process.value = option.process
|
await getProcessCardList(option.processId,option.process)
|
buttonLoading.value = false
|
if(store.choiceDevice.value===null){
|
messageToggle('warn','未选择设备,报工设备将以手机形式报工!')
|
}
|
})
|
//查询流程卡
|
const getProcessCardList = (processId,process1) => {
|
const processIdList = processId.split('/')
|
const reportType = 2//报工是否查询样品订单2查询,1不查询
|
request.post(`/reportingWork/addSelectLastWork/${processIdList[0]}/${processIdList[1]}/${process1}/${reportType}`)
|
.then((res) => {
|
if (res.code == 200) {
|
processList.value = res.data.Detail
|
res.data.data.processId = processId
|
processTitle.value = res.data.data
|
//历史班组
|
titleSelectJson.value.historyTeams= res.data.historyTeams
|
titleSelectJson.value.historyTeams.unshift(
|
{
|
basic_name:store.user.userName,
|
process:process.value
|
}
|
)
|
//历史设备
|
titleSelectJson.value.historyDevice = res.data.historyDevice
|
//历史工序
|
titleSelectJson.value.historyProcess = res.data.historyProcess
|
//次破类型
|
titleSelectJson.value.breakageType = res.data.breakageType
|
//次破原因
|
titleSelectJson.value.breakageReason = res.data.breakageReason
|
if(res.data.data.reviewedState==1){
|
reportState.value=true
|
}
|
}
|
}).catch(err => {
|
uni.showModal({
|
title: '提示',
|
content: err,
|
showCancel:false
|
});
|
})
|
}
|
//报工保存
|
const saveReportForWork = () => {
|
if(finishNum.value===0){
|
messageToggle('error','完工数量或次破数量至少大于0')
|
return
|
}
|
let notSame = null
|
|
for(let i in processList.value){
|
if(processList.value[i].breakageQuantity!== undefined && processList.value[i].breakageQuantity!==null && processList.value[i].breakageQuantity!==''){
|
if(processList.value[i].damageDetails === undefined){
|
messageToggle('error',`序号'${processList.value[i].order_number}'未检测到次破数据`)
|
return
|
}else{
|
if(processList.value[i].damageDetails[0].breakageQuantity*1!==processList.value[i].breakageQuantity*1){
|
messageToggle('error',`序号'${processList.value[i].order_number}'次破数量不匹配`)
|
return
|
}
|
}
|
}else{
|
delete processList.value[i].breakageQuantity
|
}
|
|
|
}
|
|
|
const hasConflict = processList.value.some((item, index) => {
|
// 检查当前元素之后是否有相同 id 但不同 num 的对象
|
return processList.value.slice(index + 1).some(other => {
|
if(other.order_number === item.order_number
|
&& other.completedQuantity !== item.completedQuantity
|
|| other.quantity<other.completedQuantity){
|
|
notSame = other
|
return true
|
}
|
}
|
)
|
})
|
if(hasConflict){
|
messageToggle('error',`序号'${notSame.order_number}'同序号完工不相同或数量超过总数`)
|
return
|
}
|
|
|
buttonLoading.value = true
|
processTitle.value.teamsGroupsName = store.user.userName
|
processTitle.value.deviceName =store.choiceDevice.text ||'phone'
|
processTitle.value.deviceId =store.choiceDevice.value ||''
|
processTitle.value.creatorId = store.user.userId
|
processTitle.value.creator = store.user.userName
|
const requestData = {
|
title:processTitle.value,
|
detail:processList.value,
|
type:0,//审核状态
|
userId:store.user.userId,
|
userName:store.user.userName,
|
class:"",
|
qualityInsStatus:2//跨工序质检审核,1不需要,2需要
|
}
|
request.post(`/reportingWork/saveReportingWork`,requestData).then(res =>{
|
if(res.code == 200){
|
//messageToggle('success','成功')
|
if(allQuantity.value>finishNum.value){
|
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 = computed( () => {
|
let sum = 0
|
processList.value.forEach( item => {
|
let quantity = item.quantity*1 || 0
|
sum += quantity
|
})
|
return sum
|
})
|
// 完工次破总数量
|
const finishNum = computed( () => {
|
let sum = 0
|
processList.value.forEach( item => {
|
let finish = item.completedQuantity*1 || 0
|
let breakNum = item.breakageQuantity*1 || 0
|
sum += finish
|
sum += breakNum
|
})
|
return sum
|
})
|
//打开提示框
|
const messageToggle = (type,msg) => {
|
msgType.value = type
|
messageText.value = msg
|
message.value.open()
|
}
|
//判断可利用
|
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
|
}
|
processList.value.forEach(item => {
|
if(item.order_number == row.order_number && finishNum<=item.quantity){
|
item.completedQuantity = finishNum
|
}
|
})
|
}
|
const changeBreakNum = (row,index) => {
|
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(processList.value[index].damageDetails){
|
damageDetail.value = processList.value[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
|
popup.value.open()
|
}else{
|
delete processList.value[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
|
}
|
}
|
//每行破损赋值
|
processList.value[damageShowRow.value-1].damageDetails = [
|
JSON.parse(JSON.stringify(damageDetail.value))
|
]
|
}else{
|
delete processList.value[damageShowRow.value-1].breakageQuantity
|
delete processList.value[damageShowRow.value-1].damageDetails
|
}
|
popup.value.close()
|
}
|
|
const cleanAllFinish = () => {
|
processList.value.forEach(item => {
|
item.completedQuantity = 0
|
})
|
}
|
|
|
</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;
|
}
|
</style>
|