Blame view

ant-design-vue-base/src/views/inspect/modules/WhisperingsModal.vue 4.82 KB
1a2d344e   wxy   初始化项目
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
  <template>
    <j-modal
      :maskClosable="false"
      :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
      :title="title"
      :visible="visible"
      :width="800"
      switchFullscreen @cancel="handleCancel">
      <div v-infinite-scroll="handleInfiniteOnLoad" :infinite-scroll-disabled="busy" :infinite-scroll-distance="10"
           class="demo-infinite-container">
        <a-list :data-source="data" class="comment-list" item-layout="vertical">
          <a-list-item slot="renderItem" slot-scope="item, index">
            <a-comment :author="Base64.decode(item.wxUser.nickName)" :avatar="item.wxUser.avatarUrl">
              <p slot="content">
                {{ item.content }}
              </p>
              <a-tooltip slot="datetime">
                <span>{{ item.createTime }}</span>
              </a-tooltip>
              <a-comment v-for="(reply,i) in item.replys" :key="i">
                <a slot="author">{{ reply.realname }}</a>
                <a-avatar slot="avatar" :size="32" icon="user" />
                <p slot="content">
                  {{ reply.content }}
                </p>
                <a-tooltip slot="datetime">
                  <span>{{ reply.createTime }}</span>
                </a-tooltip>
              </a-comment>
              <a-comment class="reply_box">
                <div slot="content">
                  <a-textarea :rows="4" :value="replyContent" @change="handleReplyChange" />
                  <div v-if="showTips" class="ant-form-explain" style="color: #f5222d">请输入回复内容!</div>
                  <a-button :loading="submitting" html-type="submit" type="primary" @click="handleSubmitReply(item.id)">
                    回复
                  </a-button>
                </div>
              </a-comment>
            </a-comment>
          </a-list-item>
        </a-list>
      </div>
    </j-modal>
  </template>
  
  <script>
  import infiniteScroll from 'vue-infinite-scroll'
  import { getAction, putAction } from '@api/manage'
  import { Base64 } from 'js-base64'
  
  const fakeDataUrl = 'https://randomuser.me/api/?results=5&inc=name,gender,email,nat&noinfo'
  export default {
    name: 'WhisperingsModal',
    components: {},
    directives: { infiniteScroll },
    data() {
      return {
        submitting: false,
        data: [],
        loading: false,
        busy: false,
        title: '',
        width: 800,
        visible: false,
        disableSubmit: false,
        replyContent: '',
        Base64,
        showTips: false,
        model: ''
      }
    },
    methods: {
      handleSubmitReply(id) {
        const that = this
        if (null == that.replyContent || '' == that.replyContent) {
          that.showTips = true
        } else {
          putAction('inspect/whisperings/reply', {
            whisperingsId: id,
            content: that.replyContent
          }).then((res) => {
            console.log(res)
            if (res.success) {
              that.getDatas()
  
            } else {
              that.$message.warning(res.message)
            }
          })
        }
  
      },
      handleReplyChange(e) {
        this.replyContent = e.target.value
      },
      handleInfiniteOnLoad() {
        const data = this.data
        this.loading = true
        if (data.length > 14) {
          this.$message.warning('Infinite List loaded all')
          this.busy = true
          this.loading = false
          return
        }
        this.fetchData(res => {
          this.data = data.concat(res.results)
          this.loading = false
        })
      },
      edit(record) {
        const model = Object.assign({}, record)
        console.log(model)
        const that = this
        that.model = model
        that.getDatas()
        this.visible = true
      },
      getDatas: function() {
        const that = this
        that.data = []
        getAction('inspect/whisperings/queryWhisperingsReplyByMainId', {
          id: that.model.id
        }).then((res) => {
          console.log(res)
          if (res.success) {
            var model = that.model
            const replys = res.result.replys
            model.replys = replys
            model.wxUser = res.result.wxUser
            that.data.push(model)
            that.replyContent = ''
            console.log(that.data)
          } else {
            that.$message.warning(res.message)
          }
        })
      },
      close() {
        this.$emit('close')
        this.visible = false
        this.data = []
      },
      submitCallback() {
        this.$emit('ok')
        this.visible = false
      },
      handleCancel() {
        this.close()
      }
    }
  }
  </script>
  <style scoped>
  
  .ant-comment-actions > li {
    width: 95% !important;
  }
  
  .demo-infinite-container {
    max-height: 600px;
    padding-right: 10px;
    overflow-y: auto;
  }
  
  .demo-loading-container {
    position: absolute;
    bottom: 40px;
    width: 100%;
    text-align: center;
  }
  
  .ant-comment-content-detail p {
    margin-top: 10px;
    margin-bottom: 0;
    white-space: normal !important;
    line-height: 2;
  }
  
  .reply_box button {
    margin-top: 15px;
    float: right;
  }
  </style>
  
  <style>
  .reply_box .ant-comment-avatar {
    display: none;
  }
  </style>