hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
<template>
  <div class='comment'>
    <v-header title="评论详情"></v-header>
    <div class="text">
      <section>
        <p>评论内容:</p>
        <article>{{detail.content}}</article>
      </section>
      <section>
        <p>点赞数:</p>
        <article>{{detail.fabulousNum}}</article>
      </section>
      <section>
        <p>评论人:</p>
        <article>{{detail.userName}}</article>
      </section>
      <section>
        <p>账号:</p>
        <article>{{detail.userPhone}}</article>
      </section>
      <section>
        <p>评论时间:</p>
        <article>{{detail.createAt?appTimeout(new Date(detail.createAt).getTime()):'--'}}</article>
      </section>
    </div>
    <v-header title="评论回复列表"></v-header>
    <div class="tab">
      <v-tool-table
        :trs="trs"
        :tds="tds"
      >
        <template v-slot:btn="{scope}">
          <div class="table_flex">
            <span @click="onShowDetail(scope)">查看</span>
            <span
              @click="onToggleComment(scope,2)"
              v-if="+scope.status===1"
            >隐藏</span>
            <span
              @click="onToggleComment(scope,1)"
              v-else
            >显示</span>
          </div>
        </template>
        <template v-slot:time="{scope}">
          <span>{{scope.createAt?appTimeout(new Date(scope.createAt).getTime()):''}}</span>
        </template>
        <template v-slot:status="{scope}">
          <span>{{+scope.status===1?'显示':'隐藏'}}</span>
        </template>
      </v-tool-table>
    </div>
    <v-tool-page
      :item="paged"
      @on-page="onPage"
    ></v-tool-page>
    <div class="back"><button
        class="m_btn small"
        @click="$router.back()"
      >返回</button></div>
  </div>
</template>
 
<script>
export default {
  props: {},
  components: {},
  data() {
    return {
      trs: [
        { text: "姓名", val: "userName" },
        { text: "账号", val: "userPhone" },
        { text: "内容", val: "replyContent" },
        // { text: "点赞数(个)", val: "fabulousNum" },
        { text: "状态", val: "btn", slot: "status" },
        { text: "提交时间", val: "btn", slot: "time" },
        { text: "操作", val: "btn" },
      ],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      tds: [],
      detail: {},
    };
  },
  watch: {},
  inject: ["appTimeout"],
  methods: {
    onPage(v) {
      if (v.page === this.paged.page && v.page && !v.reset) {
        return 0;
      }
      this.paged.page = v.page;
      this.paged.limit = v.limit;
      this.init();
    },
    init() {
      let v = {
        pageNum: this.paged.page,
        pageSize: this.paged.limit,
        id: this.$route.params.id,
      };
      this.$api.post("neighbor/detailNeighborCommentAllReply", v, (e) => {
        this.paged.total = e.total;
        this.tds = e.records;
      });
    },
    onToggleComment(v, n) {
      let txt = n === 1 ? "显示" : "隐藏";
      this.$js.model("", "是否" + txt, (res) => {
        if (res) {
          this.$api.post(
            "neighbor/changeCommentReplyStatusByAdmin",
            { id: v.id, status: n },
            () => {
              demo.toast(txt + "成功");
              v.status = n;
            }
          );
        }
      });
    },
    onShowDetail(v) {
      let v2 = demo.copy(v);
      v2.time = this.appTimeout(new Date(v.createAt).getTime());
      v2.status = +v2.status === 1 ? "显示" : "隐藏";
      this.$store.dispatch("setFixed", {
        event: "add",
        data: { type: "neigh-comment", data: v2 },
        timeout: Date.now(),
      });
    },
  },
  mounted() {
    this.$api.get(
      "neighbor/detailNeighborCommentByAdmin",
      { id: this.$route.params.id },
      (e) => {
        this.detail = e;
      }
    );
    this.init();
  },
};
</script>
<style lang='less' scoped>
.comment {
  overflow-y: auto;
  .text {
    font-size: 14px;
    section {
      display: flex;
      margin-bottom: 8px;
      line-height: 1.5;
      > p {
        width: 80px;
        text-align: right;
        box-sizing: border-box;
        padding-right: 8px;
      }
      article {
        width: calc(100% - 120px);
      }
    }
  }
  .back {
    margin: 30px 0;
    .m_btn {
      min-width: 80px;
    }
  }
}
</style>