step-nav.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <script>
  2. import Step from './step'
  3. import Migrating from '@/plugins/element-ui/src/mixins/migrating'
  4. function noop() {}
  5. export default {
  6. name: 'ibps-step-nav',
  7. components: {
  8. Step
  9. },
  10. mixins: [Migrating],
  11. props: {
  12. panes: Array,
  13. onStepClick: {
  14. type: Function,
  15. default: noop
  16. },
  17. space: [Number, String],
  18. active: Number,
  19. direction: {
  20. type: String,
  21. default: 'horizontal'
  22. },
  23. alignCenter: Boolean,
  24. simple: Boolean,
  25. finishStatus: {
  26. type: String,
  27. default: 'finish'
  28. },
  29. processStatus: {
  30. type: String,
  31. default: 'process'
  32. }
  33. },
  34. data() {
  35. return {
  36. steps: [],
  37. stepOffset: 0
  38. }
  39. },
  40. watch: {
  41. active(newVal, oldVal) {
  42. this.$emit('change', newVal, oldVal)
  43. },
  44. steps(steps) {
  45. steps.forEach((child, index) => {
  46. child.index = index
  47. })
  48. }
  49. },
  50. methods: {
  51. getMigratingConfig() {
  52. return {
  53. props: {
  54. 'center': 'center is removed.'
  55. }
  56. }
  57. }
  58. },
  59. render(h) {
  60. const {
  61. onStepClick,
  62. panes,
  63. direction,
  64. simple
  65. } = this
  66. const steps = this._l(panes, (pane, index) => {
  67. pane.index = `${index}`
  68. const title = pane.title
  69. const status = pane.status
  70. return (
  71. <step
  72. title={title}
  73. index={index}
  74. status={status}
  75. onClick={(ev) => { onStepClick(pane, index, ev) }}
  76. ></step>
  77. )
  78. })
  79. return (
  80. <div class={{
  81. 'el-steps': true,
  82. [`el-steps--${direction}`]: !simple,
  83. 'el-steps--simple': simple
  84. }}>
  85. {steps}
  86. </div>
  87. )
  88. }
  89. }
  90. </script>