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
| <template>
| <div>
| <el-dialog :visible.sync="dialogVisible" :title="title" :close-on-click-modal="false" :modal-append-to-body="false" v-if="dialogVisible" width="564px">
| <el-form size="mini" label-width="120px" ref="form">
| <el-form-item label="分类名称:">
| <el-input maxlength="6" v-model="content" show-word-limit placeholder="请输入不超过6个汉字长度的内容"></el-input>
| </el-form-item>
| </el-form>
| <div slot="footer" class="dialog-footer buttonPosition">
| <el-button size="mini" @click="submit" type="primary" :loading="loading">确定</el-button>
| <el-button size="mini" @click="dialogVisible = false">取消</el-button>
| </div>
| </el-dialog>
| </div>
| </template>
|
| <script>
| import integralProdApi from '@/api/member/integralProd'
| export default {
| props: {
| title: {
| type: String,
| default: null
| },
| show: {
| type: Boolean,
| default: false
| }
| },
| data () {
| return {
| dialogVisible: false,
| content: null,
| loading: false
| }
| },
| watch: {
| /**
| * 监控外部显示变量变化
| * 传递到dialog组件
| */
| show: function (newShow, oldShow) {
| this.dialogVisible = newShow
| },
| /**
| * 监控内部显示属性变化
| * 传递到外部调用变量
| */
| dialogVisible: function (newDialogShow, oldDialogShow) {
| this.$emit('update:show', newDialogShow)
| if (!newDialogShow) {
| this.content = null
| }
| }
| },
| methods: {
| // 确定
| async submit () {
| if (!this.content) {
| this.$message({
| message: '请输入分类名称',
| type: 'warning'
| })
| return
| }
| try {
| this.loading = true
| const res = await integralProdApi.addCategory({ categoryName: this.content, pid: '0', delStatus: '1' })
| if (res.code === '0' && res.data) {
| this.loading = false
| this.$emit('hand-content', { categoryName: res.data.categoryName, id: res.data.id })
| this.dialogVisible = false
| } else {
| this.loading = false
| }
| } catch (error) {
| this.loading = false
| }
| }
| }
| }
| </script>
|
| <style>
|
| </style>
|
|