supplier.js 1.7 KB

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