itemCRUDDialog.vue
2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
<el-dialog
:title="title"
:visible.sync="visible"
width="700px"
append-to-body
@close="$emit('update:show', false)"
>
<el-form ref="diaForm" :title="title" :model="data" :rules="rules" label-width="35%">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="容器类型" prop="containerType">
<el-select v-model="data.containerType" placeholder="请选择容器类型">
<el-option v-for="item in containerType"
:key="item.code"
:label="item.name"
:value="item.code" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="增加数量(个)" prop="quantity">
<el-input v-model.number="data.quantity" placeholder="请选择增加数量(个)">
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</template>
<script>
import {add} from '@/api/config/InventoryInfo/container'
export default{
name: 'itemCRUDDialog',
props:{
show:{
type:Boolean,
default:false
},
diaForm: {
type:Object,
default:()=>({})
},
containerType:{
type:Array,
default:()=>[]
}
},
watch:{
show(){
this.visible = this.show
if (!this.visible){
this.cancel()
}
}
},
computed:{
data(){
return this.diaForm
}
},
data() {
return {
visible: this.show,
rules: {
quantity: [
{ required: true, message: '请输入个数', trigger: 'blur' },
{ type:'number', message: '请输入数字'}
],
containerType: [
{ required: true, message: '请选择容器类型', trigger: 'blur' },
]
},
title:'增加容器'
}
},
methods:{
/** 提交按钮 */
submitForm: function() {
this.$refs['diaForm'].validate(valid => {
if (valid) {
add(this.data).then(response => {
if (response.code === 200) {
this.$emit('globalQuery')
this.msgSuccess('新增成功')
this.visible = false
}
})
}
})
},
// 重置对话框表单
reset() {
this.resetForm('diaForm')
this.visible = false
},
//关闭对话框
cancel() {
this.reset()
},
}
}
</script>
<style scoped>
</style>