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

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,7 +46,11 @@
<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" />
@ -58,7 +58,11 @@
<uni-forms-item label="附件">
<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
@ -166,9 +177,16 @@
<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="损坏原因">
@ -185,7 +203,11 @@
<uni-forms-item label="附件">
<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)
queryParams.value = JSON.parse(options.queryParams)
rowIndex.value = options.rowIndex;
rowIndex.value = options.rowIndex
console.log(queryParams.value)
getScrapReasonListData()
})
const repairType = ref(1)
const changeTab = async (e) => {
@ -221,9 +250,37 @@ 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)
@ -234,40 +291,49 @@ 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 imgBeseUrl = ref('') //
const bmFileInfos = ref([]) //
//
const uploadImg = () => {
uni.chooseImage({
count: 1, //
sizeType: ['original', 'compressed'], //original compressed
sourceType: ['album', 'camera',], //album camera 使
success: res => {
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
url: '/file/upload', //h5
filePath: imgFiles[0],
name: 'file',
success: (res) => {
res = JSON.parse(res.data)
console.log('上传成功', res);
console.log('上传成功', res)
if (res.code && res.code == 200) {
let obj = {
"name":res.data.name,
"url":res.data.url
name: res.data.name,
url: res.data.url,
}
bmFileInfos.value = [obj]
console.log('上传成功', bmFileInfos.value);
console.log('上传成功', bmFileInfos.value)
uni.showToast({ title: '上传成功', icon: 'none' })
} else {
bmFileInfos.value = []
@ -275,10 +341,10 @@ const uploadImg = () => {
}
},
fail: (err) => {
console.error('上传失败', err);
}
});
}
console.error('上传失败', err)
},
})
},
})
}
@ -287,34 +353,34 @@ const partTreeData = ref([])
const defaultProps = ref({
id: 'id',
children: 'children',
label: 'label'
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=""
partItems.value[index].partId = ''
}
const partTreeChange = (val, index) => {
const isHas = partItems.value.findIndex(v => v.partId === val.id)
if (isHas > -1) {//
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;
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;
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 addPart = () => {
@ -330,7 +396,6 @@ const formLeft = ref({
// repairNum:0
})
//
const partsMillList = ref([])
const getSupplierListData = async () => {
@ -370,34 +435,35 @@ const formMiddle = ref({
const formRight = ref({
// scrapNum:0,
scrapType: 0,
scrapReason: '',
fileList:[]
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 => {
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
url: '/file/upload', //h5
filePath: imgFiles[0],
name: 'file',
success: (res) => {
res = JSON.parse(res.data)
console.log('上传成功', res);
console.log('上传成功', res)
if (res.code && res.code == 200) {
let obj = {
"name":res.data.name,
"url":res.data.url
name: res.data.name,
url: res.data.url,
}
formRight.value.fileList = [obj]
uni.showToast({ title: '上传成功', icon: 'none' })
@ -407,10 +473,10 @@ const uploadScrapImg = () => {
}
},
fail: (err) => {
console.error('上传失败', err);
}
});
}
console.error('上传失败', err)
},
})
},
})
}
@ -441,9 +507,9 @@ 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==""){
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' })
@ -453,10 +519,10 @@ const saveCode = () => {
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==""){
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' })
@ -469,29 +535,26 @@ const saveCode = () => {
}
} else if (repairType.value == 3) {
console.log(formRight.value)
//formRight.value
if(repairPerson.value==""){
if (repairPerson.value == '') {
uni.showToast({ title: '请先选择维修人员!', icon: 'none' })
}else if(formRight.value.scrapReason==""){
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 = queryParams.value
//
rowData.value.repairDeviceList[rowIndex.value].repairList = [
{
repairer: repairPerson.value,
remark: remark.value,
fileList:bmFileInfos.value
}
fileList: bmFileInfos.value,
},
]
if (repairType.value == 1) {
for (let i = 0; i < partItems.value.length; i++) {
@ -517,7 +580,7 @@ const saveCodeApi = async () => {
} else if (repairType.value == 3) {
rowData.value.repairDeviceList[rowIndex.value].codeScrapRepairPartList.push(formRight.value)
}
rowData.value.repairDeviceList[rowIndex.value].repairType = repairType.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) {
@ -528,10 +591,6 @@ const saveCodeApi = async () => {
}
})
}
</script>
<style lang="scss" scoped>

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