mt-yj-wms-ui/src/views/modules/generator/mtcctaskruninfo-add-or-update.vue
2021-10-29 14:38:18 +08:00

180 lines
5.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-dialog
:title="!dataForm.id ? '新增' : '修改'"
:close-on-click-modal="false"
:visible.sync="visible"
>
<el-form
:model="dataForm"
:rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()"
label-width="80px"
>
<el-form-item label="任务类型" prop="taskType">
<el-select
v-model="dataForm.taskType"
placeholder="任务类型0 出库1入库"
style="width:80%"
>
<el-option label="出库" :value="0"></el-option>
<el-option label="入库" :value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item label="产品编码" prop="model">
<el-autocomplete
class="inline-input"
v-model="dataForm.model"
placeholder="产品编码"
:fetch-suggestions="querySearch"
popper-class="select-option"
clearable
></el-autocomplete>
</el-form-item>
<!-- <el-form-item label="起点" prop="startPoint">
<el-input v-model="dataForm.startPoint" placeholder="起点"></el-input>
</el-form-item> -->
<!-- <el-form-item label="终点" prop="endPoint">
<el-input v-model="dataForm.endPoint" placeholder="终点"></el-input>
</el-form-item> -->
<el-form-item label="数量" prop="num">
<el-input v-model="dataForm.num" placeholder="数量" oninput = "value=value.replace(/[^\d]/g,'')"></el-input>
</el-form-item>
<el-form-item label="批次号" prop="dateNum">
<el-input
v-model="dataForm.dateNum"
placeholder="请填写批次号"
></el-input>
<!-- oninput = "value=value.replace(/[^\d]/g,'')" -->
</el-form-item>
<el-form-item label="备注" prop="remarks">
<el-input v-model="dataForm.remarks" placeholder="备注"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="dataFormSubmit()">确定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data () {
return {
visible: false,
dataForm: {
id: 0,
taskType: '',
model: '',
// startPoint: '',
// endPoint: '',
num: '',
unit: '',
remarks: '',
dateNum: ''
},
dataRule: {
taskType: [
{ required: true, message: '任务类型不能为空', trigger: 'blur' }
],
model: [
{ required: true, message: '型号不能为空', trigger: 'blur' }
],
num: [
{ required: true, message: '数量不能为空', trigger: 'blur' }
]
// startPoint: [
// { required: true, message: '起点不能为空', trigger: 'blur' }
// ],
// endPoint: [
// { required: true, message: '终点不能为空', trigger: 'blur' }
// ]
}
}
},
props: {
inout: {
type: Number
}
},
methods: {
init (id) {
if (this.inout === 1) {
this.dataForm.taskType = 0
} else if (this.inout === 2) {
this.dataForm.taskType = 1
}
this.dataForm.id = id || 0
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/generator/mtcctaskruninfo/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataForm = data.mtCcTaskRunInfo
}
})
}
})
},
querySearch (queryString, cb) {
var results = []
this.$http({
url: this.$http.adornUrl('/generator/mtcctaskruninfo/getLikeList'),
method: 'get',
params: this.$http.adornParams({
'key': queryString
})
}).then(({ data }) => {
for (var i = 0; i < data.length; i++) {
var obj = { value: '' }
obj.value = data[i]
results[i] = obj
}
cb(results)
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/generator/mtcctaskruninfo/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'taskType': this.dataForm.taskType,
'model': this.dataForm.model,
'num': this.dataForm.num,
// 'startPoint': this.dataForm.startPoint,
// 'endPoint': this.dataForm.endPoint,
'remarks': this.dataForm.remarks,
'dateNum': this.dataForm.dateNum
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: '操作成功',
type: 'success',
duration: 1500,
onClose: () => {
this.visible = false
this.$emit('refreshDataList')
}
})
} else {
this.$message.error(data.msg)
}
})
}
})
}
}
}
</script>