焊接日报上传附件
This commit is contained in:
+46
-2
@@ -1,7 +1,10 @@
|
|||||||
import {
|
import {
|
||||||
get,
|
get,
|
||||||
post
|
post,
|
||||||
|
baseUrl
|
||||||
} from '@/utils/request.js'
|
} from '@/utils/request.js'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求单位工程
|
* 请求单位工程
|
||||||
@@ -21,4 +24,45 @@ export const reqUnitByProjectIdUnitType = (projectId, unitType="")=>get(`Unit/ge
|
|||||||
/**
|
/**
|
||||||
* 获取待办
|
* 获取待办
|
||||||
*/
|
*/
|
||||||
export const reqToDoItemByProjectIdUserId = (projectId, personId)=>get(`ToDoItem/getToDoItemByProjectIdUserId?projectId=${projectId}&personId=${personId}`)
|
export const reqToDoItemByProjectIdUserId = (projectId, personId)=>get(`ToDoItem/getToDoItemByProjectIdUserId?projectId=${projectId}&personId=${personId}`)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件上传
|
||||||
|
* @param {string} filePath - 本地文件路径
|
||||||
|
* @param {object} formData - 额外表单参数,如 { typeName: 'TestRecord', ... }
|
||||||
|
* @param {function} onProgress - 上传进度回调 (progress: number)
|
||||||
|
* @returns {Promise<array>} 返回服务器返回的附件地址数组
|
||||||
|
*/
|
||||||
|
export const uploadAttach = (filePath, formData = {}, onProgress) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const uploadTask = uni.uploadFile({
|
||||||
|
url: `${baseUrl}FileUpload/Post`,
|
||||||
|
filePath,
|
||||||
|
name: 'files',
|
||||||
|
formData,
|
||||||
|
header: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
'accept': 'application/json',
|
||||||
|
'token': userStore.token
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
try {
|
||||||
|
const data = JSON.parse(res.data)
|
||||||
|
resolve(data)
|
||||||
|
} catch (e) {
|
||||||
|
reject(new Error('解析上传响应失败'))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (e) => {
|
||||||
|
reject(e)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (onProgress) {
|
||||||
|
uploadTask.onProgressUpdate((res) => {
|
||||||
|
onProgress(res.progress)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -17,8 +17,8 @@ export const reqGetWeldJointByWeldJointId = (id) => get(`PipeJoint/getWeldJointB
|
|||||||
/**
|
/**
|
||||||
* 焊接日报填报
|
* 焊接日报填报
|
||||||
*/
|
*/
|
||||||
export const reqSaveWeldingDailyByWeldJointId = (data) => get(
|
export const reqSaveWeldingDailyByWeldJointId = (data={}) => post(
|
||||||
`PreWeldingDaily/SaveWeldingDailyByWeldJointId?WeldJointId=${data.WeldJointId||''}&Personid=${data.Personid||''}&time=${data.time||''}&weldingLocation=${data.weldingLocation||''}&welderType=${data.welderType||''}`
|
`PreWeldingDaily/SaveWeldingDailyByWeldJointId`,data
|
||||||
)
|
)
|
||||||
// ==================== 点口管理 ================================================
|
// ==================== 点口管理 ================================================
|
||||||
/**
|
/**
|
||||||
|
|||||||
+6
-6
@@ -50,12 +50,6 @@
|
|||||||
"navigationBarTitleText": "点口管理"
|
"navigationBarTitleText": "点口管理"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path": "weld/daily_paper",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "焊接日报"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path": "pressure/index",
|
"path": "pressure/index",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -144,6 +138,12 @@
|
|||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "组队抽查"
|
"navigationBarTitleText": "组队抽查"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hj/daily_paper",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "焊接日报"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,208 +0,0 @@
|
|||||||
<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.WeldingDate || '--' }}</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="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 userStroe = useUserStore()
|
|
||||||
const {userInfo} = userStroe
|
|
||||||
// ===== 表单数据 =====
|
|
||||||
const form = 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 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 () => {
|
|
||||||
// TODO: 调用点口 API
|
|
||||||
const res = await reqGetManualPointSave(form.value.WeldJointId)
|
|
||||||
uni.showToast({
|
|
||||||
title: '点口成功',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 1500)
|
|
||||||
}
|
|
||||||
// 填报事件
|
|
||||||
const handleReport = async () => {
|
|
||||||
uni.showModal({
|
|
||||||
title: '信息提示',
|
|
||||||
content: '确定要填报吗?',
|
|
||||||
success: async (res) => {
|
|
||||||
if (res.confirm) {
|
|
||||||
// TODO: 调用填报 API
|
|
||||||
const result = await reqSaveWeldingDailyByWeldJointId(
|
|
||||||
form.value.WeldJointId,
|
|
||||||
userInfo.value.PersonId,
|
|
||||||
$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd'),
|
|
||||||
form.value.WeldingLocationId,
|
|
||||||
form.value.welderType
|
|
||||||
)
|
|
||||||
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
|
|
||||||
}
|
|
||||||
form.value.welderType = 0
|
|
||||||
form.value.welderTypeName = "打底/盖面"
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -0,0 +1,409 @@
|
|||||||
|
<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="info-group photo-section">
|
||||||
|
<view class="section-header">
|
||||||
|
<text class="section-title">焊前拍照</text>
|
||||||
|
<text class="section-tip" v-if="beforePhotoList.length === 0">请拍摄焊接前照片</text>
|
||||||
|
</view>
|
||||||
|
<view class="photo-grid">
|
||||||
|
<view class="photo-item" v-for="(photo, index) in beforePhotoList" :key="photo._id">
|
||||||
|
<image class="photo-img" :src="photo.src" mode="aspectFill" @click="previewPhoto(beforePhotoList, index)"></image>
|
||||||
|
<view class="photo-tag" v-if="photo.uploaded">✓</view>
|
||||||
|
<view class="photo-delete" @tap.stop="deletePhoto(beforePhotoList, index)">
|
||||||
|
<u-icon name="close" color="#fff" size="14"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="photo-item photo-add" @click="handleTakeBeforePhoto" v-if="beforePhotoList.length < 6">
|
||||||
|
<u-icon name="camera" color="#ccc" size="40"></u-icon>
|
||||||
|
<text class="add-text">拍照</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 焊后拍照 -->
|
||||||
|
<view class="info-group photo-section">
|
||||||
|
<view class="section-header">
|
||||||
|
<text class="section-title">焊后拍照</text>
|
||||||
|
<text class="section-tip" v-if="afterPhotoList.length === 0">请拍摄焊接后照片</text>
|
||||||
|
</view>
|
||||||
|
<view class="photo-grid">
|
||||||
|
<view class="photo-item" v-for="(photo, index) in afterPhotoList" :key="photo._id">
|
||||||
|
<image class="photo-img" :src="photo.src" mode="aspectFill" @click="previewPhoto(afterPhotoList, index)"></image>
|
||||||
|
<view class="photo-tag" v-if="photo.uploaded">✓</view>
|
||||||
|
<view class="photo-delete" @tap.stop="deletePhoto(afterPhotoList, index)">
|
||||||
|
<u-icon name="close" color="#fff" size="14"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="photo-item photo-add" @click="handleTakeAfterPhoto" v-if="afterPhotoList.length < 6">
|
||||||
|
<u-icon name="camera" color="#ccc" size="40"></u-icon>
|
||||||
|
<text class="add-text">拍照</text>
|
||||||
|
</view>
|
||||||
|
</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, uploadAttach } from '@/api/base.js'
|
||||||
|
import { baseFileUrl, parseAttachUrls } from '@/utils/request.js'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
const userStore = useUserStore()
|
||||||
|
const { userInfo } = userStore
|
||||||
|
|
||||||
|
// ===== 表单数据 =====
|
||||||
|
const form = 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 beforePhotoList = ref([])
|
||||||
|
const afterPhotoList = ref([])
|
||||||
|
let photoIdSeed = 0
|
||||||
|
|
||||||
|
// ===== 拍照(只存本地,等填报时统一上传) =====
|
||||||
|
const handleTakeBeforePhoto = () => takePhoto(beforePhotoList)
|
||||||
|
const handleTakeAfterPhoto = () => takePhoto(afterPhotoList)
|
||||||
|
|
||||||
|
const takePhoto = (listRef) => {
|
||||||
|
uni.chooseImage({
|
||||||
|
count: 1,
|
||||||
|
sourceType: ['camera'],
|
||||||
|
success: (res) => {
|
||||||
|
const tempPath = res.tempFilePaths[0]
|
||||||
|
const id = ++photoIdSeed
|
||||||
|
listRef.value.push({
|
||||||
|
_id: id,
|
||||||
|
src: tempPath,
|
||||||
|
uploaded: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 是否需要上传(本地临时路径才需要) =====
|
||||||
|
const isLocalPath = (src) => src && !src.startsWith(baseFileUrl)
|
||||||
|
|
||||||
|
// ===== 批量上传 =====
|
||||||
|
const uploadAllPhotos = async (listRef, typeName) => {
|
||||||
|
const photos = listRef.value.filter(p => !p.uploaded && isLocalPath(p.src))
|
||||||
|
const urls = []
|
||||||
|
for (const photo of photos) {
|
||||||
|
photo.uploading = true
|
||||||
|
photo.progress = 0
|
||||||
|
try {
|
||||||
|
const result = await uploadAttach(photo.src, { typeName }, (progress) => {
|
||||||
|
photo.progress = progress
|
||||||
|
})
|
||||||
|
photo.uploading = false
|
||||||
|
photo.uploaded = true
|
||||||
|
photo.result = result
|
||||||
|
const url = Array.isArray(result) ? result[0] : result
|
||||||
|
if (url) {
|
||||||
|
urls.push(url)
|
||||||
|
photo.src = `${baseFileUrl}${url}`
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
photo.uploading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return urls
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasPendingBefore = () => beforePhotoList.value.some(p => !p.uploaded && isLocalPath(p.src))
|
||||||
|
const hasPendingAfter = () => afterPhotoList.value.some(p => !p.uploaded && isLocalPath(p.src))
|
||||||
|
|
||||||
|
// ===== 预览照片 =====
|
||||||
|
const previewPhoto = (list, index) => {
|
||||||
|
const urls = list.map(p => p.src)
|
||||||
|
uni.previewImage({ current: index, urls })
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 删除照片 =====
|
||||||
|
const deletePhoto = (list, index) => {
|
||||||
|
uni.showModal({
|
||||||
|
title: '确认删除',
|
||||||
|
content: '确定要删除这张照片吗?',
|
||||||
|
success: ({ confirm }) => {
|
||||||
|
if (confirm) list.splice(index, 1)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== 弹窗 ========
|
||||||
|
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) {
|
||||||
|
const needBefore = hasPendingBefore()
|
||||||
|
const needAfter = hasPendingAfter()
|
||||||
|
let PreWeldAttachUrl = form.value.PreWeldAttachUrl || ''
|
||||||
|
let PostWeldAttachUrl = form.value.PostWeldAttachUrl || ''
|
||||||
|
|
||||||
|
if (needBefore || needAfter) {
|
||||||
|
uni.showLoading({ title: '上传照片中...', mask: true })
|
||||||
|
if (needBefore) {
|
||||||
|
const urls = await uploadAllPhotos(beforePhotoList, 'WeldingDaily_Before')
|
||||||
|
if (urls.length) {
|
||||||
|
PreWeldAttachUrl = PreWeldAttachUrl
|
||||||
|
? PreWeldAttachUrl + ',' + urls.join(',')
|
||||||
|
: urls.join(',')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (needAfter) {
|
||||||
|
const urls = await uploadAllPhotos(afterPhotoList, 'WeldingDaily_After')
|
||||||
|
if (urls.length) {
|
||||||
|
PostWeldAttachUrl = PostWeldAttachUrl
|
||||||
|
? PostWeldAttachUrl + ',' + urls.join(',')
|
||||||
|
: urls.join(',')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uni.hideLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
await reqSaveWeldingDailyByWeldJointId({
|
||||||
|
WeldJointId: form.value.WeldJointId,
|
||||||
|
Personid: userInfo.PersonId,
|
||||||
|
time: form.value.WeldingDateTemp,
|
||||||
|
weldingLocation: form.value.WeldingLocationId || '',
|
||||||
|
welderType: form.value.welderType,
|
||||||
|
PreWeldAttachUrl,
|
||||||
|
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 = "打底/盖面"
|
||||||
|
|
||||||
|
// 回显已有照片
|
||||||
|
beforePhotoList.value = parseAttachUrls(form.value.PreWeldAttachUrl, photoIdSeed)
|
||||||
|
photoIdSeed += beforePhotoList.value.length
|
||||||
|
afterPhotoList.value = parseAttachUrls(form.value.PostWeldAttachUrl, photoIdSeed)
|
||||||
|
photoIdSeed += afterPhotoList.value.length
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.photo-section {
|
||||||
|
.section-header {
|
||||||
|
padding: 24rpx 32rpx 16rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-tip {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding: 0 24rpx 24rpx;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-item {
|
||||||
|
width: 200rpx;
|
||||||
|
height: 200rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
background: #f5f6f8;
|
||||||
|
|
||||||
|
.photo-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-tag {
|
||||||
|
position: absolute;
|
||||||
|
top: 6rpx;
|
||||||
|
left: 6rpx;
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(0, 200, 83, 0.85);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 22rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-delete {
|
||||||
|
position: absolute;
|
||||||
|
top: 6rpx;
|
||||||
|
right: 6rpx;
|
||||||
|
width: 36rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-add {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 2rpx dashed #ddd;
|
||||||
|
|
||||||
|
.add-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #ccc;
|
||||||
|
margin-top: 8rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 378 KiB |
+17
-1
@@ -2,7 +2,7 @@ import { useUserStore } from '@/store'
|
|||||||
|
|
||||||
// TODO: 替换为实际的 API 地址
|
// TODO: 替换为实际的 API 地址
|
||||||
export const baseUrl = 'https://lygcgs.com.cn:8078/shjapi/api/'
|
export const baseUrl = 'https://lygcgs.com.cn:8078/shjapi/api/'
|
||||||
|
export const baseFileUrl = 'https://lygcgs.com.cn:8078/shj/'
|
||||||
// ===== 防止重复请求 =====
|
// ===== 防止重复请求 =====
|
||||||
const pendingRequests = new Map()
|
const pendingRequests = new Map()
|
||||||
|
|
||||||
@@ -148,6 +148,22 @@ export const post = (url, data = {}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析附件 URL 字符串为可展示的照片列表
|
||||||
|
* @param {string} urlStr - 逗号分隔的附件路径,如 "FileUpLoad/xxx.png,FileUpLoad/yyy.png"
|
||||||
|
* @param {number} startId - 起始 ID,用于生成唯一标识
|
||||||
|
* @returns {Array<{_id: number, src: string, uploaded: boolean}>}
|
||||||
|
*/
|
||||||
|
export const parseAttachUrls = (urlStr, startId = 0) => {
|
||||||
|
if (!urlStr) return []
|
||||||
|
let id = startId
|
||||||
|
return urlStr.split(',').filter(Boolean).map(url => ({
|
||||||
|
_id: ++id,
|
||||||
|
src: `${baseFileUrl}${url}`,
|
||||||
|
uploaded: true
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
export const getUrlParam = (url, name) => {
|
export const getUrlParam = (url, name) => {
|
||||||
if (!url || !name) return null;
|
if (!url || !name) return null;
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -9,12 +9,12 @@ export const parseScanResult = (str) => {
|
|||||||
if (!str) return null
|
if (!str) return null
|
||||||
|
|
||||||
// 焊接接头二维码:https://sggl.sedin.com.cn/StaticPage/HJGL/index.html?id=xxx&weldjoint=1
|
// 焊接接头二维码:https://sggl.sedin.com.cn/StaticPage/HJGL/index.html?id=xxx&weldjoint=1
|
||||||
// if (str.includes('weldjoint')) {
|
if (str.includes('weldjoint')) {
|
||||||
// const id = getUrlParam(str, 'id')
|
const id = getUrlParam(str, 'id')
|
||||||
// if (id) {
|
if (id) {
|
||||||
// return { path: '/scanpages/hj/material_sampling', query: `id=${id}` }
|
return { path: '/scanpages/hj/daily_paper', query: `id=${id}` }
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 后续可在此扩展其他扫码类型...
|
// 后续可在此扩展其他扫码类型...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user