Commit 012ca3e4 by tang

feat: 添加分頁顯示

parent ed68a4ad
...@@ -99,10 +99,10 @@ ...@@ -99,10 +99,10 @@
<div class="result-box" v-show="showResult && resultType === 'company'"> <div class="result-box" v-show="showResult && resultType === 'company'">
<div class="result-box-title">查询 {{ searchCodeShow }} 结果</div> <div class="result-box-title">查询 {{ searchCodeShow }} 结果</div>
<div class="result-box-body"> <div class="result-box-body">
<template v-if="result"> <template v-if="currentData">
<!--结果表格--> <!--结果表格-->
<el-table <el-table
:data="result" :data="currentData"
header-cell-class-name="search-table-hc" header-cell-class-name="search-table-hc"
style="width: 100%" style="width: 100%"
> >
...@@ -139,6 +139,8 @@ ...@@ -139,6 +139,8 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pages2 :total="pagination.total" :currPage="pagination.currPage" :pageSize="pagination.pageSize"
@getLimit='handlePageChange'></pages2>
</template> </template>
<span style="color: rgb(255, 59, 48)" v-else>{{ errorMsg }}</span> <span style="color: rgb(255, 59, 48)" v-else>{{ errorMsg }}</span>
</div> </div>
...@@ -146,10 +148,10 @@ ...@@ -146,10 +148,10 @@
<div class="result-box" v-show="showResult && resultType === 'product'"> <div class="result-box" v-show="showResult && resultType === 'product'">
<div class="result-box-title">查询 {{ searchCodeShow }} 结果</div> <div class="result-box-title">查询 {{ searchCodeShow }} 结果</div>
<div class="result-box-body"> <div class="result-box-body">
<template v-if="result"> <template v-if="currentData">
<!--结果表格--> <!--结果表格-->
<el-table <el-table
:data="result" :data="currentData"
header-cell-class-name="search-table-hc" header-cell-class-name="search-table-hc"
style="width: 100%" style="width: 100%"
> >
...@@ -167,6 +169,8 @@ ...@@ -167,6 +169,8 @@
</el-table-column> </el-table-column>
<el-table-column prop="status" label="状态"></el-table-column> <el-table-column prop="status" label="状态"></el-table-column>
</el-table> </el-table>
<pages2 :total="pagination.total" :currPage="pagination.currPage" :pageSize="pagination.pageSize"
@getLimit='handlePageChange'></pages2>
</template> </template>
<span style="color: rgb(255, 59, 48)" v-else>{{ errorMsg }}</span> <span style="color: rgb(255, 59, 48)" v-else>{{ errorMsg }}</span>
</div> </div>
...@@ -265,14 +269,16 @@ ...@@ -265,14 +269,16 @@
<script> <script>
import Vcode from "vue-puzzle-vcode"; import Vcode from "vue-puzzle-vcode";
import validation from "@/views/Search/validation"; import validation from "@/views/Search/validation";
import pagination from "@/views/Search/pagination";
import moment from "moment"; import moment from "moment";
import Pages2 from "@/views/comps/pages2";
const CODE = '1'; const CODE = '1';
const NAME = '2'; const NAME = '2';
const ADDRESS = '3'; const ADDRESS = '3';
export default { export default {
mixins: [validation], mixins: [validation, pagination],
data() { data() {
return { return {
CODE, CODE,
...@@ -306,6 +312,7 @@ export default { ...@@ -306,6 +312,7 @@ export default {
}; };
}, },
components: { components: {
Pages2,
Vcode, Vcode,
}, },
created() { created() {
...@@ -390,7 +397,11 @@ export default { ...@@ -390,7 +397,11 @@ export default {
const searchGlnRes = await this.$api.search.searchInternal(params); const searchGlnRes = await this.$api.search.searchInternal(params);
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
if (returnCode === "0" || returnCode === 0) { if (returnCode === "0" || returnCode === 0) {
this.result = data.hits.hits; // this.result = data.hits.hits;
this.dataTotal = data.hits.hits;
this.pagination.total = data.hits.hits.length;
this.pagination.totalPage = Math.floor(data.hits.hits.length / this.pagination.pageSize) + 1;
this.handlePageChange(1);
} else { } else {
this.errorMsg = this.errorMsg =
searchGlnRes.returnMsg || searchGlnRes.returnMsg ||
......
export default {
data() {
return {
dataTotal: [],
currentData: null,
pagination: {
total: 0,
totalPage: 1,
pageSize: 10,
page: 1
},
}
},
methods: {
handlePageChange(page) {
const start = (page - 1) * this.pagination.pageSize
if (page === this.pagination.totalPage) {
this.currentData = this.dataTotal.slice(start, this.dataTotal.length)
} else {
this.currentData = this.dataTotal.slice(start, start + this.pagination.pageSize)
}
console.log(this)
console.log(this.currentData)
}
},
}
...@@ -61,9 +61,9 @@ ...@@ -61,9 +61,9 @@
<div class="result-box" v-if="showResult"> <div class="result-box" v-if="showResult">
<div class="result-box-title">查询 {{ searchCodeShow }} 结果</div> <div class="result-box-title">查询 {{ searchCodeShow }} 结果</div>
<div class="result-box-body"> <div class="result-box-body">
<template v-if="result"> <template v-if="currentData">
<el-table <el-table
:data="result" :data="currentData"
header-cell-class-name="search-table-hc" header-cell-class-name="search-table-hc"
style="width: 100%" style="width: 100%"
> >
...@@ -79,6 +79,8 @@ ...@@ -79,6 +79,8 @@
<el-table-column prop="producePack" label="包装" width="100px"></el-table-column> <el-table-column prop="producePack" label="包装" width="100px"></el-table-column>
<el-table-column prop="firmName" label="厂商名称" width="210px"></el-table-column> <el-table-column prop="firmName" label="厂商名称" width="210px"></el-table-column>
</el-table> </el-table>
<pages2 :total="pagination.total" :currPage="pagination.currPage" :pageSize="pagination.pageSize"
@getLimit='handlePageChange'></pages2>
</template> </template>
<span class="error-msg" v-else>{{ errorMsg }}</span> <span class="error-msg" v-else>{{ errorMsg }}</span>
</div> </div>
...@@ -98,12 +100,15 @@ ...@@ -98,12 +100,15 @@
<script> <script>
import validation from "@/views/Search/validation"; import validation from "@/views/Search/validation";
import pagination from "@/views/Search/pagination";
import pages2 from "@/views/comps/pages2";
const CODE = 0; const CODE = 0;
const NAME = 1; const NAME = 1;
const ADDRESS = 2; const ADDRESS = 2;
export default { export default {
mixins: [validation], mixins: [validation, pagination],
components: {pages2},
data() { data() {
return { return {
CODE, CODE,
...@@ -142,7 +147,11 @@ export default { ...@@ -142,7 +147,11 @@ export default {
const searchGlnRes = await this.$api.search.searchGetList(params); const searchGlnRes = await this.$api.search.searchGetList(params);
const {returnCode, data} = searchGlnRes; const {returnCode, data} = searchGlnRes;
if (returnCode === "0") { if (returnCode === "0") {
this.result = data; // this.result = data;
this.dataTotal = data;
this.pagination.total = data.length;
this.pagination.totalPage = Math.floor(data.length / this.pagination.pageSize) + 1;
this.handlePageChange(1);
} else { } else {
this.errorMsg = this.errorMsg =
searchGlnRes.returnMsg || searchGlnRes.returnMsg ||
......
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