index.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!--
  2. * @Author: wanglj 471442253@qq.com
  3. * @Date: 2022-12-29 18:00:08
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-06-08 10:17:38
  6. * @Description: file content
  7. * @FilePath: \订单全流程管理系统\src\views\base\components\PostComments.vue
  8. -->
  9. <template>
  10. <el-dialog :title="reply ? '回复' : '发表评论'" :visible.sync="visible">
  11. <el-form ref="editForm" :model="editForm" :rules="editRules">
  12. <el-form-item :label="reply ? '回复' : '评论'" prop="content">
  13. <el-input
  14. v-model="editForm.content"
  15. maxlength="500"
  16. :placeholder="reply ? '请输入回复内容' : '请输入评论内容'"
  17. resize="none"
  18. :rows="5"
  19. show-word-limit
  20. type="textarea" />
  21. </el-form-item>
  22. </el-form>
  23. <span slot="footer">
  24. <el-button :loading="loading" type="primary" @click="postContent">提交</el-button>
  25. <el-button @click="handleClose">关闭</el-button>
  26. </span>
  27. </el-dialog>
  28. </template>
  29. <script>
  30. import api from '@/api/customer/follow'
  31. import to from 'await-to-js'
  32. export default {
  33. data() {
  34. return {
  35. loading: false,
  36. visible: false,
  37. reply: false,
  38. editForm: {
  39. content: '',
  40. },
  41. form: {},
  42. editRules: {
  43. content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
  44. },
  45. }
  46. },
  47. created() {
  48. // console.log(this.visible)
  49. // console.log(this.editForm)
  50. // console.log(this.editRules)
  51. console.log(this.form)
  52. console.log('reply', this.reply)
  53. },
  54. methods: {
  55. async postContent() {
  56. this.$refs['editForm'].validate(async (valid) => {
  57. if (valid) {
  58. this.loading = true
  59. let params = {
  60. followId: this.reply ? '' + this.form.followId : '' + this.form.id,
  61. content: this.editForm.content,
  62. pid: this.reply ? this.form.id : 0,
  63. }
  64. const post = this.reply ? api.addReply : api.addComment
  65. const [err, res] = await to(post({ ...params }))
  66. this.loading = false
  67. if (err) return
  68. if (res.code == 200) {
  69. this.$baseMessage('发表成功', 'success', 'vab-hey-message-success')
  70. this.visible = false
  71. this.handleSub()
  72. }
  73. }
  74. })
  75. },
  76. handleSub() {},
  77. handleClose() {
  78. this.visible = false
  79. },
  80. },
  81. }
  82. </script>
  83. <style></style>