productBrand.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import { productBrandQuery } from '@/api/productBrand'
  2. const ProductBrand = {
  3. template: `
  4. <a-select
  5. :placeholder="placeholder"
  6. :id="id"
  7. allowClear
  8. :value="defaultVal"
  9. :showSearch="true"
  10. :disabled="disabled"
  11. @change="handleChange"
  12. option-filter-prop="children"
  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. placeholder:{
  27. type: String,
  28. default: '请选择产品品牌'
  29. },
  30. sysFlag: {
  31. type: String,
  32. default: ''
  33. },
  34. brandType: {
  35. type: String,
  36. default: ''
  37. },
  38. disabled: {
  39. type: Boolean,
  40. default: false
  41. }
  42. },
  43. data() {
  44. return {
  45. defaultVal: this.value,
  46. productBrandList: []
  47. };
  48. },
  49. mounted() {
  50. this.getProductBrand()
  51. },
  52. watch: {
  53. value(newValue, oldValue) {
  54. this.defaultVal = newValue
  55. },
  56. brandType(newValue,oldValue){
  57. this.handleChange(undefined)
  58. this.getProductBrand()
  59. }
  60. },
  61. methods: {
  62. filterOption (input, option) {
  63. return (
  64. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  65. )
  66. },
  67. handleChange(value) {
  68. this.defaultVal = value;
  69. const row = this.productBrandList.find(item => item.brandSn == value)
  70. this.$emit('input', value);
  71. this.$emit('change', value, this.id, row);
  72. },
  73. // 产品品牌列表, sysFlag: 1 箭冠 0 自建
  74. getProductBrand () {
  75. productBrandQuery({ 'sysFlag': this.sysFlag, 'brandType': this.brandType }).then(res => {
  76. if (res.status == 200) {
  77. this.productBrandList = res.data
  78. } else {
  79. this.productBrandList = []
  80. }
  81. })
  82. },
  83. },
  84. };
  85. export default ProductBrand