feat(crm): 将礼品选择下拉框替换为按钮触发的礼品选择弹窗组件

- 将礼品选择下拉框替换为按钮触发的礼品选择弹窗组件
- 集成 GiftSelect 组件实现单选礼品功能
- 移除原有的礼品列表加载逻辑,改用弹窗方式获取礼品信息
- 调整业务标题格式,简化显示内容
- 修复库存不足提示对话框组件引用问题
- 优化新增表单初始化逻辑,保留申请人信息并设置默认申请日期
- 调整表格列配置,隐藏流程状态列并重新排序创建时间列
- 添加详细的礼品选择确认回调处理逻辑
dev
zangch@mesnac.com 4 days ago
parent f4e72ac152
commit 46c2207b98

@ -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();
} }
}); });

@ -63,12 +63,12 @@
<dict-tag :options="gift_apply_status" :value="scope.row.applicationStatus" /> <dict-tag :options="gift_apply_status" :value="scope.row.applicationStatus" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="流程状态" align="center" prop="flowStatus" width="100" v-if="columns[9].visible"> <!-- <el-table-column label="流程状态" align="center" prop="flowStatus" width="100" v-if="columns[9].visible">
<template #default="scope"> <template #default="scope">
<dict-tag :options="wf_business_status" :value="scope.row.flowStatus" /> <dict-tag :options="wf_business_status" :value="scope.row.flowStatus" />
</template> </template>
</el-table-column> </el-table-column> -->
<el-table-column label="创建时间" align="center" prop="createTime" width="160" v-if="columns[10].visible"> <el-table-column label="创建时间" align="center" prop="createTime" width="160" v-if="columns[9].visible">
<template #default="scope"> <template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span> <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
</template> </template>
@ -178,9 +178,9 @@ const columns = ref<FieldOption[]>([
{ key: 5, label: `客人姓名`, visible: true }, { key: 5, label: `客人姓名`, visible: true },
{ key: 6, label: `人数`, visible: true }, { key: 6, label: `人数`, visible: true },
{ key: 7, label: `申请总金额`, visible: true }, { key: 7, label: `申请总金额`, visible: true },
{ key: 8, label: `申请状态`, visible: true }, // { key: 8, label: ``, visible: true },
{ key: 9, label: `流程状态`, visible: true }, { key: 8, label: `流程状态`, visible: true },
{ key: 10, label: `创建时间`, visible: true } { key: 9, label: `创建时间`, visible: true }
]); ]);
const queryParams = reactive<CrmGiftApplyQuery>({ const queryParams = reactive<CrmGiftApplyQuery>({

Loading…
Cancel
Save