|
|
|
|
@ -18,11 +18,7 @@
|
|
|
|
|
<el-row :gutter="20">
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
<el-form-item label="机票预订编号" prop="applyCode">
|
|
|
|
|
<el-input v-model="form.applyCode" placeholder="请输入机票预订编号" :disabled="true">
|
|
|
|
|
<template #append>
|
|
|
|
|
<el-button type="primary" @click="generateContractCode" :disabled="isCodeGenerated">生成机票预订编号 </el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</el-input>
|
|
|
|
|
<el-input v-model="form.applyCode" placeholder="自动生成" :disabled="true" />
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="12">
|
|
|
|
|
@ -175,8 +171,8 @@ const validateAmount = (rule: any, value: any, callback: any) => {
|
|
|
|
|
callback();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 机票编号生成状态
|
|
|
|
|
const isCodeGenerated = ref(false);
|
|
|
|
|
// // 机票编号生成状态
|
|
|
|
|
// const isCodeGenerated = ref(false);
|
|
|
|
|
/** 查询用户信息下拉框结构 */
|
|
|
|
|
const userInfoList = ref([]);
|
|
|
|
|
// 存储当前登录用户信息
|
|
|
|
|
@ -285,7 +281,7 @@ const data = reactive<PageData<FlightBookingForm, FlightBookingQuery>>({
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
passengerId: [{ required: true, message: '乘机人ID不能为空', trigger: 'blur' }],
|
|
|
|
|
applyCode: [{ required: true, message: '机票编码不能为空', trigger: 'blur' }],
|
|
|
|
|
// applyCode: [{ required: true, message: '机票编码不能为空', trigger: 'blur' }],
|
|
|
|
|
travelDate: [{ required: true, message: '出行日期不能为空', trigger: 'blur' }],
|
|
|
|
|
departureLocation: [{ required: true, message: '出发地点不能为空', trigger: 'blur' }],
|
|
|
|
|
arrivalLocation: [{ required: true, message: '到达地点不能为空', trigger: 'blur' }],
|
|
|
|
|
@ -300,20 +296,7 @@ const data = reactive<PageData<FlightBookingForm, FlightBookingQuery>>({
|
|
|
|
|
const { queryParams, form, rules } = toRefs(data);
|
|
|
|
|
|
|
|
|
|
const flightBookingFormRef = ref<ElFormInstance>();
|
|
|
|
|
// 生成机票编号
|
|
|
|
|
const generateContractCode = async () => {
|
|
|
|
|
if (isCodeGenerated.value) return; // 如果已经生成过,直接返回
|
|
|
|
|
try {
|
|
|
|
|
const params = { codeRuleCode: CodeRuleEnum.FLIGHT_BOOKING } as any;
|
|
|
|
|
const res = await getRuleGenerateCode(params);
|
|
|
|
|
form.value.applyCode = res.msg;
|
|
|
|
|
isCodeGenerated.value = true; // 标记为已生成
|
|
|
|
|
proxy?.$modal.msgSuccess('机票编号生成成功');
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('生成机票编号失败:', error);
|
|
|
|
|
proxy?.$modal.msgError('机票编号生成失败');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => form.value.passengerId, // 监听 passengerId
|
|
|
|
|
(newPassengerId) => {
|
|
|
|
|
@ -393,12 +376,6 @@ onMounted(async () => {
|
|
|
|
|
const res = await getFlightBooking(id);
|
|
|
|
|
Object.assign(form.value, res.data);
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
// 编辑模式:如果已有合同编号,禁用生成按钮
|
|
|
|
|
if (form.value.applyCode) {
|
|
|
|
|
isCodeGenerated.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
isCodeGenerated.value = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// 新增模式:获取登录用户部门ID并自动赋值
|
|
|
|
|
// try {
|
|
|
|
|
@ -410,13 +387,6 @@ onMounted(async () => {
|
|
|
|
|
// } catch (error) {
|
|
|
|
|
// console.error('获取用户信息失败:', error);
|
|
|
|
|
// }
|
|
|
|
|
// 新增模式:如果已有机票编号,禁用生成按钮
|
|
|
|
|
if (form.value.applyCode) {
|
|
|
|
|
isCodeGenerated.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
// 如果有合同但没有编号,允许生成
|
|
|
|
|
isCodeGenerated.value = false;
|
|
|
|
|
}
|
|
|
|
|
proxy?.$modal.closeLoading();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|