123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <template>
- <div class="step-progress">
- <div class="step-menu">
- <el-steps :active="current" align-center process-status="finish">
- <el-step
- v-for="(step, index) in STEPS_LIST"
- :key="index"
- :title="step.title"
- ></el-step>
- </el-steps>
- </div>
- <div class="step-body">
- <component
- :is="currentComponent"
- :ref="currentComponent"
- @on-next="toNext"
- @on-ready="stepReady"
- ></component>
- </div>
- <div class="step-ctrl">
- <el-button type="primary" @click="prevStep" :disabled="isFirstStep"
- >上一步</el-button
- >
- <el-button
- type="primary"
- @click="nextStep"
- :disabled="nextHolder || isLastStep"
- >下一步</el-button
- >
- </div>
- </div>
- </template>
- <script>
- import StepOne from "./StepOne";
- import StepTwo from "./StepTwo";
- import StepThree from "./StepThree";
- import StepFour from "./StepFour";
- const STEPS_LIST = [
- {
- name: "step-one",
- title: "步骤1"
- },
- {
- name: "step-two",
- title: "步骤2"
- },
- {
- name: "step-three",
- title: "步骤3"
- },
- {
- name: "step-four",
- title: "步骤4"
- }
- ];
- export default {
- name: "step-progress",
- components: {
- StepOne,
- StepTwo,
- StepThree,
- StepFour
- },
- data() {
- return {
- STEPS_LIST,
- current: 0,
- nextHolder: true,
- dataReady: true
- };
- },
- computed: {
- currentComponent() {
- return this.STEPS_LIST[this.current].name;
- },
- isFirstStep() {
- return this.current === 0;
- },
- isLastStep() {
- return this.current === this.lastStep;
- },
- lastStep() {
- return this.STEPS_LIST.length - 1;
- }
- },
- watch: {
- current() {
- // 滚动条置顶
- // document.getElementById("home-body").scrollTop = 0;
- }
- },
- methods: {
- prevStep() {
- if (this.isFirstStep) return;
- this.current -= 1;
- },
- nextStep() {
- if (this.isLastStep || this.nextHolder) return;
- this.$refs[this.currentComponent].checkValid();
- },
- toNext() {
- if (this.isLastStep) return;
- this.current += 1;
- this.nextHolder = true;
- },
- stepReady() {
- this.nextHolder = false;
- }
- }
- };
- </script>
- <style lang="css">
- .step-body {
- min-height: 600px;
- padding: 20px;
- }
- .step-ctrl {
- text-align: center;
- margin-top: 50px;
- }
- </style>
|