123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import { queryAuthWarehouse, warehouseAllList } from '@/api/warehouse'
- const warehouse = {
- template: `
- <a-select
- :placeholder="placeholder"
- :id="id"
- :allowClear="allowClear"
- :value="defaultVal"
- :showSearch="true"
- :disabled="disabled"
- :mode="modeType"
- @change="handleChange"
- :filter-option="filterOption">
- <a-select-option v-for="item in warehouseData" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
- </a-select>
- `,
- props: {
- value: {
- type: [String, Array],
- defatut: ''
- },
- isPermission: {// false无权限 true有权限
- type: Boolean,
- default: false
- },
- allowClear:{
- type: Boolean,
- default: true
- },
- id: {
- type: String,
- default: ''
- },
- placeholder: {
- type: String,
- default: '请选择仓库'
- },
- disabled: {
- type: Boolean,
- default: false
- },
- modeType: {
- type: String,
- default: 'default'
- }
- },
- data () {
- return {
- defaultVal: this.value,
- warehouseData: [],
- pageNo: 1,
- pageSize: 1000
- }
- },
- mounted () {
- if(this.isPermission){
- this.$store.state.app.defWarehouse = null
- this.$store.state.app.isWarehouse = false
- }
- this.getWarehouse()
- },
- watch: {
- value (newValue, oldValue) {
- this.defaultVal = newValue
- }
- },
- methods: {
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- handleChange (value) {
- this.defaultVal = value
- this.$emit('input', value)
- this.$emit('change', value)
- },
- // 获取仓库列表
- getWarehouse () {
- const ajaxName = this.isPermission ? queryAuthWarehouse : warehouseAllList
- ajaxName({}).then(res => {
- if (res.status == 200) {
- if(this.isPermission){
- this.$store.state.app.isWarehouse = res.data && res.data.length > 1
- const defWarehouse = res.data.find(item => item.defaultFlag == 1)
- this.$store.state.app.defWarehouse = this.isPermission ? res.data && res.data[0] : defWarehouse
- }
- this.warehouseData = res.data || []
- } else {
- if(this.isPermission){
- this.$store.state.app.isWarehouse = false
- this.$store.state.app.defWarehouse = null
- }
- this.warehouseData = []
- }
- this.$emit('load')
- })
- },
- clearData () {
- this.handleChange([])
- }
- }
- }
- export default warehouse
|