维修-报废原因下拉,与默认维修人设置

This commit is contained in:
bb_pan 2025-02-11 17:08:21 +08:00
parent bd255a7012
commit 6eb97747c1
2 changed files with 326 additions and 258 deletions

View File

@ -21,26 +21,22 @@
</uni-col>
</uni-row>
</view>
<uni-row :gutter="24" class="search-form" style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px">
<uni-row
:gutter="24"
class="search-form"
style="background: #fff; padding: 10px; margin: 5px; border-radius: 5px"
>
<uni-col :span="6">
<view class="btnBox internal" @click="changeTab(1)">
内部维修
</view>
<view class="btnBox internal" @click="changeTab(1)"> 内部维修 </view>
</uni-col>
<uni-col :span="6">
<view class="btnBox return" @click="changeTab(2)">
返厂维修
</view>
<view class="btnBox return" @click="changeTab(2)"> 返厂维修 </view>
</uni-col>
<uni-col :span="6">
<view class="btnBox scrap" @click="changeTab(3)">
待报废
</view>
<view class="btnBox scrap" @click="changeTab(3)"> 待报废 </view>
</uni-col>
<uni-col :span="6">
<view class="btnBox complete" @click="saveCode">
维修完成
</view>
<view class="btnBox complete" @click="saveCode"> 维修完成 </view>
</uni-col>
</uni-row>
<scroll-view scroll-y style="padding-bottom: 20rpx">
@ -50,15 +46,23 @@
<h2 style="padding: 4rpx 0; font-weight: bold">维修信息</h2>
<uni-forms ref="baseForm" label-align="right">
<uni-forms-item label="维修人员">
<uni-data-select :localdata="repairPersonData" v-model="repairPerson" placeholder="请选择维修人员" />
<uni-data-select
:localdata="repairPersonData"
v-model="repairPerson"
placeholder="请选择维修人员"
/>
</uni-forms-item>
<uni-forms-item label="备注">
<uni-easyinput placeholder="请填写备注" maxlength="50" v-model="remark"/>
<uni-easyinput placeholder="请填写备注" maxlength="50" v-model="remark" />
</uni-forms-item>
<uni-forms-item label="附件">
<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>
<image
:src="imgBeseUrl"
style="width: 160rpx; height: 160rpx"
mode=""
></image>
</div>
</uni-forms-item>
</uni-forms>
@ -73,8 +77,15 @@
</uni-forms-item> -->
<div v-for="(item, index) in partItems" :key="index">
<uni-forms-item label="配件类型">
<treeSelect style="width: 100%;height: 90rpx;" ref="treeSelectRef"
:options="partTreeData" @change="partTreeChange" :index="index" @clear="clearPart" :defaultProps="defaultProps"></treeSelect>
<treeSelect
style="width: 100%; height: 90rpx"
ref="treeSelectRef"
:options="partTreeData"
@change="partTreeChange"
:index="index"
@clear="clearPart"
:defaultProps="defaultProps"
></treeSelect>
</uni-forms-item>
<uni-forms-item label="配件数量">
<uni-easyinput
@ -91,7 +102,7 @@
:localdata="isChargeList"
v-model="item.partType"
placeholder="请选择是否收费"
:clear="false"
:clear="false"
/>
<div class="operation-btns">
<span class="add" @click="addPart">+</span>
@ -126,7 +137,7 @@
<uni-data-select
:localdata="isChargeList"
v-model="item.partType"
:clearable="false"
:clearable="false"
placeholder="请选择是否收费"
/>
</uni-forms-item>
@ -166,14 +177,21 @@
<uni-easyinput placeholder="请填写报废数量" v-model="formRight.scrapNum"/>
</uni-forms-item> -->
<uni-forms-item label="报废原因">
<uni-easyinput
<!-- <uni-easyinput
placeholder="请填写报废原因"
v-model="formRight.scrapReason"
/> -->
<uni-data-select
:clearable="false"
:localdata="scrapReasonList"
v-model="formRight.scrapId"
placeholder="请选择报废原因"
@change="changeScrap"
/>
</uni-forms-item>
<uni-forms-item label="损坏原因">
<uni-data-select
:clearable="false"
:clearable="false"
:localdata="damageReasonList"
v-model="formRight.scrapType"
placeholder="请选择损坏原因"
@ -183,9 +201,13 @@
<uni-easyinput placeholder="请填写其他原因" />
</uni-forms-item> -->
<uni-forms-item label="附件">
<div class="upload" @click="uploadScrapImg" v-if="imgBeseUrl2==''">+</div>
<div class="upload" @click="uploadScrapImg" v-if="imgBeseUrl2 == ''">+</div>
<div class="upload" @click="uploadScrapImg" v-else>
<image :src="imgBeseUrl2" style="width: 160rpx;height: 160rpx;" mode=""></image>
<image
:src="imgBeseUrl2"
style="width: 160rpx; height: 160rpx"
mode=""
></image>
</div>
</uni-forms-item>
</uni-forms>
@ -195,18 +217,25 @@
</template>
<script setup>
import { computed, ref } from 'vue'
import { partTypeTreeList, getSupplierList, getRepairerListApi,saveRepairRow } from '@/services/repair/repair.js'
import { computed, ref, reactive } from 'vue'
import {
partTypeTreeList,
getSupplierList,
getRepairerListApi,
saveRepairRow,
getScrapReasonList,
} from '@/services/repair/repair.js'
import { baseURL } from '@/utils/http'
import treeSelect from '../tree-select/tselect.vue';
import treeSelect from '../tree-select/tselect.vue'
import { onLoad } from '@dcloudio/uni-app'
const queryParams = ref({})
const rowIndex = ref(-1)
onLoad((options) => {
console.log(options)
console.log(options)
queryParams.value = JSON.parse(options.queryParams)
rowIndex.value = options.rowIndex;
console.log(queryParams.value)
rowIndex.value = options.rowIndex
console.log(queryParams.value)
getScrapReasonListData()
})
const repairType = ref(1)
const changeTab = async (e) => {
@ -221,12 +250,40 @@ const isChargeList = ref([
{ value: 0, text: '否' },
])
const { userInfo } = JSON.parse(uni.getStorageSync('member'))
// console.log('🚀 ~ userInfo:', userInfo)
//
const scrapReasonList = ref([])
const getScrapReasonListData = async () => {
const params = {
typeId: queryParams.value.typeId,
}
const res = await getScrapReasonList(params)
scrapReasonList.value = res.data.map((item) => {
let obj = {
value: item.id,
text: item.reason,
}
return obj
})
console.log('🚀 ~ 报废原因下拉 ~ res:', res)
}
// change
const changeScrap = (val) => {
console.log('🚀 ~ changeScrap ~ val:', val)
const scrapReason = scrapReasonList.value.find((v) => v.value === val)
console.log('🚀 ~ changeScrap ~ scrapReason:', scrapReason)
formRight.value.scrapReason = scrapReason.text
}
//
const repairPersonData = ref([])
const repairPerson = ref("")
const repairPerson = ref('')
const getRepairerListData = async () => {
const res = await getRepairerListApi({})
console.log(res)
console.log(res)
repairPersonData.value = res.data.map((item) => {
let obj = {
value: item.userId,
@ -234,91 +291,100 @@ const getRepairerListData = async () => {
}
return obj
})
// userInfo.userId repairPersonData.value ,
if (
repairPersonData.value &&
repairPersonData.value.findIndex((v) => v.value === userInfo.userId) > -1
) {
repairPerson.value = userInfo.userId
} else {
repairPerson.value = repairPersonData.value[0].value
}
}
getRepairerListData()
const remark = ref("") //
const remark = ref('') //
const imgBeseUrl = ref("") //
const bmFileInfos = ref([])//
const imgBeseUrl = ref('') //
const bmFileInfos = ref([]) //
//
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('', 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);
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('', 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)
if(res.code&&res.code==200){
let obj = {
"name":res.data.name,
"url":res.data.url
}
bmFileInfos.value = [obj]
console.log('上传成功', bmFileInfos.value);
uni.showToast({ title: '上传成功', icon: 'none' })
}else{
bmFileInfos.value = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err);
}
});
}
})
if (res.code && res.code == 200) {
let obj = {
name: res.data.name,
url: res.data.url,
}
bmFileInfos.value = [obj]
console.log('上传成功', bmFileInfos.value)
uni.showToast({ title: '上传成功', icon: 'none' })
} else {
bmFileInfos.value = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err)
},
})
},
})
}
//
const partTreeData = ref([])
const defaultProps = ref({
id: 'id',
children: 'children',
label: 'label'
id: 'id',
children: 'children',
label: 'label',
})
const getPartTreeData = async () => {
const res = await partTypeTreeList({})
partTreeData.value = res.data;
partTreeData.value = res.data
}
getPartTreeData()
const treeSelectRef = ref([])
const clearPart = (index) =>{
partItems.value[index].partId=""
const clearPart = (index) => {
partItems.value[index].partId = ''
}
const partTreeChange = (val,index) =>{
const isHas = partItems.value.findIndex(v => v.partId === val.id)
if (isHas > -1) {//
console.log(isHas)
uni.showToast({ title: '已存在该配件类型', icon: 'none' })
treeSelectRef.value[index].clearInput();
partItems.value[index].partId="";
partItems.value[index].storageNum="";
partItems.value[index].partNum=0;
}else{
partItems.value[index].partId=val.id;
partItems.value[index].storageNum=val.storageNum;
partItems.value[index].partNum=0;
}
const partTreeChange = (val, index) => {
const isHas = partItems.value.findIndex((v) => v.partId === val.id)
if (isHas > -1) {
//
console.log(isHas)
uni.showToast({ title: '已存在该配件类型', icon: 'none' })
treeSelectRef.value[index].clearInput()
partItems.value[index].partId = ''
partItems.value[index].storageNum = ''
partItems.value[index].partNum = 0
} else {
partItems.value[index].partId = val.id
partItems.value[index].storageNum = val.storageNum
partItems.value[index].partNum = 0
}
}
//
const partItems = ref([{ partNum: '', partType: 0, partId: '', storageNum: ''}])
const partItems = ref([{ partNum: '', partType: 0, partId: '', storageNum: '' }])
const addPart = () => {
partItems.value.push({ partNum: '', partType: 0, partId: '' ,storageNum: ''})
partItems.value.push({ partNum: '', partType: 0, partId: '', storageNum: '' })
}
const delPart = (index) => {
if (partItems.value.length > 1) {
@ -330,7 +396,6 @@ const formLeft = ref({
// repairNum:0
})
//
const partsMillList = ref([])
const getSupplierListData = async () => {
@ -369,49 +434,50 @@ const formMiddle = ref({
//
const formRight = ref({
// scrapNum:0,
scrapType:0,
scrapReason: '',
fileList:[]
scrapType: 0,
scrapId: null, // id
scrapReason: '', //
fileList: [],
})
const imgBeseUrl2 = ref("") //
const imgBeseUrl2 = ref('') //
//
const uploadScrapImg = () => {
uni.chooseImage({
count: 1, //
sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera',], //album camera 使
success: res => {
console.log(res)
let imgFiles = res.tempFilePaths //
imgBeseUrl2.value = imgFiles[0]
// 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);
count: 1, //
sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera'], //album camera 使
success: (res) => {
console.log(res)
let imgFiles = res.tempFilePaths //
imgBeseUrl2.value = imgFiles[0]
// 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)
if(res.code&&res.code==200){
let obj = {
"name":res.data.name,
"url":res.data.url
}
formRight.value.fileList = [obj]
uni.showToast({ title: '上传成功', icon: 'none' })
}else{
formRight.value.fileList = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err);
}
});
}
})
if (res.code && res.code == 200) {
let obj = {
name: res.data.name,
url: res.data.url,
}
formRight.value.fileList = [obj]
uni.showToast({ title: '上传成功', icon: 'none' })
} else {
formRight.value.fileList = []
uni.showToast({ title: '上传失败', icon: 'none' })
}
},
fail: (err) => {
console.error('上传失败', err)
},
})
},
})
}
const rowData = ref({})
@ -421,13 +487,13 @@ const partCheckNum = (item) => {
// console.log(item.partNum)
setTimeout(() => {
item.partNum = Number(String(item.partNum).replace(/[^\d.]/g, ''))
if(item.storageNum){
// console.log(item.partNum)
// console.log(item.storageNum)
if(Number(item.partNum)>=Number(item.storageNum)){
item.partNum=Number(item.storageNum)
}
}
if (item.storageNum) {
// console.log(item.partNum)
// console.log(item.storageNum)
if (Number(item.partNum) >= Number(item.storageNum)) {
item.partNum = Number(item.storageNum)
}
}
}, 500)
}
// change
@ -440,126 +506,119 @@ const costCheckNum = (item) => {
}
//
const saveCode = () => {
if(repairType.value == 1){
let index1=partItems.value.findIndex(v=>v.partId=="")
let index2=partItems.value.findIndex(v=>v.partNum==0)
if(repairPerson.value==""){
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
}else if(index1>-1){
uni.showToast({ title: '请先选择配件类型!', icon: 'none' })
}else if(index2>-1){
uni.showToast({ title: '请填写配件数量!', icon: 'none' })
}else{
saveCodeApi()
}
}else if(repairType.value == 2){
let index1=partItemsMiddle.value.findIndex(v=>v.partName=="")
let index2=partItemsMiddle.value.findIndex(v=>v.supplierId=="")
let index3=partItemsMiddle.value.findIndex(v=>v.partNum==0)
if(repairPerson.value==""){
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
}else if(index1>-1){
uni.showToast({ title: '请先填写配件名称!', icon: 'none' })
}else if(index2>-1){
uni.showToast({ title: '请选择物资厂家!', icon: 'none' })
}else if(index3>-1){
uni.showToast({ title: '请填写配件数量!', icon: 'none' })
}else{
saveCodeApi()
}
}else if(repairType.value == 3){
console.log(formRight.value)
//formRight.value
if(repairPerson.value==""){
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
}else if(formRight.value.scrapReason==""){
uni.showToast({ title: '请先填写报废原因', icon: 'none' })
}else{
saveCodeApi()
}
}
if (repairType.value == 1) {
let index1 = partItems.value.findIndex((v) => v.partId == '')
let index2 = partItems.value.findIndex((v) => v.partNum == 0)
if (repairPerson.value == '') {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
} else if (index1 > -1) {
uni.showToast({ title: '请先选择配件类型!', icon: 'none' })
} else if (index2 > -1) {
uni.showToast({ title: '请填写配件数量!', icon: 'none' })
} else {
saveCodeApi()
}
} else if (repairType.value == 2) {
let index1 = partItemsMiddle.value.findIndex((v) => v.partName == '')
let index2 = partItemsMiddle.value.findIndex((v) => v.supplierId == '')
let index3 = partItemsMiddle.value.findIndex((v) => v.partNum == 0)
if (repairPerson.value == '') {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
} else if (index1 > -1) {
uni.showToast({ title: '请先填写配件名称!', icon: 'none' })
} else if (index2 > -1) {
uni.showToast({ title: '请选择物资厂家!', icon: 'none' })
} else if (index3 > -1) {
uni.showToast({ title: '请填写配件数量!', icon: 'none' })
} else {
saveCodeApi()
}
} else if (repairType.value == 3) {
console.log(formRight.value)
if (repairPerson.value == '') {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
} else if (formRight.value.scrapReason == '') {
uni.showToast({ title: '请选择报废原因', icon: 'none' })
} else {
saveCodeApi()
}
}
}
//
const saveCodeApi = async () => {
console.log("维修完成请求")
//
rowData.value = queryParams.value;
//
rowData.value.repairDeviceList[rowIndex.value].repairList=[
{
repairer:repairPerson.value,
remark:remark.value,
fileList:bmFileInfos.value
}
]
if (repairType.value == 1) {
for (let i = 0; i < partItems.value.length; i++) {
rowData.value.repairDeviceList[rowIndex.value].codeInRepairPartList.push({
partType: partItems.value[i].partType,
partId: partItems.value[i].partId,
partNum: partItems.value[i].partNum,
storageNum: partItems.value[i].storageNum,
// repairNum: formLeft.value.repairNum,
})
}
} else if (repairType.value == 2) {
for (let i = 0; i < partItemsMiddle.value.length; i++) {
rowData.value.repairDeviceList[rowIndex.value].codeOutRepairPartList.push({
partType: partItemsMiddle.value[i].partType,
partPrice: partItemsMiddle.value[i].partPrice,
partNum: partItemsMiddle.value[i].partNum,
partName: partItemsMiddle.value[i].partName,
supplierId: partItemsMiddle.value[i].supplierId,
// repairNum: formMiddle.value.repairNum,
})
}
} else if (repairType.value == 3) {
rowData.value.repairDeviceList[rowIndex.value].codeScrapRepairPartList.push(formRight.value)
}
rowData.value.repairDeviceList[rowIndex.value].repairType = repairType.value;
console.log(rowData.value.repairDeviceList)
saveRepairRow(rowData.value.repairDeviceList).then(async (response) => {
if (response.code == 200) {
uni.showToast({ title: '保存成功', icon: 'none' })
uni.navigateBack({
delta: 2, //
})
}
})
//
rowData.value = queryParams.value
//
rowData.value.repairDeviceList[rowIndex.value].repairList = [
{
repairer: repairPerson.value,
remark: remark.value,
fileList: bmFileInfos.value,
},
]
if (repairType.value == 1) {
for (let i = 0; i < partItems.value.length; i++) {
rowData.value.repairDeviceList[rowIndex.value].codeInRepairPartList.push({
partType: partItems.value[i].partType,
partId: partItems.value[i].partId,
partNum: partItems.value[i].partNum,
storageNum: partItems.value[i].storageNum,
// repairNum: formLeft.value.repairNum,
})
}
} else if (repairType.value == 2) {
for (let i = 0; i < partItemsMiddle.value.length; i++) {
rowData.value.repairDeviceList[rowIndex.value].codeOutRepairPartList.push({
partType: partItemsMiddle.value[i].partType,
partPrice: partItemsMiddle.value[i].partPrice,
partNum: partItemsMiddle.value[i].partNum,
partName: partItemsMiddle.value[i].partName,
supplierId: partItemsMiddle.value[i].supplierId,
// repairNum: formMiddle.value.repairNum,
})
}
} else if (repairType.value == 3) {
rowData.value.repairDeviceList[rowIndex.value].codeScrapRepairPartList.push(formRight.value)
}
rowData.value.repairDeviceList[rowIndex.value].repairType = repairType.value
console.log(rowData.value.repairDeviceList)
saveRepairRow(rowData.value.repairDeviceList).then(async (response) => {
if (response.code == 200) {
uni.showToast({ title: '保存成功', icon: 'none' })
uni.navigateBack({
delta: 2, //
})
}
})
}
</script>
<style lang="scss" scoped>
//
.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;
&:active {
background-color: #f0f0f0;
border-color: #3784fb;
}
&:active {
background-color: #f0f0f0;
border-color: #3784fb;
}
image {
width: 100%;
height: 100%;
border-radius: 12rpx;
object-fit: cover;
}
image {
width: 100%;
height: 100%;
border-radius: 12rpx;
object-fit: cover;
}
}
.page-container {
display: flex;

View File

@ -104,3 +104,12 @@ export const getDetailsListApi = (data) => {
data,
})
}
// 报废原因
export const getScrapReasonList = (data) => {
return http({
method: 'GET',
url: '/material/scrap_reason/getList',
data,
})
}