StepForm.vue 2.25 KB
<template>
  <j-modal
    :title="title"
    :width="1000"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">

    <a-steps class="steps" :current="currentTab">
      <a-step title="第1页"/>
      <a-step title="第2页"/>
      <a-step title="第3页"/>
    </a-steps>
    <a-input  v-model="snCode" type="text" hidden="hidden"   placeholder="请输入sn编码"  ></a-input>
    <div class="content">
      <step1 v-if="currentTab === 0" @nextStep="nextStep" @setSnData="setSnData"/>
      <step2 v-if="currentTab === 1" @nextStep="nextStep" @prevStep="prevStep" :sn-code="snCode"/>
      <step3 v-if="currentTab === 2" @prevStep="prevStep" @finish="finish" :sn-code="snCode"/>
    </div>

  </j-modal>
</template>

<script>
import Step1 from './CheckStepThreeForm'
import Step2 from './CheckStepThreeDataForm'
import Step3 from './CheckStepThreeData2Form'



export default {
  name: "StepForm",
  components: {
    Step1,
    Step2,
    Step3
  },
  data() {
    return {
      title:'',
      width:800,
      snCode:'',
      visible: false,
      disableSubmit: false,
      description: '将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。',
      currentTab: 0,

      // form
      form: null,
    }
  },
  methods: {
    edit(record){
      this.visible=true
    },
    // handler
    nextStep() {
      if (this.currentTab < 2) {
        // 在切换到 step2 时传递 snCode
        this.currentTab += 1
      }
    },
    prevStep() {
      if (this.currentTab > 0) {
        this.currentTab -= 1
      }
    },
    finish() {
      this.$emit('close');
      this.visible = false;
      this.currentTab = 0
    },
    close () {
      this.$emit('close');
      this.visible = false;
    },
    handleOk () {
      // this.$refs.realForm.submitForm();
      this.currentTab=0;
    },
    submitCallback(){
      this.$emit('ok');
      this.visible = false;
      this.currentTab=0;
    },
    handleCancel () {
      this.close()
      this.currentTab=0;
    },
    setSnData(sncode){
      this.snCode=sncode;
    }
  }
}
</script>

<style lang="less" scoped>
.steps {
  max-width: 750px;
  margin: 16px auto;
}
</style>