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
| <template>
| <el-dialog
| :title="title"
| :visible="value"
| width="30%"
| :modal="false"
| :show-close="false"
| :before-close="onCancel"
| >
|
| <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="demo-ruleForm">
| <el-form-item label="类型名称" prop="name">
| <el-input v-model="ruleForm.name" placeholder="请输入团队类型名称" maxlength="10" show-word-limit></el-input>
| </el-form-item>
| </el-form>
| <!-- 底部按钮 -->
| <span slot="footer" class="dialog-footer">
| <el-button @click="onCancel">取 消</el-button>
| <el-button type="primary" @click="onOk('ruleForm')">确 定</el-button>
| </span>
| </el-dialog>
| </template>
|
| <script>
| export default {
| props: {
| value: { type: Boolean },
| editData: { }
| },
| data() {
| return {
| ruleForm: {
| name: '',
| },
| rules: {
| name: [
| { required: true, message: '请输入团队类型', trigger: 'blur' }
| ]
| },
| title: ''
| }
| },
| watch: {
| editData (val) {
| if (val.id) {
| this.ruleForm = {
| name: val.name,
| id: val.id
| }
| this.title = '编辑团队类型'
| } else {
| this.ruleForm = {
| name: '',
| }
| this.title = '添加团队类型'
| }
| }
| },
| mounted() {
|
| },
| methods: {
| /** 取消 */
| onCancel () {
| this.$emit('change', false);
| },
|
| /** 确认 */
| onOk(formName) {
| this.$refs[formName].validate((valid) => {
| if (valid) {
| if (this.ruleForm.id) {
| this.edit()
| } else {
| this.save()
| }
| } else {
| return false;
| }
| });
| },
|
| save() {
| this.$api.post("fms/teamType/add", this.ruleForm, e => {
| this.$message('保存成功');
| this.$emit('success');
| });
| },
| edit() {
| this.$api.post("fms/teamType/edit", this.ruleForm, e => {
| this.$message('编辑成功');
| this.$emit('success');
| });
| }
|
| }
|
| }
| </script>
|
| <style lang="less" scoped>
|
| </style>
|
|