supplier.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { supplierAllList } from '@/api/supplier.js'
  2. const Employee = {
  3. template: `
  4. <a-select
  5. :placeholder="placeholder"
  6. :id="id"
  7. allowClear
  8. :value="defaultVal"
  9. :showSearch="true"
  10. :disabled="disabledFlag"
  11. @change="handleChange"
  12. option-filter-prop="children"
  13. :filter-option="filterOption">
  14. <a-select-option v-for="item in list" :key="item.supplierSn" :value="item.supplierSn">
  15. {{ item.supplierName }}
  16. </a-select-option>
  17. </a-select>
  18. `,
  19. props: {
  20. value: {
  21. type: String,
  22. defatut: ''
  23. },
  24. id: {
  25. type: String,
  26. default: ''
  27. },
  28. placeholder: {
  29. type: String,
  30. default: '请选择供应商'
  31. },
  32. enableFlag: {
  33. type: String,
  34. default: ''
  35. },
  36. disabledFlag: {
  37. type: Boolean,
  38. default: false
  39. }
  40. },
  41. data () {
  42. return {
  43. defaultVal: this.value,
  44. list: []
  45. }
  46. },
  47. mounted () {
  48. this.getList()
  49. },
  50. watch: {
  51. value (newValue, oldValue) {
  52. this.defaultVal = newValue
  53. }
  54. },
  55. methods: {
  56. filterOption (input, option) {
  57. return (
  58. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  59. )
  60. },
  61. handleChange (value) {
  62. this.defaultVal = value
  63. const item = this.list.find(item => item.supplierSn == value)
  64. this.$emit('input', value)
  65. this.$emit('change', value, item)
  66. },
  67. getList () {
  68. supplierAllList().then(res => {
  69. if (res.status == 200) {
  70. if (this.enableFlag != '') {
  71. this.list = res.data.filter(item => item.enableFlag == this.enableFlag)
  72. } else {
  73. this.list = res.data
  74. }
  75. } else {
  76. this.list = []
  77. }
  78. })
  79. }
  80. }
  81. }
  82. export default Employee