Files
sh-app/scanpages/hj/daily_paper.vue
T
2026-07-06 17:05:24 +08:00

244 lines
8.1 KiB
Vue

<template>
<view class="page-detail">
<!-- 信息列表 -->
<view class="info-group">
<view class="info-item">
<text class="info-label">管线</text>
<text class="info-value">{{ form.PipelineCode || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">焊口</text>
<text class="info-value">{{ form.WeldJointCode || '--' }}</text>
</view>
<view class="info-item info-link" @click="handleShowLocationSelect">
<text class="info-label">焊口位置</text>
<text class="info-value">{{ form.WeldingLocationCode ? `${form.WeldingLocationCode||'--'}(${form.WeldingLocationName||'--'})` : '请选择' }}</text>
<u-icon name="arrow-right" :size="28" color="#ccc"></u-icon>
</view>
<view class="info-item">
<text class="info-label">焊接日期</text>
<text class="info-value">{{ form.WeldingDateTemp || '--' }}</text>
</view>
<view class="info-item info-link" @click="showTypePicker = true">
<text class="info-label">焊工类型</text>
<text class="info-value">{{ form.welderTypeName || '请选择' }}</text>
<u-icon name="arrow-right" :size="28" color="#ccc"></u-icon>
</view>
<view class="info-item">
<text class="info-label">焊工</text>
<text class="info-value">{{ form.welderName || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">材质1</text>
<text class="info-value">{{ form.Material1Code || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">材质2</text>
<text class="info-value">{{ form.Material2Code || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">达因</text>
<text class="info-value">{{ form.Size || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">外径</text>
<text class="info-value">{{ form.Dia || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">DN公称直径</text>
<text class="info-value">{{ form.DNDia || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">壁厚</text>
<text class="info-value">{{ form.Thickness || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">规格</text>
<text class="info-value">{{ form.Specification || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">焊接方法</text>
<text class="info-value">{{ form.WeldingMethodCode || '--' }}</text>
</view>
<view class="info-item">
<text class="info-label">焊缝类型</text>
<text class="info-value">{{ form.WeldTypeCode || '--' }}</text>
</view>
</view>
<!-- 焊前拍照 -->
<view class="section">
<view class="section-header">
<text class="section-title">焊前拍照</text>
</view>
<view class="section-body">
<nbd-photo-upload ref="beforePhotoRef" v-model:attachUrl="preWeldAttachUrl" typeName="WeldingDaily_Before" />
</view>
</view>
<!-- 焊后拍照 -->
<view class="section">
<view class="section-header">
<text class="section-title">焊后拍照</text>
</view>
<view class="section-body">
<nbd-photo-upload ref="afterPhotoRef" v-model:attachUrl="postWeldAttachUrl" typeName="WeldingDaily_After" />
</view>
</view>
<!-- 底部按钮 -->
<view class="bottom-btns">
<u-button v-if="!form.WeldingDate" class="btn-submit" size="medium" type="primary" @click="handleReport">填报</u-button>
<u-button v-if="form.WeldingDailyId" class="btn-point" size="medium" type="primary" @click="handlePoint">点口</u-button>
<u-button class="btn-cancel" size="medium" @click="handleClose">取消</u-button>
</view>
<!-- 焊口位置选择弹窗 -->
<nbd-select v-model="showLocationPicker" :show-search="true" title="选择焊口位置" :list="locationList" label-key="BaseInfoCode" value-key="BaseInfoId" @confirm="handleConfirmLocation" />
<!-- 焊工类型选择弹窗 -->
<nbd-select v-model="showTypePicker" title="选择焊工类型" :list="welderTypeList" label-key="BaseInfoName" value-key="BaseInfoCode" @confirm="handleConfirmType" />
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { reqGetWeldJointByWeldJointId, reqSaveWeldingDailyByWeldJointId, reqGetManualPointSave } from '@/api/hj.js'
import { reqWeldingLocation } from '@/api/base.js'
import { useUserStore } from '@/store'
const userStore = useUserStore()
const { userInfo } = userStore
// ===== 表单数据 =====
const form = ref({})
const preWeldAttachUrl = ref('')
const postWeldAttachUrl = ref('')
// ===== 弹窗 =====
const showLocationPicker = ref(false)
const showTypePicker = ref(false)
const locationList = ref([])
const welderTypeList = ref([
{ BaseInfoName: '打底/盖面', BaseInfoCode: 0 },
{ BaseInfoName: '打底', BaseInfoCode: 1 },
{ BaseInfoName: '盖面', BaseInfoCode: 2 },
])
const beforePhotoRef = ref(null)
const afterPhotoRef = ref(null)
// ===== 弹窗 ========
const handleShowLocationSelect = () => {
reqWeldingLocation().then(res => {
locationList.value = res.data
showLocationPicker.value = true
})
}
const handleConfirmLocation = (item) => {
form.value.WeldingLocationCode = item.BaseInfoCode
form.value.WeldingLocationName = item.BaseInfoName
form.value.WeldingLocationId = item.BaseInfoId
showLocationPicker.value = false
}
const handleConfirmType = (item) => {
form.value.welderType = item.BaseInfoCode
form.value.welderTypeName = item.BaseInfoName
showTypePicker.value = false
}
// ===== 操作 =====
const handlePoint = async () => {
await reqGetManualPointSave(form.value.WeldJointId)
uni.showToast({ title: '点口成功', icon: 'none' })
setTimeout(() => { uni.navigateBack() }, 1500)
}
const handleReport = () => {
uni.showModal({
title: '信息提示',
content: '确定要填报吗?',
success: async ({ confirm }) => {
if (confirm) {
console.log(beforePhotoRef.value?.hasPending())
const needBefore = beforePhotoRef.value?.hasPending()
const needAfter = afterPhotoRef.value?.hasPending()
if (needBefore || needAfter) {
uni.showLoading({ title: '上传照片中...', mask: true })
if (needBefore) await beforePhotoRef.value.uploadAll()
if (needAfter) await afterPhotoRef.value.uploadAll()
uni.hideLoading()
}
await reqSaveWeldingDailyByWeldJointId({
WeldJointId: form.value.WeldJointId,
Personid: userInfo.PersonId,
time: form.value.WeldingDateTemp,
weldingLocation: form.value.WeldingLocationId || '',
welderType: form.value.welderType,
PreWeldAttachUrl: preWeldAttachUrl.value || form.value.PreWeldAttachUrl || '',
PostWeldAttachUrl: postWeldAttachUrl.value || form.value.PostWeldAttachUrl || ''
})
uni.showToast({ title: '保存成功', icon: 'none' })
setTimeout(() => { uni.navigateBack() }, 1500)
}
}
})
}
const handleClose = () => { uni.navigateBack() }
// ===== 生命周期 =====
onLoad((opt) => {
reqGetWeldJointByWeldJointId(opt.id).then(res => {
form.value = res.data || {}
if (form.value.CoverWelderName) {
form.value.welderName = form.value.CoverWelderName
}
if (form.value.BackingWelderName) {
form.value.welderName += '/' + form.value.BackingWelderName
}
const now = new Date()
const today = `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`
form.value.WeldingDateTemp = form.value.WeldingDate || today
form.value.welderType = 0
form.value.welderTypeName = "打底/盖面"
// 回显已有照片
preWeldAttachUrl.value = form.value.PreWeldAttachUrl || ''
postWeldAttachUrl.value = form.value.PostWeldAttachUrl || ''
})
})
</script>
<style scoped lang="scss">
.section {
background: #ffffff;
margin: 24rpx;
border-radius: 16rpx;
overflow: hidden;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
.section-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 32rpx 16rpx;
.section-title {
font-size: 28rpx;
font-weight: 600;
color: #333;
}
}
.section-body {
padding: 0 24rpx 24rpx;
}
}
</style>