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-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
<uni-col :span="6">设备编码</uni-col> <uni-col :span="6">设备编码</uni-col>
<uni-col :span="12"> <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>
<uni-col :span="6"> <uni-col :span="6">
<view class="coding-btn search-btn" @click="getMaInfo">编码检索</view> <view class="coding-btn search-btn" @click="getMaInfo">编码检索</view>
@ -111,9 +119,10 @@
<script setup> <script setup>
import { ref, reactive } from 'vue' import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app' 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 ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
import { baseURL } from '@/utils/http' import { baseURL } from '@/utils/http'
import eselect from '@/components/tree-select/eselect.vue'
const taskInfo = ref({}) const taskInfo = ref({})
const maId = ref('') // const maId = ref('') //
const maCode = ref('') // const maCode = ref('') //
@ -126,15 +135,62 @@ const imgBeseUrl = ref('') //图片展示
const imgList = ref([]) // const imgList = ref([]) //
const bmFileInfos = ref([]) // const bmFileInfos = ref([]) //
const scanQrCodeRef = ref(null) const scanQrCodeRef = ref(null)
const codeList = ref([])
const changeRadio = (e) => { const changeRadio = (e) => {
console.log(e.detail.value) console.log(e.detail.value)
apDetection.value = 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 = () => { const getMaInfo = () => {
console.log(maCode.value) console.log(maCode.value)
if (!maCode.value) {
uni.showToast({ title: '请选择设备编码!', icon: 'none' })
return
}
let param = { let param = {
maCode: maCode.value, maCode: maCode.value,
unitId: taskInfo.value.unitId, unitId: taskInfo.value.unitId,
@ -303,7 +359,7 @@ const submitCode = () => {
console.log(taskInfo.value) console.log(taskInfo.value)
if (maId.value == '') { if (maId.value == '') {
uni.showToast({ title: '请先添加退料设备编码!', icon: 'none' }) 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' }) uni.showToast({ title: '请上传附件!', icon: 'none' })
} else { } else {
// console.log(typeList.value) // console.log(typeList.value)
@ -335,6 +391,8 @@ const submitCode = () => {
apDetection.value = '完好' apDetection.value = '完好'
bmFileInfos.value = [] bmFileInfos.value = []
imgBeseUrl.value = '' imgBeseUrl.value = ''
imgList.value = []
getMaCodeList()
// uni.navigateBack({ // uni.navigateBack({
// delta: 1 // // delta: 1 //
// }); // });
@ -365,12 +423,12 @@ const uploadImg = () => {
for (let i = 0; i < tempFiles.length; i++) { for (let i = 0; i < tempFiles.length; i++) {
imgList.value.push({ imgList.value.push({
url: tempFiles[i].path, url: tempFiles[i].path,
uploading: true uploading: true,
}) })
} }
// //
const uploadPromises = tempFiles.map(file => { const uploadPromises = tempFiles.map((file) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.uploadFile({ uni.uploadFile({
url: '/file/upload', url: '/file/upload',
@ -382,7 +440,7 @@ const uploadImg = () => {
resolve({ resolve({
name: resData.data.name, name: resData.data.name,
url: resData.data.url, url: resData.data.url,
taskType: '10' taskType: '10',
}) })
} else { } else {
reject(new Error('上传失败')) reject(new Error('上传失败'))
@ -390,7 +448,7 @@ const uploadImg = () => {
}, },
fail: (err) => { fail: (err) => {
reject(err) reject(err)
} },
}) })
}) })
}) })
@ -401,18 +459,18 @@ const uploadImg = () => {
uni.showToast({ title: '上传成功', icon: 'none' }) uni.showToast({ title: '上传成功', icon: 'none' })
// //
imgList.value = imgList.value.map(img => { imgList.value = imgList.value.map((img) => {
return { return {
...img, ...img,
uploading: false uploading: false,
} }
}) })
} catch (error) { } catch (error) {
uni.showToast({ title: '部分图片上传失败', icon: 'none' }) 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) console.log(options)
taskInfo.value = JSON.parse(options.taskInfo) taskInfo.value = JSON.parse(options.taskInfo)
console.log(taskInfo.value) console.log(taskInfo.value)
getMaCodeList()
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .tree-item .head {
justify-content: center !important;
}
::v-deep .uni-easyinput__content { ::v-deep .uni-easyinput__content {
padding: 0 !important; padding: 0 !important;
} }

View File

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

View File

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

View File

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

View File

@ -97,6 +97,7 @@ const complete = (e) => {
// console.log(e) // base // console.log(e) // base
const img = new Image() const img = new Image()
img.src = e img.src = e
console.log('🚀 ~ complete ~ img.src:', img.src)
img.onload = () => { img.onload = () => {
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
canvas.width = img.width canvas.width = img.width
@ -105,7 +106,7 @@ const complete = (e) => {
ctx.drawImage(img, 0, 0) ctx.drawImage(img, 0, 0)
// WebP 0.8 // 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) console.log('🚀 ~ WebP base64:', webpBase64)
uploadImg2(webpBase64) uploadImg2(webpBase64)

View File

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