index.js 1014 B

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