index.js 984 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { getColumns } from '../utils'
  2. export const commonMixin = {
  3. data () {
  4. return {
  5. indicatorStyle: `height: 34px`
  6. }
  7. },
  8. created () {
  9. this.init('init')
  10. },
  11. methods: {
  12. init (changeType) {
  13. if (this.list && this.list.length) {
  14. const column = getColumns({
  15. value: this.value,
  16. list: this.list,
  17. mode: this.mode,
  18. props: this.props,
  19. level: this.level
  20. })
  21. const { columns, value, item, index } = column
  22. this.selectValue = value
  23. this.selectItem = item
  24. this.pickerColumns = columns
  25. this.pickerValue = index
  26. this.$emit('change', {
  27. value: this.selectValue,
  28. item: this.selectItem,
  29. index: this.pickerValue,
  30. change: changeType
  31. })
  32. }
  33. }
  34. },
  35. watch: {
  36. value () {
  37. if (!this.isConfirmChange) {
  38. this.init('value')
  39. }
  40. },
  41. list () {
  42. this.init('list')
  43. }
  44. }
  45. }