退料建立,选择单位,工程可以互选,

This commit is contained in:
bb_pan 2025-02-10 18:17:00 +08:00
parent 39a81033d0
commit 3459699fcf
3 changed files with 376 additions and 311 deletions

View File

@ -91,7 +91,7 @@
if(!e.children){ if(!e.children){
this.show = false; this.show = false;
this.showLabel=e.name; this.showLabel=e.name;
this.$emit('change', e,index) this.$emit('change', e)
} }
}, },
clearInput(){ clearInput(){

View File

@ -1,17 +1,36 @@
<template> <template>
<view style="padding-top: 4vh;background-color: rgb(220, 244, 255);"> <view style="padding-top: 4vh; background-color: rgb(220, 244, 255)">
<uni-nav-bar left-icon="left" @clickLeft="leftClick" right-icon="scan" @clickRight="rightClick" title="退料新增" title-style="font-weight: bolder;" backgroundColor="rgb(220, 244, 255)" :border="false" /> <uni-nav-bar
</view> left-icon="left"
@clickLeft="leftClick"
right-icon="scan"
@clickRight="rightClick"
title="退料新增"
title-style="font-weight: bolder;"
backgroundColor="rgb(220, 244, 255)"
:border="false"
/>
</view>
<view class="accept page-common"> <view class="accept page-common">
<div class="card"> <div class="card">
<uni-forms :model="formData" label-width="170rpx" :border="true"> <uni-forms :model="formData" label-width="170rpx" :border="true">
<uni-forms-item label="退料单位:" name="unitId"> <uni-forms-item label="退料单位:" name="unitId">
<eselect style="width: 100%;height: 90rpx;" <eselect
ref="treeSelect" :options="unitList" @change="getProject" @clear="clearUnit"></eselect> style="width: 100%; height: 90rpx"
ref="treeSelect"
:options="unitList"
@change="getProject"
@clear="clearUnit"
></eselect>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="退料工程:" name="proId"> <uni-forms-item label="退料工程:" name="proId">
<eselect style="width: 100%;height: 90rpx;" <eselect
ref="treeSelect2" :options="proList" @change="changePro" @clear="clearPro"></eselect> style="width: 100%; height: 90rpx"
ref="treeSelect2"
:options="proList"
@change="changePro"
@clear="clearPro"
></eselect>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="退料人员:" name="backPerson"> <uni-forms-item label="退料人员:" name="backPerson">
<uni-easyinput v-model="backPerson" maxlength="10" placeholder="请输入退料人" /> <uni-easyinput v-model="backPerson" maxlength="10" placeholder="请输入退料人" />
@ -32,141 +51,163 @@
<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 { getUnitList,getProjectList,insertApp,getAgreementInfoById } from '../../services/back.js'; import {
import eselect from '@/components/tree-select/eselect.vue'; getUnitList,
getProjectList,
insertApp,
getAgreementInfoById,
} from '../../services/back.js'
import eselect from '@/components/tree-select/eselect.vue'
const treeSelect = ref(null) const treeSelect = ref(null)
const treeSelect2 = ref(null) const treeSelect2 = ref(null)
const formData = ref({}) const formData = ref({})
const unitId = ref("") const unitId = ref('')
const proId = ref("") const proId = ref('')
const agreementId = ref("") const agreementId = ref('')
const unitList = ref([]) const unitList = ref([])
const proList = ref([]) const proList = ref([])
const backPerson = ref("") const backPerson = ref('')
const phone = ref("") const phone = ref('')
// //
const getUnit = () => { const getUnit = () => {
// proId.value=e.id; // proId.value=e.id;
let obj = { let obj = {
// "projectId":proId.value, projectId: proId.value,
} }
getUnitList(obj).then(res => { getUnitList(obj)
console.log(res) .then((res) => {
unitList.value = res.data; console.log(res)
// getAgreement() unitList.value = res.data
}).catch(error => { // getAgreement()
console.log(error) if (unitId.value && proId.value) {
}) getAgreement()
}
})
.catch((error) => {
console.log(error)
})
} }
// //
const getProject = (e) => { const getProject = (e) => {
// console.log(e) console.log('🚀 ~ getProject ~ e:', e)
unitId.value=e.id; unitId.value = e?.id || ''
let obj = { let obj = {
"unitId":unitId.value, unitId: unitId.value,
// "isApp":true // "isApp":true
} }
getProjectList(obj).then(res => { getProjectList(obj)
proList.value = res.data .then((res) => {
proId.value="" proList.value = res.data
treeSelect2.value.clearInput(); // proId.value=""
agreementId.value="" // treeSelect2.value.clearInput();
// getAgreement() agreementId.value = ''
}).catch(error => { if (unitId.value && proId.value) {
console.log(error) getAgreement()
}) }
})
.catch((error) => {
console.log(error)
})
} }
const clearUnit = () =>{ const clearUnit = () => {
unitId.value=""; unitId.value = ''
agreementId.value="" agreementId.value = ''
getUnit()
getProject()
} }
const clearPro = () =>{ const clearPro = () => {
proId.value=""; proId.value = ''
agreementId.value="" agreementId.value = ''
getProject()
getProject()
} }
// //
const changePro = (e) => { const changePro = (e) => {
// console.log(e) console.log(e)
proId.value=e.id proId.value = e.id
getAgreement() getUnit()
// getAgreement()
} }
// //
const getAgreement = () => { const getAgreement = () => {
let obj = { let obj = {
"unitId":unitId.value, unitId: unitId.value,
"projectId":proId.value projectId: proId.value,
} }
getAgreementInfoById(obj).then(res => { getAgreementInfoById(obj)
console.log(res) .then((res) => {
if(res.code==200){ console.log(res)
agreementId.value=res.data.agreementId if (res.code == 200) {
}else{ agreementId.value = res.data.agreementId
agreementId.value="" } else {
} agreementId.value = ''
}).catch(error => { }
console.log(error) })
}) .catch((error) => {
console.log(error)
})
} }
// //
const clearForm = () => { const clearForm = () => {
unitId.value="" unitId.value = ''
proId.value="" proId.value = ''
backPerson.value="" backPerson.value = ''
phone.value="" phone.value = ''
agreementId.value="" agreementId.value = ''
treeSelect.value.clearInput() treeSelect.value.clearInput()
treeSelect2.value.clearInput() treeSelect2.value.clearInput()
getUnit() getUnit()
// getProject() // getProject()
} }
// //
const confirmAdd = () => { const confirmAdd = () => {
if(agreementId.value==""){ if (agreementId.value == '') {
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==""){ } else if (phone.value == '') {
uni.showToast({ title: "请确认联系电话!", icon: 'none' }) uni.showToast({ title: '请确认联系电话!', icon: 'none' })
}else{ } else {
let obj = { let obj = {
"backApplyInfo":{ backApplyInfo: {
"agreementId":agreementId.value, agreementId: agreementId.value,
"backPerson":backPerson.value, backPerson: backPerson.value,
"phone":phone.value phone: phone.value,
} },
} }
insertApp(obj).then(res => { insertApp(obj)
console.log(res) .then((res) => {
if(res.code==200){ console.log(res)
uni.showToast({ title: '新增成功', icon: 'none' }) if (res.code == 200) {
uni.navigateBack({ uni.showToast({ title: '新增成功', icon: 'none' })
delta: 1 // uni.navigateBack({
}); delta: 1, //
}else{ })
uni.showToast({ title: res.msg, icon: 'none' }) } else {
} uni.showToast({ title: res.msg, icon: 'none' })
}).catch(error => { }
console.log(error) })
}) .catch((error) => {
} console.log(error)
})
}
} }
const leftClick = () => { const leftClick = () => {
console.log(1) console.log(1)
uni.navigateBack({ uni.navigateBack({
delta: 1 // delta: 1, //
}); })
} }
const rightClick = () => { const rightClick = () => {
console.log(2) console.log(2)
uni.navigateTo({ url: `/pages/back/backCodeAdd` }) uni.navigateTo({ url: `/pages/back/backCodeAdd` })
} }
onLoad((options)=>{ onLoad((options) => {
getUnit() getUnit()
// getProject() getProject()
// formData.value = JSON.parse(options.item) // formData.value = JSON.parse(options.item)
}) })
</script> </script>

