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

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){
this.show = false;
this.showLabel=e.name;
this.$emit('change', e,index)
this.$emit('change', e)
}
},
clearInput(){

View File

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

View File

@ -5,75 +5,83 @@
<uni-col :span="6">任务创建</uni-col>
<uni-col :span="6">
<view class="coding-btn" @click="codeScan">编码识别</view>
</uni-col>
</uni-col>
<uni-col :span="6">
<view class="coding-btn" @click="codeScan">二维码识别</view>
</uni-col>
</uni-row>
</div>
</div>
<div class="card">
<uni-row :gutter="24" style="display: flex; align-items: center;margin-bottom: 20px;">
<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-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 20px">
<uni-col :span="8">设备编码</uni-col>
<uni-col :span="16">
<uni-easyinput placeholder="请输入内容" v-model="apDetection"/>
{{ maInfo.maCode }}
</uni-col>
</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="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>
<image :src="imgBeseUrl" style="width: 160rpx;height: 160rpx;" mode=""></image>
</div>
<image
:src="imgBeseUrl"
style="width: 160rpx; height: 160rpx"
mode=""
></image>
</div>
</uni-col>
</uni-row>
</div>
@ -86,165 +94,181 @@
<script setup>
import { ref, reactive } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getMachine,insertBack,getMachineByQrCodeApi } from '../../services/back.js';
import { baseURL } from '@/utils/http'
const backPerson = ref("")
const phone = ref("")
const apDetection = ref("") //
const imgBeseUrl = ref("") //
const bmFileInfos = ref([])//
const qrCode = ref("") //
const maInfo = ref({}) //
import { onLoad } from '@dcloudio/uni-app'
import { getMachine, insertBack, getMachineByQrCodeApi } from '../../services/back.js'
import { baseURL } from '@/utils/http'
const backPerson = ref('')
const phone = ref('')
const apDetection = ref('完好') //
const imgBeseUrl = ref('') //
const bmFileInfos = ref([]) //
const qrCode = ref('') //
const maInfo = ref({}) //
//
const codeScan = async () => {
qrCode.value=""
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
mpaasScanModule.mpaasScan({
// qrCodebarCode
'scanType': ['qrCode','barCode'],
// false
'hideAlbum': false,
//ios zh-Hansen
'language' : 'en',
//(ios)
'failedMsg': '未识别到二维码,请重试',
//Android
'screenType': 'full'
},(ret) => {
console.log(ret)
if(ret.resp_code==10){
uni.showToast({ title: '用户取消', icon: 'none' })
maInfo.value = {}
}
if(ret.resp_code==11){
uni.showToast({ title: '扫码失败', icon: 'none' })
}
if(ret.resp_code==1000){
// uni.showToast({ title: '', icon: 'none' })
qrCode.value = ret.resp_result;
codeToBack()
}
})
const codeScan = async () => {
qrCode.value = ''
var mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
mpaasScanModule.mpaasScan(
{
// qrCodebarCode
scanType: ['qrCode', 'barCode'],
// false
hideAlbum: false,
//ios zh-Hansen
language: 'en',
//(ios)
failedMsg: '未识别到二维码,请重试',
//Android
screenType: 'full',
},
(ret) => {
console.log(ret)
if (ret.resp_code == 10) {
uni.showToast({ title: '用户取消', icon: 'none' })
maInfo.value = {}
}
if (ret.resp_code == 11) {
uni.showToast({ title: '扫码失败', icon: 'none' })
}
if (ret.resp_code == 1000) {
// uni.showToast({ title: '', icon: 'none' })
qrCode.value = ret.resp_result
codeToBack()
}
},
)
}
//
const codeToBack = async () => {
if(qrCode.value==""){
uni.showToast({ title: '扫码识别失败', icon: 'none'})
}else{
let param = {
qrCode: qrCode.value
}
//
const res = await getMachineByQrCodeApi(param)
console.log(res)
if(res.code==200){
if(res.data.length>0){
maInfo.value = res.data[0]
console.log('22222222',maInfo.value)
}else{
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none'})
}
}else{
uni.showToast({ title: res.data.msg, icon: 'none'})
}
}
const codeToBack = async () => {
if (qrCode.value == '') {
uni.showToast({ title: '扫码识别失败', icon: 'none' })
} else {
let param = {
qrCode: qrCode.value,
}
//
const res = await getMachineByQrCodeApi(param)
console.log(res)
if (res.code == 200) {
if (res.data.length > 0) {
maInfo.value = res.data[0]
console.log('22222222', maInfo.value)
} else {
uni.showToast({ title: '扫码二维码未绑定设备编码!', icon: 'none' })
}
} else {
uni.showToast({ title: res.data.msg, icon: 'none' })
}
}
}
const changeRadio = (e) => {
console.log(e.detail.value)
apDetection.value = e.detail.value
}
//
const submitCode = () => {
if(maInfo.value.agreementId==undefined){
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,
backPerson:backPerson.value,
phone:phone.value,
proId:maInfo.value.proId,
unitId:maInfo.value.unitId
}
let detail = [{
"maId":maInfo.value.maId,
"maCode":maInfo.value.maCode,
"typeId":maInfo.value.typeId,
"apDetection":apDetection.value,
"bmFileInfos":bmFileInfos.value,
"preNum":1,
}]
let param = {
"backApplyInfo":info,
"backApplyDetailsList":detail
}
insertBack(param).then(res => {
console.log(res)
if(res.code==200){
uni.showToast({ title: '新增成功', icon: 'none' })
uni.navigateBack({
delta: 1 //
});
}else{
uni.showToast({ title: res.msg, icon: 'none' })
}
}).catch(error => {
console.log(error)
})
}
}
if (maInfo.value.agreementId == undefined) {
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,
backPerson: backPerson.value,
phone: phone.value,
proId: maInfo.value.proId,
unitId: maInfo.value.unitId,
}
let detail = [
{
maId: maInfo.value.maId,
maCode: maInfo.value.maCode,
typeId: maInfo.value.typeId,
apDetection: apDetection.value,
bmFileInfos: bmFileInfos.value,
preNum: 1,
},
]
let param = {
backApplyInfo: info,
backApplyDetailsList: detail,
}
insertBack(param)
.then((res) => {
console.log(res)
if (res.code == 200) {
uni.showToast({ title: '新增成功', icon: 'none' })
uni.navigateBack({
delta: 1, //
})
} else {
uni.showToast({ title: res.msg, icon: 'none' })
}
})
.catch((error) => {
console.log(error)
})
}
}
//
const uploadImg = () => {
uni.chooseImage({
count: 1, //
sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera',], //album camera 使
success: res => {
console.log(res)
let imgFiles = res.tempFilePaths //
imgBeseUrl.value = imgFiles[0]
// console.log('', imgFiles)
// console.log('', baseURL+"/file/upload")
uni.uploadFile({
// url: baseURL+"/file/upload",//app
url: "/file/upload",//h5
filePath: imgFiles[0],
name: 'file',
success: (res) => {
res = JSON.parse(res.data)
console.log('上传成功', res.code);
console.log('上传成功', res.data);
if(res.code&&res.code==200){
let obj = {
"name":res.data.name,
"url":res.data.url,
"taskType":"10"
}
// console.log(obj)
bmFileInfos.value = [obj]
uni.showToast({ title: '上传成功', icon: 'none' })
}else{
bmFileInfos.value = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err);
}
});
// this.$refs.vForm.clearValidate()
}
})
count: 1, //
sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera'], //album camera 使
success: (res) => {
console.log(res)
let imgFiles = res.tempFilePaths //
imgBeseUrl.value = imgFiles[0]
// console.log('', imgFiles)
// console.log('', baseURL+"/file/upload")
uni.uploadFile({
// url: baseURL+"/file/upload",//app
url: '/file/upload', //h5
filePath: imgFiles[0],
name: 'file',
success: (res) => {
res = JSON.parse(res.data)
console.log('上传成功', res.code)
console.log('上传成功', res.data)
if (res.code && res.code == 200) {
let obj = {
name: res.data.name,
url: res.data.url,
taskType: '10',
}
// console.log(obj)
bmFileInfos.value = [obj]
uni.showToast({ title: '上传成功', icon: 'none' })
} else {
bmFileInfos.value = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err)
},
})
// this.$refs.vForm.clearValidate()
},
})
}
onLoad((options)=>{
console.log(options)
onLoad((options) => {
console.log(options)
})
</script>
<style lang="scss">
<style lang="scss" scoped>
::v-deep .uni-radio-input {
width: 16px;
height: 16px;
}
.accept {
padding: 24rpx;
height: 95vh;