Audit.vue 6.52 KB
<template>
  <el-card class="account-container">
    <div class="experience">
      <div class="control">
        <p class="control_name">解忧杂货铺-审核中心</p>
      </div>
      <div class="btn_box">
        <span :class="showTab1?'active':''" @click="handleChangeTab(true)">待审核问题</span>
        <span :class="!showTab1?'active':''" @click="handleChangeTab(false)">待审核回复</span>
      </div>
      <!-- 待审核问题表 -->
      <el-table v-loading="loading" :data="tableData" v-if="showTab1&&tableData.length>0">
        <el-table-column label="时间">
          <template #default="props">
            <p class="time">{{formatTime(props.row.createTime)}}</p>
          </template>
        </el-table-column>
        <el-table-column label="问题" min-width="220">
          <template #default="props">
            <p class="title">{{props.row.messageTitle}}</p>
            <p class="content">{{props.row.messageContent}}</p>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="180" align="center">
          <template #default="scope">
            <el-button type="primary" @click="handlePass(scope.row)">通过</el-button>
            <el-button type="danger" @click="handleNoPass(scope.row)">不通过</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 待审核评论表 -->
      <el-table v-loading="loading" :data="tableData" v-if="!showTab1&&tableData.length>0">
        <el-table-column label="时间">
          <template #default="props">
            <p class="time">{{formatTime(props.row.createTime)}}</p>
          </template>
        </el-table-column>
        <el-table-column label="回复" min-width="220">
          <template #default="props">
            <p class="title">{{props.row.replyContent}}</p>
            <p class="content">所属问题:{{props.row.messageTitle}}</p>
          </template>
        </el-table-column>
        <el-table-column label="操作" min-width="180" align="center">
          <template #default="scope">
            <el-button type="primary" @click="handleReplyPass(scope.row)">通过</el-button>
            <el-button type="danger" @click="handleReplyNoPass(scope.row)">不通过</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-empty description="暂无待审核内容" v-if="tableData.length==0"></el-empty>
    </div>
  </el-card>
</template>

<script>
import { nextTick, onMounted, reactive, ref, toRefs } from 'vue'
import { useStore } from 'vuex'
import { ElMessage } from 'element-plus'
import { formatTime } from '@/utils'
import axios from '@/utils/axios'
export default {
  name: 'ExperienceAudit',
  setup () {
    const formRef = ref(null)
    const store = useStore()

    const state = reactive({
      showTab1: true,//显示问题列表或回复列表
      search: '',
      tableData: [],
      total: 0,
      loading: false,
      UserId: store.state.userInfo?.userId,
      userType: store.state.userInfo?.userType,
    })
    onMounted(() => {
      if (!state.UserId) return;
      getPostMessage()
    })
    // 经验分享
    const getPostMessage = () => {
      state.loading = true
      axios.post('/Exchange/PostMessage/List', {
        "MessageTitle": state.search,
        "CheckStatus": 1,
        // "UserId": state.showAll ? '' : state.UserId,//显示全部userid传空
        "PageIndex": 1,
        "PageSize": 999
      }).then(res => {
        // console.log('经验分享:', res)

        state.tableData = res.data
        state.total = res.count
        state.loading = false
      }).catch(err => {
        console.log('err', err)

      })
    }
    // 问题回复列表
    const getReply = () => {
      state.loading = true
      axios.post('/Exchange/Reply/List/All', {
        "PostId": 0,
        "CheckStatus": 1,
        "PageIndex": 1,
        "PageSize": 1000
      }).then(res => {
        console.log('问题回复列表:', res.data)
        state.tableData = res.data
        state.total = res.count
        state.loading = false
      }).catch(err => {
        console.log('err', err)

      })
    }
    // 显示全部或者我的问题
    const handleChangeTab = (boo) => {
      state.showTab1 = boo
      if (boo) {
        getPostMessage()
      } else {
        getReply()
      }
    }
    // 问题审核通过
    const handlePass = (e) => {
      axios.put(`/Exchange/PostMessage/Check?id=${e.id}&status=2`).then(res => {
        // console.log('经验分享:', res)
        ElMessage.success('审核成功')
        getPostMessage()
      }).catch(err => {
        console.log('err', err)
      })
    }
    // 问题审核不通过
    const handleNoPass = (e) => {
      axios.put(`/Exchange/PostMessage/Check?id=${e.id}&status=3`).then(res => {
        // console.log('经验分享:', res)
        ElMessage.success('审核成功')
        getPostMessage()
      }).catch(err => {
        console.log('err', err)
      })
    }
    // 回复审核通过
    const handleReplyPass = (e) => {
      axios.put(`/Exchange/Reply/Check?id=${e.id}&status=2`).then(res => {
        // console.log('经验分享:', res)
        ElMessage.success('审核成功')
        getReply()
      }).catch(err => {
        console.log('err', err)
      })
    }
    // 回复审核不通过
    const handleReplyNoPass = (e) => {
      axios.put(`/Exchange/Reply/Check?id=${e.id}&status=3`).then(res => {
        // console.log('经验分享:', res)
        ElMessage.success('审核成功')
        getReply()
      }).catch(err => {
        console.log('err', err)
      })
    }
    return {
      ...toRefs(state),
      formatTime,
      handleChangeTab,
      handlePass,
      handleNoPass,
      handleReplyPass,
      handleReplyNoPass
    }
  }
}
</script>
<style lang="scss" scoped>
.control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .control_name {
    font-size: 23px;
    font-weight: bold;
  }
  .el-input {
    width: 300px;
  }
}
.btn_box {
  padding: 20px 0;
  span {
    cursor: pointer;
    padding: 10px;
    margin-right: 50px;
    font-size: 16px;
  }
  .active {
    color: #3a84ff;
  }
}
.experience {
  background: #fff;
  padding: 0 20px;
  padding-bottom: 40px;
  .time {
    color: #999;
  }
  .title {
    font-size: 23px;
    color: #333;
  }
  .content {
    font-size: 16px;
    color: #999;
    margin-top: 16px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .reply {
    color: #3a84ff;
    font-size: 16px;
    text-align: right;
  }
  .del {
    color: rgb(249, 62, 62);
  }
}
</style>