feat(采购模块): 实现订单选择组件并优化UI交互
refactor(采购管理): 替换输入框为选择组件提升用户体验 style(表格样式): 调整表格边框和间距优化视觉效果
This commit is contained in:
82
klp-ui/src/components/KLPService/OrderSelect/index.vue
Normal file
82
klp-ui/src/components/KLPService/OrderSelect/index.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<el-select
|
||||
v-model="innerValue"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="输入订单号搜索"
|
||||
:remote-method="remoteMethod"
|
||||
:loading="loading"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listPurchaseOrder } from '@/api/erp/purchase'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// innerValue: this.value, // 内部维护的选中值
|
||||
options: [],
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 计算属性,将内部值同步到父组件
|
||||
innerValue: {
|
||||
get() {
|
||||
return this.value
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('input', val)
|
||||
}
|
||||
}
|
||||
},
|
||||
// watch: {
|
||||
// // 监听父组件传入的value变化,同步到内部值
|
||||
// value(newVal) {
|
||||
// this.innerValue = newVal
|
||||
// },
|
||||
// // 监听内部值变化,同步到父组件
|
||||
// innerValue(newVal) {
|
||||
// this.$emit('input', newVal)
|
||||
// }
|
||||
// },
|
||||
methods: {
|
||||
remoteMethod(query) {
|
||||
if (query !== '') {
|
||||
this.loading = true
|
||||
listPurchaseOrder({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
orderCode: query
|
||||
}).then(res => {
|
||||
this.loading = false
|
||||
this.options = res.rows.map(item => ({
|
||||
value: item.orderId,
|
||||
label: item.orderCode
|
||||
}))
|
||||
}).catch(error => {
|
||||
this.loading = false
|
||||
console.error('订单搜索失败:', error)
|
||||
})
|
||||
} else {
|
||||
this.options = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user