项目弹窗组件分离

This commit is contained in:
weibl
2025-11-07 11:49:35 +08:00
parent 3d93388b47
commit c1611b2497
4 changed files with 45 additions and 26 deletions

View File

@@ -69,11 +69,11 @@
</div>
</template>
<script lang='ts' setup>
import { addNodeApi, editNodeApi } from '@/api/project/node';
import { addNodeApi, editNodeApi, getNodeDetailApi } from '@/api/project/node';
import Dialog from '@/components/common/dialog/index.vue';
import { getTagKeyMap, NODE_TYPE } from '@/utils/enum/node';
import { ElMessage } from 'element-plus';
import { computed, nextTick, ref, watch } from 'vue';
import { computed, reactive, ref, watch } from 'vue';
import { getProjectExeStatus, getTagMapList } from '@/views/task/projectDetail/components/project';
import TableForm from '@/components/common/table/tableForm.vue';
import { PROJECT_EXE_STATUS_CODE } from '@/utils/enum/project';
@@ -81,10 +81,8 @@ import { getMemberListStr } from '@/utils/task';
const props = defineProps<{
modelValue: boolean;
dialogType: string;
nodeLevel1List: Array<any>;
exeStatus?: string;
currentRow?: any;
projectId?: string;
}>();
const tableFormRef = ref();
@@ -110,7 +108,7 @@ const addOrEditProject = async () => {
if (await tableFormRef.value.validateFun()) {
if (hasSameValue()) return;
loadingInterface.value = true;
if (props.dialogType === 'create') {
if (props?.projectId) {
await createProject();
} else {
// console.log('编辑项目', projectForm);
@@ -202,19 +200,20 @@ const closeFun = () => {
// emits('nextPageFun', 'basePage');
// };
const setEditForm = (val: any) => {
console.log('val', val, tableFormRef.value);
nextTick(() => {
const memberStr = getMemberListStr(val?.memberList);
tableFormRef.value.setFormDataFun({ ...val, memberList: memberStr });
});
};
// const setEditForm = (val: any) => {
// console.log('val', val, tableFormRef.value);
// nextTick(() => {
// const memberStr = getMemberListStr(val?.memberList);
// tableFormRef.value.setFormDataFun({ ...val, memberList: memberStr });
// });
// };
const setOptionsFun = (key: string, options: any[]) => {
console.log('key options', key, options);
tableFormRef.value.setOptionsFun(key, options);
};
const loadFun = () => {
const loadFun = async() => {
await getNodeDetailFun();
initTableForm();
};
@@ -222,22 +221,45 @@ const initTableForm = () => {
console.log('tableFormRef.value', tableFormRef.value);
if (tableFormRef.value) {
let statusList = [];
if (props.dialogType === 'create') {
if (!props?.projectId) {
statusList = [{ label: '未开始', value: PROJECT_EXE_STATUS_CODE.NOT_STARTED }];
tableFormRef.value.resetFun();
setEditForm({ exeStatus: PROJECT_EXE_STATUS_CODE.NOT_STARTED });
// setEditForm({ exeStatus: PROJECT_EXE_STATUS_CODE.NOT_STARTED });
} else {
setEditForm({ ...props.currentRow });
statusList = getProjectExeStatus(props.exeStatus as PROJECT_EXE_STATUS_CODE);
// setEditForm({ ...props.currentRow });
statusList = getProjectExeStatus(projectInfo.exeStatus as PROJECT_EXE_STATUS_CODE);
}
tableFormRef.value.setOptionsFun('exeStatus', statusList);
}
};
const projectInfo = reactive<any>({});
const getNodeDetailFun = async() => {
if (tableFormRef.value) {
if (!props?.projectId ) {
for (const key in projectInfo) {
projectInfo[key] = '';
}
tableFormRef.value.setFormDataFun({ exeStatus: PROJECT_EXE_STATUS_CODE.NOT_STARTED });
} else {
const res:any = await getNodeDetailApi({ projectNodeId: props.projectId });
if (res.code === 200) {
for (const key in res.data) {
projectInfo[key] = res.data[key];
}
console.log('123', { ...projectInfo, memberList: getMemberListStr(projectInfo.memberList) });
tableFormRef.value.setFormDataFun({ ...projectInfo, memberList: getMemberListStr(projectInfo.memberList) });
}
}
}
};
watch(
() => props.modelValue,
(val: any) => {
async (val: any) => {
if (val) {
await getNodeDetailFun();
initTableForm();
}
},

View File

@@ -39,7 +39,7 @@
</tr>
<tr>
<td>创建人</td>
<td>{{ nodeInfo.creator }}</td>
<td>{{ nodeInfo?.creatorObj?.nickname }}</td>
</tr>
<tr>
<td>创建时间</td>
@@ -90,6 +90,7 @@ const emits = defineEmits(['update:projectInfo']);
const nodeInfo = reactive<any>({
nodeName: '',
creator: '',
creatorObj: '',
exeStatusName: '',
exeStatus: '',
nodeCode: '',

View File

@@ -58,12 +58,10 @@
</el-tabs>
</div>
<projectInfoDialog
:exeStatus="currentProjectInfo.exeStatus"
:currentRow="currentProjectInfo"
:projectId="currentProjectInfo.uuid"
ref="basePageFormRef"
v-if="showProjectInfoDialog"
v-model="showProjectInfoDialog"
dialogType="edit"
:nodeLevel1List="nodeLevel1List"
@update:currentProjectBaseInfo="updateCurrentProjectBaseInfo"
@completeFun="completeFun"

View File

@@ -97,11 +97,9 @@
</div>
</div>
<projectInfoDialog
:exeStatus="currentProjectBaseInfo.exeStatus"
ref="basePageRef"
v-model="showProjectInfoDialog"
:dialogType="dialogType"
:currentRow="currentRow"
:projectId="currentProjectBaseInfo.uuid"
:nodeLevel1List="baseTableRef?.tableData||[]"
@update:currentProjectBaseInfo="updateCurrentProjectBaseInfoFun"
@nextPageFun="nextPageFun"