productBrand.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  2. const ProductBrand = {
  3. template: `
  4. <a-select
  5. placeholder="请选择产品品牌"
  6. :id="id"
  7. allowClear
  8. :value="defaultVal"
  9. :showSearch="true"
  10. @change="handleChange"
  11. option-filter-prop="children"
  12. :dropdownMatchSelectWidth="false"
  13. :filter-option="filterOption">
  14. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  15. </a-select>
  16. `,
  17. props: {
  18. value: {
  19. type: String,
  20. defatut: ''
  21. },
  22. id: {
  23. type: String,
  24. default: ''
  25. },
  26. sysFlag: {
  27. type: String,
  28. default: '1'
  29. }
  30. },
  31. data() {
  32. return {
  33. defaultVal: this.value,
  34. productBrandList: []
  35. };
  36. },
  37. mounted() {
  38. this.getProductBrand()
  39. },
  40. watch: {
  41. value(newValue, oldValue) {
  42. this.defaultVal = newValue
  43. }
  44. },
  45. methods: {
  46. filterOption (input, option) {
  47. return (
  48. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  49. )
  50. },
  51. handleChange(value) {
  52. this.defaultVal = value;
  53. this.$emit('change', value);
  54. this.$emit('input', value);
  55. },
  56. // 产品品牌列表, sysFlag: 1 箭冠 0 自建
  57. getProductBrand () {
  58. dealerProductBrandQuery({ 'sysFlag': this.sysFlag }).then(res => {
  59. if (res.status == 200) {
  60. this.productBrandList = res.data
  61. } else {
  62. this.productBrandList = []
  63. }
  64. })
  65. },
  66. },
  67. };
  68. export default ProductBrand