DepartMentSelect.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <el-select
  3. v-model="selected"
  4. v-bind="$attrs"
  5. :loading="loading"
  6. @change="change"
  7. >
  8. <el-option
  9. v-for="item in options"
  10. :key="item.id"
  11. :label="item.name"
  12. :value="item.code"
  13. >
  14. <el-row :gutter="20">
  15. <el-col :span="12">{{ item.code }}</el-col>
  16. <el-col :span="12" class="text-right">{{ item.name }}</el-col>
  17. </el-row>
  18. </el-option>
  19. </el-select>
  20. </template>
  21. <script>
  22. import { getDepartmentList } from '@/api/wms/incoming/register'
  23. export default {
  24. props: {
  25. value: {
  26. type: [String, Number],
  27. default: ''
  28. },
  29. inspectionType: {
  30. type: Number,
  31. default: 0
  32. }
  33. },
  34. data() {
  35. return {
  36. options: [],
  37. loading: false
  38. }
  39. },
  40. computed: {
  41. selected: {
  42. get() {
  43. return this.value
  44. },
  45. set(v) {
  46. this.$emit('input', v)
  47. }
  48. }
  49. },
  50. created() {
  51. this.fetchCustomerList()
  52. },
  53. methods: {
  54. fetchCustomerList() {
  55. this.loading = true
  56. const params = {
  57. pageNo: 1,
  58. pageSize: 100
  59. }
  60. getDepartmentList(params).then(res => {
  61. const { list = [] } = res.data || {}
  62. this.options = list
  63. }).finally(() => {
  64. this.loading = false
  65. })
  66. },
  67. change(value) {
  68. const item = this.options.find(item => item.code === value)
  69. this.$emit('change', item)
  70. }
  71. }
  72. }
  73. </script>
  74. <style>
  75. </style>