addDesk.vue
3.12 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
<template>
<div>
<el-dialog :title="isEdit?'编辑货架':'新增货架'" class="manage-dialog" :visible.sync="addDialogVisible"
:close-on-click-modal="false" @close="addDialogClose()">
<el-form :model="addForm" status-icon :rules="rules" ref="addForm">
<!-- 区域名称 -->
<el-form-item :label="$t('货架名称')" prop="name">
<el-input v-model.trim="addForm.name"></el-input>
<i class="error-tip">*</i>
</el-form-item>
<el-form-item :label="$t('出入口')" prop="name">
<el-switch v-model="addForm.doorway"></el-switch>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="addDialogVisible = false" class="dialog-btn">{{ $t('dialog.cancel') }}</el-button>
<el-button type="primary" @click="addSubmit('addForm')" class="dialog-btn dialog-confirm-btn">
{{ $t('dialog.confirm') }}</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
data() {
var checkName = (rule, value, callback) => {
//var flag = new RegExp("[`’\"·_ ~!%\\-@#$^&*=|{}':;',\\[\\].<>《》/?~!@#¥……&*——|{}【】‘;:”“'。,、? ]");
var flag = new RegExp("'");
if (flag.test(value) || /\\/.test(value)) {
callback(new Error("名称包含特殊字符,请重新输入!"));
} else {
callback();
}
}
return {
addDialogVisible: false,
addForm: {
name: '',
doorway:0
},
isEdit:false,
rules: {
name: [{
required: true,
message: '请输入货架名称',
trigger: 'blur'
},{
validator: checkName,
trigger: "blur"
}]
}
}
},
created() {
// zoneTypeList
},
methods: {
dialogInit(data) {
this.addForm = {};
if(data){
this.isEdit = true;
this.addForm = Object.assign({},data,{doorway:data.doorway==1?true:false});
this.deskObj = data;
}else{
this.isEdit = false
}
this.addDialogVisible = true;
},
addSubmit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.$emit('submit',this.addForm)
} else {
return false;
}
});
},
addDialogClose() {
this.addDialogVisible = false;
this.$refs.addForm.resetFields();
},
}
}
</script>
<style scoped>
.bdmap-btn {
margin-left: 17px;
padding: 0 8px;
height: 30px;
box-sizing: border-box;
border-radius: 2px;
font-size: 13px;
}
.unit-input {
width: 100%;
}
</style>