feat(KLPService选择组件): 新增分页控制参数,支持全量加载选项

1. 为CustomerSelect和OrderSelect组件新增pager参数,默认开启分页模式
2. 分页模式下保持每页10条的远程搜索逻辑,非分页模式下加载全量10000条数据
3. 调整OrderSelect组件的加载状态绑定方式,统一使用v-loading指令
4. 为OrderSelect新增mounted钩子,非分页模式下初始化加载全量订单数据
This commit is contained in:
2026-05-23 16:25:53 +08:00
parent eb8e797a4d
commit 13ad671b29
2 changed files with 32 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-select filterable v-model="_customerId" remote :remote-method="remoteSearchCustomer" :style="style" :loading="customerLoading" placeholder="请选择客户"> <el-select filterable v-model="_customerId" :remote="pager" :remote-method="pager ? remoteSearchCustomer : undefined" :style="style" v-loading="customerLoading" placeholder="请选择客户">
<el-option v-for="item in customerList" :key="item[bindField]" :label="item.companyName" :value="item[bindField]" /> <el-option v-for="item in customerList" :key="item[bindField]" :label="item.companyName" :value="item[bindField]" />
</el-select> </el-select>
</template> </template>
@@ -21,6 +21,10 @@
style: { style: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
},
pager: {
type: Boolean,
default: true
} }
}, },
computed: { computed: {
@@ -51,7 +55,7 @@
methods: { methods: {
remoteSearchCustomer(query) { remoteSearchCustomer(query) {
this.customerLoading = true; this.customerLoading = true;
listCustomer({ companyName: query, pageNum: 1, pageSize: 10 }).then(response => { listCustomer({ companyName: query, pageNum: 1, pageSize: this.pager ? 10 : 10000 }).then(response => {
this.customerList = response.rows; this.customerList = response.rows;
}).finally(() => { }).finally(() => {
this.customerLoading = false; this.customerLoading = false;

View File

@@ -2,11 +2,11 @@
<el-select <el-select
v-model="innerValue" v-model="innerValue"
filterable filterable
remote :remote="pager"
:remote-method="pager ? remoteMethod : undefined"
reserve-keyword reserve-keyword
placeholder="输入订单号搜索" placeholder="输入订单号搜索"
:remote-method="remoteMethod" v-loading="loading"
:loading="loading"
> >
<el-option <el-option
v-for="item in options" v-for="item in options"
@@ -25,6 +25,10 @@ export default {
value: { value: {
type: String, type: String,
default: '' default: ''
},
pager: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@@ -55,13 +59,31 @@ export default {
// this.$emit('input', newVal) // this.$emit('input', newVal)
// } // }
// }, // },
mounted() {
if (!this.pager) {
this.loading = true
listPurchaseOrder({
pageNum: 1,
pageSize: 10000
}).then(res => {
this.options = res.rows.map(item => ({
value: item.orderId,
label: item.orderCode
}))
}).catch(error => {
console.error('订单加载失败:', error)
}).finally(() => {
this.loading = false
})
}
},
methods: { methods: {
remoteMethod(query) { remoteMethod(query) {
if (query !== '') { if (query !== '') {
this.loading = true this.loading = true
listPurchaseOrder({ listPurchaseOrder({
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: this.pager ? 10 : 10000,
orderCode: query orderCode: query
}).then(res => { }).then(res => {
this.loading = false this.loading = false