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>
@ -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 //
// });
@ -365,12 +423,12 @@ const uploadImg = () => {
for (let i = 0; i < tempFiles.length; i++) {
imgList.value.push({
url: tempFiles[i].path,
uploading: true
uploading: true,
})
}
//
const uploadPromises = tempFiles.map(file => {
const uploadPromises = tempFiles.map((file) => {
return new Promise((resolve, reject) => {
uni.uploadFile({
url: '/file/upload',
@ -382,7 +440,7 @@ const uploadImg = () => {
resolve({
name: resData.data.name,
url: resData.data.url,
taskType: '10'
taskType: '10',
})
} else {
reject(new Error('上传失败'))
@ -390,7 +448,7 @@ const uploadImg = () => {
},
fail: (err) => {
reject(err)
}
},
})
})
})
@ -401,18 +459,18 @@ const uploadImg = () => {
uni.showToast({ title: '上传成功', icon: 'none' })
//
imgList.value = imgList.value.map(img => {
imgList.value = imgList.value.map((img) => {
return {
...img,
uploading: false
uploading: false,
}
})
} catch (error) {
uni.showToast({ title: '部分图片上传失败', icon: 'none' })
//
imgList.value = imgList.value.filter(img => !img.uploading)
}
imgList.value = imgList.value.filter((img) => !img.uploading)
}
},
})
}
@ -426,10 +484,14 @@ 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;
}

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,
})
}