allocateTypeByLevel.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { queryListByTreeLevel } from '@/api/allocateType'
  2. const AllocateTypeByLevel = {
  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.allocateTypeSn" :value="item.allocateTypeSn">{{ item.name }}</a-select-option>
  14. </a-select>
  15. `,
  16. props: {
  17. value: {
  18. type: [String,Number],
  19. defatut: ''
  20. },
  21. id: {
  22. type: String,
  23. default: ''
  24. },
  25. level: {
  26. type: [String,Number],
  27. default: '3'
  28. },
  29. placeholder:{
  30. type: String,
  31. default: '请选择'
  32. }
  33. },
  34. data() {
  35. return {
  36. defaultVal: this.value,
  37. list: []
  38. };
  39. },
  40. mounted() {
  41. this.getProductBrand()
  42. },
  43. watch: {
  44. value(newValue, oldValue) {
  45. this.defaultVal = newValue
  46. }
  47. },
  48. methods: {
  49. filterOption (input, option) {
  50. return (
  51. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  52. )
  53. },
  54. handleChange(value) {
  55. this.defaultVal = value;
  56. this.$emit('input', value);
  57. this.$emit('change', value);
  58. },
  59. // 调拨类型
  60. getProductBrand () {
  61. queryListByTreeLevel({"treeLevel":this.level}).then(res => {
  62. if (res.status == 200) {
  63. this.list = res.data
  64. } else {
  65. this.list = []
  66. }
  67. })
  68. },
  69. },
  70. };
  71. export default AllocateTypeByLevel