| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?php
- ?>
- <div id="app" v-cloak>
- <el-card shadow="never" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <span>列表</span>
- <el-button style="margin: -5px 0" type="primary" size="small" @click="$navigate({r:'mall/postage-rules/index'})">添加
- </el-button>
- </div>
- <div class="table-body">
- <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
- <el-form-item>
- <el-input placeholder="请输入名称" v-model="search_data.title"></el-input>
- </el-form-item>
- <el-form-item>
- <el-input placeholder="请输入ID精准搜索" v-model="search_data.id"></el-input>
- </el-form-item>
- <el-form-item>
- <el-date-picker style="margin-top: 1px;" @change="changeTime" v-model="datetime" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']"></el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button size="small" type="primary" @click="search">搜索</el-button>
- <el-button size="small" type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件</el-button>
- </el-form-item>
- </el-form>
- <el-table v-loading="listLoading" :data="list" stripe style="width: 100%">
- <el-table-column label="ID" prop="id" align="center"></el-table-column>
- <el-table-column label="标题" prop="title" align="center">
- <template slot-scope="scope">
- <div size="small">{{scope.row.title}}</div>
- </template>
- </el-table-column>
- <el-table-column label="操作" min-width="300" align="center">
- <template slot-scope="scope">
- <el-button type="text" @click="handle('edit',scope.row)">编辑</el-button>
- <el-button type="text" @click="handle('delete',scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </div>
- </el-card>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- list: [{
- title: "测试标题"
- }],
- listLoading: false,
- page: 1,
- pageCount: 0,
- search_data: { // 筛选条件
- start: null,
- end: null,
- id: null,
- name: null,
- },
- datetime:[]
- };
- },
- mounted: function() {
- this.getList();
- },
- computed: {
- show_clear_search_btn: function() {
- return !isEmpty(this.search_data.start) || !isEmpty(this.search_data.end)
- || !isEmpty(this.search_data.id) || !isEmpty(this.search_data.name);
- }
- },
- methods: {
- changeTime(e) {
- // console.log(e)
- this.search_data.start = e[0]
- this.search_data.end = e[1]
- },
- sortChange(row) {
- if (row.prop) {
- this.search_data.sort_field = row.prop;
- this.search_data.sort_type = row.order == "descending" ? 'desc' : 'asc';
- } else {
- this.search_data.sort_prop = null;
- this.search_data.sort_type = null;
- }
- this.getList(this.search_data);
- },
- search() {
- this.getList(this.search_data);
- },
- clearSearch() {
- this.search_data.start = null;
- this.search_data.end = null;
- this.search_data.id = null;
- this.search_data.name = null;
- this.datetime = [];
- this.getList();
- },
- handle(type, data = null) {
- let id = data ? parseInt(data.id) : '';
- switch (type) {
- case 'edit':
- let params = {
- //编辑页面路径
- r: ''
- };
- if (id) params = Object.assign(params, {id: id});
- navigateTo(params);
- break;
- }
- },
- pagination(currentPage) {
- let self = this;
- self.page = currentPage;
- self.getList();
- },
- // 获取广告列表
- getList() {
- let self = this;
- if (self.listLoading == false) {
- self.listLoading = true;
- request({
- params: {
- r: '',
- page: self.page,
- },
- method: 'get',
- }).then(e => {
- self.listLoading = false;
- if (e.data.code == 0) {
- self.list = e.data.data.list;
- self.pageCount = e.data.data.page_count;
- } else {
- self.$message.error(e.data.msg);
- }
- }).catch(e => {
- self.$message.error(e.data.msg);
- self.listLoading = false;
- });
- }
- },
- }
- });
- </script>
|