123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <template>
- <div class="communityManage app-container">
- <div class="search">
- <div>
- <el-date-picker
- v-model="date"
- size="small"
- class="item-width-350"
- value-format="yyyy-MM-dd HH:mm:ss"
- type="datetimerange"
- range-separator="至"
- :default-time="['00:00:00', '23:59:59']"
- start-placeholder="开始日期"
- end-placeholder="结束日期">
- </el-date-picker>
- <el-button
- class="ml10"
- type="primary"
- size="small"
- icon="el-icon-search"
- @click="handleSearch"
- >
- 搜索
- </el-button>
- </div>
- <el-button class="add-btn" type="primary" size="small" @click="handleAdd">添加</el-button>
- </div>
- <el-table
- :data="tableData"
- tooltip-effect="dark"
- border
- v-loading="loading"
- style="width: 100%"
- >
- <el-table-column
- align="center"
- label="用户ID"
- prop="publishUserId"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="nickname"
- align="center"
- label="昵称"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="createTime"
- align="center"
- label="创建时间"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="communityTitle"
- align="center"
- label="标题"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="viewedCount"
- align="center"
- label="浏览数"
- show-overflow-tooltip
- >
- </el-table-column>
- <!-- <el-table-column
- prop="payAmount"
- align="center"
- label="评论数"
- show-overflow-tooltip
- >
- </el-table-column> -->
- <el-table-column
- prop="likeCount"
- align="center"
- label="点赞数"
- show-overflow-tooltip
- >
- </el-table-column>
- <el-table-column
- prop="createTime"
- align="center"
- label="状态"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <span :class="[scope.row.state == 1?'red':'green']">{{scope.row.state == 1?'隐藏':'显示' }}</span>
- </template>
- </el-table-column>
-
- <el-table-column prop="address" align="center" label="操作">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="handleDetail(scope.row)">编辑</el-button>
- <el-button type="text" size="small" @click="handleTop(scope.row.id)">置顶</el-button>
- <el-button type="text" size="small" @click="handleState(scope.row.id,scope.row.state == 1?2:1)">{{scope.row.state == 1?'显示':'隐藏' }}</el-button>
- <el-button type="text" class="red" size="small" @click="handleDel(scope.row.id)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="page-box">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- background
- :current-page="query.currentPage"
- :page-sizes="[10, 20, 30, 40]"
- :page-size="query.pageSize"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- </div>
- </template>
-
- <script>
- import {debounce} from '@/utils/index'
- import {getCommunityList,operate,delCommunity,top} from '@/api/study'
- export default {
- name: "communityManage",
- data() {
- return {
- date:'',//时间
- tableData: [],
- loading: false,
- query: {
- "currentPage": 1,
- "pageSize": 10,
- "startDate":'',
- "endDate":'',
- },
- title: "",
- total: 0,
- };
- },
- watch: {
- // query: {
- // handler: debounce(function(val) {
- // this.getCommunityList()
-
- // }),
- // deep:true
- // },
- date(val){
- if(val){
- this.query.startDate = val[0]
- this.query.endDate = val[1]
- }else{
- this.query.startDate = ''
- this.query.endDate = ''
- }
- }
- },
- methods: {
- handleSearch(){
- this.query.currentPage = 1
- this.getCommunityList();
- },
- handleAdd(){
- this.$router.push('/studyManage/communityManage/addArticle')
- },
- handleTop(id){
- this.$confirm(`此操作将置顶该数据, 是否继续?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- top({id}).then(res=>{
- if(res.state == 'Success'){
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.search()
- }
- })
- })
- },
- handleState(id,state){
- let msg
- if(state == 2){
- msg = '显示'
- }else{
- msg = '隐藏'
- }
- this.$confirm(`此操作将${msg}该数据, 是否继续?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- operate({id,state}).then(res=>{
- if(res.state == 'Success'){
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.getCommunityList()
- }
- })
- })
-
- },
- // 点击删除
- handleDel(id) {
- this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- delCommunity({id}).then(res=>{
- if(res.state == 'Success'){
- this.$notify({
- title: '成功',
- message: '操作成功',
- type: 'success'
- });
- this.search()
- }
- })
- })
- },
- handleDetail(row){
- this.$router.push({
- path:'/studyManage/communityManage/addArticle',
- query:{
- id:row.id
- }
- })
- },
- handleSizeChange(val) {
- this.query.currentPage = 1;
- this.query.pageSize = val;
- this.getCommunityList()
- },
- handleCurrentChange(val) {
- this.query.currentPage = val;
- this.getCommunityList()
- },
- search() {
- this.query.currentPage = 1;
- this.getCommunityList()
- },
- getCommunityList(){
- this.loading = true
- getCommunityList(this.query).then(res=>{
- this.loading = false
- if(res.state == 'Success'){
- this.tableData = res.content.records
- this.total = res.content.total
- }
- })
- }
- },
- created() {
- this.getCommunityList()
- },
- };
- </script>
-
- <style lang="scss" scoped>
- .communityManage {
- .search{
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- }
- </style>
-
|