Commit a3f31c64 authored by liuyangyang's avatar liuyangyang

分页问题修改

parent ef68a0a1
...@@ -93,7 +93,7 @@ const props = defineProps({ ...@@ -93,7 +93,7 @@ const props = defineProps({
align: { align: {
type: String, type: String,
default: "left", default: "left",
} },
}); });
const emit = defineEmits([ const emit = defineEmits([
...@@ -148,7 +148,7 @@ const total = computed(() => props.total); ...@@ -148,7 +148,7 @@ const total = computed(() => props.total);
// 当前页数据 // 当前页数据
const currentPageData = computed(() => { const currentPageData = computed(() => {
if (!props.showPagination) return props.data; if (props.showPagination) return props.data;
const start = (currentPage.value - 1) * pageSize.value; const start = (currentPage.value - 1) * pageSize.value;
const end = start + pageSize.value; const end = start + pageSize.value;
return props.data.slice(start, end); return props.data.slice(start, end);
...@@ -178,11 +178,17 @@ const emitPaginationChange = () => { ...@@ -178,11 +178,17 @@ const emitPaginationChange = () => {
emit("update:page-size", pageSize.value); emit("update:page-size", pageSize.value);
}; };
const setCurrentPage = () => {
currentPage.value = 1;
};
defineExpose({ setCurrentPage })
// 监听数据变化,重置分页 // 监听数据变化,重置分页
watch( watch(
() => props.data, () => props.data,
() => { () => {
currentPage.value = 1; // currentPage.value = 1;
}, },
{ deep: true } { deep: true }
); );
......
...@@ -74,10 +74,11 @@ ...@@ -74,10 +74,11 @@
</div> </div>
<div class="table-box"> <div class="table-box">
<common-table <common-table
ref="pageRef"
:data="tableData.list" :data="tableData.list"
:columns="tableColumns" :columns="tableColumns"
:total="total" :total="total"
:default-page-size="pageSize" :default-page-size="20"
@pagination-change="handlePaginationChange" @pagination-change="handlePaginationChange"
:pagination-texts="{ :pagination-texts="{
total: '共', total: '共',
...@@ -167,7 +168,7 @@ const tableColumns = ref([ ...@@ -167,7 +168,7 @@ const tableColumns = ref([
{ {
prop: "index", prop: "index",
label: "序号", label: "序号",
width: "5%", width: "4%",
}, },
{ {
prop: "eventName", prop: "eventName",
...@@ -177,22 +178,22 @@ const tableColumns = ref([ ...@@ -177,22 +178,22 @@ const tableColumns = ref([
{ {
prop: "name", prop: "name",
label: "发生位置", label: "发生位置",
width: "9%", width: "15%",
}, },
{ {
prop: "deviceType", prop: "deviceType",
label: "设备类型", label: "设备类型",
width: "9%", width: "7%",
}, },
{ {
prop: "alarmIndicators", prop: "alarmIndicators",
label: "告警指标", label: "告警指标",
width: "9%", width: "7%",
}, },
{ {
prop: "value", prop: "value",
label: "监测值", label: "监测值",
width: "9%", width: "5%",
}, },
{ {
prop: "eventTime", prop: "eventTime",
...@@ -202,7 +203,7 @@ const tableColumns = ref([ ...@@ -202,7 +203,7 @@ const tableColumns = ref([
{ {
prop: "isSuspendAlarm", prop: "isSuspendAlarm",
label: "是否挂起期间告警", label: "是否挂起期间告警",
width: "9%", width: "8%",
}, },
{ {
prop: "operate", prop: "operate",
...@@ -212,20 +213,7 @@ const tableColumns = ref([ ...@@ -212,20 +213,7 @@ const tableColumns = ref([
]); ]);
const tableData = reactive({ const tableData = reactive({
list: [ list: [],
{
deviceName: "1#除尘器",
compart: "1234567890",
position: "转炉",
changeDateRemind: "xx",
changeDate: "xx",
changePeo: "xx",
ownerdeviceName: "xx",
lastAlarmTime: "xx",
changeRound: "xx",
operate: "挂起",
},
],
}); });
const typeList = reactive({ const typeList = reactive({
...@@ -251,9 +239,12 @@ const handlePaginationChange = (pagination) => { ...@@ -251,9 +239,12 @@ const handlePaginationChange = (pagination) => {
}; };
const onSubmit = () => { const onSubmit = () => {
currentPage.value = 1;
pageRef.value.setCurrentPage(currentPage.value);
getAlarmList(); getAlarmList();
}; };
const pageRef = ref(null);
const onReset = () => { const onReset = () => {
formInline.value = { formInline.value = {
eventName: "", eventName: "",
...@@ -265,6 +256,7 @@ const onReset = () => { ...@@ -265,6 +256,7 @@ const onReset = () => {
}; };
currentPage.value = 1; currentPage.value = 1;
pageSize.value = 20; pageSize.value = 20;
pageRef.value.setCurrentPage(currentPage.value);
getAlarmList(); getAlarmList();
}; };
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</div> </div>
<div class="table-box"> <div class="table-box">
<common-table <common-table
ref="pageRef"
:data="tableData.list" :data="tableData.list"
:columns="tableColumns" :columns="tableColumns"
:default-page-size="20" :default-page-size="20"
...@@ -184,17 +185,17 @@ const tableColumns = ref([ ...@@ -184,17 +185,17 @@ const tableColumns = ref([
const tableData = reactive({ const tableData = reactive({
list: [ list: [
{ // {
deviceName: "1#除尘器", // deviceName: "1#除尘器",
compart: "1234567890", // compart: "1234567890",
position: "转炉", // position: "转炉",
changeDateRemind: "xx", // changeDateRemind: "xx",
changeDate: "xx", // changeDate: "xx",
changePeo: "xx", // changePeo: "xx",
ownerdeviceName: "xx", // ownerdeviceName: "xx",
lastAlarmTime: "xx", // lastAlarmTime: "xx",
changeRound: "xx", // changeRound: "xx",
}, // },
], ],
}); });
...@@ -246,9 +247,12 @@ const handlePaginationChange = (pagination) => { ...@@ -246,9 +247,12 @@ const handlePaginationChange = (pagination) => {
}; };
const onSubmit = () => { const onSubmit = () => {
currentPage.value = 1;
pageRef.value.setCurrentPage(currentPage.value);
getAllDustList(); getAllDustList();
}; };
const pageRef = ref(null);
const onReset = () => { const onReset = () => {
formInline.value = { formInline.value = {
compart: "", compart: "",
...@@ -257,6 +261,7 @@ const onReset = () => { ...@@ -257,6 +261,7 @@ const onReset = () => {
}; };
currentPage.value = 1; currentPage.value = 1;
pageSize.value = 20; pageSize.value = 20;
pageRef.value.setCurrentPage(currentPage.value);
getAllDustList(); getAllDustList();
}; };
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
</div> </div>
<div class="table-box"> <div class="table-box">
<common-table <common-table
ref="pageRef"
:data="tableData.list" :data="tableData.list"
:columns="tableColumns" :columns="tableColumns"
:default-page-size="20" :default-page-size="20"
...@@ -229,9 +230,12 @@ const handlePaginationChange = (pagination) => { ...@@ -229,9 +230,12 @@ const handlePaginationChange = (pagination) => {
}; };
const onSubmit = () => { const onSubmit = () => {
currentPage.value = 1;
pageRef.value.setCurrentPage(1);
getManagementList(); getManagementList();
}; };
const pageRef = ref(null);
const onReset = () => { const onReset = () => {
formInline.value = { formInline.value = {
deviceType: "", deviceType: "",
...@@ -240,6 +244,7 @@ const onReset = () => { ...@@ -240,6 +244,7 @@ const onReset = () => {
}; };
currentPage.value = 1; currentPage.value = 1;
pageSize.value = 20; pageSize.value = 20;
pageRef.value.setCurrentPage(currentPage.value);
getManagementList(); getManagementList();
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment