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)
}
},
}
...@@ -3,67 +3,67 @@ ...@@ -3,67 +3,67 @@
<div class="title">缩短码查询</div> <div class="title">缩短码查询</div>
<div class="body"> <div class="body">
<div style="padding-top:20px"> <div style="padding-top:20px">
<el-radio-group v-model="company"> <el-radio-group v-model="company">
<el-radio :label="CODE">EAN/UCC-8缩短码</el-radio> <el-radio :label="CODE">EAN/UCC-8缩短码</el-radio>
<el-radio :label="NAME">根据厂商名称查询</el-radio> <el-radio :label="NAME">根据厂商名称查询</el-radio>
<el-radio :label="ADDRESS">根据厂商地址查询</el-radio> <el-radio :label="ADDRESS">根据厂商地址查询</el-radio>
</el-radio-group> </el-radio-group>
<el-form <el-form
label-position="left" label-position="left"
label-width="120px" label-width="120px"
style="margin-top:40px" style="margin-top:40px"
:model="companySearch" :model="companySearch"
> >
<el-form-item label="缩短码查询:"> <el-form-item label="缩短码查询:">
<el-input <el-input
v-show="company === CODE" v-show="company === CODE"
v-model="companySearch.code" v-model="companySearch.code"
placeholder="请输入正确的8位商品条码!" placeholder="请输入正确的8位商品条码!"
class="w240" class="w240"
></el-input> ></el-input>
<el-input <el-input
v-show="company === NAME" v-show="company === NAME"
v-model="companySearch.name" v-model="companySearch.name"
placeholder="请输入正确的厂商名称!" placeholder="请输入正确的厂商名称!"
class="w240" class="w240"
></el-input> ></el-input>
<el-input <el-input
v-show="company === ADDRESS" v-show="company === ADDRESS"
v-model="companySearch.address" v-model="companySearch.address"
placeholder="请输入正确的厂商地址!" placeholder="请输入正确的厂商地址!"
class="w240" class="w240"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="验证码:"> <el-form-item label="验证码:">
<div class="y-center"> <div class="y-center">
<el-input <el-input
v-model="captcha" v-model="captcha"
placeholder="请输入验证码" placeholder="请输入验证码"
class="w160" class="w160"
></el-input> ></el-input>
<div class="validate-code"> <div class="validate-code">
<img :src="captchaPath" @click="getCaptcha()" alt=""/> <img :src="captchaPath" @click="getCaptcha()" alt=""/>
</div> </div>
<el-button <el-button
style="margin-left:40px" style="margin-left:40px"
type="primary" type="primary"
@click="handleSearchCompany" @click="handleSearchCompany"
>查询 >查询
</el-button </el-button
> >
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
</div> </div>
<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%"
> >
...@@ -76,9 +76,11 @@ ...@@ -76,9 +76,11 @@
</el-table-column> </el-table-column>
<el-table-column prop="brandName" label="商标"></el-table-column> <el-table-column prop="brandName" label="商标"></el-table-column>
<el-table-column prop="produceStyle" label=规格 width="80px"></el-table-column> <el-table-column prop="produceStyle" label=规格 width="80px"></el-table-column>
<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 ||
......
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
pages: { pages: {
size: 10, size: 10,
}, },
}; };
}, },
mounted(){ mounted(){
...@@ -191,4 +191,4 @@ export default { ...@@ -191,4 +191,4 @@ export default {
} }
} }
} }
</style> </style>
\ No newline at end of file
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