123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <template>
- <div class="right" :style="{ height: height, width: width }">
- <div class="up">
- <div>
- <div class="up-title"><i class="el-icon-search"></i>筛选搜索</div>
- <div class="btn">
- <el-button plain @click="reset">重置</el-button>
- <el-button type="primary" @click="searchJingMessage" plain>查询列表</el-button>
- </div>
- </div>
- <div class="left-up">
- <div class="up-input-title">
- 消息标题:<el-input v-model="input" class="up-input" placeholder="请输入内容"></el-input>
- </div>
- <div class="up-input-title-right">
- <span class="demonstration" >发布时间:</span>
- <el-date-picker v-model="value2" type="datetimerange" class="up-input-right" :picker-options="pickerOptions"
- range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" align="right">
- </el-date-picker>
- </div>
- </div>
- </div>
- <div class="down">
- <div class="down-add">
- <el-row :gutter="24">
- <el-col :span="22" class="down-title"> <i class="el-icon-tickets">消息列表</i> </el-col>
- <el-col :span="2"> <el-button id="addBtn" size="small" @click="addNoticce">添加</el-button> </el-col>
- </el-row>
- </div>
- <div class="down-table">
- <el-table :data="tableData" order style="width: 100%" class="messagetable">
- <el-table-column prop="newsId" label="ID">
- </el-table-column>
- <el-table-column :formatter="stateFormat" prop="newsTitle" label="消息标题">
- </el-table-column>
- <el-table-column prop="userPhone" label="手机号">
- </el-table-column>
- <el-table-column prop="createTime" label="发布时间">
- </el-table-column>
- <el-table-column prop="operate" label="操作">
- <template slot-scope="scope">
- <el-button size="mini" type="text" @click="viewDetails(scope)" v-bind:row_ = "row_">查看详情</el-button>
- <el-popconfirm title="你确定删除本条消息吗?" @confirm="deleteMessage(scope)">
- <el-button class="btn-delete" size="mini" type="text" icon="el-icon-delete"
- slot="reference">删除</el-button>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <div class="bottom">
- <div class="bottom-page">
- <el-pagination layout="prev, pager, next" :total="tableData.length" @size-change="handleSizeChange"
- @current-change="handleCurrentChange">
- </el-pagination>
- </div>
- <span class="bottom-number">共{{ tableData.length }}条 </span>
- </div>
- </div>
- </template>
- <script>
- import { getMessage, deleteMessage, searchJMessage } from '../../api/message/message.js'
- import mitt from '@/utils/mitt.js';
- export default {
- props: {
- },
- data() {
- return {
- tableData: [],
- input: "",
- value2: "",
- mock: "",
- mockMessageList: [],
- currentPage: 1,
- pagesize: 10,
- row_ : "1",
- }
- },
- mounted() {
- this.getMockMessageList();
- },
- beforeDestroy() {
- },
- methods: {
- getMockMessageList() {
- getMessage().then((res) => {
- this.tableData = res.rows
- console.log(res.rows);
- })
- },
- //分页功能
- getPageData() {
- console.log(this.mockMessageList);
- let start = (this.currentPage - 1) * this.pagesize;
- let end = start + this.pagesize;
- this.tableData = this.mockMessageList.slice(start, end);
- },
- handleSizeChange(val) {
- this.pagesize = val;
- this.getPageData();
- },
- handleCurrentChange(val) {
- this.currentPage = val;
- this.getPageData();
- },
- stateFormat(row, column, cellValue) {
- if (!cellValue) return ''
- if (cellValue.length > 15) { //最长固定显示10个字符
- return cellValue.slice(0, 15) + '...'
- }
- return cellValue
- },
- //删除列表
- deleteMessage(row) {
- console.log(row);
- row = row.row.newsId
- console.log(row);
- deleteMessage(row).then((res) => {
- console.log(res);
- this.$message({
- message: '恭喜你,删除成功!',
- type: 'success'
- });
- this.$router.go(0)
- })
- },
- //查看详情
- viewDetails(row) {
- row = row.row.newsId
- mitt.emit('searchMore', row)
- this.row_ = row
- console.log(this.row_);
- this.$router.push({path:"/messageList/messageDetails",query:{row_: this.row_}})
- // this.$router.push("/messageList/messageDetails");
- },
- //添加跳转
- addNoticce() {
- this.$router.push("/messageList/addMessage");
- },
- //搜索
- searchJingMessage() {
- // console.log(this.input );
- searchJMessage(
- this.input
- ).then((res) => {
- console.log(res);
- this.tableData = res.rows
- })
- this.reset();
- },
- //重置
- reset() {
- this.input = ""
- this.value2 = ""
- }
- }
- }
- </script>
- <style scoped>
- .up {
- width: 96%;
- height: 170px;
- margin-top: 20px;
- margin-left: 2%;
- border: 1px solid #ccc;
- border-radius: 4px;
- }
- .up-title {
- font-size: 20px;
- width: 20%;
- margin-left: 20px;
- margin-top: 20px;
- float: left;
- }
- .btn {
- float: right;
- padding-right: 3%;
- margin-top: 2.5%;
- }
- .up-input {
- width: 250px;
- margin-left: 15px;
- }
- .up-input-title {
- margin-left: 40px;
- float: left;
- }
- .up-input-right {
- margin-left: 15px;
- width: 500px;
- }
- .up-input-title-right {
- width: 800px;
- margin-left: 450px;
- }
- .left-up {
- width: 80%;
- float: left;
- height: 37px;
- margin-top: 50px;
- }
- .right-up {
- width: 16%;
- margin-top: 2%;
- float: right;
- }
- .anniu {
- padding-right: 5%;
- }
- .down {
- margin-top: 40px;
- }
- .down-add {
- padding: 10px;
- margin: 0 27px;
- border: 1px solid #ccc;
- border-radius: 2px
- }
- .down-title {
- padding-top: 10px;
- color: #303133;
- }
- .down-table {
- margin-top: 15px;
- text-align: center;
- margin: 35px 27px;
- }
- .el-table .el-table__header-wrapper th,
- .el-table .el-table__fixed-header-wrapper th {
- word-break: break-word;
- /* background-color: #f8f8f9; */
- color: #515a6e;
- height: 40px;
- font-size: 13px;
- text-align: center;
- }
- .bottom-number {
- padding-top: 5px;
- color: #303133;
- float: right;
- }
- .bottom-page {
- float: right;
- }
- .el-icon-search {
- padding-right: 10px;
- }
- .btn-delete {
- margin-left: 20px;
- }
- /**
- 自适应
- */
- /* .demonstration{
- width: 50%;
- } */
- .right {
- float: none;
- width: 100%;
- height: 100%;
- /* background-color: #9dc3e6; */
- }
- </style>
|