This commit is contained in:
bb_pan 2025-06-20 11:25:17 +08:00
parent 28fdc5b9e1
commit 2628a1dbb7
6 changed files with 206 additions and 132 deletions

View File

@ -52,7 +52,15 @@
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="6">设备编码</uni-col>
<uni-col :span="12">
<uni-easyinput placeholder="请输入内容" maxlength="30" v-model="maCode" />
<!-- <uni-easyinput placeholder="请输入内容" maxlength="30" v-model="maCode" /> -->
<eselect
style="width: 100%; height: 90rpx"
v-model="maCode"
ref="treeSelect2"
:options="codeList"
@change="changeMaCode"
@clear="clearMaCode"
></eselect>
</uni-col>
<uni-col :span="6">
<view class="coding-btn search-btn" @click="getMaInfo">编码检索</view>
@ -87,18 +95,18 @@
</radio-group>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="4">附件</uni-col>
<uni-col :span="20">
<div class="upload-container">
<div class="upload" @click="uploadImg" v-if="imgList.length < 3">+</div>
<div class="image-preview" v-for="(img, index) in imgList" :key="index">
<image :src="img.url" mode="aspectFill"></image>
<view class="delete-btn" @click.stop="deleteImage(index)">×</view>
</div>
</div>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="4">附件</uni-col>
<uni-col :span="20">
<div class="upload-container">
<div class="upload" @click="uploadImg" v-if="imgList.length < 3">+</div>
<div class="image-preview" v-for="(img, index) in imgList" :key="index">
<image :src="img.url" mode="aspectFill"></image>
<view class="delete-btn" @click.stop="deleteImage(index)">×</view>
</div>
</div>
</uni-col>
</uni-row>
</div>
<div class="btn">
@ -111,9 +119,10 @@
<script setup>
import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getMachine, insertApp } from '../../services/back.js'
import { getMachine, insertApp, getSelectMachineByIdApi } from '../../services/back.js'
import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
import { baseURL } from '@/utils/http'
import eselect from '@/components/tree-select/eselect.vue'
const taskInfo = ref({})
const maId = ref('') //
const maCode = ref('') //
@ -126,15 +135,62 @@ const imgBeseUrl = ref('') //图片展示
const imgList = ref([]) //
const bmFileInfos = ref([]) //
const scanQrCodeRef = ref(null)
const codeList = ref([])
const changeRadio = (e) => {
console.log(e.detail.value)
apDetection.value = e.detail.value
}
//
const getMaCodeList = async () => {
let param = {
unitId: taskInfo.value.unitId,
proId: taskInfo.value.proId,
id: taskInfo.value.id,
}
try {
const res = await getSelectMachineByIdApi(param)
console.log('🚀 ~ getMaCodeList ~ res:', res)
if (!res.data || res.data.length === 0) return
codeList.value = res.data.map((item) => {
return {
id: item.maCode,
name: item.maCode,
parentId: 0,
}
})
} catch (error) {
console.log('🚀 ~ getMaCodeList ~ error:', error)
}
}
const changeMaCode = (e) => {
console.log('🚀 ~ changeMaCode ~ e:', e)
maCode.value = e.id
}
const clearMaCode = () => {
maCode.value = ''
typeName.value = ''
materialName.value = ''
maStatusName.value = ''
typeId.value = ''
maId.value = ''
maCode.value = ''
typeId.value = ''
apDetection.value = '完好'
bmFileInfos.value = []
imgBeseUrl.value = ''
imgList.value = []
}
//
const getMaInfo = () => {
console.log(maCode.value)
if (!maCode.value) {
uni.showToast({ title: '请选择设备编码!', icon: 'none' })
return
}
let param = {
maCode: maCode.value,
unitId: taskInfo.value.unitId,
@ -303,7 +359,7 @@ const submitCode = () => {
console.log(taskInfo.value)
if (maId.value == '') {
uni.showToast({ title: '请先添加退料设备编码!', icon: 'none' })
} else if(apDetection.value == '不合格' && bmFileInfos.value.length == 0) {
} else if (apDetection.value == '不合格' && bmFileInfos.value.length == 0) {
uni.showToast({ title: '请上传附件!', icon: 'none' })
} else {
// console.log(typeList.value)
@ -335,6 +391,8 @@ const submitCode = () => {
apDetection.value = '完好'
bmFileInfos.value = []
imgBeseUrl.value = ''
imgList.value = []
getMaCodeList()
// uni.navigateBack({
// delta: 1 //
// });
@ -350,151 +408,155 @@ const submitCode = () => {
//
const uploadImg = () => {
uni.chooseImage({
count: 3 - imgList.value.length, // 3
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: async (res) => {
const tempFiles = res.tempFiles
if (imgList.value.length + tempFiles.length > 3) {
uni.showToast({ title: '最多只能上传3张图片', icon: 'none' })
return
}
//
for (let i = 0; i < tempFiles.length; i++) {
imgList.value.push({
url: tempFiles[i].path,
uploading: true
})
}
//
const uploadPromises = tempFiles.map(file => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: '/file/upload',
filePath: file.path,
name: 'file',
success: (uploadRes) => {
const resData = JSON.parse(uploadRes.data)
if (resData.code === 200) {
resolve({
name: resData.data.name,
url: resData.data.url,
taskType: '10'
})
} else {
reject(new Error('上传失败'))
}
},
fail: (err) => {
reject(err)
uni.chooseImage({
count: 3 - imgList.value.length, // 3
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: async (res) => {
const tempFiles = res.tempFiles
if (imgList.value.length + tempFiles.length > 3) {
uni.showToast({ title: '最多只能上传3张图片', icon: 'none' })
return
}
})
})
})
try {
const results = await Promise.all(uploadPromises)
bmFileInfos.value = [...bmFileInfos.value, ...results]
uni.showToast({ title: '上传成功', icon: 'none' })
//
for (let i = 0; i < tempFiles.length; i++) {
imgList.value.push({
url: tempFiles[i].path,
uploading: true,
})
}
//
imgList.value = imgList.value.map(img => {
return {
...img,
uploading: false
}
})
} catch (error) {
uni.showToast({ title: '部分图片上传失败', icon: 'none' })
//
imgList.value = imgList.value.filter(img => !img.uploading)
}
}
})
//
const uploadPromises = tempFiles.map((file) => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: '/file/upload',
filePath: file.path,
name: 'file',
success: (uploadRes) => {
const resData = JSON.parse(uploadRes.data)
if (resData.code === 200) {
resolve({
name: resData.data.name,
url: resData.data.url,
taskType: '10',
})
} else {
reject(new Error('上传失败'))
}
},
fail: (err) => {
reject(err)
},
})
})
})
try {
const results = await Promise.all(uploadPromises)
bmFileInfos.value = [...bmFileInfos.value, ...results]
uni.showToast({ title: '上传成功', icon: 'none' })
//
imgList.value = imgList.value.map((img) => {
return {
...img,
uploading: false,
}
})
} catch (error) {
uni.showToast({ title: '部分图片上传失败', icon: 'none' })
//
imgList.value = imgList.value.filter((img) => !img.uploading)
}
},
})
}
//
const deleteImage = (index) => {
imgList.value.splice(index, 1)
bmFileInfos.value.splice(index, 1)
imgList.value.splice(index, 1)
bmFileInfos.value.splice(index, 1)
}
onLoad((options) => {
console.log(options)
taskInfo.value = JSON.parse(options.taskInfo)
console.log(taskInfo.value)
getMaCodeList()
})
</script>
<style lang="scss" scoped>
::v-deep .tree-item .head {
justify-content: center !important;
}
::v-deep .uni-easyinput__content {
padding: 0 !important;
}
/* 在style部分添加 */
.upload-container {
display: flex;
flex-wrap: wrap;
gap: 10px;
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.upload {
width: 160rpx;
height: 160rpx;
background-color: #f7f8fa;
border: 2rpx dashed #d9d9d9;
border-radius: 12rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 48rpx;
color: #bfbfbf;
transition: all 0.3s ease;
width: 160rpx;
height: 160rpx;
background-color: #f7f8fa;
border: 2rpx dashed #d9d9d9;
border-radius: 12rpx;
display: flex;
justify-content: center;
align-items: center;
font-size: 48rpx;
color: #bfbfbf;
transition: all 0.3s ease;
}
.image-preview {
width: 160rpx;
height: 160rpx;
position: relative;
border-radius: 12rpx;
overflow: hidden;
width: 160rpx;
height: 160rpx;
position: relative;
border-radius: 12rpx;
overflow: hidden;
}
.image-preview image {
width: 100%;
height: 100%;
width: 100%;
height: 100%;
}
.delete-btn {
position: absolute;
top: 0;
right: 0;
width: 40rpx;
height: 40rpx;
background-color: rgba(0, 0, 0, 0.5);
color: white;
display: flex;
justify-content: center;
align-items: center;
border-bottom-left-radius: 12rpx;
font-size: 32rpx;
line-height: 32rpx;
position: absolute;
top: 0;
right: 0;
width: 40rpx;
height: 40rpx;
background-color: rgba(0, 0, 0, 0.5);
color: white;
display: flex;
justify-content: center;
align-items: center;
border-bottom-left-radius: 12rpx;
font-size: 32rpx;
line-height: 32rpx;
}
.uploading-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 24rpx;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
color: white;
font-size: 24rpx;
}
::v-deep .uni-radio-input {

View File

@ -185,8 +185,6 @@ const submitCode = () => {
uni.showToast({ title: '请先扫码确认退料单位,退料工程!', icon: 'none' })
} else if (backPerson.value == '') {
uni.showToast({ title: '请填写退料人!', icon: 'none' })
} else if (phone.value == '') {
uni.showToast({ title: '请确认联系电话!', icon: 'none' })
} else {
let info = {
agreementId: maInfo.value.agreementId,

View File

@ -16,8 +16,8 @@
</uni-col>
</uni-row>
<div class="table-list-item" v-for="(item, index) in tableList" :key="index">
<uni-swipe-action class="swipe-action">
<uni-swipe-action-item @click="onClick($event, item)" :right-options="item.manageType==1 ? options:options2">
<uni-swipe-action class="swipe-action" ref="swipeRef">
<uni-swipe-action-item @click="onClick($event, item, index)" :right-options="item.manageType==1 ? options:options2">
<div class="title">
<span style="font-size: 15px; font-weight: 800">退料任务</span>
<!-- <span v-if="item.status == 2" style="color: #ff4d4f">未验收</span> -->
@ -65,6 +65,7 @@ const taskId = ref('')
const statusList = ref(["2","12"])
const tableList = ref([])
const taskInfo = ref({})
const swipeRef = ref()
//
const options = ref([
@ -127,7 +128,7 @@ const goCode = () => {
const goNum = () => {
uni.navigateTo({ url: `/pages/back/backNum?taskInfo=${JSON.stringify(taskInfo.value)}` })
}
const onClick = (e, item) => {
const onClick = (e, item, itemIndex) => {
const { index } = e
// 1.
if (index === 0) {
@ -155,6 +156,7 @@ const onClick = (e, item) => {
console.log(error)
})
}
swipeRef.value[itemIndex].closeAll()
}
onLoad((options)=>{
console.log(options)

View File

@ -52,8 +52,8 @@
</uni-row>
<scroll-view scroll-y @scrolltolower="onScrollTolower" class="scroll-container">
<div class="table-list-item" v-for="(item, index) in tableList" :key="index" @click="handleItem(item)">
<uni-swipe-action class="swipe-action">
<uni-swipe-action-item :right-options="item.taskStatus==0 ? options:options2" @click="onClick($event,item)">
<uni-swipe-action class="swipe-action" ref="swipeRef">
<uni-swipe-action-item :right-options="item.taskStatus==0 ? options:options2" @click="onClick($event,item, index)">
<div class="title">
<span class="code">{{ item.code }}</span>
<div class="status-tag">
@ -151,6 +151,7 @@ const total = ref(0) // 数据总量
const active = ref(1) // tap
const tableList = ref([]) //
const dateArray = ref([]) //
const swipeRef = ref()
//
const signOptions = ref([
{ value: 0, text: "全部" },
@ -223,7 +224,7 @@ const options2 = ref([
// },
])
//
const onClick=(e,item)=> {
const onClick=(e,item,itemIndex)=> {
console.log('🚀 ~ onClick ~ item:', item)
const { index } = e
console.log(index)
@ -280,6 +281,7 @@ const onClick=(e,item)=> {
console.log(error)
})
}
swipeRef.value[itemIndex].closeAll()
}
//

View File

@ -97,6 +97,7 @@ const complete = (e) => {
// console.log(e) // base
const img = new Image()
img.src = e
console.log('🚀 ~ complete ~ img.src:', img.src)
img.onload = () => {
const canvas = document.createElement('canvas')
canvas.width = img.width
@ -105,7 +106,7 @@ const complete = (e) => {
ctx.drawImage(img, 0, 0)
// WebP 0.8
const webpBase64 = canvas.toDataURL('image/webp', 0.8)
const webpBase64 = canvas.toDataURL('image/webp', 0.8).replace(/^data:image\/(jpeg|png|webp);base64,/, '')
console.log('🚀 ~ WebP base64:', webpBase64)
uploadImg2(webpBase64)

View File

@ -263,3 +263,12 @@ export const directEdit = (data) => {
data:data,
})
}
// 退料编码-下拉
export const getSelectMachineByIdApi = (data) => {
return http({
method: 'GET',
url: '/material/back_apply_info/selectMachineById',
data:data,
})
}