qy-renren-qt/src/views/modules/work/mtcommunlog-add-or-update.vue
2022-05-26 16:00:10 +08:00

106 lines
3.5 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="status">
<el-input v-model="dataForm.status" placeholder="状态 0表示写入设备1接受设备信息" clearable />
</el-form-item>
<el-form-item label="通讯类型" prop="type">
<el-input v-model="dataForm.type" placeholder="通讯类型:1 wms-to-wcs, 0 wcs-to-wms" clearable />
</el-form-item>
<el-form-item label="内容集" prop="content">
<el-input v-model="dataForm.content" placeholder="内容集" clearable />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="dataForm.remark" placeholder="" clearable />
</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,
status: '',
type: '',
content: '',
remark: ''
},
dataRule: {
status: [
{ required: true, message: '状态0表示写入设备1接受设备信息不能为空', trigger: 'blur' }
],
type: [
{ required: true, message: '通讯类型:1 wms-to-wcs, 0 wcs-to-wms不能为空', trigger: 'blur' }
],
content: [
{ required: true, message: '内容集不能为空', trigger: 'blur' }
]
}
}
},
methods: {
init (id) {
this.dataForm.id = id || ''
this.visible = true
this.$nextTick(() => {
this.$refs['dataForm'].resetFields()
if (this.dataForm.id) {
this.$http({
url: this.$http.adornUrl(`/work/mtcommunlog/info/${this.dataForm.id}`),
method: 'get',
params: this.$http.adornParams()
}).then(({data}) => {
if (data && data.code === 0) {
this.dataForm = data.mtCommunLog
}
})
}
})
},
// 表单提交
dataFormSubmit () {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.$http({
url: this.$http.adornUrl(`/work/mtcommunlog/${!this.dataForm.id ? 'save' : 'update'}`),
method: 'post',
data: this.$http.adornData({
'id': this.dataForm.id || undefined,
'status': this.dataForm.status,
'type': this.dataForm.type,
'content': this.dataForm.content,
'remark': this.dataForm.remark
})
}).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>