12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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-badge count="已注销" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#666',background:'#f8f8f8' }" v-if="item.state=='WRITE_OFF'"></a-badge>
- </a-select-option>
- </a-select>
- `,
- props: {
- value: {
- type: [String, Array, Object],
- },
- id: {
- type: String,
- default: ''
- },
- mode: {
- type: String,
- default: 'default'
- },
- showAll: {
- type: Boolean,
- default: false
- }
- },
- 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('input', value, row)
- this.$emit('change', value, row)
- },
- // 货架列表
- getShelf () {
- const params = {pageNo: 1, pageSize: 1000}
- if(!this.showAll){
- params.stateSet = [ 'ENABLE', 'SUSPEND', 'DISABLED' ]
- }
- shelfList(params).then(res => {
- if (res.status == 200) {
- this.shelfList = res.data && res.data.list ? res.data.list : []
- } else {
- this.shelfList = []
- }
- })
- }
- }
- }
- export default shelfSList
|