新增待办迭代

This commit is contained in:
魏保林
2026-04-13 18:04:04 +08:00
parent df37b5a6c8
commit 442b422bcb
5 changed files with 35 additions and 938 deletions

View File

@@ -74,10 +74,7 @@
{{ disposeMemberList(row, 'tMemberList') }}
</template>
<template #demandName="{ row }">
<span v-if="nameClick" class="see-relation-task-btn" @click="nameClickFun(row)">
{{ row.demandName }}
</span>
<span v-else>
<span class="see-relation-task-btn" @click="nameClickFun(row)">
{{ row.demandName }}
</span>
</template>
@@ -259,7 +256,7 @@ const showTaskListDialogFun = (row: any) => {
const data = res.data?.data || [];
if (data.length > 0) {
showTaskDetailDialog.value = true;
currentTaskInfo.value = data[0];
currentTaskInfo.value = { ...data[0], demandId: row.uuid };
} else {
ElMessage.warning('当前需求下没有任务');
}

View File

@@ -2,8 +2,8 @@
<div class="gl-page-content-full">
<div class="tabs">
<el-tabs v-model="isSend" type="card" @tab-change="tabChangeFun">
<el-tab-pane label="未分发任务" :name="false" />
<el-tab-pane label="已分发任务" :name="true" />
<el-tab-pane label="未分发任务" :name="'false'" />
<el-tab-pane label="已分发任务" :name="'true'" />
</el-tabs>
<el-button
class="sync-btn"
@@ -125,7 +125,7 @@ const formAttrs = ref({
},
});
const isSend = ref(getPageStorage('isSend') || false);
const isSend = ref(getPageStorage('isSend') || 'false');
const tabChangeFun = (val: any) => {
setPageStorage('isSend', val);
@@ -135,7 +135,7 @@ const tabChangeFun = (val: any) => {
};
const taskParams = computed(() => {
if (isSend.value) {
if (isSend.value === 'true') {
// 已分发的任务
return { type: 3 };
} else {
@@ -156,7 +156,7 @@ const actionList = ref([
click: (row: any) => {
// 从需求来的任务,走分发逻辑,lyric定制逻辑
if (
!isSend.value &&
!(isSend.value === 'true') &&
enableConfigByTenant([TENANT_ENUM.LYRIC]) &&
row['tag9'] === 'FROM_DEMAND'
) {

View File

@@ -4,7 +4,7 @@
<div class="card-item">
<div class="content" @click="openFun('robot')">
<div class="pic">
<el-image class="img" fit="cover" :src="RobotBg" />
<el-image class="img" fit="cover" :src="projectGreen" />
</div>
<div class="title">机器人仿真待办</div>
</div>
@@ -12,7 +12,7 @@
<div class="card-item">
<div class="content" @click="openFun('animation')">
<div class="pic">
<el-image class="img" fit="cover" :src="AnimationBg" />
<el-image class="img" fit="cover" :src="projectBlue" />
</div>
<div class="title">动画仿真待办</div>
</div>
@@ -20,7 +20,7 @@
<div class="card-item">
<div class="content" @click="openFun('industry')">
<div class="pic">
<el-image class="img" fit="cover" :src="IndustryBg" />
<el-image class="img" fit="cover" :src="projectGreen" />
</div>
<div class="title">工业设计待办</div>
</div>
@@ -28,7 +28,7 @@
<div class="card-item">
<div class="content" @click="openFun('tolerance')">
<div class="pic">
<el-image class="img" fit="cover" :src="ToleranceBg" />
<el-image class="img" fit="cover" :src="projectBlue" />
</div>
<div class="title">公差分析待办</div>
</div>
@@ -36,7 +36,7 @@
<div class="card-item">
<div class="content" @click="openFun('finiteElement')">
<div class="pic">
<el-image class="img" fit="cover" :src="FiniteElementBg" />
<el-image class="img" fit="cover" :src="projectGreen" />
</div>
<div class="title">有限元仿真待办</div>
</div>
@@ -44,7 +44,7 @@
<div class="card-item">
<div class="content" @click="openFun('logistics')">
<div class="pic">
<el-image class="img" fit="cover" :src="LogisticsBg" />
<el-image class="img" fit="cover" :src="projectBlue" />
</div>
<div class="title">物流仿真待办</div>
</div>
@@ -122,12 +122,14 @@ import Industry from './industry.vue';
import Logistics from './logistics.vue';
import Robot from './robot.vue';
import Tolerance from './tolerance.vue';
import RobotBg from '@/assets/imgs/projectList/project-blue.png';
import AnimationBg from '@/assets/imgs/projectList/project-green.png';
import IndustryBg from '@/assets/imgs/projectList/project-blue.png';
import ToleranceBg from '@/assets/imgs/projectList/project-green.png';
import FiniteElementBg from '@/assets/imgs/projectList/project-green.png';
import LogisticsBg from '@/assets/imgs/projectList/project-blue.png';
import projectGreen from '@/assets/imgs/projectList/project-green.png';
import projectBlue from '@/assets/imgs/projectList/project-blue.png';
// import RobotBg from './imgs/robot.png';
// import AnimationBg from './imgs/animation.png';
// import IndustryBg from './imgs/industry.png';
// import ToleranceBg from './imgs/tolerance.png';
// import FiniteElementBg from './imgs/finiteElement.png';
// import LogisticsBg from './imgs/logistics.png';
// import PlanBg from './imgs/plan.png';
import { addDemandNoPermissionApi } from '@/api/project/demand';
import { enableConfigByTenant, TENANT_ENUM } from '@/tenants/tenant';

View File

@@ -1,9 +1,9 @@
<template>
<demandVue pageType="create" />
<demandVue/>
</template>
<script setup lang="ts">
import demandVue from '@/tenants/lyric/views/task/demand.vue';
import demandVue from './components/index.vue';
</script>
<style lang="scss" scoped></style>

View File

@@ -25,228 +25,34 @@
@click="syncDemandList"
>同步</el-button
>
<el-button
v-if="!enableConfigByTenant([TENANT_ENUM.LYRIC])"
icon="plus"
type="primary"
v-permission="'demand_add_demand'"
@click="visibleDialog(true)"
>创建待办</el-button
>
</template>
</demandTable>
<!-- <DemandDetail v-model="formVisible" :demandId="demandId" /> -->
<Dialog
v-model="formVisible"
:loading="loadingInterface"
:diaTitle="isCreateDialog ? '创建待办' : '编辑待办'"
width="60%"
:height="700"
@close="closeFun"
show-footer
>
<div class="tabs">
<el-tabs @tab-change="changeSimulationType" v-model="simulationType" type="card">
<el-tab-pane
v-for="item in simulationTypeList"
:label="item.label + '待办'"
:name="item.value"
:key="item.value"
/>
</el-tabs>
</div>
<PlanningInformation :data="simulationType"></PlanningInformation>
<!-- <div class="message-info">
<div v-if="simulationType === SIMULATION_TYPE.FINITE_ELEMENT" class="message-item">
1有限元仿真登记提醒 若不清楚本待办需求如何填写请看<span class="down-file"
>填写指导书</span
>
</div>
</div> -->
<!-- {{ editFormInfo }} -->
<TableForm
ref="tableFormRef"
:tableName="demandFormName"
:formAttrs="{
projectId: {
auth: false,
},
workspaceCode: {
filterable: true,
},
description: {
placeholder: simulationType === '有限元仿真' ? finiteElementDesc : '',
},
endTime: {
remarkText: endTimeRemark,
},
attachments: {
remarkText: attachmentRemark,
},
simType: {
tipText: simulationType === '有限元仿真' ? simTypeTipText : '',
},
}"
:colNum="3"
:hideKeys="hideKeys.concat(formHideKeys)"
v-model:data="editFormInfo"
@change="changeFun($event)"
@load="loadTableForm"
>
<template #form-pMemberList v-if="enableConfigByTenant([TENANT_ENUM.LYRIC])">
<el-select v-model="editFormInfo.pMemberList" filterable placeholder="请选择">
<el-option
v-for="item in deptOptions"
:key="item.value + item.label"
:label="item.label + '(' + item.userName + ')'"
:value="item.value + '-' + item.label"
/>
</el-select>
</template>
<!-- ep 的仿真用途 -->
<template #form-simulationPurpose>
<el-select v-model="editFormInfo.simulationPurpose" filterable placeholder="请选择">
<el-option
v-for="item in finiteElementPurposeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
</TableForm>
<template #footer>
<div>
<el-button @click="closeFun">取消</el-button>
<el-button :loading="loadingInterface" type="primary" @click="confirmFun">确认</el-button>
</div>
</template>
</Dialog>
</div>
<!-- 新增待办 -->
<div v-else class="gl-page-content-full new-demand">
<div v-show="!finishTip" class="content">
<div class="tabs">
<el-tabs @tab-change="changeSimulationType" v-model="simulationType" type="card">
<el-tab-pane
v-for="item in simulationTypeList"
:label="item.label + '待办'"
:name="item.value"
:key="item.value"
/>
</el-tabs>
</div>
<div class="tab-content">
<PlanningInformation :data="simulationType"></PlanningInformation>
<TableForm
ref="tableFormRef"
:tableName="demandFormName"
:formAttrs="{
projectId: {
auth: false,
},
description: {
placeholder: simulationType === '有限元仿真' ? finiteElementDesc : '',
},
workspaceCode: {
filterable: true,
},
endTime: {
remarkText: endTimeRemark,
'disabled-date': disabledEndDateFun,
'disabled-hours': disabledEndHoursFun,
},
attachments: {
remarkText: attachmentRemark,
},
simType: {
tipText: simulationType === '有限元仿真' ? simTypeTipText : '',
},
}"
:colNum="3"
:hideKeys="hideKeys.concat(formHideKeys)"
v-model:data="editFormInfo"
@change="changeFun($event)"
@load="loadTableForm"
>
<template #form-pMemberList v-if="enableConfigByTenant([TENANT_ENUM.LYRIC])">
<el-select v-model="editFormInfo.pMemberList" filterable placeholder="请选择">
<el-option
v-for="item in deptOptions"
:key="item.value + item.label"
:label="item.label + '(' + item.userName + ')'"
:value="item.value + '-' + item.label"
/>
</el-select>
</template>
<!-- ep 的仿真用途 -->
<template #form-simulationPurpose>
<el-select v-model="editFormInfo.simulationPurpose" filterable placeholder="请选择">
<el-option
v-for="item in finiteElementPurposeOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
</TableForm>
</div>
<div class="action-btns">
<el-button :loading="loadingInterface" type="primary" @click="confirmFun">确认</el-button>
</div>
</div>
<!-- 创建完成页面 -->
<div v-show="finishTip" class="finish-tip">
<img class="finish-icon" src="@/assets/imgs/btnIcon/finish.svg" alt="" />
<div class="finish-btn">
<el-button @click="continueCreateFun">继续创建</el-button>
<el-button type="primary" @click="goListPageFun">查看列表</el-button>
</div>
</div>
<DemandDetail v-model="formVisible" :demandId="demandId" />
</div>
<attachments :demandId="demandInfo.uuid" v-model:visible="attachmentsVisible"></attachments>
</template>
<script setup lang="ts">
import { nextTick, reactive, ref, watch } from 'vue';
import Dialog from '@/components/common/dialog/index.vue';
import TableForm from '@/components/common/table/tableForm.vue';
import {
addDemandNoPermissionApi,
deleteDemandApi,
demandListApi,
editDemandApi,
} from '@/api/project/demand';
import { getChildrenNodeList } from '../../projectDetail/components/projectApi';
import { getTagReq, NODE_TYPE } from '@/utils/enum/node';
import { reactive, ref } from 'vue';
import { deleteDemandApi, demandListApi } from '@/api/project/demand';
// import { upload } from '@/api/request';
import { CommonStore } from '@/stores/common';
import attachments from '@/views/task/simulationTask/components/attachments.vue';
// import { FILE_TYPE } from '@/utils/enum/file';
import { ElMessage } from 'element-plus';
import { batchAddFileInfoApi, dataDelFileApi, dataQueryDirApi } from '@/api/data/data';
import demandTable from '../components/demandTable.vue';
import { getMemberListIds } from '@/utils/task';
import { enableConfigByTenant, TENANT_ENUM } from '@/tenants/tenant';
import { syncDemandList } from '../taskPage';
import { getChildrenNodeListApi } from '@/api/project/node';
import { listDeptApi } from '@/api/system/departMent';
import { uploadBigFile } from '@/utils/file';
import { getAttachmentsRemark, getDemandHideKeys } from '@/tenants/lyric/views/task/lyricTask';
import PlanningInformation from '@/tenants/lyric/views/task/components/planningInformation.vue';
import { FILE_TYPE } from '@/utils/enum/file';
import { jumpPage } from '@/utils/common';
import dayjs from 'dayjs';
import { getPageStorage, setPageStorage } from '@/utils/common';
// import DemandDetail from './components/detail.vue';
import { getPageStorage } from '@/utils/common';
import DemandDetail from './components/detail.vue';
// import emitter from '@/utils/eventBus';
// const env = import.meta.env;
// const PREFIX = env.VITE_API_PREFIX_PROJECT;
// 只有利元亨才需要这三个参数
const props = defineProps({
defineProps({
hideKeys: {
type: Array,
default: () => [],
@@ -265,18 +71,6 @@ const props = defineProps({
},
});
const goListPageFun = () => {
jumpPage({ path: '/task/sponsor' });
};
const continueCreateFun = () => {
finishTip.value = false;
loadingInterface.value = false;
tableFormRef.value.resetFun();
editFormInfo.value.projectUndertaker = '';
};
const emits = defineEmits(['visibleDialog', 'loadTableForm', 'changeForm']);
// enum SIMULATION_TYPE {
// /** 有限元仿真待办 */
// FINITE_ELEMENT = 'finiteElement',
@@ -295,8 +89,9 @@ const commonStore = CommonStore();
const showTaskDetailFun = (row: any) => {
// showTaskDetailDialog.value = true;
// currentTaskInfo.value = row;
visibleDialog(false, row);
demandId.value = row.uuid;
formVisible.value = true;
// visibleDialog(false, row);
};
const demandId = ref<any>('');
const actionList = ref([
@@ -305,7 +100,8 @@ const actionList = ref([
type: 'primary',
click: (row: any) => {
demandId.value = row.uuid;
visibleDialog(false, row);
formVisible.value = true;
// visibleDialog(false, row);
},
},
{
@@ -319,17 +115,7 @@ const actionList = ref([
},
]);
const loadingInterface = ref(false);
const formVisible = ref(false);
const closeFun = () => {
tableFormRef.value.resetFun();
formVisible.value = false;
attachmentsVisible.value = false;
// 清空删除的文件
deleteFileList.value = [];
tableFormRef.value?.resetFun();
};
const attachmentsVisible = ref(false);
@@ -342,123 +128,8 @@ const demandInfo = reactive({
uuid: '',
});
const isCreateDialog = ref(true);
const editFormInfo = ref<any>({});
const visibleDialog = async (isCreate: boolean, row?: any) => {
formVisible.value = true;
isCreateDialog.value = isCreate;
loadingInterface.value = true;
// if (isCreate) {
// nextTick(() => {
// tableFormRef.value.resetFun();
// });
// }
nextTick(() => {
changeSimulationType(simulationType.value);
});
if (!isCreateDialog.value) {
simulationType.value = row.demandType;
// if (row?.isMoldMaking === 'Y') {
// formHideKeys.value = [];
// } else {
// formHideKeys.value = ['materialNo'];
// }
const res: any = await dataQueryDirApi({ uuid: row.uuid, current: 1, size: 99 });
row.attachments =
res.data?.data?.map((item: { originalName: any; fileSize: any; id: number }) => {
return {
name: item.originalName,
size: item.fileSize,
id: item.id,
};
}) || [];
oldAttachments.value = [...row.attachments];
let phaseList = [];
if (row.phaseId) {
phaseList = await getChildrenNodeList(NODE_TYPE.PHASE, row.projectId);
phaseList = phaseList.map((item: any) => {
if (row.phaseId === item.uuid) {
row.selectPhaseName = item.nodeName;
}
return {
label: item.nodeName,
value: item.uuid,
};
});
}
let workspaceList = [];
if (row.workspaceCode && row.phaseId) {
workspaceList = await getChildrenNodeList(NODE_TYPE.WORKSPACE, row.phaseId);
workspaceList = workspaceList.map((item: any) => {
return {
label: item.nodeCode,
value: item.nodeCode,
uuid: item.uuid,
parentId: item.parentId,
};
});
}
if (enableConfigByTenant([TENANT_ENUM.LYRIC])) {
const projectUndertaker = row.extras.find((item: any) => {
return item.propertyName === 'projectUndertaker';
});
if (projectUndertaker) {
currentProjectUndertaker.value = projectUndertaker.propertyValue;
}
}
let simList: any;
if (row.simType) {
simList = commonStore.getDictData(row.demandType);
}
row.planTime = [row.beginTime, row.endTime];
nextTick(async () => {
tableFormRef.value.setOptionsFun('phaseId', phaseList);
tableFormRef.value.setOptionsFun('workspaceCode', workspaceList);
if (simList?.A) {
tableFormRef.value.setOptionsFun('simType', simList.A);
}
// let pMemberList = '';
// if (row.pMemberList) {
// pMemberList = getMemberListIds(row.pMemberList);
// }
let tMemberList = '';
if (row.tMemberList) {
tMemberList = getMemberListIds(row.tMemberList);
}
let aMemberList = '';
if (row.aMemberList) {
aMemberList = getMemberListIds(row.aMemberList);
}
editFormInfo.value = {
...row,
// pMemberList,
tMemberList,
aMemberList,
};
// 利元亨走部门逻辑回显
if (enableConfigByTenant([TENANT_ENUM.LYRIC])) {
// 处理 回显 pMemberList
await disposeDeptMember();
} else {
editFormInfo.value.pMemberList = getMemberListIds(row.pMemberList);
}
// tableFormRef.value.setFormDataFun({ ...row, pMemberList, tMemberList, aMemberList });
});
} else {
editFormInfo.value = {};
// nextTick(() => {
// tableFormRef.value.resetFun();
// });
}
emits('visibleDialog', { isCreate, row });
loadingInterface.value = false;
};
const deleteDemandFun = async (uuid: number) => {
const res: any = await deleteDemandApi({ deleteNodeIdList: [uuid] });
if (res.code === 200) {
@@ -467,582 +138,9 @@ const deleteDemandFun = async (uuid: number) => {
}
};
const finishTip = ref(false);
const confirmFun = async () => {
if (await tableFormRef.value.validateFun()) {
loadingInterface.value = true;
// if (editFormInfo.value.planTime) {
// editFormInfo.value.beginTime = editFormInfo.value.planTime[0];
// editFormInfo.value.endTime = editFormInfo.value.planTime[1];
// }
if (isCreateDialog.value) {
const demandId = await createDemandApiFun(editFormInfo.value);
// 没有demandId就是创建待办失败
if (demandId && editFormInfo.value.attachments?.length > 0) {
const files = editFormInfo.value.attachments.filter((item: any) => item.raw);
if (files.length > 0) {
const params = {
fileList: files, // 文件列表
// dirId: demandId, // 文件目录id
projectId: editFormInfo.value.projectId, // 项目id
callbackFlag: '/task/sponsor', // 回调标识
uuid: demandId,
tagReq: getTagReq({
tag1: editFormInfo.value.projectId,
tag2: editFormInfo.value.phaseId,
}),
fileTypeDictValue: FILE_TYPE.DEMAND_ATTACHMENTS || '',
disciplineDictValue: editFormInfo.value.simType || '',
fileTypeDictClass: 'ALL_FILE_TYPE',
disciplineTypeDictClass: 'DISCIPLINE_TYPE',
dictTags: [
'fileTypeDictClass',
'fileTypeDictValue',
'disciplineTypeDictClass',
'disciplineDictValue',
],
};
await uploadBigFile(params, batchAddFileInfoApi);
}
formVisible.value = false;
loadingInterface.value = false;
closeFun();
} else {
loadingInterface.value = false;
}
// batchUploadFile(fromData.attachments, fromData.projectId, demandId);
} else {
await editDemandApiFun(editFormInfo.value);
}
loadingInterface.value = false;
tableRef.value?.tableRef.resetFun();
}
};
const getPMemberId = () => {
const pMemberIdArr = editFormInfo.value.pMemberList.split('-');
let pMemberId = '';
if (pMemberIdArr.length > 0) {
pMemberId = pMemberIdArr[0];
}
return pMemberId;
};
const createDemandApiFun = async (fromData: any) => {
const params = {
pid: fromData.nodeId,
// 'demandName': fromData.demandName,
// 'demandCode': fromData.demandCode,
// demandType: fromData.demandType,
// simType: fromData.simType,
// 'beginTime': fromData.beginTime,
// 'endTime': fromData.endTime,
// 'pMemberList': fromData.pMemberList,
eMemberList: '',
// 'projectId': fromData.projectId,
// 'phaseId': fromData.phaseId,
// 'nodeId': fromData.nodeId,
...fromData,
pMemberList: getPMemberId(),
demandStatus: '0',
machineId: fromData.machineId,
workspaceId: fromData.workspaceId,
// 待办所属类型
demandType: simulationType.value,
// 是否走利元亨创建待办直接创建任务逻辑
isLyric: enableConfigByTenant([TENANT_ENUM.LYRIC]),
};
// return;
const res: any = await addDemandNoPermissionApi(params);
if (res.code === 200) {
formVisible.value = false;
ElMessage.success('创建成功');
if (props.pageType === 'create') {
finishTip.value = true;
}
return res.data;
} else {
return null;
}
};
const editDemandApiFun = async (fromData: any) => {
// let addFileList = [];
// let deleteFileList = [];
// formData.attachments.forEach((item: any) => {
// if(item?.raw) {
// const form = new FormData();
// form.append('fileType', String(FILE_TYPE.DEMAND_ATTACHMENTS));
// form.append('nodeId ', String(demandInfo.id));
// form.append('fileName ', item.name);
// form.append('file ', item.raw);
// upload(`${PREFIX}data/uploadFiles`, form);
// }
// })
// oldAttachments.value.forEach((item: any) => {
// formData.attachments.some((item2: any) => item2.name ===)
// })
const res: any = await editDemandApi({
...fromData,
pMemberList: getPMemberId(),
eMemberList: '',
machineId: fromData.machineId,
workspaceId: fromData.workspaceId,
// 待办所属类型
demandType: simulationType.value,
});
if (res.code === 200) {
ElMessage.success('修改成功');
formVisible.value = false;
if (fromData.attachments.length > 0) {
const files = fromData.attachments.filter((item: any) => item.raw);
const params = {
fileList: files, // 文件列表
// dirId: fromData.uuid, // 文件目录id
projectId: fromData.projectId, // 项目id
callbackFlag: '/task/sponsor', // 回调标识
// isApprove: 0, // 0不需要审批 1需要审批 默认0
// type: 0,
uuid: fromData.uuid,
tagReq: getTagReq({ tag1: fromData.projectId, tag2: fromData.phaseId }),
fileTypeDictValue: FILE_TYPE.DEMAND_ATTACHMENTS || '',
disciplineDictValue: fromData.simType || '',
fileTypeDictClass: 'ALL_FILE_TYPE',
disciplineTypeDictClass: 'DISCIPLINE_TYPE',
dictTags: [
'fileTypeDictClass',
'fileTypeDictValue',
'disciplineTypeDictClass',
'disciplineDictValue',
],
};
if (enableConfigByTenant([TENANT_ENUM.LYRIC])) {
params.tagReq = getTagReq({
tag1: fromData.projectId,
tag2: fromData.phaseId,
tag4: fromData.machineId,
tag5: fromData.workspaceId,
});
}
await uploadBigFile(params, batchAddFileInfoApi);
// batchUploadFile(
// fromData.attachments.filter((item: any) => item.raw),
// fromData.projectId,
// fromData.uuid
// );
// fromData.attachments.forEach((item: any) => {
// if (item.raw) {
// const form = new FormData();
// form.append('fileType', String(FILE_TYPE.DEMAND_ATTACHMENTS));
// form.append('nodeId ', fromData.id);
// form.append('uuid ', fromData.uuid);
// form.append('fileName ', item.name);
// form.append('file ', item.raw);
// form.append('projectId ', String(fromData.projectId));
// upload(`${PREFIX}demand/uploadDemandFiles`, form);
// }
// });
}
oldAttachments.value.forEach((item: any) => {
if (
!fromData.attachments.some((item2: any) => {
if (item2.name === item.name) {
return true;
}
})
) {
dataDelFileApi({ delFileId: item.id });
}
});
}
};
const deleteFileList = ref<number[]>([]);
const oldAttachments = ref<any[]>([]);
const formHideKeys = ref<any[]>([]);
const currentProjectUndertaker = ref('');
const simulationTypeList = ref(commonStore.getDictData('SIMULATION_TYPE').A);
const simulationType = ref(getPageStorage('simulationType') || simulationTypeList.value[0].value);
const attachmentRemark = ref('');
const endTimeRemark = ref('【需求时间】请参考发图时间或客户评审时间');
const simTypeTipText = ref(`
流体仿真:(结构风速、除尘、氮气保护等分析)
结构仿真:(结构受力、变形、校核、应力、支反力、扭矩等分析)
热力学仿真:(结构加热、散热、热变形分析)
其他类型:(激光焊接、冲坑等其他类型和工艺仿真分析)
`);
const finiteElementDesc = '输入条件1、3D模型 2、xxx输出结果xxx变形量xxx应力值';
watch(
() => simulationType.value,
(val) => {
if (enableConfigByTenant([TENANT_ENUM.LYRIC])) {
attachmentRemark.value = getAttachmentsRemark(val);
}
},
{
immediate: true,
}
);
const demandFormName = ref('SIMULATION_TASK_DEMAND_CREATE');
const changeSimulationType = (val: string) => {
tableFormRef.value.resetFun();
setPageStorage('simulationType', val);
if (simulationType.value === '工业设计') {
demandFormName.value = 'SIMULATION_TASK_DEMAND_INDUSTRIAL_CREATE';
} else {
demandFormName.value = 'SIMULATION_TASK_DEMAND_CREATE';
}
// TODO 临时修复
setTimeout(() => {
let simTypeList = [];
simTypeList = commonStore.getDictData(val).A;
tableFormRef.value.setOptionsFun('simType', simTypeList);
formHideKeys.value = getDemandHideKeys(val);
}, 500);
};
const changeFun = async (val: any) => {
if (val.key === 'projectId') {
let nodeType = '';
let nextKey = '';
let nodeId = '';
if (val.key === 'projectId') {
nodeType = NODE_TYPE.PHASE;
nextKey = 'phaseId';
nodeId = val.data.projectId;
if (enableConfigByTenant([TENANT_ENUM.LYRIC])) {
currentProjectUndertaker.value = '';
// if (val.val?.projectUndertaker) {
// currentProjectUndertaker.value = val.val?.projectUndertaker;
// }
// if (val.val?.produceLine) {
// editFormInfo.value.produceLine = val.val?.produceLine;
// }
for (let index = 0; index < val.val.extras.length; index++) {
if (val.val.extras[index]?.propertyName === 'projectUndertaker') {
currentProjectUndertaker.value = val.val.extras[index]?.propertyValue || '';
}
if (val.val.extras[index]?.propertyName === 'produceLine') {
editFormInfo.value.produceLine = val.val.extras[index]?.propertyValue;
}
}
// 将项目的项目承接主体的数据存入到待办里
editFormInfo.value.projectUndertaker = currentProjectUndertaker.value;
// editFormInfo.value.extras.map((item: any) => {
// if (item.propertyName === 'projectUndertaker') {
// item.propertyValue = currentProjectUndertaker.value;
// }
// return {
// ...item,
// };
// });
}
}
if (nodeId) {
const optionList = await getPhaseList(nodeType, nodeId);
tableFormRef.value.setOptionsFun(nextKey, optionList);
if (nextKey === 'phaseId' && optionList.length > 0) {
// 阶段默认选择当前阶段
if (val.val?.currentPhase) {
const currentPhase = optionList.find((item: any) => {
return item.label === val.val?.currentPhase;
});
if (currentPhase) {
editFormInfo.value.phaseId = currentPhase.value;
editFormInfo.value.selectPhaseName = currentPhase.label;
editFormInfo.value.phaseName = currentPhase.label;
} else {
editFormInfo.value.phaseId = optionList[0].value;
editFormInfo.value.selectPhaseName = optionList[0].label;
editFormInfo.value.phaseName = optionList[0].label;
}
} else {
editFormInfo.value.phaseId = optionList[0].value;
editFormInfo.value.selectPhaseName = optionList[0].label;
editFormInfo.value.phaseName = optionList[0].label;
}
const workspaceInfo = await getWorkSpaceList(editFormInfo.value.phaseId);
editFormInfo.value.workspaceId = workspaceInfo.uuid;
editFormInfo.value.workspaceCode = workspaceInfo.value;
editFormInfo.value.machineId = '';
if (editFormInfo.value.phaseId !== workspaceInfo.parentId) {
editFormInfo.value.machineId = workspaceInfo.parentId;
}
// formData.workspaceName = workspaceInfo.label;
// formData.extras = setWorkSpaceValue(
// formData.extras,
// formData.workspace,
// formData.workspaceName
// );
}
if (optionList.length === 0) {
editFormInfo.value.phaseId = '';
editFormInfo.value.selectPhaseName = '';
editFormInfo.value.phaseName = '--';
// 清空工位数据
editFormInfo.value.machineId = '';
editFormInfo.value.workspaceId = '';
editFormInfo.value.workspaceCode = '';
// formData.extras = setWorkSpaceValue(formData.extras, '', '');
tableFormRef.value.setOptionsFun('workspaceId', []);
tableFormRef.value.setOptionsFun('workspaceCode', []);
}
if (editFormInfo.value.simType && editFormInfo.value?.selectPhaseName) {
await disposeDeptMember();
}
} else {
tableFormRef.value.setOptionsFun(nextKey, []);
editFormInfo.value.phaseId = '';
editFormInfo.value.selectPhaseName = '';
editFormInfo.value.phaseName = '--';
editFormInfo.value.machineId = '';
editFormInfo.value.workspaceId = '';
editFormInfo.value.workspaceCode = '';
// formData.workspaceName = '';
// formData.extras = setWorkSpaceValue(formData.extras, '', '');
}
}
if (val.key === 'phaseId') {
if (editFormInfo.value.phaseId) {
const workspaceInfo = await getWorkSpaceList(editFormInfo.value.phaseId);
editFormInfo.value.machineId = '';
if (editFormInfo.value.phaseId !== workspaceInfo.parentId) {
editFormInfo.value.machineId = workspaceInfo.parentId;
}
editFormInfo.value.workspaceId = workspaceInfo.uuid;
editFormInfo.value.workspaceCode = workspaceInfo.value;
// formData.workspaceName = workspaceInfo.label;
// formData.extras = setWorkSpaceValue(
// formData.extras,
// formData.workspace,
// formData.workspaceName
// );
} else {
editFormInfo.value.workspaceId = '';
editFormInfo.value.workspaceCode = '';
// formData.workspaceName = '';
// formData.extras = setWorkSpaceValue(
// formData.extras,
// formData.workspace,
// formData.workspaceName
// );
}
// editFormInfo.value = { ...formData };
}
if (val.key === 'workspaceCode') {
if (editFormInfo.value.workspaceCode) {
editFormInfo.value.machineId = '';
if (editFormInfo.value.phaseId !== val.val.parentId) {
editFormInfo.value.machineId = val.val.parentId;
}
editFormInfo.value.workspaceCode = val.val.value;
editFormInfo.value.workspaceId = val.val.uuid;
// formData.workspaceName = val.val.label;
// formData.extras = setWorkSpaceValue(
// formData.extras,
// formData.workspace,
// formData.workspaceName
// );
} else {
editFormInfo.value.machineId = '';
editFormInfo.value.workspaceId = '';
editFormInfo.value.workspaceCode = '';
// formData.workspaceName = '';
// formData.extras = setWorkSpaceValue(
// formData.extras,
// formData.workspace,
// formData.workspaceName
// );
}
// editFormInfo.value = { ...formData };
}
if (val.key === 'simType') {
if (editFormInfo.value.projectId) {
await disposeDeptMember();
}
}
// if (val.key === 'isMoldMaking') {
// if (val.val?.value === 'Y') {
// formHideKeys.value = [];
// } else {
// formHideKeys.value = ['materialNo'];
// }
// }
emits('changeForm', { val, editFormInfo: editFormInfo.value });
};
const deptList = ref<any[]>([]);
const disposeDeptMember = async () => {
let pMemberId = '';
editFormInfo.value.pMemberList = '';
editFormInfo.value.pMemberName = '';
if (!currentProjectUndertaker.value) {
return '';
}
if (deptList.value.length === 0) {
const res = await listDeptApi({ current: 1, size: 999 });
deptList.value = res.data.data;
}
if (simulationType.value !== '有限元仿真') {
for (let index = 0; index < deptList.value.length; index++) {
if (simulationType.value === deptList.value[index].deptName) {
editFormInfo.value.pMemberList =
deptList.value[index].userId + '-' + deptList.value[index].deptName;
pMemberId = deptList.value[index].userId;
editFormInfo.value.pMemberName = deptList.value[index].userResp.nickname;
}
}
return pMemberId;
}
const matchingDeptList = deptList.value.filter((item: any) => {
// 非设计阶段 走技术中心 设计阶段不走技术中心
if (editFormInfo.value?.selectPhaseName.indexOf('设计') !== -1) {
return (
item.deptName.startsWith(currentProjectUndertaker.value) &&
!item.deptName.endsWith('技术中心')
);
} else {
return (
item.deptName.startsWith(currentProjectUndertaker.value) &&
item.deptName.endsWith('技术中心')
);
}
});
if (matchingDeptList.length > 0) {
// if (matchingDeptList.length === 1) {
// pMemberId = matchingDeptList[0].userId;
// editFormInfo.value.pMemberList =
// matchingDeptList[0].userId + '-' + matchingDeptList[0].deptName;
// } else {
const machDept = matchingDeptList.find((item: any) => {
// if()
return item.deptName.indexOf(editFormInfo.value.simType) !== -1;
});
if (machDept) {
pMemberId = machDept.userId;
editFormInfo.value.pMemberList = machDept.userId + '-' + machDept.deptName;
editFormInfo.value.pMemberName = machDept.userResp.nickname;
}
// }
}
return pMemberId;
};
// const setWorkSpaceValue = (extras: any, workspace: string, workspaceName: string) => {
// return extras.map((item: any) => {
// if (item.propertyName === NODE_TYPE.WORKSPACE) {
// item.propertyValue = workspace;
// }
// if (item.propertyName === NODE_TYPE.WORKSPACE + 'Name') {
// item.propertyValue = workspaceName;
// }
// return {
// ...item,
// };
// });
// };
const getWorkSpaceList = async (phaseId: string) => {
const res: any = await getChildrenNodeListApi({
current: 1,
size: 999,
nodeId: phaseId,
nodeType: NODE_TYPE.WORKSPACE,
});
if (res.code === 200) {
if (res.data.length === 0) {
ElMessage.warning('该阶段下没有工位,请先做仿真策划!');
// 清空工位数据
tableFormRef.value.setOptionsFun('workspaceCode', []);
} else {
const optionList = res.data.map((item: any) => {
return {
label: item.nodeCode,
value: item.nodeCode,
uuid: item.uuid,
parentId: item.parentId,
};
});
tableFormRef.value.setOptionsFun('workspaceCode', optionList);
if (optionList.length > 0) {
return optionList[0];
}
}
}
return {
label: '',
value: '',
parentId: '',
};
};
const getPhaseList = async (nodeType: string, projectUuid: string) => {
let optionList = await getChildrenNodeList(nodeType, projectUuid);
optionList = optionList.map((item: any) => {
return {
label: item.nodeName,
value: item.uuid,
};
});
return optionList;
};
const initFormFlag = ref(false);
const loadTableForm = () => {
emits('loadTableForm');
if (props.pageType === 'create' && !initFormFlag.value) {
changeSimulationType(simulationType.value);
initFormFlag.value = true;
}
};
const disabledEndDateFun = (time: any) => {
if (simulationType.value.includes('物流')) {
return new Date().getTime() + 2 * 24 * 60 * 60 * 1000 > time.getTime();
}
return false;
};
const disabledEndHoursFun = () => {
// 物流仿真只能选择三天后的时间,精确到小时
if (simulationType.value.includes('物流')) {
const currentTime = new Date(editFormInfo.value.endTime).getTime();
if (
new Date().getTime() + 2 * 24 * 60 * 60 * 1000 <= currentTime &&
new Date().getTime() + 3 * 24 * 60 * 60 * 1000 >= currentTime
) {
const hour = dayjs(new Date()).get('hour');
const num = [];
for (let index = 0; index < 24; index++) {
if (hour > index) {
num.push(index);
}
}
return num;
}
}
return [];
};
// const searchChange = async (val: any) => {
// const optionList = await getPhaseList(nodeType, nodeId);
// tableFormRef.value.setOptionsFun(nextKey, optionList);
// };
defineExpose({
tableFormRef,
editFormInfo,