qiyunfeng-create
2 天以前 5f00696dfb25bc90034448ceb634ed1ef256681a
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<template>
  <div class="classManagePage-box">
    <div class="classManagePage-nav">
      <el-breadcrumb :separator-icon="ArrowRight">
        <el-breadcrumb-item>我的班级</el-breadcrumb-item>
        <el-breadcrumb-item>{{ classInfo?.name }}</el-breadcrumb-item>
        <el-breadcrumb-item>班级通知审核</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="classManagePage-content">
      <div class="backBtn">
        <el-button @click="goBack()" type="primary" link>
          <el-icon style="margin-right: 5px"><ArrowLeftBold /></el-icon> 返回
        </el-button>
      </div>
      <div class="contentBox">
        <div class="titleOptions">
          <span>班级通知审核列表</span>
        </div>
        <div class="content-tab-box">
          <div class="content-list-box">
            <el-table
              :header-cell-style="{ background: '#eee' }"
              :data="dataList"
              max-height="600px"
              style="width: 100%"
              v-loading="pages.loading"
            >
              <el-table-column prop="id" label="序号" width="70" />
              <el-table-column prop="name" label="通知" width="500" />
              <el-table-column prop="state" label="状态" #default="scope">
                <span style="color: #ff6d00" v-if="scope.row.state == 'WaitAudit'">待审核</span>
                <span style="color: #67c23a" v-if="scope.row.state == 'Normal'">已通过</span>
                <span style="color: red" v-if="scope.row.state == 'Reject'">已拒绝</span>
              </el-table-column>
              <el-table-column prop="createDate" label="创建时间" />
              <el-table-column label="操作" #default="scope">
                <el-button
                  link
                  v-if="scope.row.state != 'Normal'"
                  type="success"
                  size="small"
                  @click="successMessage(scope.row)"
                >
                  发布
                </el-button>
                <el-button link type="danger" size="small" @click="removeMessage(scope.row)">
                  删除
                </el-button>
              </el-table-column>
            </el-table>
            <div class="pageBox">
              <el-pagination
                style="float: right"
                v-model:current-page="pages.currentPage"
                :page-size="pages.pageSize"
                :size="'small'"
                :disabled="pages.count <= 1"
                layout="total, prev, pager, next"
                :total="pages.count"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
import { inject, onMounted, reactive, ref } from 'vue'
import { Search, UserFilled, ArrowRight } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import moment from 'moment'
 
const route: any = useRoute()
const router = useRouter()
const classInfo = JSON.parse(route.query.classInfo)
const MG: any = inject('MG')
const config: any = inject('config')
const tool: any = inject('toolClass')
 
let pages = reactive({
  currentPage: 1,
  page: 1,
  pageSize: 15,
  count: 0,
  loading: true
})
 
const dataList: any = ref([])
 
// 获取班级通知
const getNotice = () => {
  const data = {
    start: (pages.page - 1) * pages.pageSize,
    size: pages.pageSize,
    appRefCode: config.appRefCode,
    topicIdOrRefCode: String(sessionStorage.messageId),
    sort: {
      type: 'Desc',
      field: 'CreateDate',
      subSorts: []
    }
  }
  MG.ugc
    .getTopicMessageList(data)
    .then((res: any) => {
      pages.loading = false
      pages.count = res.totalSize
      const list = res.datas
      dataList.value = list.map((item: any) => {
        return {
          ...item,
          createDate: moment(item.createDate).format('YYYY-MM-DD')
        }
      })
    })
    .catch((err: any) => {
      pages.loading = false
      console.log(err)
    })
}
 
// 通过
const successMessage = (item: any) => {
  const data = {
    id: item.id,
    name: item.name,
    description: item.description,
    icon: item.icon,
    type: item.type,
    state: 'Normal',
    content: JSON.stringify(item.publicText),
    newDataRequests: [],
    updateDataRequests: []
  }
  MG.ugc
    .updateTopicMessage(data)
    .then((res: any) => {
      if (res) {
        ElMessage({
          type: 'success',
          message: '已发布'
        })
        getNotice()
      }
    })
    .catch((err: any) => {
      console.log(err, '审核话题')
    })
}
 
// 删除
const removeMessage = (item: any) => {
  const data = {
    messageIds: [item.id]
  }
  MG.ugc
    .delTopicMessage(data)
    .then((res: any) => {
      if (res) {
        ElMessage.success('已删除')
        getNotice()
      }
    })
    .catch((err: any) => {
      ElMessage.error('删除失败,请稍后再试')
      console.log(err)
    })
}
 
//  分页
const handleSizeChange = (val: number) => {
  pages.pageSize = val
  getNotice()
}
 
const handleCurrentChange = (val: number) => {
  pages.page = val
  pages.currentPage = val
  getNotice()
}
 
const goBack = () => {
  router.go(-1)
}
 
onMounted(() => {
  getNotice()
})
</script>
 
<style lang="less" scoped>
.classManagePage-box {
  background: #fff;
 
  .classManagePage-nav {
    width: 100%;
    padding: 0 20px;
    height: 40px;
    border-bottom: 1px solid #e6e8ed;
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    background: #fff;
  }
  .classManagePage-content {
    width: 100%;
    position: relative;
    .backBtn {
      width: 100%;
      height: 45px;
      margin-bottom: 10px;
      padding: 0 20px;
      display: flex;
      align-items: center;
      position: sticky;
      top: 40px;
      z-index: 99;
      background: #fff;
      box-shadow: 0px 0px 20px 1px #eeeeee83;
    }
    .contentBox {
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      .titleOptions {
        width: 160px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        span {
          height: 30px;
          font-family: PingFang SC;
          font-weight: bold;
          font-size: 16px;
          color: #333;
          line-height: 30px;
          text-align: left;
          border-left: 6px solid #ff6c00;
          padding-left: 10px;
        }
      }
    }
  }
}
</style>