Files
bj_power/bj_power_wms/frontend/src/components/MaterialSelect.vue
T
SunYF 2544c6141d refactor: 合并原库房客户端到主WMS服务,退役8891端口
1.  将bj_power_wms_client的前端代码、配置及网关逻辑全部迁移到bj_power_wms主项目
2.  删除原库房客户端相关的所有文件与配置
3.  更新README与部署文档,说明合并后的服务架构
4.  新增Web配置项支持自动打开浏览器开关,统一服务端口为8890
2026-09-07 15:55:30 +08:00

54 lines
1.9 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup>
// 物料下拉选择器(公共组件)
// 规范:数据量不确定的下拉只加载最近 100 条(created_at desc),支持远程模糊搜索(keyword 查询,结果仍封顶 100)。
// 选中后通过 item-change 事件抛出完整物料对象(无匹配为 null),供页面校验 manageMode 等。
import { ref, onMounted } from 'vue'
import request from '../utils/request'
const props = defineProps({
modelValue: { type: [String, Array], default: '' },
multiple: { type: Boolean, default: false },
manageMode: { type: Number, default: 0 }, // 0=全部 1=结构件 2=精密件
placeholder: { type: String, default: '选择物料' },
clearable: { type: Boolean, default: true },
width: { type: String, default: '100%' }
})
const emit = defineEmits(['update:modelValue', 'item-change'])
const options = ref([])
const loading = ref(false)
// 最近 100 条 + keyword 模糊搜索(后端 /material/query 兼容空 keyword
async function load(kw = '') {
loading.value = true
try {
const data = await request.get('/material/query', {
params: { page: 1, pageSize: 100, keyword: kw || '', manageMode: props.manageMode || '' }
})
options.value = data?.list || []
} catch {
options.value = []
} finally {
loading.value = false
}
}
function onChange(v) {
emit('update:modelValue', v)
if (props.multiple) {
emit('item-change', options.value.filter((o) => v.includes(o.code)))
} else {
emit('item-change', options.value.find((o) => o.code === v) || null)
}
}
</script>
<template>
<el-select :model-value="modelValue" :multiple="multiple" filterable remote clearable
:remote-method="load" :loading="loading" :placeholder="placeholder"
:style="{ width }" @change="onChange">
<el-option v-for="m in options" :key="m.id" :value="m.code"
:label="`${m.code} ${m.name || ''}`" />
</el-select>
</template>