<template>
<div class="app-container">
<el-card class="box-card">
<el-select
v-model="select_product"
placeholder="请选择"
clearable
filterable
>
<el-option
v-for="(item, index) in product_list"
:key="index"
:value="item.id"
:label="item.name"
></el-option>
</el-select>
</el-card>
</div>
</template>
<script>
import { getProductList } from "@/views/settings/apis/product"
export default {
data() {
return {
select_product: "",
product_list: []
}
},
created() {
this.get_product_list()
},
methods: {
get_product_list() {
getProductList({ limit: 100 })
.then((resp) => {
this.product_list = resp.data.results
this.select_product = this.product_list[0].id
})
.catch((err) => {
this.$message({
type: "error",
message: err
})
})
}
}
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49