productBrand.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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" :pinyin="item.pinyin" :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,Number],
  28. default: ''
  29. },
  30. tenantId: {
  31. type: String,
  32. default: ''
  33. }
  34. },
  35. data() {
  36. return {
  37. defaultVal: this.value,
  38. productBrandList: []
  39. };
  40. },
  41. mounted() {
  42. this.getProductBrand()
  43. },
  44. watch: {
  45. value(newValue, oldValue) {
  46. this.defaultVal = newValue
  47. },
  48. tenantId(newValue, oldValue){
  49. console.log(newValue)
  50. }
  51. },
  52. methods: {
  53. filterOption (input, option) {
  54. console.log(input, option.data.attrs.pinyin)
  55. return (
  56. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
  57. option.data.attrs.pinyin && option.data.attrs.pinyin.toLowerCase().indexOf(input.toLowerCase()) >= 0
  58. )
  59. },
  60. handleChange(value) {
  61. this.defaultVal = value;
  62. this.$emit('change', value);
  63. this.$emit('input', value);
  64. },
  65. // 产品品牌列表, sysFlag: 1 箭冠 0 自建
  66. getProductBrand () {
  67. const params = {'sysFlag': this.sysFlag}
  68. if(this.tenantId!="NONE"){
  69. params.tenantId = this.tenantId
  70. }
  71. if(this.tenantId=="NONE"){
  72. params.sysFlag = '1'
  73. }
  74. dealerProductBrandQuery(params).then(res => {
  75. if (res.status == 200) {
  76. this.productBrandList = res.data
  77. } else {
  78. this.productBrandList = []
  79. }
  80. })
  81. },
  82. },
  83. };
  84. export default ProductBrand