inleft
2022-03-02 34223b096cf6ad9d92c3702bb9529e764f523b11
commit | author | age
88f419 1 <template>
I 2   <a-modal
3     title="新增文章评论"
4     :width="900"
5     :visible="visible"
6     :confirmLoading="confirmLoading"
7     @ok="handleSubmit"
8     @cancel="handleCancel"
9   >
10     <a-spin :spinning="confirmLoading">
11       <a-form :form="form">
12         <a-form-item
13           label="访客名称"
14           :labelCol="labelCol"
15           :wrapperCol="wrapperCol"
16           has-feedback
17         >
18           <a-input placeholder="请输入访客名称" v-decorator="['visitorNickName', {rules: [{required: true, message: '请输入访客名称!'}]}]" />
19         </a-form-item>
20         <a-form-item
21           label="访客邮箱"
22           :labelCol="labelCol"
23           :wrapperCol="wrapperCol"
24           has-feedback
25         >
26           <a-input placeholder="请输入访客邮箱" v-decorator="['visitorEmail']" />
27         </a-form-item>
28         <a-form-item
29           label="访客主页"
30           :labelCol="labelCol"
31           :wrapperCol="wrapperCol"
32           has-feedback
33         >
34           <a-input placeholder="请输入访客主页" v-decorator="['visitorHomePage']" />
35         </a-form-item>
36         <a-form-item
37           label="留言内容(500字内)"
38           :labelCol="labelCol"
39           :wrapperCol="wrapperCol"
40           has-feedback
41         >
42           <a-textarea placeholder="请输入留言内容(500字内)" v-decorator="['commentContent']" :auto-size="{ minRows: 3, maxRows: 6 }"/>
43         </a-form-item>
44         <a-form-item
45           label="是否已审核 0:否 1:是"
46           :labelCol="labelCol"
47           :wrapperCol="wrapperCol"
48         >
49           <a-select style="width: 100%" placeholder="请选择是否已审核 0:否 1:是">
50             <a-select-option v-for="(item,index) in isCheckData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
51           </a-select>
52         </a-form-item>
53         <a-form-item
54           label="公开状态 1:公开 2:私密 3:密码授权"
55           :labelCol="labelCol"
56           :wrapperCol="wrapperCol"
57         >
58           <a-select style="width: 100%" placeholder="请选择公开状态 1:公开 2:私密 3:密码授权">
59             <a-select-option v-for="(item,index) in authStatusData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
60           </a-select>
61         </a-form-item>
62         <a-form-item
63           label="是否启用 0:否 1是"
64           :labelCol="labelCol"
65           :wrapperCol="wrapperCol"
66         >
67           <a-select style="width: 100%" placeholder="请选择是否启用 0:否 1是">
68             <a-select-option v-for="(item,index) in isEnableData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
69           </a-select>
70         </a-form-item>
71       </a-form>
72     </a-spin>
73   </a-modal>
74 </template>
75
76 <script>
77   import { blogArticleCommentAdd } from '@/api/modular/main/blogarticlecomment/blogArticleCommentManage'
78   export default {
79     data () {
80       return {
81         labelCol: {
82           xs: { span: 24 },
83           sm: { span: 5 }
84         },
85         wrapperCol: {
86           xs: { span: 24 },
87           sm: { span: 15 }
88         },
89         isCheckData: [],
90         authStatusData: [],
91         isEnableData: [],
92         visible: false,
93         confirmLoading: false,
94         form: this.$form.createForm(this)
95       }
96     },
97     methods: {
98       // 初始化方法
99       add (record) {
100         this.visible = true
101         const commentTypeOption = this.$options
102         this.commentTypeData = commentTypeOption.filters['dictData']('blog_comment_type')
103         const isCheckOption = this.$options
104         this.isCheckData = isCheckOption.filters['dictData']('blog_yes_or_no')
105         const authStatusOption = this.$options
106         this.authStatusData = authStatusOption.filters['dictData']('blog_auth_status')
107         const isEnableOption = this.$options
108         this.isEnableData = isEnableOption.filters['dictData']('blog_yes_or_no')
109       },
110       /**
111        * 提交表单
112        */
113       handleSubmit () {
114         const { form: { validateFields } } = this
115         this.confirmLoading = true
116         validateFields((errors, values) => {
117           if (!errors) {
118             for (const key in values) {
119               if (typeof (values[key]) === 'object' && values[key] != null) {
120                 values[key] = JSON.stringify(values[key])
121               }
122             }
123             blogArticleCommentAdd(values).then((res) => {
124               if (res.success) {
125                 this.$message.success('新增成功')
126                 this.confirmLoading = false
127                 this.$emit('ok', values)
128                 this.handleCancel()
129               } else {
130                 this.$message.error('新增失败')// + res.message
131               }
132             }).finally((res) => {
133               this.confirmLoading = false
134             })
135           } else {
136             this.confirmLoading = false
137           }
138         })
139       },
140       handleCancel () {
141         this.form.resetFields()
142         this.visible = false
143       }
144     }
145   }
146 </script>