logisticsCompany.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { pickUpLogisticsList } from '@/api/pickUp'
  2. const LogisticsCompany = {
  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.id" :value="item.logisticsCompany">
  14. {{ item.logisticsCompany }}
  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. },
  32. data() {
  33. return {
  34. defaultVal: this.value,
  35. list: []
  36. };
  37. },
  38. mounted() {
  39. this.getList()
  40. },
  41. watch: {
  42. value(newValue, oldValue) {
  43. this.defaultVal = newValue
  44. },
  45. },
  46. methods: {
  47. filterOption (input, option) {
  48. return (
  49. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  50. )
  51. },
  52. handleChange(value) {
  53. this.defaultVal = value;
  54. const row = this.list.find(item => item.logisticsCompany == value)
  55. this.$emit('change', value, row);
  56. this.$emit('input', value);
  57. },
  58. getList () {
  59. pickUpLogisticsList({}).then(res => {
  60. if (res.status == 200) {
  61. this.list = res.data
  62. } else {
  63. this.list = []
  64. }
  65. })
  66. },
  67. getPoint(v){
  68. const row = this.list.find(item => item.logisticsCompany == v)
  69. return row ? row.logisticsPointList : []
  70. }
  71. },
  72. };
  73. export default LogisticsCompany