<template>
|
<el-dialog
|
width="60%"
|
title="下发包装任务"
|
top="15vh"
|
:visible.sync="innerVisible"
|
append-to-body
|
@close="$emit('update:currshowlist', false)"
|
:show="currshowlist"
|
:close-on-click-modal="false"
|
class="establishpackaging-dialog"
|
>
|
<el-form
|
:model="dataForm"
|
:rules="dataRule"
|
ref="dataForm"
|
label-width="80px"
|
class="l-mes"
|
>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="工作站" prop="workstationName">
|
<el-input
|
v-model="dataForm.workstationName"
|
placeholder="工作站"
|
readonly
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openWorkstationDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="库位" prop="locationName">
|
<el-input
|
v-model="dataForm.locationName"
|
placeholder="库位"
|
readonly
|
>
|
<el-button
|
slot="append"
|
icon="el-icon-search"
|
@click="openLocationDialog()"
|
></el-button>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div slot="footer" class="dialog-footer">
|
<el-button @click="innerVisible = false">取 消</el-button>
|
<el-button
|
type="primary"
|
:disabled="isSubmit"
|
v-thinclick="`createPackaging`"
|
>下 发</el-button
|
>
|
</div>
|
<workstationDialog
|
:currshowlist.sync="showWorkstation"
|
@listenToWorkStationEvent="selectWorkstation"
|
/>
|
<locationDialog
|
:currshowlist.sync="showLocation"
|
@listenToLocationEvent="selectLocation"
|
/>
|
</el-dialog>
|
</template>
|
<script>
|
import { addObj } from '@/api/warehouse/splittask'
|
import { fetchList as fetchLocationList } from '@/api/warehouse/location'
|
import workstationDialog from '@/views/common/workstation.vue'
|
import locationDialog from '@/views/common/location.vue'
|
export default {
|
props: {
|
currshowlist: {
|
type: Boolean,
|
default: false
|
},
|
splitTasks: {
|
type: Array,
|
default: () => {
|
return []
|
}
|
}
|
},
|
components: {
|
workstationDialog,
|
locationDialog
|
},
|
data() {
|
return {
|
innerVisible: false,
|
showWorkstation: false,
|
showLocation: false,
|
dataForm: {
|
locationId: null,
|
locationName: null,
|
workstationId: null,
|
workstationName: null
|
},
|
dataRule: {
|
workstationName: [
|
{ required: true, message: '工作站不能为空', trigger: 'blur' }
|
],
|
locationName: [
|
{ required: true, message: '库位不能为空', trigger: 'blur' }
|
]
|
},
|
isSubmit: false
|
}
|
},
|
methods: {
|
// 初始化页面数据
|
initForm() {
|
this.$refs.dataForm.resetFields()
|
this.getDefaultLocation()
|
},
|
// 获取默认的待发货库位
|
getDefaultLocation() {
|
fetchLocationList(
|
Object.assign(
|
{
|
current: 1,
|
size: 20
|
},
|
{ locType: '9' }
|
)
|
).then((res) => {
|
if (res.data.code === 0) {
|
const toBeShippeds = res.data.data.records
|
if ((toBeShippeds != null) & (toBeShippeds.length > 0)) {
|
const toBeShipped = toBeShippeds[0]
|
this.dataForm.locationId = toBeShipped.id
|
this.dataForm.locationName = toBeShipped.locName
|
}
|
}
|
})
|
},
|
// 打开工作站对话框
|
openWorkstationDialog() {
|
this.showWorkstation = true
|
},
|
// 选中工作站
|
selectWorkstation(workstation) {
|
if (workstation) {
|
this.dataForm.workstationId = workstation.id
|
this.dataForm.workstationName = workstation.name
|
}
|
},
|
// 库位弹窗
|
openLocationDialog() {
|
this.showLocation = true
|
},
|
// 选中库位
|
selectLocation(location) {
|
if (location) {
|
this.dataForm.locationId = location.id
|
this.dataForm.locationName = location.locName
|
}
|
},
|
// 下达包装任务
|
createPackaging() {
|
this.isSubmit = true
|
this.$refs.dataForm.validate((valid) => {
|
if (valid) {
|
let splitTask
|
let packaging
|
const packagings = []
|
for (let i = 0; i < this.splitTasks.length; i++) {
|
splitTask = this.splitTasks[i]
|
packaging = {
|
splitTaskId: splitTask.id,
|
stockOrderId: splitTask.stockOrderId,
|
partId: splitTask.partId,
|
number: splitTask.reservedQuantity,
|
outLocationId: splitTask.locationId,
|
inLocationId: this.dataForm.locationId,
|
partBatchNo: splitTask.partBatchNo,
|
workstationId: this.dataForm.workstationId,
|
reelNumber: splitTask.reelNumber,
|
packingManner: '不打圈'
|
}
|
packagings.push(packaging)
|
}
|
addObj(packagings).then((response) => {
|
if (response.data.code === 0) {
|
// const data = response.data.data
|
this.$message.success('下发成功')
|
this.innerVisible = false
|
this.$emit('refreshDataList')
|
} else {
|
this.$message.error('下发失败')
|
}
|
this.isSubmit = false
|
})
|
} else {
|
this.isSubmit = false
|
}
|
})
|
}
|
},
|
watch: {
|
currshowlist() {
|
this.innerVisible = this.currshowlist
|
if (this.currshowlist) {
|
this.$nextTick(() => {
|
this.initForm()
|
})
|
}
|
}
|
}
|
}
|
</script>
|
<style>
|
/*.establishpackaging-dialog .el-dialog__header {
|
padding: 10px 20px 10px;
|
}
|
.establishpackaging-dialog .el-dialog__header .el-dialog__headerbtn {
|
top: 10px;
|
}
|
.establishpackaging-dialog .el-dialog__body {
|
padding: 5px 20px;
|
}
|
|
.establishpackaging-dialog .el-dialog__footer {
|
padding: 5px 20px 10px;
|
}
|
|
.establishpackaging-dialog .el-dialog__body .avue-crud__pagination {
|
margin-top: 0px;
|
margin-bottom: 5px;
|
}*/
|
</style>
|