<template>
<view class="form-item">
<text class="label">作业日期</text>
<cu-datetime-picker class="date-container" fields="day" placeholder="请选择作业日期" @change="timeStartChange"/>
</view>
<view class="form-item">
<text class="label">备注</text>
<uni-easyinput
type="textarea"
v-model="remark"
placeholder="请输入"
/>
</view>
<view class="form-item" @click="gotoSelectPerson">
<text class="label">协助人</text>
<input
type="text"
v-model="helper"
placeholder="请选择协助人"
readonly
class="input-helper"
@click="gotoSelectPerson"
/>
</view>
<view class="form-item">
<view class="btn-group">
<button class="btn-select" @click="addPipeWeld">添加焊缝</button>
</view>
</view>
<scroll-view
scroll-y
class="data-list"
>
<view v-for="(item, index) in weldingDataList"
:key="index"
class="data-item">
<button class="btn-close" @click="deleteWeldingRow(index)">
<text class="icon">✕</text>
</button>
<view class="main-content">
<view class="header-row">
<view class="info-group">
<view class="label-row">
<text>项目号:{{ item.projectNo }}</text>
</view>
<view class="info-row">
<text>管号: {{ item.pipeNo }}</text>
<text>版本号: {{ item.pipeVersion }}</text>
</view>
<view class="info-row">
<text>焊缝号: {{ item.weldNo }}</text>
</view>
<view class="info-row" @click="handleWpsNoClick(item, index)">
<text>WPS NO: {{ item.wpsNo || '无' }}</text>
</view>
<view class="info-row">
<text>焊接方法: {{ item.weldProcess }}</text>
</view>
<view class="info-row">
<text>焊材规格: {{ item.weldingMatSpec }}</text>
</view>
<view class="info-row">
<text style="margin-top: 1rem; margin-right: -0.5rem">批号:</text>
<view class="batch-selector-container">
<uni-data-select
v-model="item.rootBatchNo"
:localdata="rootBatchNoDataList.map(batchNo => ({ value: batchNo, text: batchNo }))"
@click="() => handleRootBatchNoClick(item)"
@change="(val) => handleRootBatchNoChange(val, item)"
:popper="true"
style="min-width: 107px; flex: 1; margin-right: 0.5rem;"
/>
<text style="margin: 0 0.5rem;">-</text>
<uni-data-select
v-model="item.fillBatchNo"
:localdata="fillBatchNoDataList.map(batchNo => ({ value: batchNo, text: batchNo }))"
@click="() => handleFillBatchNoClick(item)"
@change="(val) => handleFillBatchNoChange(val, item)"
style="min-width: 107px; flex: 1; margin-left: 0.5rem; position: relative; z-index: 100;"
/>
</view>
</view>
<view class="info-row">
<text style="margin-top: 1rem">证书号: {{ item.rootWeldCert }} - {{ item.fillWeldCert }}</text>
</view>
</view>
<view class="btn-pipe-group">
<uni-button size="mini" type="warn" @click.stop="reportAbnormal(index)">异常上报</uni-button>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="footer">
<button class="submit-btn" @click="submitForm">提交</button>
</view>
<cu-modal :visible="isShowModal" title="异常上报" @cancel="hideModal" @ok="submitModal(currentRowIndex)">
<uni-forms ref="baseForm" :modelValue="exceptionParams">
<uni-forms-item label="异常类型" required name="exceptionType" :label-width="80" style="flex: 0 0 30%;">
<uni-data-select
v-model="exceptionParams.exceptionType"
:localdata="formattedExceptionTypeList"
/>
</uni-forms-item>
<uni-forms-item label="异常描述" required name="exceptionMsg" :label-width="80" style="flex: 0 0 30%;">
<uni-easyinput type="textarea" v-model="exceptionParams.exceptionMsg"/>
</uni-forms-item>
</uni-forms>
</cu-modal>
</template>
<script setup>
import {ref, onMounted, onActivated, computed} from 'vue'
import * as serve from '@/api/modules/piping/pre/prePipeFeedBack'
import {useRoute} from 'vue-router'
import {useRouter} from 'vue-router'
import {getDislist} from "@/api/modules/piping/handover";
const router = useRouter()
const route = useRoute()
const currentRowIndex = ref(null)
const weldList = ref([])
const orderNo = ref('')
const workDate = ref('')
const remark = ref('')
const weldingDataList = ref([])
const rootBatchNoDataList = ref([])
const fillBatchNoDataList = ref([])
const currentWeldingItemIndex = ref(null)
const rootCerNoList = ref([])
const fillCertNoList = ref([])
const exceptionTypeList = ref([])
const isShowModal = ref(false)
const exceptionParams = ref({
exceptionType: '',
exceptionMsg: ''
})
const process = ref('')
const helper = ref('')
const orgNo = ref('')
onMounted(() => {
orderNo.value = route.query.orderNo
orgNo.value = route.query.orgNo
weldingDataList.value = []
uni.$on('preAddPersons', (data) => {
if (data && data.length > 0) {
helper.value = data[0].userCode + '-' + data[0].userName;
}
uni.removeStorageSync('preAddPersons')
})
uni.$on('preSelectedWeldToAdd', (data) => {
const newWeldItems = data.filter(newItem => {
return !weldingDataList.value.some(existingItem =>
existingItem.projectNo === newItem.projectNo &&
existingItem.pipeNo === newItem.pipeNo &&
existingItem.pipeVersion === newItem.pipeVersion &&
existingItem.weldNo === newItem.weldNo
)
}).map(item => ({
...item,
rootBatchNo: '',
fillBatchNo: '',
rootWeldCert: '',
fillWeldCert: '',
rootGrade: '',
fillGrade: ''
}));
weldingDataList.value.push(...newWeldItems)
uni.removeStorageSync('preSelectedWeldToAdd')
})
uni.$on('preSelectedWpsNo', (data) => {
if (Array.isArray(data) && data.length > 0 && currentWeldingItemIndex.value !== null) {
const currentIndex = currentWeldingItemIndex.value
if (currentIndex >= 0 && currentIndex < weldingDataList.value.length) {
weldingDataList.value[currentIndex].wpsNo = data[0].wpsNo
weldingDataList.value[currentIndex].weldProcess = data[0].process
weldingDataList.value[currentIndex].weldingMatSpec = data[0].type
weldingDataList.value[currentIndex].rootGrade = data[0].rootGrade
weldingDataList.value[currentIndex].fillGrade = data[0].fillGrade
}
}
uni.removeStorageSync('preSelectedWpsNo')
})
getDislist({code: "CP_EXCEPTION_TYPE"}).then((res) => {
if (res.status === 200) {
exceptionTypeList.value = res.data || []
}
})
})
onActivated(() => {
orderNo.value = route.query.orderNo
process.value = route.query.process
serve.workOrderPipeDetail({orderNo: orderNo.value}).then((res) => {
weldList.value = res.data
})
})
const handleRootBatchNoClick = async (item) => {
serve.getQcWeldMatSnDropList({grade: item.rootGrade}).then((res) => {
const rootPairs = (res.data || []).map(item => ({
batchNo: item.batchNo,
weldCert: item.certNo
}))
rootBatchNoDataList.value = rootPairs.map(p => p.batchNo)
rootCerNoList.value = rootPairs
console.log(rootBatchNoDataList, rootCerNoList)
})
}
const handleFillBatchNoClick = async (item) => {
serve.getQcWeldMatSnDropList({grade: item.fillGrade}).then((res) => {
const fillPairs = (res.data || []).map(item => ({
batchNo: item.batchNo,
weldCert: item.certNo
}))
fillBatchNoDataList.value = fillPairs.map(p => p.batchNo)
fillCertNoList.value = fillPairs
})
}
const handleRootBatchNoChange = (val, item) => {
item.rootBatchNo = val
const certItem = rootCerNoList.value.find(i => i.batchNo === val)
item.rootWeldCert = certItem?.weldCert || ''
}
const handleFillBatchNoChange = (val, item) => {
item.fillBatchNo = val
const certItem = fillCertNoList.value.find(i => i.batchNo === val)
item.fillWeldCert = certItem?.weldCert || ''
}
const handleWpsNoClick = (item, index) => {
currentWeldingItemIndex.value = index
console.log('currentWeldingItemIndex', currentWeldingItemIndex.value)
uni.navigateTo({
url: '/pages/piping/pre/selectWpsNo?weldId=' + item.id
})
}
const gotoSelectPerson = () => {
// 打开选择弹窗
uni.navigateTo({
url: '/pages/piping/pre/selectPerson?isHelper=' + 'Y'
})
}
const formattedExceptionTypeList = computed(() => {
return exceptionTypeList.value.map(item => {
return {
value: item.name,
text: item.name
}
})
})
const addPipeWeld = () => {
uni.navigateTo({
url: '/pages/piping/pre/selectWeld?orderNo=' + orderNo.value
})
}
const timeStartChange = (value) => {
if (value) {
workDate.value = `${value.YYYY}-${value.MM}-${value.DD}`
console.log('workDate', workDate.value)
}
}
const deleteWeldingRow = (index) => {
weldingDataList.value.splice(index, 1)
}
const reportAbnormal = (index) => {
exceptionParams.value ={
exceptionType: '',
exceptionMsg: ''
}
currentRowIndex.value = index
isShowModal.value = true
}
const hideModal = () => {
isShowModal.value = false
}
const submitModal = (index) => {
const item = weldingDataList.value[index];
const params = exceptionParams.value;
if (!params.exceptionType) {
uni.showToast({
title: '请选择异常类型',
icon: 'none'
});
return;
}
if (!params.exceptionMsg) {
uni.showToast({
title: '请输入异常描述',
icon: 'none'
});
return;
}
const submitData = [{
projectNo: item.projectNo,
orgNo: orgNo.value,
bomNo: item.pipeNo,
bomVersion: item.pipeVersion,
exceptionType: params.exceptionType,
exceptionMsg: params.exceptionMsg
}]
serve.saveException(submitData).then(res => {
uni.showToast({
title: '提交成功',
icon: 'success'
})
isShowModal.value = false
}).catch(err => {
uni.showToast({
title: '提交失败',
icon: 'none'
});
console.error('提交异常:', err);
})
}
const submitForm = () => {
if (!workDate.value) {
uni.showToast({title: '请输入作业日期', icon: 'none'})
return
}
if (!weldingDataList.value && weldingDataList.value.length == 0) {
uni.showToast({title: '请选择焊缝', icon: 'none'})
return
}
const data = {
orderNo: orderNo.value,
process: process.value,
workDate: workDate.value,
remark: remark.value,
helperNo: helper.value.split('-')[0],
weldList: weldingDataList.value
}
serve.weldingFeedback(data).then((res) => {
if (res.status === 200) {
uni.showToast({title: '提交成功', icon: 'none'})
setTimeout(() => {
uni.navigateBack()
}, 1000)
}
})
}
</script>
<style scoped lang="scss">
.data-list {
background-color: #f9f9f9;
border-radius: 8rpx;
margin-bottom: 40rpx;
max-height: 950rpx;
overflow-y: auto;
}
.data-item {
margin-bottom: 20rpx;
background-color: white;
border-radius: 6rpx;
padding: 20rpx;
position: relative; /* 确保相对定位,使绝对定位的叉号正确显示 */
}
.btn-pipe-container {
display: flex;
justify-content: flex-end;
}
.btn-pipe-group {
display: flex;
flex-direction: column;
align-items: flex-end;
gap: 8px;
}
.btn-group {
display: flex;
}
.main-content {
padding-top: 40rpx;
}
.header-row {
display: flex;
justify-content: space-between;
align-items: flex-start; /* 顶部对齐 */
position: relative;
}
.info-group {
flex: 1;
}
.label-row {
display: flex;
gap: 20rpx;
font-size: 24rpx;
color: #666;
flex-wrap: wrap;
margin-bottom: 5rpx;
}
.info-row {
display: flex;
gap: 20rpx;
font-size: 24rpx;
color: #333;
}
.form-item {
display: flex;
align-items: center;
margin-bottom: 50rpx;
}
.label {
width: 160rpx;
font-size: 28rpx;
color: #333;
}
.date-container {
margin-top: 0.7rem;
height: 60rpx;
font-size: 28rpx;
}
.btn-group {
display: flex;
gap: 20rpx;
}
.btn-select,
.btn-add,
.btn-view {
font-size: 24rpx;
margin-left: 20rpx;
}
.btn-select {
background-color: #007aff;
color: #f0f0f0;
}
.btn-add {
background-color: #007aff;
color: #f0f0f0;
}
.btn-close {
position: absolute;
top: 0;
right: 0;
width: 30rpx;
height: 30rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 20rpx;
color: #999;
border: none;
margin: 5rpx;
}
.btn-view {
background-color: #007aff;
color: #f0f0f0;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: #fff;
box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);
}
.submit-btn {
background-color: #007aff;
color: white;
border: none;
font-size: 28rpx;
width: 100%;
}
.batch-selector-container{
display: flex;
align-items: center;
margin-top: 0.5rem;
}
</style>
其中:
<view class="main-content"> <view class="header-row"> <view class="info-group"> <view class="label-row"> <text>项目号:{{ item.projectNo }}</text> </view> <view class="info-row"> <text>管号: {{ item.pipeNo }}</text> <text>版本号: {{ item.pipeVersion }}</text> </view> <view class="info-row"> <text>焊缝号: {{ item.weldNo }}</text> </view> <view class="info-row" @click="handleWpsNoClick(item, index)"> <text>WPS NO: {{ item.wpsNo || '无' }}</text> </view> <view class="info-row"> <text>焊接方法: {{ item.weldProcess }}</text> </view> <view class="info-row"> <text>焊材规格: {{ item.weldingMatSpec }}</text> </view> <view class="info-row"> <text style="margin-top: 1rem; margin-right: -0.5rem">批号:</text> <view class="batch-selector-container"> <uni-data-select v-model="item.rootBatchNo" :localdata="rootBatchNoDataList.map(batchNo => ({ value: batchNo, text: batchNo }))" @click="() => handleRootBatchNoClick(item)" @change="(val) => handleRootBatchNoChange(val, item)" :popper="true" style="min-width: 107px; flex: 1; margin-right: 0.5rem;" /> <text style="margin: 0 0.5rem;">-</text> <uni-data-select v-model="item.fillBatchNo" :localdata="fillBatchNoDataList.map(batchNo => ({ value: batchNo, text: batchNo }))" @click="() => handleFillBatchNoClick(item)" @change="(val) => handleFillBatchNoChange(val, item)" style="min-width: 107px; flex: 1; margin-left: 0.5rem; position: relative; z-index: 100;" /> </view> </view> <view class="info-row"> <text style="margin-top: 1rem">证书号: {{ item.rootWeldCert }} - {{ item.fillWeldCert }}</text> </view> </view> <view class="btn-pipe-group"> <uni-button size="mini" type="warn" @click.stop="reportAbnormal(index)">异常上报</uni-button> </view> </view> </view>
其中批号的两个选择改变一下,变成从底下弹窗,然后进行选择
最新发布