addMaterialGroupDia.vue
2.48 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
<template>
<div>
<el-dialog :title="title" :visible.sync="dialogVisible" width="30%" :before-close="!dialogVisible">
<el-form ref="materialGroupAddForm" :model="materialGroupAddForm" label-width="120px" :rules="materialGroupAddRules">
<el-form-item label="分组名称:" prop="groupName">
<el-input v-model="materialGroupAddForm.groupName" maxlength="8" show-word-limit></el-input>
</el-form-item>
<el-form-item label="业务类型:" prop="businessType">
<el-checkbox-group v-model="materialGroupAddForm.businessType" @change="handleCheckChange">
<el-checkbox v-for="value in businessTypes" :key="value" :label="value">{{ value }}</el-checkbox>
</el-checkbox-group>
</el-form-item>
</el-form>
<span>添加业务类型,该素材组里面的所有素材均会添加此业务类型</span>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="submitForm">确定创建</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'addMaterialGroupDia',
data() {
return {
title: '新增素材组',
dialogVisible: false,
materialGroupAddForm: {
groupName: '',
businessType: []
},
businessTypes: ['整车/新车','保养','维修','车险','二手车','改装','汽车金融','零配件/精品','通用(节假日等关怀素材)'],
materialGroupAddRules: {
groupName: [
{ required: true, message: '请输入分组名称', trigger: 'blur' },
{ max: 16, message: '分组名称最长为8个字', trigger: 'blur' }
]
}
}
},
methods: {
init(value) {
// console.log(value, '~~~~');
if (value == 1) {
this.materialGroupAddForm = {
groupName: '',
businessType: []
}
}
this.dialogVisible = true
},
// 创建
submitForm() {
this.$refs.materialGroupAddForm.validate((valid) => {
if (valid) {
this.$emit('addMaterialGroup', this.materialGroupAddForm)
this.dialogVisible = false
} else {
alert('请输入分组名称')
return false;
}
});
},
handleCheckChange(val) {
console.log(val);
this.materialGroupAddForm.businessType = val
// console.log(this.materialGroupAddForm);
}
}
}
</script>
<style>
</style>