Files
klp-mono/apps/hand-factory/components/klp-product-select/klp-product-select.vue

74 lines
1.2 KiB
Vue
Raw Normal View History

<template>
<view>
<uni-data-select v-model="itemId" :localdata="localData"></uni-data-select>
</view>
</template>
<script>
import {
listProduct
} from '@/api/wms/product.js'
import {
listRawMaterial
} from '@/api/wms/rawMaterial.js'
export default {
name: "klp-product-select",
props: {
itemType: {
type: String,
},
value: {
type: String
}
},
watch: {
itemType() {
this.$emit('input', undefined)
}
},
mounted() {
listProduct({ pageSize: 9999, pageNum: 1 }).then(res => {
this.products = res.rows
})
listRawMaterial({ pageSize: 9999, pageNum: 1 }).then(res => {
this.raws = res.rows
})
},
computed: {
itemId: {
get() {
this.value
},
set(v) {
this.$emit('input', v)
}
},
localData() {
if (this.itemType == 'raw_material') {
return this.raws.map(item => ({
text: item.rawMaterialName,
value: item.rawMaterialId
}))
} else if (this.itemType == 'product') {
return this.products.map(item => ({
text: item.productName,
value: item.productId
}))
} else {
return []
}
}
},
data() {
return {
raws: [],
products: []
};
},
}
</script>
<style>
</style>