This commit is contained in:
gtz 2022-08-16 16:55:59 +08:00
parent a551d6e61b
commit 4685447c1e
5 changed files with 109 additions and 58 deletions

View File

@ -62,6 +62,15 @@ export const itemList = data => {
}) })
} }
// 获取设备巡检项目列表
export const eqItemList = data => {
return request({
url: '/api/equipment/inspectionItem/list-WithEQ',
method: 'POST',
data
})
}
// 获取设备信息 // 获取设备信息
export const getEqInfo = data => { export const getEqInfo = data => {
return request({ return request({

View File

@ -53,10 +53,10 @@ export const eqList = data => {
}) })
} }
// 获取批次列表 // 获取物料列表
export const batchList = data => { export const materialList = data => {
return request({ return request({
url: '/api/material/material-date/list', url: '/api/basic/material/page',
method: 'POST', method: 'POST',
data data
}) })

View File

@ -180,7 +180,7 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import { detail, eqList, itemList, getInsList, updateInsStatus, add, update } from '@/api/eqInspection' import { detail, eqList, itemList, eqItemList, getInsList, updateInsStatus, add, update } from '@/api/eqInspection'
import { uploadFile, downloadFile } from '@/api/file' import { uploadFile, downloadFile } from '@/api/file'
import { blobToBase64 } from '@/util/utils' import { blobToBase64 } from '@/util/utils'
import shortLine from '@/components/shortLine.vue' import shortLine from '@/components/shortLine.vue'
@ -206,6 +206,7 @@ export default {
itemList: [] itemList: []
}, },
itemList: [], itemList: [],
eqItemList: [],
itemObj: {}, itemObj: {},
itemShow: null, itemShow: null,
insList: [], insList: [],
@ -233,6 +234,7 @@ export default {
this.getEqList() this.getEqList()
if (!(this.$route.query.id)) { if (!(this.$route.query.id)) {
this.getItemList() this.getItemList()
this.getEqItemList()
} }
}, },
methods: { methods: {
@ -269,6 +271,19 @@ export default {
}) })
} }
}, },
//
async getEqItemList () {
const result = await eqItemList({
current: 1,
size: 999,
equipmentId: this.$route.query.equipmentId
})
if (result.success) {
this.eqItemList = result.data.map(item => {
return item.itemId
})
}
},
// //
async getDetail () { async getDetail () {
this.eqId = this.$route.query.id this.eqId = this.$route.query.id
@ -377,6 +392,7 @@ export default {
if (this.$route.query.id) { if (this.$route.query.id) {
result = await update(this.dataForm) result = await update(this.dataForm)
} else { } else {
this.dataForm.itemList = this.dataForm.itemList.concat(this.eqItemList)
result = await add(this.dataForm) result = await add(this.dataForm)
} }
if (result.success) { if (result.success) {

View File

@ -9,7 +9,7 @@
<template> <template>
<van-popup v-model="show" position="bottom" class="eqPopup"> <van-popup v-model="show" position="bottom" class="eqPopup">
<van-picker <van-picker
title="选择批次" title="选择物料"
show-toolbar show-toolbar
:columns="showList" :columns="showList"
@confirm="onConfirm" @confirm="onConfirm"
@ -23,7 +23,7 @@
export default { export default {
name: 'eqPopup', name: 'eqPopup',
props: { props: {
batchList: { materialList: {
type: Array, type: Array,
default: () => [] default: () => []
} }
@ -35,7 +35,7 @@ export default {
}, },
computed: { computed: {
showList: function () { showList: function () {
return this.batchList.map(item => { return this.materialList.map(item => {
return item.name return item.name
}) })
} }
@ -45,7 +45,7 @@ export default {
this.show = true this.show = true
}, },
onConfirm (val, index) { onConfirm (val, index) {
this.$emit('changeBatch', index) this.$emit('changeMaterial', index)
this.show = false this.show = false
}, },
onCancel () { onCancel () {

View File

@ -21,7 +21,7 @@
</van-sticky> </van-sticky>
<div class="eq-edit-main"> <div class="eq-edit-main">
<div class="eq-main-item"> <div class="eq-main-item">
<van-row class="eq-field-item"> <!-- <van-row class="eq-field-item">
<van-col :span="7" class="eq-field-item-lable"> <van-col :span="7" class="eq-field-item-lable">
<short-line /> <short-line />
批次 批次
@ -36,23 +36,7 @@
right-icon="arrow-down" right-icon="arrow-down"
/> />
</van-col> </van-col>
</van-row> </van-row> -->
<van-row class="eq-field-item">
<van-col :span="7" class="eq-field-item-lable">
<short-line />
换料时间
</van-col>
<van-col :span="15" :offset="1" class="eq-field-item-input">
<van-field
v-model="dataForm.replaceTime"
disabled
class="canInput"
placeholder="请选择换料时间"
@click="handleDate"
right-icon="arrow-down"
/>
</van-col>
</van-row>
<van-row class="eq-field-item"> <van-row class="eq-field-item">
<van-col :span="7" class="eq-field-item-lable"> <van-col :span="7" class="eq-field-item-lable">
<short-line /> <short-line />
@ -61,8 +45,11 @@
<van-col :span="15" :offset="1" class="eq-field-item-input"> <van-col :span="15" :offset="1" class="eq-field-item-input">
<van-field <van-field
v-model="dataForm.materialName" v-model="dataForm.materialName"
class="canInput"
disabled disabled
placeholder="请选择批次" placeholder="请选择物料"
@click="handleSelectMaterial"
right-icon="arrow-down"
/> />
</van-col> </van-col>
</van-row> </van-row>
@ -75,7 +62,36 @@
<van-field <van-field
v-model="dataForm.materialCode" v-model="dataForm.materialCode"
disabled disabled
placeholder="请选择批次" placeholder="请选择物料"
/>
</van-col>
</van-row>
<van-row class="eq-field-item">
<van-col :span="7" class="eq-field-item-lable">
<short-line />
数量
</van-col>
<van-col :span="15" :offset="1" class="eq-field-item-input">
<van-field
v-model="dataForm.num"
type="number"
placeholder="请输入数量"
/>
</van-col>
</van-row>
<van-row class="eq-field-item">
<van-col :span="7" class="eq-field-item-lable">
<short-line />
换料时间
</van-col>
<van-col :span="15" :offset="1" class="eq-field-item-input">
<van-field
v-model="formatTime"
disabled
class="canInput"
placeholder="请选择换料时间"
@click="handleDate"
right-icon="arrow-down"
/> />
</van-col> </van-col>
</van-row> </van-row>
@ -165,7 +181,7 @@
/> />
</van-popup> </van-popup>
<material-popup ref="eqPopup" :eq-list="eqList" @changeEq="changeEq" /> <material-popup ref="eqPopup" :eq-list="eqList" @changeEq="changeEq" />
<material-popup-batch ref="batchPopup" :batch-list="batchList" @changeBatch="changeBatch" /> <material-popup-material ref="materialPopup" :material-list="materialList" @changeMaterial="changeMaterial" />
<material-popup-worker ref="workerPopup" :worker-list="workerList" @changeWorker="changeWorker" /> <material-popup-worker ref="workerPopup" :worker-list="workerList" @changeWorker="changeWorker" />
<material-popup-source ref="sourcePopup" :source-list="sourceList" @changeSource="changeSource" /> <material-popup-source ref="sourcePopup" :source-list="sourceList" @changeSource="changeSource" />
</div> </div>
@ -173,39 +189,41 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import { detail, eqList, batchList, workerList, materialInfo, add, update } from '@/api/material' import { detail, eqList, materialList, workerList, add, update } from '@/api/material'
import shortLine from '@/components/shortLine.vue' import shortLine from '@/components/shortLine.vue'
import materialPopup from './components/materialPopup' import materialPopup from './components/materialPopup'
import materialPopupBatch from './components/materialPopup-batch' import materialPopupMaterial from './components/materialPopup-material'
import materialPopupWorker from './components/materialPopup-worker' import materialPopupWorker from './components/materialPopup-worker'
import materialPopupSource from './components/materialPopup-source' import materialPopupSource from './components/materialPopup-source'
import { Toast } from 'vant' import { Toast } from 'vant'
export default { export default {
name: 'materialEdit', name: 'materialEdit',
components: { shortLine, materialPopup, materialPopupBatch, materialPopupWorker, materialPopupSource }, components: { shortLine, materialPopup, materialPopupMaterial, materialPopupWorker, materialPopupSource },
data () { data () {
return { return {
eqList: [], eqList: [],
batchList: [], materialList: [],
workerList: [], workerList: [],
sourceList: ['手动', 'PDA'], sourceList: ['手动', 'PDA'],
dataForm: { dataForm: {
id: null, id: null,
equipmentId: null, equipmentId: null,
equipmentName: null, equipmentName: null,
materialDateId: null, // materialDateId: null,
materialDateName: null, // materialDateName: null,
materialDateCode: null, // materialDateCode: null,
materialId: null, materialId: null,
materialName: null, materialName: null,
materialCode: null, materialCode: null,
replaceTime: null, replaceTime: null,
operator: null, operator: null,
num: null,
source: 'PDA', source: 'PDA',
remark: null remark: null
}, },
minDate: new Date(2020, 0, 1), minDate: new Date(2020, 0, 1),
formatTime: null,
showDate: false, showDate: false,
currentDate: null currentDate: null
} }
@ -230,9 +248,9 @@ export default {
if (resultEq.success) { if (resultEq.success) {
this.eqList = resultEq.data this.eqList = resultEq.data
} }
const resultBatch = await batchList(listQuery) const resultMaterial = await materialList(listQuery)
if (resultBatch.success) { if (resultMaterial.success) {
this.batchList = resultBatch.data this.materialList = resultMaterial.data.records
} }
const resultWorker = await workerList(listQuery) const resultWorker = await workerList(listQuery)
if (resultWorker.success) { if (resultWorker.success) {
@ -252,11 +270,13 @@ export default {
}) })
if (result.success) { if (result.success) {
this.dataForm = result.data this.dataForm = result.data
this.formatTime = moment(result.data.replaceTime).format('YYYY-MM-DD HH:mm:ss')
} }
}, },
// //
setDate (v) { setDate (v) {
this.dataForm.replaceTime = moment(v).format('YYYY-MM-DDTHH:mm:ss') this.dataForm.replaceTime = moment(v).format('YYYY-MM-DDTHH:mm:ss')
this.formatTime = moment(v).format('YYYY-MM-DD HH:mm:ss')
this.showDate = false this.showDate = false
}, },
// //
@ -273,22 +293,26 @@ export default {
this.$refs.eqPopup.init(this.dataForm.equipmentName) this.$refs.eqPopup.init(this.dataForm.equipmentName)
}, },
// //
async changeBatch (index) { async changeMaterial (index) {
const result = await materialInfo({ console.log()
externalCode: this.batchList[index].code this.dataForm.materialName = this.materialList[index].name
}) this.dataForm.materialCode = this.materialList[index].code
if (result.success) { this.dataForm.materialId = this.materialList[index].id
this.dataForm.materialDateId = result.data.id // const result = await materialInfo({
this.dataForm.materialDateName = result.data.name // externalCode: this.materialList[index].code
this.dataForm.materialDateCode = result.data.code // })
this.dataForm.materialName = result.data.materialName // if (result.success) {
this.dataForm.materialCode = result.data.materialCode // // this.dataForm.materialDateId = result.data.id
this.dataForm.materialId = result.data.materialId // // this.dataForm.materialDateName = result.data.name
} // // this.dataForm.materialDateCode = result.data.code
// this.dataForm.materialName = result.data.materialName
// this.dataForm.materialCode = result.data.materialCode
// this.dataForm.materialId = result.data.materialId
// }
}, },
// //
handleSelectBatch () { handleSelectMaterial () {
this.$refs.batchPopup.init(this.dataForm.materialDateName) this.$refs.materialPopup.init(this.dataForm.materialName)
}, },
// //
changeWorker (val) { changeWorker (val) {
@ -306,7 +330,7 @@ export default {
}, },
// //
async handleSubmit () { async handleSubmit () {
if (this.dataForm.replaceTime && this.dataForm.materialDateCode && this.dataForm.equipmentId) { if (this.dataForm.replaceTime && this.dataForm.materialId && this.dataForm.equipmentId) {
let result = {} let result = {}
if (this.$route.query.id) { if (this.$route.query.id) {
result = await update(this.dataForm) result = await update(this.dataForm)
@ -324,25 +348,27 @@ export default {
}) })
} }
} else { } else {
this.$notify('批次号、设备、换料时间必须选择!') this.$notify('物料、设备、换料时间必须选择!')
} }
}, },
// //
resetForm () { resetForm () {
const id = this.dataForm.id const id = this.dataForm.id
this.formatTime = null
this.dataForm = { this.dataForm = {
id, id,
equipmentId: null, equipmentId: null,
equipmentName: null, equipmentName: null,
materialDateId: null, // materialDateId: null,
materialDateName: null, // materialDateName: null,
materialDateCode: null, // materialDateCode: null,
materialId: null, materialId: null,
materialName: null, materialName: null,
materialCode: null, materialCode: null,
replaceTime: null, replaceTime: null,
operator: null, operator: null,
source: 'PDA', source: 'PDA',
num: null,
remark: null remark: null
} }
} }