1.0.46:

前端:
   fix(budget):新增router的问题
dev
xs 2 weeks ago
parent 76497b4c44
commit d3d99e72e5

@ -175,11 +175,12 @@
<script setup lang="ts" name="BudgetInfoEdit">
import { ref, reactive } from 'vue';
import { ElMessage } from 'element-plus';
import { listProjectInfo, addErpBudgetInfo, updateErpBudgetInfo, getErpBudgetInfo } from '@/api/oa/erp/budgetInfo';
import { listProjectInfo, addErpBudgetInfo, updateErpBudgetInfo, changeErpBudgetInfo, getErpBudgetInfo } from '@/api/oa/erp/budgetInfo';
import { ProjectInfoVO, ProjectInfoQuery } from '@/api/oa/erp/projectInfo/types';
import { getUserList } from '@/api/system/user';
import { deepEqualArrays } from '@/utils/objHandle';
import { cloneDeep } from 'lodash-es';
const router = useRouter();
@ -644,11 +645,20 @@ const handleSave = async (status: string, mode: boolean) => {
ElMessage.warning('不支持的预算类型');
return;
}
console.log('----');
console.log(budgetForm);
//
const saveOperation = budgetForm.budgetId ? () => updateErpBudgetInfo(budgetForm) : () => addErpBudgetInfo(budgetForm);
await saveOperation();
if (budgetForm.budgetId) {
await updateErpBudgetInfo(budgetForm);
} else {
if (routeParams.value.changeFlag === '1') {
await changeErpBudgetInfo(budgetForm);
} else {
budgetForm.budgetVersion = 1;
await addErpBudgetInfo(budgetForm);
}
}
ElMessage.success('操作成功');
handleSaveSuccess();
@ -685,8 +695,6 @@ const processRdBudgetForm = async (status: string): Promise<budgetInfoForm> => {
...initializeRdCostLists()
};
console.log(budgetForm);
//
processRdCostData(budgetForm);
@ -760,6 +768,8 @@ const initializeMarketCostLists = () => ({
//
const processRdCostData = (budgetForm: budgetInfoForm) => {
//
console.log(rdMaterialCostRef.value?.allMaterialData);
console.log(oriRdBudgetMaterialCostList.value);
if (assignIfChanged([], rdEquipmentCostRef.value?.equipmentData, oriRdBudgetEquipmentCostList.value).length) {
budgetForm.erpRdBudgetEquipmentCostList = rdEquipmentCostRef.value?.equipmentData || [];
}
@ -883,153 +893,437 @@ const handleClose = () => {
const route = useRoute();
const budgetId = ref();
//
//
const PRIMARY_KEY_MAP = {
//
erpRdBudgetEquipmentCostList: 'equipmentCostId',
erpRdBudgetMaterialCostList: 'materialCostId',
erpRdBudgetTravelCostList: 'travelCostId',
erpRdBudgetMeetingCostList: 'meetingCostId',
erpRdBudgetExchangeCostList: 'exchangeCostId',
erpRdBudgetTechCostList: 'techCostId',
erpRdBudgetLaborCostList: 'laborCostId',
erpRdBudgetLiteratureCostList: 'literatureCostId',
erpRdBudgetTestingCostList: 'testingCostId',
erpRdBudgetOtherCostList: 'otherCostId',
//
erpBudgetMaterialCostList: 'materialCostId',
erpBudgetLaborCostList: 'laborCostId',
erpBudgetInstallCostList: 'installCostId',
erpBudgetTravelCostList: 'travelCostId',
erpBudgetOtherCostList: 'otherCostId',
//
erpBudgetDetailList: 'budgetDetailId',
erpBudgetInfo: 'budgetId',
//
default: 'id'
} as const;
//
const COMMON_FIELDS_TO_REMOVE = ['budgetId', 'createDept', 'createBy', 'createTime', 'updateBy', 'updateTime', 'delFlag'];
onMounted(() => {
nextTick(async () => {
//
routeParams.value = route.query;
budgetId.value = routeParams.value.id as string | number;
if (budgetId.value && (routeParams.value.type === 'update' || routeParams.value.type === 'view' || routeParams.value.type === 'approval')) {
proxy?.$modal.loading('正在加载数据,请稍后...');
const res = await getErpBudgetInfo(budgetId.value);
Object.assign(searchForm, res.data);
console.log(res.data);
await getUsers();
if (searchForm.projectCategory === PROJECT_CATEGORY.RD || searchForm.projectCategory === PROJECT_CATEGORY.PRE_PRODUCTION) {
oriRdBudgetEquipmentCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetEquipmentCostList));
const erpRdBudgetMaterialCostList = res.data.erpRdBudgetMaterialCostList;
const groupedRdBudgetMaterialCostListByMaterialType = erpRdBudgetMaterialCostList.reduce((acc, item) => {
const materialType = item.materialType;
if (!acc[materialType]) {
acc[materialType] = [];
}
acc[materialType].push(item);
return acc;
}, {});
const rdBudgetMainMaterialCostList = groupedRdBudgetMaterialCostListByMaterialType[MATERIAL_TYPE.MAIN] || [];
const rdBudgetOtherMaterialCostList = groupedRdBudgetMaterialCostListByMaterialType[MATERIAL_TYPE.OTHER] || [];
oriRdBudgetMaterialCostList.value = JSON.parse(JSON.stringify(erpRdBudgetMaterialCostList));
oriRdBudgetTravelCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetTravelCostList));
oriRdBudgetMeetingCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetMeetingCostList));
oriRdBudgetExchangeCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetExchangeCostList));
const erpRdBudgetTechCostList = res.data.erpRdBudgetTechCostList;
const groupedRdBudgetTechCostListByTechType = erpRdBudgetTechCostList.reduce((acc, item) => {
const techType = item.techType;
if (!acc[techType]) {
acc[techType] = [];
}
acc[techType].push(item);
return acc;
}, {});
const rdBudgetTechConsultCostList = groupedRdBudgetTechCostListByTechType[TECH_TYPE.TECH_CONSULT] || [];
const rdBudgetExpertMeetingCostList = groupedRdBudgetTechCostListByTechType[TECH_TYPE.EXPERT_MEETING] || [];
const rdBudgetExpertCommCostList = groupedRdBudgetTechCostListByTechType[TECH_TYPE.EXPERT_COMM] || [];
oriRdBudgetTechConsultCostList.value = JSON.parse(JSON.stringify(rdBudgetTechConsultCostList)); //
oriRdBudgetExpertMeetingCostList.value = JSON.parse(JSON.stringify(rdBudgetExpertMeetingCostList)); //
oriRdBudgetExpertCommCostList.value = JSON.parse(JSON.stringify(rdBudgetExpertCommCostList)); //
const erpRdBudgetLaborCostList = res.data.erpRdBudgetLaborCostList;
const groupedRdBudgetLaborCostListByLaborType = erpRdBudgetLaborCostList.reduce((acc, item) => {
const laborType = item.laborType;
if (!acc[laborType]) {
acc[laborType] = [];
}
acc[laborType].push(item);
return acc;
}, {});
const rdBudgetLaborCostList = groupedRdBudgetLaborCostListByLaborType[LABOR_TYPE.LABOR] || [];
const rdBudgetServiceCostList = groupedRdBudgetLaborCostListByLaborType[LABOR_TYPE.SERVICE] || [];
oriRdBudgetLaborCostList.value = JSON.parse(JSON.stringify(rdBudgetLaborCostList)); //
oriRdBudgetServiceCostList.value = JSON.parse(JSON.stringify(rdBudgetServiceCostList)); //
const erpRdBudgetLiteratureCostList = res.data.erpRdBudgetLiteratureCostList;
const groupedRdBudgetLiteratureCostListByLiteratureType = erpRdBudgetLiteratureCostList.reduce((acc, item) => {
const literatureType = item.literatureType;
if (!acc[literatureType]) {
acc[literatureType] = [];
}
acc[literatureType].push(item);
return acc;
}, {});
const rdBudgetLiteratureMaterialCostList = groupedRdBudgetLiteratureCostListByLiteratureType[LITERATURE_TYPE.MATERIAL] || [];
const rdBudgetLiteratureSoftwareCostList = groupedRdBudgetLiteratureCostListByLiteratureType[LITERATURE_TYPE.SOFTWARE] || [];
oriRdBudgetLiteratureMaterialCostList.value = JSON.parse(JSON.stringify(rdBudgetLiteratureMaterialCostList)); //
oriRdBudgetLiteratureSofwareCostList.value = JSON.parse(JSON.stringify(rdBudgetLiteratureSoftwareCostList)); //
const rdBudgetLiteratureRetrievalCostList = groupedRdBudgetLiteratureCostListByLiteratureType[LITERATURE_TYPE.DOCUMENT] || []; //
oriRdBudgetTestingCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetTestingCostList));
oriRdBudgetOtherCostList.value = JSON.parse(JSON.stringify(res.data.erpRdBudgetOtherCostList));
nextTick(() => {
console.log(rdBudgetTableRef.value?.budgetForm);
Object.assign(rdBudgetTableRef.value?.rdBudgetInfoForm, res.data);
Object.assign(rdBudgetTableRef.value?.footerForm, res.data);
Object.assign(rdBudgetTableRef.value?.budgetDetailData || [], res.data.erpBudgetDetailList);
Object.assign(rdEquipmentCostRef.value?.equipmentData || [], res.data.erpRdBudgetEquipmentCostList);
Object.assign(rdMaterialCostRef.value?.materialData || [], rdBudgetMainMaterialCostList);
Object.assign(rdMaterialCostRef.value?.otherMaterial || [], rdBudgetOtherMaterialCostList[0]);
Object.assign(rdTravelMeetingExchangeRef.value?.travelList || [], res.data.erpRdBudgetTravelCostList);
Object.assign(rdTravelMeetingExchangeRef.value?.meetingList || [], res.data.erpRdBudgetMeetingCostList);
Object.assign(rdTravelMeetingExchangeRef.value?.exchangeList || [], res.data.erpRdBudgetExchangeCostList);
Object.assign(rdLaborServiceRef.value?.techConsultList || [], rdBudgetTechConsultCostList);
Object.assign(rdLaborServiceRef.value?.expertMeetingList || [], rdBudgetExpertMeetingCostList);
Object.assign(rdLaborServiceRef.value?.expertCommList || [], rdBudgetExpertCommCostList);
Object.assign(rdLaborServiceRef.value?.laborList || [], rdBudgetLaborCostList);
Object.assign(rdLaborServiceRef.value?.serviceList || [], rdBudgetServiceCostList);
Object.assign(rdLiteratureCostRef.value?.materialsList || [], rdBudgetLiteratureMaterialCostList);
Object.assign(rdLiteratureCostRef.value?.softwareList || [], rdBudgetLiteratureSoftwareCostList);
Object.assign(
rdLiteratureCostRef.value?.literatureRetrieval || [],
rdBudgetLiteratureRetrievalCostList.length > 0 ? rdBudgetLiteratureRetrievalCostList[0] : {}
);
Object.assign(rdTestingCostRef.value?.testData || [], res.data.erpRdBudgetTestingCostList);
Object.assign(rdOtherCostRef.value?.otherCostList || [], res.data.erpRdBudgetOtherCostList);
});
} else if (searchForm.projectCategory === PROJECT_CATEGORY.MARKET || searchForm.projectCategory === PROJECT_CATEGORY.MARKET_PART) {
//
oriBudgetMaterialCostList.value = JSON.parse(JSON.stringify(res.data.erpBudgetMaterialCostList));
oriBudgetLaborCostList.value = JSON.parse(JSON.stringify(res.data.erpBudgetLaborCostList));
oriBudgetInstallCostList.value = JSON.parse(JSON.stringify(res.data.erpBudgetInstallCostList));
oriBudgetTravelCostList.value = JSON.parse(JSON.stringify(res.data.erpBudgetTravelCostList));
oriBudgetOtherCostList.value = JSON.parse(JSON.stringify(res.data.erpBudgetOtherCostList));
nextTick(() => {
console.log(budgetTableRef.value?.budgetForm);
Object.assign(budgetTableRef.value?.budgetForm, res.data);
Object.assign(budgetTableRef.value?.budgetDetailData, res.data.erpBudgetDetailList);
Object.assign(materialCostRef.value?.budgetMaterialCostList, res.data.erpBudgetMaterialCostList);
Object.assign(laborCostRef.value?.budgetLaborCostList, res.data.erpBudgetLaborCostList);
Object.assign(installationCostRef.value?.installCostList, res.data.erpBudgetInstallCostList);
Object.assign(travelCostRef.value?.travelCostList, res.data.erpBudgetTravelCostList);
Object.assign(otherCostRef.value?.otherCostList, res.data.erpBudgetOtherCostList);
});
}
proxy?.$modal.closeLoading();
} else {
searchForm.projectCategory = routeParams.value.projectCategory;
//
// if (form.value.contractCode) {
// isCodeGenerated.value = true;
// } else if (form.value.contractFlag === '1') {
// //
// isCodeGenerated.value = false;
// }
}
queryParams.value.projectCategory = searchForm.projectCategory;
await loadBudgetData();
});
});
async function loadBudgetData() {
routeParams.value = route.query;
budgetId.value = routeParams.value.id as string | number;
if (!budgetId.value || !['update', 'view', 'approval'].includes(routeParams.value.type as string)) {
handleAddMode();
return;
}
await handleLoadMode();
}
function handleAddMode() {
searchForm.projectCategory = routeParams.value.projectCategory;
queryParams.value.projectCategory = searchForm.projectCategory;
}
async function handleLoadMode() {
proxy?.$modal.loading('正在加载数据,请稍后...');
try {
const res = await getErpBudgetInfo(budgetId.value);
Object.assign(searchForm, res.data);
if (routeParams.value.changeFlag === '1') {
searchForm.flowStatus = 'draft';
}
await getUsers();
if (isRdOrPreProductionCategory()) {
await handleRdOrPreProductionData(res.data);
} else if (isMarketCategory()) {
await handleMarketCategoryData(res.data);
}
} finally {
proxy?.$modal.closeLoading();
}
}
function isRdOrPreProductionCategory(): boolean {
return searchForm.projectCategory === PROJECT_CATEGORY.RD || searchForm.projectCategory === PROJECT_CATEGORY.PRE_PRODUCTION;
}
function isMarketCategory(): boolean {
return searchForm.projectCategory === PROJECT_CATEGORY.MARKET || searchForm.projectCategory === PROJECT_CATEGORY.MARKET_PART;
}
async function handleRdOrPreProductionData(data: any) {
const isChangeType = routeParams.value.changeFlag === '1';
//
if (!isChangeType) {
initOriginalRdData(data);
}
//
const groupedMaterialData = groupByField(data.erpRdBudgetMaterialCostList, 'materialType');
const groupedTechData = groupByField(data.erpRdBudgetTechCostList, 'techType');
const groupedLaborData = groupByField(data.erpRdBudgetLaborCostList, 'laborType');
const groupedLiteratureData = groupByField(data.erpRdBudgetLiteratureCostList, 'literatureType');
//
const categorizedData = {
rdBudgetMainMaterialCostList: handleChangeTypeIds(groupedMaterialData[MATERIAL_TYPE.MAIN] || [], 'erpRdBudgetMaterialCostList', isChangeType),
rdBudgetOtherMaterialCostList: handleChangeTypeIds(groupedMaterialData[MATERIAL_TYPE.OTHER] || [], 'erpRdBudgetMaterialCostList', isChangeType),
rdBudgetTechConsultCostList: handleChangeTypeIds(groupedTechData[TECH_TYPE.TECH_CONSULT] || [], 'erpRdBudgetTechCostList', isChangeType),
rdBudgetExpertMeetingCostList: handleChangeTypeIds(groupedTechData[TECH_TYPE.EXPERT_MEETING] || [], 'erpRdBudgetTechCostList', isChangeType),
rdBudgetExpertCommCostList: handleChangeTypeIds(groupedTechData[TECH_TYPE.EXPERT_COMM] || [], 'erpRdBudgetTechCostList', isChangeType),
rdBudgetLaborCostList: handleChangeTypeIds(groupedLaborData[LABOR_TYPE.LABOR] || [], 'erpRdBudgetLaborCostList', isChangeType),
rdBudgetServiceCostList: handleChangeTypeIds(groupedLaborData[LABOR_TYPE.SERVICE] || [], 'erpRdBudgetLaborCostList', isChangeType),
rdBudgetLiteratureMaterialCostList: handleChangeTypeIds(
groupedLiteratureData[LITERATURE_TYPE.MATERIAL] || [],
'erpRdBudgetLiteratureCostList',
isChangeType
),
rdBudgetLiteratureSoftwareCostList: handleChangeTypeIds(
groupedLiteratureData[LITERATURE_TYPE.SOFTWARE] || [],
'erpRdBudgetLiteratureCostList',
isChangeType
),
rdBudgetLiteratureRetrievalCostList: handleChangeTypeIds(
groupedLiteratureData[LITERATURE_TYPE.DOCUMENT] || [],
'erpRdBudgetLiteratureCostList',
isChangeType
)
};
await nextTick();
assignRdDataToComponents(data, categorizedData, isChangeType);
}
async function handleMarketCategoryData(data: any) {
const isChangeType = routeParams.value.changeFlag === '1';
//
if (!isChangeType) {
initOriginalMarketData(data);
}
//
const processedLists = {
materialCostList: handleChangeTypeIds(data.erpBudgetMaterialCostList, 'erpBudgetMaterialCostList', isChangeType),
laborCostList: handleChangeTypeIds(data.erpBudgetLaborCostList, 'erpBudgetLaborCostList', isChangeType),
installCostList: handleChangeTypeIds(data.erpBudgetInstallCostList, 'erpBudgetInstallCostList', isChangeType),
travelCostList: handleChangeTypeIds(data.erpBudgetTravelCostList, 'erpBudgetTravelCostList', isChangeType),
otherCostList: handleChangeTypeIds(data.erpBudgetOtherCostList, 'erpBudgetOtherCostList', isChangeType),
detailList: handleChangeTypeIds(data.erpBudgetDetailList, 'erpBudgetDetailList', isChangeType)
};
await nextTick();
assignMarketDataToComponents(data, processedLists, isChangeType);
}
//
function getPrimaryKeyField(listName: string): string {
return PRIMARY_KEY_MAP[listName] || PRIMARY_KEY_MAP.default;
}
// ID
function handleChangeTypeIds(data: any[], listName: string, isChangeType: boolean): any[] {
if (!isChangeType || !data || data.length === 0) {
return data || [];
}
const primaryKey = getPrimaryKeyField(listName);
return data.map((item) => {
return processFormDataForChange(item, primaryKey);
});
}
//
function processFormDataForChange(data: any, primaryKey: string): any {
const processedData = { ...data };
//
if (primaryKey in processedData) {
delete processedData[primaryKey];
}
//
COMMON_FIELDS_TO_REMOVE.forEach((field) => {
if (field in processedData) {
delete processedData[field];
}
});
// "Id"
// Object.keys(newItem).forEach((key) => {
// if (key.endsWith('Id') && key !== primaryKey) {
// delete newItem[key];
// }
// });
return processedData;
}
function groupByField(array: any[], field: string): Record<string, any[]> {
if (!array) return {};
return array.reduce((acc, item) => {
const key = item[field];
if (!acc[key]) {
acc[key] = [];
}
acc[key].push(item);
return acc;
}, {});
}
function initOriginalRdData(data: any) {
//
oriRdBudgetEquipmentCostList.value = deepClone(data.erpRdBudgetEquipmentCostList);
oriRdBudgetMaterialCostList.value = deepClone(data.erpRdBudgetMaterialCostList);
oriRdBudgetTravelCostList.value = deepClone(data.erpRdBudgetTravelCostList);
oriRdBudgetMeetingCostList.value = deepClone(data.erpRdBudgetMeetingCostList);
oriRdBudgetExchangeCostList.value = deepClone(data.erpRdBudgetExchangeCostList);
oriRdBudgetTestingCostList.value = deepClone(data.erpRdBudgetTestingCostList);
oriRdBudgetOtherCostList.value = deepClone(data.erpRdBudgetOtherCostList);
//
if (data.erpRdBudgetTechCostList) {
const groupedTechData = groupByField(data.erpRdBudgetTechCostList, 'techType');
oriRdBudgetTechConsultCostList.value = deepClone(groupedTechData[TECH_TYPE.TECH_CONSULT] || []);
oriRdBudgetExpertMeetingCostList.value = deepClone(groupedTechData[TECH_TYPE.EXPERT_MEETING] || []);
oriRdBudgetExpertCommCostList.value = deepClone(groupedTechData[TECH_TYPE.EXPERT_COMM] || []);
}
if (data.erpRdBudgetLaborCostList) {
const groupedLaborData = groupByField(data.erpRdBudgetLaborCostList, 'laborType');
oriRdBudgetLaborCostList.value = deepClone(groupedLaborData[LABOR_TYPE.LABOR] || []);
oriRdBudgetServiceCostList.value = deepClone(groupedLaborData[LABOR_TYPE.SERVICE] || []);
}
if (data.erpRdBudgetLiteratureCostList) {
const groupedLiteratureData = groupByField(data.erpRdBudgetLiteratureCostList, 'literatureType');
oriRdBudgetLiteratureMaterialCostList.value = deepClone(groupedLiteratureData[LITERATURE_TYPE.MATERIAL] || []);
oriRdBudgetLiteratureSofwareCostList.value = deepClone(groupedLiteratureData[LITERATURE_TYPE.SOFTWARE] || []);
}
}
// initOriginalMarketData isChangeType
function initOriginalMarketData(data: any) {
//
oriBudgetMaterialCostList.value = deepClone(data.erpBudgetMaterialCostList);
oriBudgetLaborCostList.value = deepClone(data.erpBudgetLaborCostList);
oriBudgetInstallCostList.value = deepClone(data.erpBudgetInstallCostList);
oriBudgetTravelCostList.value = deepClone(data.erpBudgetTravelCostList);
oriBudgetOtherCostList.value = deepClone(data.erpBudgetOtherCostList);
}
//
function assignRdDataToComponents(data: any, categorizedData: any, isChangeType: boolean) {
if (!rdBudgetTableRef.value) return;
// - ID
const formData = isChangeType ? processFormDataForChange(data, 'budgetId') : data;
Object.assign(rdBudgetTableRef.value.rdBudgetInfoForm, formData);
Object.assign(rdBudgetTableRef.value.footerForm, formData);
//
const budgetDetailList = isChangeType
? handleChangeTypeIds(data.erpBudgetDetailList, 'erpBudgetDetailList', true)
: deepClone(data.erpBudgetDetailList || []);
//
if (rdBudgetTableRef.value.budgetDetailData) {
rdBudgetTableRef.value.budgetDetailData = budgetDetailList;
}
// - categorizedData ori
const equipmentData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetEquipmentCostList, 'erpRdBudgetEquipmentCostList', true)
: oriRdBudgetEquipmentCostList.value;
if (rdEquipmentCostRef.value?.equipmentData) {
rdEquipmentCostRef.value.equipmentData = deepClone(equipmentData);
}
//
if (rdMaterialCostRef.value) {
//
if (rdMaterialCostRef.value.materialData) {
rdMaterialCostRef.value.materialData = deepClone(categorizedData.rdBudgetMainMaterialCostList);
}
//
if (categorizedData.rdBudgetOtherMaterialCostList.length > 0) {
rdMaterialCostRef.value.otherMaterial = deepClone(categorizedData.rdBudgetOtherMaterialCostList[0]);
}
}
// //
if (rdTravelMeetingExchangeRef.value) {
//
const travelData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetTravelCostList, 'erpRdBudgetTravelCostList', true)
: oriRdBudgetTravelCostList.value;
if (rdTravelMeetingExchangeRef.value.travelList) {
rdTravelMeetingExchangeRef.value.travelList = deepClone(travelData);
}
//
const meetingData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetMeetingCostList, 'erpRdBudgetMeetingCostList', true)
: oriRdBudgetMeetingCostList.value;
if (rdTravelMeetingExchangeRef.value.meetingList) {
rdTravelMeetingExchangeRef.value.meetingList = deepClone(meetingData);
}
//
const exchangeData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetExchangeCostList, 'erpRdBudgetExchangeCostList', true)
: oriRdBudgetExchangeCostList.value;
if (rdTravelMeetingExchangeRef.value.exchangeList) {
rdTravelMeetingExchangeRef.value.exchangeList = deepClone(exchangeData);
}
}
// /
if (rdLaborServiceRef.value) {
//
if (rdLaborServiceRef.value.techConsultList) {
rdLaborServiceRef.value.techConsultList = deepClone(categorizedData.rdBudgetTechConsultCostList);
}
//
if (rdLaborServiceRef.value.expertMeetingList) {
rdLaborServiceRef.value.expertMeetingList = deepClone(categorizedData.rdBudgetExpertMeetingCostList);
}
//
if (rdLaborServiceRef.value.expertCommList) {
rdLaborServiceRef.value.expertCommList = deepClone(categorizedData.rdBudgetExpertCommCostList);
}
//
if (rdLaborServiceRef.value.laborList) {
rdLaborServiceRef.value.laborList = deepClone(categorizedData.rdBudgetLaborCostList);
}
//
if (rdLaborServiceRef.value.serviceList) {
rdLaborServiceRef.value.serviceList = deepClone(categorizedData.rdBudgetServiceCostList);
}
}
// //
if (rdLiteratureCostRef.value) {
//
if (rdLiteratureCostRef.value.materialsList) {
rdLiteratureCostRef.value.materialsList = deepClone(categorizedData.rdBudgetLiteratureMaterialCostList);
}
//
if (rdLiteratureCostRef.value.softwareList) {
rdLiteratureCostRef.value.softwareList = deepClone(categorizedData.rdBudgetLiteratureSoftwareCostList);
}
//
if (rdLiteratureCostRef.value.literatureRetrieval && categorizedData.rdBudgetLiteratureRetrievalCostList.length > 0) {
rdLiteratureCostRef.value.literatureRetrieval = deepClone(categorizedData.rdBudgetLiteratureRetrievalCostList[0]);
}
}
// //
const testingData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetTestingCostList, 'erpRdBudgetTestingCostList', true)
: oriRdBudgetTestingCostList.value;
if (rdTestingCostRef.value?.testData) {
rdTestingCostRef.value.testData = deepClone(testingData);
}
//
const otherData = isChangeType
? handleChangeTypeIds(data.erpRdBudgetOtherCostList, 'erpRdBudgetOtherCostList', true)
: oriRdBudgetOtherCostList.value;
if (rdOtherCostRef.value?.otherCostList) {
rdOtherCostRef.value.otherCostList = deepClone(otherData);
}
}
// assignMarketDataToComponents isChangeType
function assignMarketDataToComponents(data: any, processedLists: any, isChangeType: boolean) {
if (!budgetTableRef.value) return;
//
const formData = isChangeType ? processFormDataForChange(data, 'budgetId') : data;
Object.assign(budgetTableRef.value.budgetForm, formData);
//
if (budgetTableRef.value.budgetDetailData) {
budgetTableRef.value.budgetDetailData = deepClone(processedLists.detailList);
}
//
if (materialCostRef.value?.budgetMaterialCostList) {
materialCostRef.value.budgetMaterialCostList = deepClone(processedLists.materialCostList);
}
//
if (laborCostRef.value?.budgetLaborCostList) {
laborCostRef.value.budgetLaborCostList = deepClone(processedLists.laborCostList);
}
//
if (installationCostRef.value?.installCostList) {
installationCostRef.value.installCostList = deepClone(processedLists.installCostList);
}
//
if (travelCostRef.value?.travelCostList) {
travelCostRef.value.travelCostList = deepClone(processedLists.travelCostList);
}
//
if (otherCostRef.value?.otherCostList) {
otherCostRef.value.otherCostList = deepClone(processedLists.otherCostList);
}
}
function deepClone<T>(obj: T): T {
return cloneDeep(obj);
}
import SubmitVerify from '@/components/Process/submitVerify.vue';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
import ApprovalButton from '@/components/Process/approvalButton.vue';

