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