View File

@ -12,68 +12,76 @@
</uni-row> </uni-row>
</div> </div>
<div class="card"> <div class="card">
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;"> <uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="8">设备编码</uni-col> <uni-col :span="8">设备编码</uni-col>
<uni-col :span="16">
{{ maInfo.maCode }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="6">退料单位</uni-col>
<uni-col :span="16">
<uni-easyinput v-model="maInfo.unitName" maxlength="20" disabled="true"/>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="6">退料工程</uni-col>
<uni-col :span="16">
<uni-easyinput v-model="maInfo.proName" maxlength="20" disabled="true"/>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="6">退料人</uni-col>
<uni-col :span="16">
<uni-easyinput placeholder="请输入退料人" maxlength="10" v-model="backPerson"/>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="6">联系电话</uni-col>
<uni-col :span="16">
<uni-easyinput placeholder="请输入联系电话" maxlength="11" v-model="phone"/>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="8">物资类型</uni-col>
<uni-col :span="16">
{{ maInfo.typeName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="8">规格型号</uni-col>
<uni-col :span="16">
{{ maInfo.typeModelName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="8">设备状态</uni-col>
<uni-col :span="16">
{{ maInfo.maStatusName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<uni-col :span="6">外观判定</uni-col>
<uni-col :span="16"> <uni-col :span="16">
<uni-easyinput placeholder="请输入内容" v-model="apDetection"/> {{ maInfo.maCode }}
</uni-col> </uni-col>
</uni-row> </uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;"> <uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">退料单位</uni-col>
<uni-col :span="16">
<uni-easyinput v-model="maInfo.unitName" maxlength="20" disabled="true" />
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">退料工程</uni-col>
<uni-col :span="16">
<uni-easyinput v-model="maInfo.proName" maxlength="20" disabled="true" />
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">退料人</uni-col>
<uni-col :span="16">
<uni-easyinput placeholder="请输入退料人" maxlength="10" v-model="backPerson" />
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">联系电话</uni-col>
<uni-col :span="16">
<uni-easyinput placeholder="请输入联系电话" maxlength="11" v-model="phone" />
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="8">物资类型</uni-col>
<uni-col :span="16">
{{ maInfo.typeName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="8">规格型号</uni-col>
<uni-col :span="16">
{{ maInfo.typeModelName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="8">设备状态</uni-col>
<uni-col :span="16">
{{ maInfo.maStatusName }}
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">外观判定</uni-col>
<uni-col :span="16">
<!-- <uni-easyinput placeholder="请输入内容" v-model="apDetection"/> -->
<radio-group v-model="apDetection" @change="changeRadio">
<radio value="完好" checked style="margin-right: 5px;">完好</radio>
<radio value="损坏">损坏</radio>
</radio-group>
</uni-col>
</uni-row>
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="6">附件</uni-col> <uni-col :span="6">附件</uni-col>
<uni-col :span="16"> <uni-col :span="16">
<div class="upload" @click="uploadImg" v-if="imgBeseUrl==''">+</div> <div class="upload" @click="uploadImg" v-if="imgBeseUrl == ''">+</div>
<div class="upload" @click="uploadImg" v-else> <div class="upload" @click="uploadImg" v-else>
<image :src="imgBeseUrl" style="width: 160rpx;height: 160rpx;" mode=""></image> <image
</div> :src="imgBeseUrl"
style="width: 160rpx; height: 160rpx"
mode=""
></image>
</div>
</uni-col> </uni-col>
</uni-row> </uni-row>
</div> </div>
@ -87,164 +95,180 @@
<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,insertBack,getMachineByQrCodeApi } from '../../services/back.js'; import { getMachine, insertBack, getMachineByQrCodeApi } from '../../services/back.js'
import { baseURL } from '@/utils/http' import { baseURL } from '@/utils/http'
const backPerson = ref("") const backPerson = ref('')
const phone = ref("") const phone = ref('')
const apDetection = ref("") // const apDetection = ref('完好') //
const imgBeseUrl = ref("") // const imgBeseUrl = ref('') //
const bmFileInfos = ref([])// const bmFileInfos = ref([]) //
const qrCode = ref("") // const qrCode = ref('') //
const maInfo = ref({}) // const maInfo = ref({}) //
// //
const codeScan = async () => { const codeScan = async () => {
qrCode.value="" qrCode.value = ''
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module") var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
mpaasScanModule.mpaasScan({ mpaasScanModule.mpaasScan(
// qrCodebarCode {
'scanType': ['qrCode','barCode'], // qrCodebarCode
// false scanType: ['qrCode', 'barCode'],
'hideAlbum': false, // false
//ios zh-Hansen hideAlbum: false,
'language' : 'en', //ios zh-Hansen
//(ios) language: 'en',
'failedMsg': '未识别到二维码,请重试', //(ios)
//Android failedMsg: '未识别到二维码,请重试',
'screenType': 'full' //Android
},(ret) => { screenType: 'full',
console.log(ret) },
if(ret.resp_code==10){ (ret) => {
uni.showToast({ title: '用户取消', icon: 'none' }) console.log(ret)
maInfo.value = {} if (ret.resp_code == 10) {
} uni.showToast({ title: '用户取消', icon: 'none' })
if(ret.resp_code==11){ maInfo.value = {}
uni.showToast({ title: '扫码失败', icon: 'none' }) }
} if (ret.resp_code == 11) {
if(ret.resp_code==1000){ uni.showToast({ title: '扫码失败', icon: 'none' })
// uni.showToast({ title: '', icon: 'none' }) }
qrCode.value = ret.resp_result; if (ret.resp_code == 1000) {
codeToBack() // uni.showToast({ title: '', icon: 'none' })
} qrCode.value = ret.resp_result
}) codeToBack()
}
},
)
} }
// //
const codeToBack = async () => { const codeToBack = async () => {
if(qrCode.value==""){ if (qrCode.value == '') {
uni.showToast({ title: '扫码识别失败', icon: 'none'}) uni.showToast({ title: '扫码识别失败', icon: 'none' })
}else{ } else {
let param = { let param = {
qrCode: qrCode.value qrCode: qrCode.value,
} }
// //
const res = await getMachineByQrCodeApi(param) const res = await getMachineByQrCodeApi(param)
console.log(res) console.log(res)
if(res.code==200){ if (res.code == 200) {
if(res.data.length>0){ if (res.data.length > 0) {
maInfo.value = res.data[0] maInfo.value = res.data[0]
console.log('22222222',maInfo.value) console.log('22222222', maInfo.value)
}else{ } else {
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none'}) uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none' })
} }
}else{ } else {
uni.showToast({ title: res.data.msg, icon: 'none'}) uni.showToast({ title: res.data.msg, icon: 'none' })
} }
} }
}
const changeRadio = (e) => {
console.log(e.detail.value)
apDetection.value = e.detail.value
} }
// //
const submitCode = () => { const submitCode = () => {
if(maInfo.value.agreementId==undefined){ if (maInfo.value.agreementId == undefined) {
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==""){ } else if (phone.value == '') {
uni.showToast({ title: "请确认联系电话!", icon: 'none' }) uni.showToast({ title: '请确认联系电话!', icon: 'none' })
}else{ } else {
let info = { let info = {
agreementId:maInfo.value.agreementId, agreementId: maInfo.value.agreementId,
backPerson:backPerson.value, backPerson: backPerson.value,
phone:phone.value, phone: phone.value,
proId:maInfo.value.proId, proId: maInfo.value.proId,
unitId:maInfo.value.unitId unitId: maInfo.value.unitId,
} }
let detail = [{ let detail = [
"maId":maInfo.value.maId, {
"maCode":maInfo.value.maCode, maId: maInfo.value.maId,
"typeId":maInfo.value.typeId, maCode: maInfo.value.maCode,
"apDetection":apDetection.value, typeId: maInfo.value.typeId,
"bmFileInfos":bmFileInfos.value, apDetection: apDetection.value,
"preNum":1, bmFileInfos: bmFileInfos.value,
}] preNum: 1,
let param = { },
"backApplyInfo":info, ]
"backApplyDetailsList":detail let param = {
} backApplyInfo: info,
insertBack(param).then(res => { backApplyDetailsList: detail,
console.log(res) }
if(res.code==200){ insertBack(param)
uni.showToast({ title: '新增成功', icon: 'none' }) .then((res) => {
uni.navigateBack({ console.log(res)
delta: 1 // if (res.code == 200) {
}); uni.showToast({ title: '新增成功', icon: 'none' })
}else{ uni.navigateBack({
uni.showToast({ title: res.msg, icon: 'none' }) delta: 1, //
} })
}).catch(error => { } else {
console.log(error) uni.showToast({ title: res.msg, icon: 'none' })
}) }
} })
.catch((error) => {
console.log(error)
})
}
} }
// //
const uploadImg = () => { const uploadImg = () => {
uni.chooseImage({ uni.chooseImage({
count: 1, // count: 1, //
sizeType: ['original', 'compressed'], //original compressed sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera',], //album camera 使 sourceType: ['album', 'camera'], //album camera 使
success: res => { success: (res) => {
console.log(res) console.log(res)
let imgFiles = res.tempFilePaths // let imgFiles = res.tempFilePaths //
imgBeseUrl.value = imgFiles[0] imgBeseUrl.value = imgFiles[0]
// console.log('', imgFiles) // console.log('', imgFiles)
// console.log('', baseURL+"/file/upload") // console.log('', baseURL+"/file/upload")
uni.uploadFile({ uni.uploadFile({
// url: baseURL+"/file/upload",//app // url: baseURL+"/file/upload",//app
url: "/file/upload",//h5 url: '/file/upload', //h5
filePath: imgFiles[0], filePath: imgFiles[0],
name: 'file', name: 'file',
success: (res) => { success: (res) => {
res = JSON.parse(res.data) res = JSON.parse(res.data)
console.log('上传成功', res.code); console.log('上传成功', res.code)
console.log('上传成功', res.data); console.log('上传成功', res.data)
if(res.code&&res.code==200){ if (res.code && res.code == 200) {
let obj = { let obj = {
"name":res.data.name, name: res.data.name,
"url":res.data.url, url: res.data.url,
"taskType":"10" taskType: '10',
} }
// console.log(obj) // console.log(obj)
bmFileInfos.value = [obj] bmFileInfos.value = [obj]
uni.showToast({ title: '上传成功', icon: 'none' }) uni.showToast({ title: '上传成功', icon: 'none' })
}else{ } else {
bmFileInfos.value = [] bmFileInfos.value = []
uni.showToast({ title: '上传失败', icon: 'none' }) uni.showToast({ title: '上传失败', icon: 'none' })
} }
}, },
fail: (err) => { fail: (err) => {
console.error('上传失败', err); console.error('上传失败', err)
} },
}); })
// this.$refs.vForm.clearValidate() // this.$refs.vForm.clearValidate()
} },
}) })
} }
onLoad((options)=>{ onLoad((options) => {
console.log(options) console.log(options)
}) })
</script> </script>
<style lang="scss"> <style lang="scss" scoped>
::v-deep .uni-radio-input {
width: 16px;
height: 16px;
}
.accept { .accept {
padding: 24rpx; padding: 24rpx;
height: 95vh; height: 95vh;