<!--
|
* @Description: file content
|
* @Author: Ben Lin
|
* @version:
|
* @Date: 2024-06-26 22:54:42
|
* @LastEditors: Ben Lin
|
* @LastEditTime: 2024-06-27 22:14:51
|
-->
|
<template>
|
<BasicModal
|
width="800px"
|
:height="600"
|
v-bind="$attrs"
|
@register="register"
|
:title="title"
|
@ok="handleSubmit"
|
>
|
<div class="step-form-form">
|
<Steps :current="current">
|
<Steps.Step title="选择客户" />
|
<Steps.Step title="添加工艺路线" />
|
<Steps.Step title="完成" />
|
</Steps>
|
</div>
|
<div class="mt-5">
|
<Step1 @next="handleStep1Next" v-show="current === 0" />
|
<Step2
|
@prev="handleStepPrev"
|
@next="handleStep2Next"
|
v-show="current === 1"
|
v-if="state.initStep2"
|
/>
|
<Step3 v-show="current === 2" @redo="handleRedo" v-if="state.initStep3" />
|
</div>
|
</BasicModal>
|
</template>
|
<script lang="ts" setup>
|
import { ref, reactive } from 'vue';
|
import Step1 from './Step1.vue';
|
import Step2 from './Step2.vue';
|
import Step3 from './Step3.vue';
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
import { Steps } from 'ant-design-vue';
|
import { useI18n } from '/@/hooks/web/useI18n';
|
import { isNullOrUnDef } from '/@/utils/is';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
defineOptions({ name: 'StepModal' });
|
|
const emit = defineEmits(['success']);
|
const { createErrorModal } = useMessage();
|
const { t } = useI18n();
|
const title = ref('');
|
const current = ref(0);
|
const step1Values = ref({});
|
const step2Values = ref({});
|
|
const state = reactive({
|
initStep2: false,
|
initStep3: false,
|
});
|
|
const [register, { setModalProps, closeModal }] = useModalInner((data) => {
|
setModalProps({ confirmLoading: false, okText: '保存提交' });
|
data && onDataReceive(data);
|
});
|
|
/**
|
* @description: 打开模态窗口时接收数据方法
|
* @param {*} data
|
* @return {*}
|
*/
|
async function onDataReceive(data) {
|
console.log('Data Received', data);
|
title.value = data?.title;
|
}
|
|
/**
|
* @description: 步骤完成后提交方法
|
* @return {*}
|
*/
|
async function handleSubmit() {
|
try {
|
if (isNullOrUnDef(step1Values.value['CUST_CODE'])) {
|
createErrorModal({
|
title: t('sys.api.errorTip'),
|
content: '步骤1未完成,请完成再保存提交',
|
});
|
return;
|
}
|
if (isNullOrUnDef(step2Values.value['ROT_CODE'])) {
|
createErrorModal({
|
title: t('sys.api.errorTip'),
|
content: '步骤2未完成,请完成再保存提交',
|
});
|
return;
|
}
|
closeModal();
|
emit('success', { ...step1Values.value, ...step2Values.value });
|
} finally {
|
setModalProps({ confirmLoading: false });
|
}
|
}
|
|
function handleStep1Next(Values: any) {
|
current.value++;
|
state.initStep2 = true;
|
console.log(Values);
|
step1Values.value = Values;
|
}
|
|
function handleStepPrev() {
|
current.value--;
|
if(current.value == 1){
|
step2Values.value = '';
|
}
|
if(current.value == 0){
|
step1Values.value = '';
|
}
|
}
|
|
function handleStep2Next(Values: any) {
|
current.value++;
|
state.initStep3 = true;
|
console.log(Values);
|
step2Values.value = Values;
|
}
|
|
function handleRedo() {
|
current.value = 0;
|
state.initStep2 = false;
|
state.initStep3 = false;
|
}
|
</script>
|
<style lang="less" scoped>
|
.step-form-content {
|
padding: 24px;
|
background-color: @component-background;
|
}
|
|
.step-form-form {
|
width: 750px;
|
margin: 0 auto;
|
}
|
</style>
|