123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { shelfList } from '@/api/shelf'
- const shelfSList = {
- template: `
- <a-select
- placeholder="请选择货架"
- :maxTagCount="3"
- :maxTagTextLength="mode=='default'?20:8"
- :mode="mode"
- :id="id"
- allowClear
- :value="defaultVal"
- :showSearch="true"
- @change="handleChange"
- option-filter-prop="children"
- :dropdownMatchSelectWidth="false"
- :filter-option="filterOption">
- <a-select-option v-for="item in shelfList" :key="item.shelfSn" :value="item.shelfSn">{{ item.shelfName }}</a-select-option>
- </a-select>
- `,
- props: {
- value: {
- type: [String,Array],
- defatut: ''
- },
- id: {
- type: String,
- default: ''
- },
- mode: {
- type: String,
- defatut: 'default'
- }
- },
- data () {
- return {
- defaultVal: this.value,
- shelfList: []
- }
- },
- mounted () {
- this.getShelf()
- },
- watch: {
- value (newValue, oldValue) {
- this.defaultVal = newValue
- }
- },
- methods: {
- filterOption (input, option) {
- console.log(input, option)
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- handleChange (value) {
- console.log(value)
- const row = this.shelfList.find(item => item.shelfSn == value)
- this.defaultVal = value
- this.$emit('change', value, row)
- this.$emit('input', value, row)
- },
- // 货架列表
- getShelf () {
- shelfList({ pageNo: 1, pageSize: 1000 }).then(res => {
- if (res.status == 200) {
- this.shelfList = res.data && res.data.list ? res.data.list : []
- } else {
- this.shelfList = []
- }
- })
- }
- }
- }
- export default shelfSList
|