<template>
|
<div class="maintaskEdit height overflow">
|
<div class="centent-form overflowy-auto">
|
<el-form
|
class="margin-auto width90"
|
ref="registerForm"
|
:model="registerForm"
|
size="mini"
|
:rules="rules"
|
label-position="left"
|
label-width="100px"
|
>
|
<el-form-item label="任务类型:" prop="taskType">
|
<el-select v-model="registerForm.taskType" @change="taskchange" clearable placeholder="请选择">
|
<el-option
|
v-for="(item, index) in taskTypeList"
|
:key="index + 'taskType'"
|
:label="item.label"
|
:value="item.value"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="起始位:" prop="sourcePlace">
|
<el-select v-model="registerForm.sourcePlace" filterable clearable placeholder="请选择">
|
<el-option
|
v-for="(item, index) in sourcePlaceList"
|
:key="index + 'sourcePlace'"
|
:label="item.placeName"
|
:value="item.placeCode"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="目标位:" prop="toPlace">
|
<el-select v-model="registerForm.toPlace" filterable clearable placeholder="请选择">
|
<el-option
|
v-for="(item, index) in toPlaceList"
|
:key="index + 'toPlace'"
|
:label="item.placeName"
|
:value="item.placeCode"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
|
<el-form-item label="任务优先级:" prop="taskLevel">
|
<el-input oninput="value=value.replace(/[^\d.]/g,'')" v-model="registerForm.taskLevel" clearable></el-input>
|
</el-form-item>
|
<el-form-item label="托盘号:" prop="containerName">
|
<el-select
|
v-model="registerForm.containerName"
|
filterable
|
remote
|
reserve-keyword
|
:remote-method="remoteMethod"
|
:loading="remoloading"
|
clearable
|
placeholder="请选择"
|
>
|
<el-option
|
v-for="(item, index) in containerNameList"
|
:key="index + 'containerName'"
|
:label="item.containerName"
|
:value="item.containerName"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-form>
|
</div>
|
<div class="maintaskEdit-button text-right margin-right15 margin-top2">
|
<el-button type="primary" size="mini" class="form-buttom" @click="submitForm('registerForm')">提交</el-button>
|
<el-button type="primary" size="mini" class="form-buttom" @click="$emit('cancel')">取消</el-button>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { TaskAddOrUpdate } from '@/api/maintask';
|
import { ContainerSearch } from '@/api/palte';
|
import { getCache } from '@/utils/sessionStorage';
|
import { PlaceGetPlace } from '@/api/position';
|
export default {
|
data() {
|
return {
|
registerForm: {
|
sourcePlace: '',
|
toPlace: '',
|
taskType: '',
|
taskStatus: '新建',
|
userName: getCache('userInfo').userName,
|
taskLevel: '',
|
hasReaded: 0,
|
containerName: ''
|
},
|
remoloading: false,
|
sourcePlace: '', //起始位
|
toPlace: '', //目标位
|
sourcePlaceList: [],
|
toPlaceList: [],
|
taskTypeList: [
|
{
|
label: '入库',
|
value: 1
|
},
|
{
|
label: '出库',
|
value: 2
|
},
|
{
|
label: '移库',
|
value: 3
|
}
|
],
|
containerNameList: [],
|
disabled: false,
|
createLineList: [],
|
|
rules: {
|
sourcePlace: { required: true, message: '请选择起始位', trigger: 'change' },
|
toPlace: { required: true, message: '请选择目标位', trigger: 'change' },
|
taskType: { required: true, message: '请选择任务类型', trigger: 'change' },
|
taskLevel: { required: true, message: '请输入任务优先级', trigger: 'change' },
|
containerName: { required: false, message: '请输入托盘号', trigger: 'change' }
|
}
|
};
|
},
|
props: {
|
rowitem: {
|
type: Object,
|
default: {}
|
}
|
},
|
mounted() {
|
if (JSON.stringify(this.rowitem) != '{}') {
|
this.registerForm = this.rowitem;
|
this.sourcePlace = this.rowitem.sourcePlace; //起始位
|
this.toPlace = this.rowitem.toPlace; //目标位
|
this.registerForm.taskType =
|
this.registerForm.taskType == '入库'
|
? 1
|
: this.registerForm.taskType == '出库'
|
? 2
|
: this.registerForm.taskType == '移库'
|
? 3
|
: this.registerForm.taskType;
|
this.disabled = true;
|
} else {
|
this.disabled = false;
|
}
|
this.ContainerSearch({ containerName: '' });
|
this.sourcePlacePlaceGetPlace();
|
this.toPlacePlacePlaceGetPlace();
|
},
|
methods: {
|
//器具
|
ContainerSearch(query) {
|
const { containerName } = query;
|
ContainerSearch('1&onePageNum=999', { containerName }).then(res => {
|
if (res.code == 0) {
|
let data = res.data || [];
|
this.containerNameList = data;
|
}
|
});
|
},
|
remoteMethod(query) {
|
if (query !== '') {
|
this.remoloading = true;
|
setTimeout(() => {
|
this.remoloading = false;
|
this.ContainerSearch({ containerName: query });
|
}, 200);
|
}
|
},
|
//起始位库位
|
sourcePlacePlaceGetPlace() {
|
let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
|
PlaceGetPlace({ isSourcePlace: 1, taskType: taskType }).then(res => {
|
if (res.code == 0) {
|
this.sourcePlaceList = res.data;
|
if (this.registerForm.sourcePlace) {
|
this.registerForm.sourcePlace = res.data.filter(item => {
|
if (item.placeCode == this.registerForm.sourcePlace) {
|
return item.placeName;
|
}
|
});
|
}
|
}
|
});
|
},
|
//目标位
|
toPlacePlacePlaceGetPlace() {
|
let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
|
PlaceGetPlace({ isSourcePlace: 0, taskType: taskType }).then(res => {
|
if (res.code == 0) {
|
this.toPlaceList = res.data;
|
if (this.registerForm.sourcePlace) {
|
this.registerForm.toPlace = res.data.filter(item => {
|
if (item.placeCode == this.registerForm.toPlace) {
|
return item.placeName;
|
}
|
});
|
}
|
}
|
});
|
},
|
//任务类型
|
taskchange() {
|
this.registerForm.sourcePlace = '';
|
this.registerForm.toPlace = '';
|
this.sourcePlaceList = [];
|
this.toPlaceList = [];
|
this.sourcePlacePlaceGetPlace();
|
this.toPlacePlacePlaceGetPlace();
|
let taskType = this.registerForm.taskType ? this.registerForm.taskType : 1;
|
this.rules.containerName.message="";
|
if(taskType==1)
|
{
|
this.rules.containerName.required=true;
|
|
}else
|
{
|
this.rules.containerName.required=false;
|
}
|
},
|
submitForm(registerForm) {
|
console.log(this.registerForm);
|
this.$refs[registerForm].validate(valid => {
|
if (valid) {
|
this.savloading = true;
|
TaskAddOrUpdate(this.registerForm).then(res => {
|
if (res.code == 0) {
|
this.$message({
|
type: 'success',
|
message: '提交成功'
|
});
|
this.$emit('addsubmit');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: '提交失败'
|
});
|
}
|
this.savloading = false;
|
});
|
}
|
});
|
}
|
},
|
watch: {}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.maintaskEdit {
|
width: 98%;
|
padding: 1%;
|
.show-pwd {
|
position: absolute;
|
right: 10px;
|
top: 3px;
|
font-size: 16px;
|
color: #889aa4;
|
cursor: pointer;
|
user-select: none;
|
}
|
.centent-form {
|
height: 92%;
|
width: 100%;
|
margin: auto;
|
}
|
.maintaskEdit-button {
|
}
|
::v-deep .el-form-item__content {
|
width: 60%;
|
}
|
::v-deep .el-select {
|
width: 100%;
|
}
|
}
|
</style>
|