1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/baiy-Cadmin-client-vue

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
tableLists.vue 3.2 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
baiy Отправлено 6 лет назад 71c2a95
<template>
<div class="table-lists">
<page-bar v-if="!hiddenFilter">
<slot name="filterContent"></slot>
<slot name="filterButton" v-if="filterType === 1">
<Button type="primary" @click="reload()">查 询</Button>
</slot>
<div slot="right">
<slot name="filterRight"></slot>
</div>
</page-bar>
<slot></slot>
<page-bar style="margin-top: 10px" :rightWidth="750">
<slot name="options"></slot>
<div slot="right">
<page @on-change="changePage" :current="page" :page-size="pageSizeData" :total="total" show-total
show-elevator show-sizer @on-page-size-change="pageSizeChange"
:page-size-opts="[10,20,50,100,200]"></page>
</div>
</page-bar>
</div>
</template>
<script>
import _ from 'lodash'
export default {
name: "tableLists",
data() {
return {
page: 1,
total: 0,
pageSizeData: this.pageSize,
};
},
props: {
value: {
type: [Array,Object],
default: function () {
return []
}
},
filter: {
type: Object,
default: function () {
return {}
}
},
pageSize: {
type: Number,
default: 20
},
requestApi: {
type: String,
required: true
},
autoLoad: {
type: Boolean,
default: true
},
hiddenFilter: {
type: Boolean,
default: false
},
// 0 不显示按钮 1 搜索按钮触发 2 筛选条件发生变化触发筛选
filterType: {
type: Number,
default: 1
}
},
watch: {
filter: {
handler: function () {
if (this.filterType === 2) {
this.reload()
}
},
deep: true
}
},
created() {
if (this.autoLoad) {
this.load();
}
},
methods: {
changePage: function (page) {
this.page = page;
this.load();
},
pageSizeChange: function (size) {
this.pageSizeData = size;
this.reload();
},
load() {
this.$request(this.requestApi).data({
offset: (this.page - 1) * this.pageSizeData,
pageSize: this.pageSizeData,
..._.cloneDeep(this.filter)
}).success((r) => {
this.total = r.data['total'];
this.$emit('input', r.data['lists']);
}).get()
},
reload(isPage) {
if (!isPage) {
this.page = 1;
}
this.load();
},
},
}
</script>

Комментарий ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/baiy-Cadmin-client-vue.git
git@gitlife.ru:oschina-mirror/baiy-Cadmin-client-vue.git
oschina-mirror
baiy-Cadmin-client-vue
baiy-Cadmin-client-vue
master