@ -73,6 +73,7 @@
</el-table-column>
<el-table-column label="项目号" align="center" prop="projectCode" v-if="columns[6].visible" />
<el-table-column label="项目名称" align="center" prop="projectName" v-if="columns[7].visible" />
<el-table-column label="版本" align="center" prop="budgetVersion" v-if="columns[34].visible" width="60"/>
<el-table-column label="项目经理" align="center" prop="managerName" v-if="columns[8].visible" width="100px;"/>
<el-table-column label="产品经理" align="center" prop="productManagerName" v-if="columns[10].visible" />
<el-table-column label="合同额(万元)" align="center" prop="contractAmount" v-if="columns[14].visible" />
@ -80,7 +81,7 @@
<el-table-column label="预算成本(万元)" align="center" prop="budgetCost" v-if="columns[16].visible" />
<el-table-column label="预算毛利率" align="center" prop="budgetRate" v-if="columns[17].visible">
<template #default="scope">
{{ formatRate(scope.row.reduceBudgetRate) }}
{{ formatRate(scope.row.budgetRate) }}
</template>
</el-table-column>
<el-table-column label="降成本后预算成本(万元)" align="center" prop="reduceBudgetCost" v-if="columns[18].visible" />
@ -110,14 +111,14 @@
type="primary"
icon="Edit"
size="small"
@click="handleUpdate(scope.row,'update')"
@click="handleUpdate(scope.row, 'update')"
v-if="scope.row.budgetStatus === BUDGET_STATUS.DRAFT"
v-hasPermi="['oa:erp/budgetInfo:edit']"
>修改&nbsp;</el-button>
</el-tooltip>
<el-tooltip content="导出" placement="top">
<el-button
type="primary"
type="success"
icon="Download"
size="small"
@click="handleExport(scope.row)"
@ -129,8 +130,8 @@
size="small"
type="warning"
icon="Delete"
@click="handleUpdate(scope.row,'change')"
v-if="scope.row.budgetStatus === BUDGET_STATUS.DRAFT"
@click="handleChange(scope.row)"
v-if="scope.row.budgetStatus === BUDGET_STATUS.AVAILABLE"
v-hasPermi="['oa:erp/budgetInfo:change']"
>变更&nbsp;</el-button>
</el-tooltip>
@ -154,7 +155,7 @@
</template>
<script setup name="budgetInfo" lang="ts">
import { listErpBudgetInfo, getErpBudgetInfo, delErpBudgetInfo, addErpBudgetInfo, updateErpBudgetInfo } from '@/api/oa/erp/budgetInfo';
import { listErpBudgetInfo, delErpBudgetInfo } from '@/api/oa/erp/budgetInfo';
import { budgetInfoVO, budgetInfoQuery, budgetInfoForm } from '@/api/oa/erp/budgetInfo/types';
import router from '@/router';
import { getUserList } from '@/api/system/user';
@ -220,7 +221,8 @@ const columns = ref<FieldOption[]>([
{ key: 30, label: `创建人`, visible: true },
{ key: 31, label: `创建时间`, visible: true },
{ key: 32, label: `更新人`, visible: true },
{ key: 33, label: `更新时间`, visible: true }
{ key: 33, label: `更新时间`, visible: true },
{ key: 34, label: `版本`, visible: true }
]);
const initFormData: budgetInfoForm = {
@ -364,7 +366,7 @@ const handleSelectionChange = (selection: budgetInfoVO[]) => {
/** 新增市场项目预算按钮操作 */
const handleAdd = () => {
router.push({
path: '/budget/budget-add/index',
path: '/budget/budgetInfo/edit',
query: {
type: 'add',
projectCategory: PROJECT_CATEGORY.MARKET,
@ -381,7 +383,7 @@ const handleAdd = () => {
/** 新增研发项目按钮操作 */
const handleAddRd = () => {
router.push({
path: '/budget/budget-add/index',
path: '/budget/budgetInfo/edit',
query: {
type: 'add',
pageNum: queryParams.value.pageNum,
@ -390,13 +392,14 @@ const handleAddRd = () => {
});
};
/** 查询、修改和变更按钮操作 */
const handleUpdate = async (row?: budgetInfoVO, type?: string) => {
/** 查询、修改按钮操作 */
const handleUpdate = async (row?: budgetInfoVO, type?: string, changeFlag?: string) => {
router.push({
path: '/budget/budget-add/index',
path: '/budget/budgetInfo/edit',
query: {
type: type,
id: row.budgetId,
changeFlag: changeFlag,
pageNum: queryParams.value.pageNum,
projectCategory: row.projectCategory
}
@ -406,13 +409,14 @@ const handleUpdate = async (row?: budgetInfoVO, type?: string) => {
// proxy.$tab.openPage('/oa/erp/budgetInfo/edit', '', params);
};
/** 修改按钮操作 */
const handleView = async (row?: budgetInfoVO) => {
/** 变更按钮操作 */
const handleChange = async (row?: budgetInfoVO) => {
router.push({
path: '/budget/budget-add/index',
path: '/budget/budgetInfo/change',
query: {
type: 'view',
type: 'update',
id: row.budgetId,
changeFlag: '1',
pageNum: queryParams.value.pageNum,
projectCategory: row.projectCategory
}

@ -253,7 +253,7 @@ const getSummaries = ({ columns, data }: any) => {
}
}, 0);
sums[index] = formatNumber(sums[index]);
footerForm.budgetCost = sums[index];
rdBudgetInfoForm.budgetCost = sums[index];
} else {
sums[index] = '';
}

@ -141,7 +141,9 @@ const materialData = ref<rdBudgetMaterialCostVO[]>([]);
const toDeletedMaterialCostIdList = ref([]);
//
const otherMaterial = reactive({
const otherMaterialData = ref<rdBudgetMaterialCostVO>();
const defaultOtherMaterial = ref({
sortOrder: 1,
materialName: '其他材料费',
materialType: MATERIAL_TYPE.OTHER,
@ -150,10 +152,12 @@ const otherMaterial = reactive({
amount: undefined,
price: 0
});
//
const otherMaterial = ref(defaultOtherMaterial);
// +
const allMaterialData = computed(() => {
return [...materialData.value, otherMaterial];
return [...materialData.value, otherMaterial.value];
});
const unitOptions = ref<UnitInfoVO[]>([]);
@ -192,6 +196,19 @@ const checkSelectable = (row: rdBudgetMaterialCostVO, index: number) => {
return row.materialType === MATERIAL_TYPE.MAIN;
};
// otherMaterialData
watch(
otherMaterialData,
(newVal) => {
if (newVal) {
otherMaterial.value = newVal;
} else {
otherMaterial.value = defaultOtherMaterial.value;
}
},
{ immediate: true }
); // immediate: true
//
watch(
() => [materialData, otherMaterial],
@ -221,7 +238,7 @@ const addSpecifiedRows = async () => {
price: 0
});
}
otherMaterial.sortOrder = currentSortOrder + 1 + addRowCount.value;
otherMaterial.value.sortOrder = currentSortOrder + 1 + addRowCount.value;
// DOM
await nextTick();
scrollToBottom();
@ -251,7 +268,7 @@ const handleDelete = (index: number, row: rdBudgetMaterialCostVO) => {
if (row.materialCostId) {
toDeletedMaterialCostIdList.value.push(row.materialCostId);
}
otherMaterial.sortOrder = otherMaterial.sortOrder - 1;
otherMaterial.value.sortOrder = otherMaterial.value.sortOrder - 1;
calculateTotal();
};
@ -272,7 +289,7 @@ const handleBatchDelete = () => {
materialData.value.forEach((item, index) => {
item.sortOrder = index + 1;
});
otherMaterial.sortOrder = otherMaterial.sortOrder - selectedRows.value.length;
otherMaterial.value.sortOrder = otherMaterial.value.sortOrder - selectedRows.value.length;
calculateTotal();
selectedRows.value = [];
};
@ -285,7 +302,7 @@ const calculateAmount = () => {
});
//
otherMaterial.price = (otherMaterial.amount || 0) * (otherMaterial.unitPrice || 0);
otherMaterial.value.price = (otherMaterial.value.amount || 0) * (otherMaterial.value.unitPrice || 0);
//
calculateTotal();
@ -294,7 +311,7 @@ const calculateAmount = () => {
//
const calculateTotal = () => {
const mainAmount = parseFloat(((Number(mainMaterialTotalAmount.value) || 0) / 10000).toFixed(2));
const otherAmount = parseFloat(((Number(otherMaterial.price) || 0) / 10000).toFixed(2));
const otherAmount = parseFloat(((Number(otherMaterial.value.price) || 0) / 10000).toFixed(2));
totalAmount.value = (mainAmount + otherAmount).toFixed(2);
};
@ -328,8 +345,8 @@ const resetData = () => {
//
// otherMaterial.unit = '';
// otherMaterial.quantity = 0;
otherMaterial.unitPrice = 0;
otherMaterial.amount = 0;
// otherMaterial.unitPrice = 0;
// otherMaterial.amount = 0;
};
//
@ -346,6 +363,7 @@ const getFormData = () => {
defineExpose({
materialData,
otherMaterial,
otherMaterialData,
allMaterialData,
toDeletedMaterialCostIdList,
getTotalAmount

Loading…
Cancel
Save