<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input v-model="listQuery.title" placeholder="标题搜索" style="width: 200px;" class="filter-item" />
      <el-button v-waves class="filter-item" type="primary" @click="getList">
        搜索
      </el-button>
      <el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate()" v-if="areaId==2">
        发布通知
      </el-button>
    </div>

    <el-table
      :key="tableKey"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="序号" align="center" width="80">
        <template slot-scope="{$index}">
          <span>{{ $index+1 }}</span>
        </template>
      </el-table-column>


      <el-table-column label="标题" width="400px" align="center">
        <template slot-scope="{row}">
          <span>{{ row.title}}</span>
        </template>
      </el-table-column>

            <el-table-column label="封面图" width="300px" align="center">
        <template slot-scope="{row}">
          <el-image :src="row.picture" style="width: 150px; height: 80px">

          </el-image>
        </template>
      </el-table-column>


      <el-table-column label="发布时间" width="400px" align="center">
        <template slot-scope="{row}">

          <span>{{ row.createdtime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发布人" width="300px" align="center">
        <template slot-scope="{row}">
          <span>孝南区市场监督管理局</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" min-width="130" class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <el-button type="primary" size="mini" @click="handleUpdate(row)">
            修改
          </el-button>
          <el-button type="danger" size="mini" @click="del(row,$index)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="listQuery.pageNum"
      :limit.sync="listQuery.pageSize"
      @pagination="getList"
    />
    <!--查看{-->
    <el-dialog title="查看" :visible.sync="dialogFormVisible">
      <div :model="temp" class="detailDialog">
        <el-row class="detailDialog-item">
          <el-col :span="4" class="detailDialog-item-tit">标题:</el-col>
          <el-col :span="20">
            <span style="line-height: 40px">{{ temp.noticeTitle}}</span>
          </el-col>
        </el-row>
        <el-row class="detailDialog-item">
          <el-col :span="4" class="detailDialog-item-tit">发布时间:</el-col>
          <el-col :span="20">
            <span style="line-height: 40px">{{temp.creationTime | parseTime('{y}-{m}-{d} {h}:{i}')}}</span>
          </el-col>
        </el-row>

         <el-row class="detailDialog-item">
          <el-col :span="4" class="detailDialog-item-tit">文章内容:</el-col>
          <el-col :span="20">
            <p style="line-height: 40px" v-html="temp.noticeContext"></p>
          </el-col>
        </el-row>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogFormVisible = false">
          关闭
        </el-button>
      </div>
    </el-dialog>
    <!---}查看-->


  </div>
</template>

<script>
/*import { findPageNotice,remove,seeDetail} from '@/api/SupervisionNoticeList'*/
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import {getUser} from "@/utils/auth";
import {AnnouncementList,DelAnnouncement} from "@/api/supervisionNotice/supervisionNotice";

export default {
  name: 'ComplexTable',
  components: { Pagination },

  directives: { waves },
  data() {
    return {
      roleView:false,
      tableKey: 0,
      list:[],
      total: 0,
      user:null,
      areaId:'',
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 10,
        title: '',
      },
      name:'',
      calendarTypeOptions:[],
      reader:[],
      temp: {
        id: undefined,
        remark: '',
        title: '',
        type: '',
        readDeptName:''
      },
      dialogFormVisible: false,
    }
  },
  created() {
    //this.name = window.localStorage.getItem('name')
    //this.getList();
    //this.user = JSON.parse(getUser())
    this.areaId=JSON.parse(getUser()).areaId
    console.log("444",this.areaId)
    // console.log(JSON.parse(getUser()).deptCode)


    this.getList();
  },
  methods: {
     //查询所有数据
/*     getList() {
      this.listLoading = true
      findPageNotice({
        page: this.listQuery.page,
        pageSize: this.listQuery.limit,
        startTime: this.listQuery.startTime,
        endTime: this.listQuery.endTime,
        keywords: this.listQuery.keyWords
      }).then(response => {
        console.log(response)
        this.listLoading = false,
        this.list = response.data.list,
        this.total = response.data.total
      })
    },*/
    //获得页面数据
    getList() {
      this.listLoading = true
      // console.log(this.listQuery)
      AnnouncementList({
        pageNum:this.listQuery.pageNum,
        pageSize:this.listQuery.pageSize,
        title:this.listQuery.title,
      }).then(response => {
        console.log("12345",response)
        this.listLoading = false
        if(response.code == 200){
          this.list = response.data.list,
          this.total = response.data.total
        }
      }).catch(function(reason) {
        // that.listLoading = false
        // that.list = null
        // console.log('catch:', reason);
      })
    },
     // 删除
    del(data){
        this.$confirm('是否删除“ '+data.title+' ”?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
        }).then(() => {

          DelAnnouncement({
                /*token:this.token,*/
                id: data.id
            }).then(res=>{
                this.$message({
                    type: 'success',
                    message: '删除成功!'
                });
                this.getList();
            })
        })
    },
    //查询方法
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    //发布通知方法
    handleCreate() {
      this.$router.push({ path: '/SupervisionNotice/AddSupervisionNotice' })
    },

    //修改通知方法
    handleUpdate(row) {
      //this.$router.push({ path: '/SupervisionNotice/UpdateSupervisionNotice',query: {id:'12'} })
      this.$router.push({ path: '/SupervisionNotice/UpdateSupervisionNotice',query: {id:row.id} })
    },
    //查看弹出框
    /*handleUpdate(row) {
       console.log('查看')
      this.temp = Object.assign({}, row) // copy obj



      this.dialogFormVisible = true
    }*/
  }
}
</script>
<style lang="scss" scoped>
   .type_box{
    margin: 0 0 10px;
  }
  .detailDialog{
    padding:0 40px;
    text-align: left;
    font-size:16px;
  }
  .detailDialog-item-tit{
    font-weight: 700;
    line-height: 40px;
  }
  .detailDialog-item{
    margin: 8px;
  }
  .detailDialog-item-pre{
    margin :0 0 10px 0;
    line-height: 25px;
  }
  .editDialog-wr{
    margin: 30px;
  }
  .fafw-btn{
    margin: 5px 5px 5px 0;
  }
</style>

  view list页面数据对接_数据

 

 

 

代码全部贴出,展现的页面效果如上,里面有些无用代码,直接忽略,具体记录下我需要记住的重点

第一个:列表分页

view list页面数据对接_搜索_02

 

 

 页面显示

view list页面数据对接_html_03

 

 

 view list页面数据对接_html_04

 

 

 view list页面数据对接_html_05

 

 第二:条件查询。传参。界面条件查询,也是请求getlist()方法

view list页面数据对接_搜索_06

 

 第三:删除方法

view list页面数据对接_数据_07

 

 

view list页面数据对接_html_08