|
|
|
@ -85,16 +85,15 @@
|
|
|
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
|
|
|
<el-table-column type="index" label="序号" width="60" align="center" />
|
|
|
|
<el-table-column label="礼品" min-width="200" align="center">
|
|
|
|
<el-table-column label="礼品" min-width="200" align="center">
|
|
|
|
<template #default="scope">
|
|
|
|
<template #default="scope">
|
|
|
|
<el-select
|
|
|
|
<el-button
|
|
|
|
v-model="scope.row.giftId"
|
|
|
|
type="primary"
|
|
|
|
placeholder="请选择礼品"
|
|
|
|
link
|
|
|
|
filterable
|
|
|
|
icon="Search"
|
|
|
|
@change="(val) => handleGiftChange(val, scope.$index)"
|
|
|
|
|
|
|
|
:disabled="routeParams.type === 'view' || routeParams.type === 'approval'"
|
|
|
|
:disabled="routeParams.type === 'view' || routeParams.type === 'approval'"
|
|
|
|
style="width: 100%"
|
|
|
|
@click="openGiftSelect(scope.$index)"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<el-option v-for="gift in giftList" :key="gift.giftId" :label="`${gift.giftCode} - ${gift.giftName}`" :value="gift.giftId" />
|
|
|
|
{{ scope.row.giftName ? `${scope.row.giftCode || ''} ${scope.row.giftName}` : '选择礼品' }}
|
|
|
|
</el-select>
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column label="规格型号" prop="specification" min-width="120" align="center" />
|
|
|
|
<el-table-column label="规格型号" prop="specification" min-width="120" align="center" />
|
|
|
|
@ -179,6 +178,9 @@
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
</el-card>
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 礼品选择弹窗(单选) -->
|
|
|
|
|
|
|
|
<GiftSelect ref="giftSelectRef" :multiple="false" @confirm-call-back="handleGiftSelectConfirm" />
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 审批弹窗 -->
|
|
|
|
<!-- 审批弹窗 -->
|
|
|
|
<SubmitVerify ref="submitVerifyRef" @submitCallback="submitCallback" />
|
|
|
|
<SubmitVerify ref="submitVerifyRef" @submitCallback="submitCallback" />
|
|
|
|
<!-- 审批记录 -->
|
|
|
|
<!-- 审批记录 -->
|
|
|
|
@ -189,7 +191,7 @@
|
|
|
|
<script setup name="CrmGiftApplyEdit" lang="ts">
|
|
|
|
<script setup name="CrmGiftApplyEdit" lang="ts">
|
|
|
|
import { addCrmGiftApply, getCrmGiftApply, giftApplySubmitAndFlowStart, updateCrmGiftApply } from '@/api/oa/crm/crmGiftApply';
|
|
|
|
import { addCrmGiftApply, getCrmGiftApply, giftApplySubmitAndFlowStart, updateCrmGiftApply } from '@/api/oa/crm/crmGiftApply';
|
|
|
|
import { CrmGiftApplyForm } from '@/api/oa/crm/crmGiftApply/types';
|
|
|
|
import { CrmGiftApplyForm } from '@/api/oa/crm/crmGiftApply/types';
|
|
|
|
import { getCrmGiftInfoList } from '@/api/oa/crm/crmGiftInfo';
|
|
|
|
import GiftSelect from '@/components/GiftSelect/index.vue';
|
|
|
|
import { CrmGiftInfoVO } from '@/api/oa/crm/crmGiftInfo/types';
|
|
|
|
import { CrmGiftInfoVO } from '@/api/oa/crm/crmGiftInfo/types';
|
|
|
|
import { getCrmCustomerInfoList } from '@/api/oa/crm/crmCustomerInfo';
|
|
|
|
import { getCrmCustomerInfoList } from '@/api/oa/crm/crmCustomerInfo';
|
|
|
|
import { CrmCustomerInfoVO } from '@/api/oa/crm/crmCustomerInfo/types';
|
|
|
|
import { CrmCustomerInfoVO } from '@/api/oa/crm/crmCustomerInfo/types';
|
|
|
|
@ -198,6 +200,8 @@ import { listUser } from '@/api/system/user';
|
|
|
|
import SubmitVerify from '@/components/Process/submitVerify.vue';
|
|
|
|
import SubmitVerify from '@/components/Process/submitVerify.vue';
|
|
|
|
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
|
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
|
|
|
|
import approvalButton from '@/components/Process/approvalButton.vue';
|
|
|
|
import approvalButton from '@/components/Process/approvalButton.vue';
|
|
|
|
|
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
const route = useRoute();
|
|
|
|
const route = useRoute();
|
|
|
|
@ -217,7 +221,9 @@ const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
|
|
|
|
|
|
|
|
|
|
|
|
// 状态
|
|
|
|
// 状态
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
const buttonLoading = ref(false);
|
|
|
|
const giftList = ref<CrmGiftInfoVO[]>([]);
|
|
|
|
// 礼品选择组件引用与当前行索引
|
|
|
|
|
|
|
|
const giftSelectRef = ref<InstanceType<typeof GiftSelect>>();
|
|
|
|
|
|
|
|
const currentRowIndex = ref<number>(-1);
|
|
|
|
const customerList = ref<CrmCustomerInfoVO[]>([]);
|
|
|
|
const customerList = ref<CrmCustomerInfoVO[]>([]);
|
|
|
|
const userList = ref<any[]>([]); // 用户列表,用于审批人选择
|
|
|
|
const userList = ref<any[]>([]); // 用户列表,用于审批人选择
|
|
|
|
|
|
|
|
|
|
|
|
@ -292,16 +298,6 @@ const loadCustomerList = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** 加载礼品列表 */
|
|
|
|
|
|
|
|
const loadGiftList = async () => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const res = await getCrmGiftInfoList({});
|
|
|
|
|
|
|
|
giftList.value = res.data || [];
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('加载礼品列表失败:', error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 加载表单数据 */
|
|
|
|
/** 加载表单数据 */
|
|
|
|
const loadFormData = async (id: string | number) => {
|
|
|
|
const loadFormData = async (id: string | number) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
@ -369,19 +365,21 @@ const handleCustomerChange = (customerId: number | string) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** 礼品选择变更 */
|
|
|
|
/** 礼品选择回填 */
|
|
|
|
const handleGiftChange = (giftId: string | number, index: number) => {
|
|
|
|
const handleGiftSelectConfirm = (data: CrmGiftInfoVO[]) => {
|
|
|
|
const gift = giftList.value.find((g) => g.giftId === giftId);
|
|
|
|
if (currentRowIndex.value < 0 || !data || data.length === 0) {
|
|
|
|
if (gift && form.value.detailList) {
|
|
|
|
return;
|
|
|
|
const detail = form.value.detailList[index];
|
|
|
|
|
|
|
|
detail.giftCode = gift.giftCode;
|
|
|
|
|
|
|
|
detail.giftName = gift.giftName;
|
|
|
|
|
|
|
|
detail.specification = gift.specification;
|
|
|
|
|
|
|
|
detail.unitPrice = gift.unitPrice;
|
|
|
|
|
|
|
|
detail.inventoryQuantity = gift.inventoryQuantity;
|
|
|
|
|
|
|
|
detail.applicationQuantity = 1;
|
|
|
|
|
|
|
|
calculateAmount(index);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const gift = data[0];
|
|
|
|
|
|
|
|
const detail = form.value.detailList[currentRowIndex.value];
|
|
|
|
|
|
|
|
detail.giftId = gift.giftId as any;
|
|
|
|
|
|
|
|
detail.giftCode = gift.giftCode;
|
|
|
|
|
|
|
|
detail.giftName = gift.giftName;
|
|
|
|
|
|
|
|
detail.specification = gift.specification;
|
|
|
|
|
|
|
|
detail.unitPrice = gift.unitPrice;
|
|
|
|
|
|
|
|
detail.inventoryQuantity = gift.inventoryQuantity;
|
|
|
|
|
|
|
|
detail.applicationQuantity = 1;
|
|
|
|
|
|
|
|
calculateAmount(currentRowIndex.value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** 计算金额 */
|
|
|
|
/** 计算金额 */
|
|
|
|
@ -420,6 +418,12 @@ const handleAddDetail = () => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 打开礼品选择弹窗 */
|
|
|
|
|
|
|
|
const openGiftSelect = (index: number) => {
|
|
|
|
|
|
|
|
currentRowIndex.value = index;
|
|
|
|
|
|
|
|
giftSelectRef.value?.open();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** 删除礼品明细 */
|
|
|
|
/** 删除礼品明细 */
|
|
|
|
const handleDeleteDetail = (index: number) => {
|
|
|
|
const handleDeleteDetail = (index: number) => {
|
|
|
|
if (form.value.detailList) {
|
|
|
|
if (form.value.detailList) {
|
|
|
|
@ -490,7 +494,7 @@ const submitForm = async (status: string) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// P2-2: 完善 businessTitle 格式,包含申请人和客户单位信息
|
|
|
|
// P2-2: 完善 businessTitle 格式,包含申请人和客户单位信息
|
|
|
|
form.value.bizExt = {
|
|
|
|
form.value.bizExt = {
|
|
|
|
businessTitle: `礼品申请审批 - ${form.value.applicantName} - ${form.value.customerUnitName}`,
|
|
|
|
businessTitle: `礼品申请审批`,
|
|
|
|
businessCode: form.value.applicationCode,
|
|
|
|
businessCode: form.value.applicationCode,
|
|
|
|
businessId: String(form.value.giftApplyId)
|
|
|
|
businessId: String(form.value.giftApplyId)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -502,7 +506,7 @@ const submitForm = async (status: string) => {
|
|
|
|
if (submitError?.message && submitError.message.includes('库存不足')) {
|
|
|
|
if (submitError?.message && submitError.message.includes('库存不足')) {
|
|
|
|
// 将换行符转换为HTML换行标签,便于弹窗展示
|
|
|
|
// 将换行符转换为HTML换行标签,便于弹窗展示
|
|
|
|
const formattedMsg = submitError.message.replace(/\n/g, '<br/>');
|
|
|
|
const formattedMsg = submitError.message.replace(/\n/g, '<br/>');
|
|
|
|
await proxy?.$alert(formattedMsg, '库存不足提示', {
|
|
|
|
await ElMessageBox.alert(formattedMsg, '库存不足提示', {
|
|
|
|
type: 'warning',
|
|
|
|
type: 'warning',
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
confirmButtonText: '我知道了'
|
|
|
|
confirmButtonText: '我知道了'
|
|
|
|
@ -553,15 +557,22 @@ onMounted(async () => {
|
|
|
|
// 初始化用户信息(申请人)
|
|
|
|
// 初始化用户信息(申请人)
|
|
|
|
await initUserInfo();
|
|
|
|
await initUserInfo();
|
|
|
|
|
|
|
|
|
|
|
|
// 查询客户、礼品列表
|
|
|
|
// 查询客户列表
|
|
|
|
await Promise.all([loadCustomerList(), loadGiftList()]);
|
|
|
|
await loadCustomerList();
|
|
|
|
|
|
|
|
|
|
|
|
// 如果有ID则查询详情
|
|
|
|
// 如果有ID则查询详情
|
|
|
|
if (currentId.value) {
|
|
|
|
if (currentId.value) {
|
|
|
|
await loadFormData(currentId.value);
|
|
|
|
await loadFormData(currentId.value);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 新增时初始化默认数据
|
|
|
|
// 新增时初始化默认数据(保留 initUserInfo 已写入的申请人/领用人信息)
|
|
|
|
form.value = { ...initFormData } as any;
|
|
|
|
// 注意:initFormData 中 recipientName 为 undefined,直接 Object.assign 会覆盖已有值
|
|
|
|
|
|
|
|
Object.assign(form.value, { ...initFormData, ...form.value });
|
|
|
|
|
|
|
|
console.debug('[crmGiftApply] init defaults merged', {
|
|
|
|
|
|
|
|
applicantName: form.value.applicantName,
|
|
|
|
|
|
|
|
recipientName: form.value.recipientName
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// 申请日期默认当天,便于快速选择
|
|
|
|
|
|
|
|
form.value.applicationDate = dayjs().format('YYYY-MM-DD');
|
|
|
|
calculateTotalAmount();
|
|
|
|
calculateTotalAmount();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|