workshop-select.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <!-- 车间 -->
  3. <el-select
  4. v-model="selectVal"
  5. filterable
  6. style="width: 100%"
  7. v-bind="$attrs"
  8. v-on="$listeners"
  9. clearable
  10. >
  11. <el-option
  12. v-for="item in dictList"
  13. :key="item.id"
  14. :label="item.name"
  15. :value="item.id"
  16. ></el-option>
  17. </el-select>
  18. </template>
  19. <script>
  20. import { listWorkshopByParentId } from '@/api/factoryModel';
  21. export default {
  22. model: {
  23. prop: 'value',
  24. event: 'updateVal'
  25. },
  26. props: {
  27. value: {
  28. type: [String, Number, Array],
  29. default: ''
  30. },
  31. init: {
  32. type: Boolean,
  33. default: true
  34. },
  35. factoryId: {
  36. type: [String, Number],
  37. default: ''
  38. }
  39. },
  40. data () {
  41. return {
  42. dictList: []
  43. };
  44. },
  45. computed: {
  46. selectVal: {
  47. set (val) {
  48. this.$emit('updateVal', val);
  49. this.$emit(
  50. 'selfChange',
  51. val,
  52. this.dictList.find((i) => i.id === val)
  53. );
  54. },
  55. get () {
  56. return this.value;
  57. }
  58. }
  59. },
  60. methods: {
  61. async getList () {
  62. const res = await listWorkshopByParentId(this.factoryId);
  63. this.dictList = res;
  64. }
  65. }
  66. };
  67. </script>