shelfList.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import { shelfList } from '@/api/shelf'
  2. const shelfSList = {
  3. template: `
  4. <a-select
  5. placeholder="请选择货架"
  6. :maxTagCount="3"
  7. :maxTagTextLength="mode=='default'?20:8"
  8. :mode="mode"
  9. :id="id"
  10. allowClear
  11. :value="defaultVal"
  12. :showSearch="true"
  13. @change="handleChange"
  14. option-filter-prop="children"
  15. :dropdownMatchSelectWidth="false"
  16. :filter-option="filterOption">
  17. <a-select-option v-for="item in shelfList" :key="item.shelfSn" :value="item.shelfSn">
  18. {{ item.shelfName }}
  19. <a-badge count="已注销" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#666',background:'#f8f8f8' }" v-if="item.state=='WRITE_OFF'"></a-badge>
  20. </a-select-option>
  21. </a-select>
  22. `,
  23. props: {
  24. value: {
  25. type: [String, Array, Object],
  26. },
  27. id: {
  28. type: String,
  29. default: ''
  30. },
  31. mode: {
  32. type: String,
  33. default: 'default'
  34. },
  35. showAll: {
  36. type: Boolean,
  37. default: false
  38. }
  39. },
  40. data () {
  41. return {
  42. defaultVal: this.value,
  43. shelfList: []
  44. }
  45. },
  46. mounted () {
  47. this.getShelf()
  48. },
  49. watch: {
  50. value (newValue, oldValue) {
  51. this.defaultVal = newValue
  52. }
  53. },
  54. methods: {
  55. filterOption (input, option) {
  56. console.log(input, option)
  57. return (
  58. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  59. )
  60. },
  61. handleChange (value) {
  62. console.log(value)
  63. const row = this.shelfList.find(item => item.shelfSn == value)
  64. this.defaultVal = value
  65. this.$emit('input', value, row)
  66. this.$emit('change', value, row)
  67. },
  68. // 货架列表
  69. getShelf () {
  70. const params = {pageNo: 1, pageSize: 1000}
  71. if(!this.showAll){
  72. params.stateSet = [ 'ENABLE', 'SUSPEND', 'DISABLED' ]
  73. }
  74. shelfList(params).then(res => {
  75. if (res.status == 200) {
  76. this.shelfList = res.data && res.data.list ? res.data.list : []
  77. } else {
  78. this.shelfList = []
  79. }
  80. })
  81. }
  82. }
  83. }
  84. export default shelfSList