创建报工功能

This commit is contained in:
weibl
2026-01-10 13:49:37 +08:00
parent 3c5dcb6032
commit b85db5776d
6 changed files with 331 additions and 8 deletions

View File

@@ -7,9 +7,35 @@
@close="closeFun"
show-footer
>
<BaseTable ref="tableRef" showIndex tableName="CREATE_WORK_TIME" :actionList="actionList">
<BaseTable
ref="tableRef"
:api="queryWorkApi"
:params="{ taskId: taskInfo.uuid }"
showIndex
tableName="CREATE_WORK_TIME"
:actionList="actionList"
full-height
>
<template #leftOptions>
<el-button icon="plus" type="primary" @click="visibleDialogFun">新增报工</el-button>
<el-button
v-if="operateType === 'addWork'"
icon="plus"
type="primary"
@click="visibleDialogFun"
>新增报工</el-button
>
</template>
<template #workName="{ row }">
{{ row.workName ? row.workName : taskInfo.workName }}
</template>
<template #shouldProgress="{ row }">
{{ TASK_PROGRESS_STATUS.O[row.shouldProgress] }}
</template>
<template #actualProgress="{ row }">
{{ TASK_PROGRESS_STATUS.O[row.actualProgress] }}
</template>
<template #owner="{ row }">
{{ disposeMemberList(row, 'owner') }}
</template>
</BaseTable>
<template #footer>
@@ -23,15 +49,24 @@
v-model="addOrEditVisible"
:diaTitle="isEdit ? '编辑报工' : '新增报工'"
width="400"
height="80%"
height="400"
@close="closeAddOrEditFun"
show-footer
>
<TableForm ref="tableFormRef" tableName="CREATE_WORK_TIME"> </TableForm>
<TableForm
ref="tableFormRef"
:hideKeys="hideKeys"
:data="editRowInfo"
tableName="CREATE_WORK_TIME"
>
<template #form-workName>
<el-input v-model="workName"></el-input>
</template>
</TableForm>
<template #footer>
<div>
<el-button @click="closeFun">取消</el-button>
<el-button type="primary" @click="closeFun">确定</el-button>
<el-button @click="closeAddFun">取消</el-button>
<el-button type="primary" @click="confirmFun">确定</el-button>
</div>
</template>
</Dialog>
@@ -42,9 +77,15 @@ import Dialog from '@/components/common/dialog/index.vue';
import { computed, ref } from 'vue';
import BaseTable from '@/components/common/table/baseTable.vue';
import TableForm from '@/components/common/table/tableForm.vue';
import { addWorkApi, queryWorkApi, updateWorkApi } from '@/api/project/work';
import { ElMessage } from 'element-plus';
import { useDict } from '@/utils/useDict';
import { disposeMemberList } from '@/views/task/projectDetail/components/project';
const props = defineProps<{
showDialog: boolean;
taskInfo: any;
operateType: string;
}>();
const dialogVisible = computed({
@@ -55,12 +96,35 @@ const dialogVisible = computed({
emits('update:showDialog', val);
},
});
const hideKeys =
props.operateType === 'addWork'
? ['actualProgress', 'actualWorkHour']
: ['shouldProgress', 'planWorkHour', 'owner'];
const { TASK_PROGRESS_STATUS } = useDict('TASK_PROGRESS_STATUS');
const tableRef = ref();
const editRowInfo = ref<any>({});
const workName = ref('');
const setWorkName = () => {
workName.value = editRowInfo.value.workName
? editRowInfo.value.workName
: props.taskInfo.workName;
};
const emits = defineEmits(['update:showDialog']);
const closeFun = () => {
emits('update:showDialog', false);
};
const closeAddFun = () => {
addOrEditVisible.value = false;
};
const closeAddOrEditFun = () => {
addOrEditVisible.value = false;
};
@@ -71,14 +135,34 @@ const actionList = ref([
{
title: '编辑',
type: 'primary',
click: () => {
hide: (row: any) => props.operateType !== 'addWork' && (!row.beginTime || !row.finishTime),
click: (row: any) => {
isEdit.value = true;
editRowInfo.value = { ...row };
setWorkName();
addOrEditVisible.value = true;
},
},
{
title: '启动',
type: 'primary',
hide: (row: any) => props.operateType === 'addWork' || row.beginTime,
click: (row: any) => {
updateWorkApiFun({ type: 0, id: row.id });
},
},
{
title: '关闭',
type: 'primary',
hide: (row: any) => props.operateType === 'addWork' || row.finishTime,
click: (row: any) => {
updateWorkApiFun({ type: 1, id: row.id });
},
},
{
title: '删除',
type: 'error',
hide: () => props.operateType !== 'addWork',
click: () => {},
},
]);
@@ -87,9 +171,59 @@ const isEdit = ref(false);
const visibleDialogFun = () => {
isEdit.value = false;
editRowInfo.value = {};
setWorkName();
addOrEditVisible.value = true;
// console.log('tableFormRef.value', tableFormRef.value);
// nextTick(() => {
// tableFormRef.value.resetFun();
// });
};
const tableFormRef = ref();
const confirmFun = async () => {
if (tableFormRef.value.validateFun()) {
const form = tableFormRef.value.getFormDataFun();
console.log('form', form);
if (isEdit.value) {
const params = {
id: form.id,
workName: workName.value === props.taskInfo.workName ? '' : workName.value,
planWorkHour: form.planWorkHour,
shouldProgress: form.shouldProgress,
actualProgress: form.actualProgress,
actualWorkHour: form.actualWorkHour,
extras: form.extras,
description: form.description,
owner: form.owner,
beginTime: form.beginTime,
finishTime: form.finishTime,
type: 2,
};
updateWorkApiFun(params);
} else {
const res: any = await addWorkApi({ ...form, taskId: props.taskInfo.uuid });
if (res.code === 200) {
ElMessage.success('新增报工成功');
closeAddFun();
tableRef.value.resetFun();
} else {
ElMessage.error(res.message);
}
}
}
};
const updateWorkApiFun = async (params: any) => {
const res: any = await updateWorkApi(params);
if (res.code === 200) {
ElMessage.success(res.message);
closeAddFun();
tableRef.value.resetFun();
} else {
ElMessage.error(res.message);
}
};
// const nextPageFun = () => {
// if (hasSameValue()) return;
// emits('update:currentProjectBaseInfo', { ...tableFormRef.value.getFormDataFun(), nodeType: NODE_TYPE.PROJECT });

View File

@@ -5,13 +5,15 @@
@loadTableForm="loadTableForm"
@changeForm="changeFun"
:hideKeys="hideKeys"
:deptOptions="deptOptions"
>
</demandVue>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { onMounted, ref } from 'vue';
import demandVue from '@/views/task/simulationTask/newDemand/index.vue';
import { CommonStore } from '@/stores/common';
import { listDeptApi } from '@/api/system/departMent';
const commonStore = CommonStore();
const demandRef = ref();
@@ -42,6 +44,7 @@ const hideKeys = ref();
* @param type
*/
const changeFun = async (val: any) => {
console.log('val', val, demandRef.value.editFormInfo);
if (val.type === 'form') {
if (val.val.key === 'demandType') {
const formData = demandRef.value.tableFormRef.getFormDataFun();
@@ -70,5 +73,22 @@ const setHideKeys = (key: string) => {
hideKeys.value = ['downAttachments', 'simulationPurpose', 'animationPurpose'];
}
};
const deptOptions = ref<any[]>([]);
const getListDept = async () => {
const res: any = await listDeptApi({ current: 1, size: 999 });
if (res.code === 200) {
deptOptions.value = res.data.data.map((item: { deptName: any; userId: any }) => {
return {
label: item.deptName,
value: String(item.userId),
};
});
}
};
onMounted(() => {
getListDept();
});
</script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,49 @@
<template>
<ExeTaskVue ref="demandRef" :actionList="actionList"> </ExeTaskVue>
<CreateWorkTime
operateType="editWork"
:taskInfo="taskInfo"
v-model:show-dialog="showCreateWorkTimeVisible"
></CreateWorkTime>
</template>
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import ExeTaskVue from '@/views/task/simulationTask/executeTask/index.vue';
import CreateWorkTime from './components/createWorkTime.vue';
import { CommonStore } from '@/stores/common';
import { NODE_TYPE } from '@/utils/enum/node';
import { disposeTagName } from '@/views/task/simulationTask/taskPage';
const taskInfo = reactive({
uuid: '',
taskName: '',
workspace: '',
description: '',
workName: '',
});
const commonStore = CommonStore();
const tagTypeMapList = commonStore.getDictData('TAG_TYPE_MAP_LIST')?.A || [];
const showCreateWorkTimeVisible = ref(false);
const actionList = ref([
{
title: '报工',
type: 'primary',
click: (row: any) => {
showCreateWorkTimeVisible.value = true;
taskInfo.uuid = row.uuid;
taskInfo.taskName = row.taskName;
taskInfo.description = row.description;
taskInfo.workName = disposeTagName(row, NODE_TYPE.PROJECT) + '-' + row.taskName;
tagTypeMapList.forEach((item: any) => {
if (item.value === NODE_TYPE.WORKSPACE) {
taskInfo.workspace = row[item.label];
}
});
},
},
]);
</script>
<style lang="scss" scoped></style>

View File

@@ -1,6 +1,7 @@
<template>
<MySendVue ref="demandRef" :actionList="actionList"> </MySendVue>
<CreateWorkTime
operateType="addWork"
:taskInfo="taskInfo"
v-model:show-dialog="showCreateWorkTimeVisible"
></CreateWorkTime>
@@ -11,12 +12,14 @@ import MySendVue from '@/views/task/simulationTask/mySend/index.vue';
import CreateWorkTime from './components/createWorkTime.vue';
import { CommonStore } from '@/stores/common';
import { NODE_TYPE } from '@/utils/enum/node';
import { disposeTagName } from '@/views/task/simulationTask/taskPage';
const taskInfo = reactive({
uuid: '',
taskName: '',
workspace: '',
description: '',
workName: '',
});
const commonStore = CommonStore();
const tagTypeMapList = commonStore.getDictData('TAG_TYPE_MAP_LIST')?.A || [];
@@ -32,6 +35,7 @@ const actionList = ref([
taskInfo.uuid = row.uuid;
taskInfo.taskName = row.taskName;
taskInfo.description = row.description;
taskInfo.workName = disposeTagName(row, NODE_TYPE.PROJECT) + '-' + row.taskName;
tagTypeMapList.forEach((item: any) => {
if (item.value === NODE_TYPE.WORKSPACE) {
taskInfo.workspace = row[item.label];

View File

@@ -0,0 +1,108 @@
<template>
<BaseTable
showIndex
tableName="DEPARTMENT_USER"
ref="tableRef"
:api="listDeptApi"
:actionList="actionList"
fullHeight
>
<template #leftOptions>
<el-button icon="plus" @click="openDialog('add')" type="primary"> 新增 </el-button>
</template>
</BaseTable>
<Dialog
v-model="dialogVisible"
:diaTitle="isEditDialog ? '编辑' : '新增'"
:width="500"
:height="500"
show-confirm-button
show-cancel-button
show-footer
>
<div class="content">
<TableForm ref="tableFormRef" tableName="DEPARTMENT_USER" :data="editRowInfo" />
</div>
<template #footer>
<div>
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmFun">确定</el-button>
</div>
</template>
</Dialog>
</template>
<script lang="ts" setup>
import BaseTable from '@/components/common/table/baseTable.vue';
import Dialog from '@/components/common/dialog/index.vue';
import { ref } from 'vue';
import TableForm from '@/components/common/table/tableForm.vue';
import { ElMessage } from 'element-plus';
import { addDeptApi, delDeptApi, editDeptApi, listDeptApi } from '@/api/system/departMent';
const isEditDialog = ref(false);
const dialogVisible = ref(false);
const actionList = ref<any>([
{
title: '编辑',
type: 'primary',
click: (row: any) => {
openDialog('edit', row);
},
},
{
title: '删除',
type: 'danger',
needConfirm: true,
confirmTip: '确认删除?',
click: (row: any) => {
delDeptApi({ id: row.id });
},
},
]);
const editRowInfo = ref({});
const openDialog = (type: string, row?: any) => {
isEditDialog.value = type === 'edit';
dialogVisible.value = true;
// nextTick(() => {
if (type === 'edit' && row) {
row.fileType = String(row.fileType);
row.files = [{ name: row.originalName }];
// tableFormRef.value.setFormDataFun(row);
editRowInfo.value = row;
} else if (type === 'add') {
editRowInfo.value = {};
// tableFormRef.value.resetFun();
}
// });
};
const tableFormRef = ref();
const tableRef = ref();
const confirmFun = async () => {
const valid = await tableFormRef.value.validateFun();
if (valid) {
const fromData = tableFormRef.value.getFormDataFun();
if (isEditDialog.value) {
const res: any = await editDeptApi(fromData);
if (res.code === 200) {
ElMessage.success('操作成功');
tableRef.value.resetFun();
dialogVisible.value = false;
}
} else {
const res: any = await addDeptApi(fromData);
if (res.code === 200) {
ElMessage.success('操作成功');
tableRef.value.resetFun();
dialogVisible.value = false;
}
}
tableRef.value.resetFun();
dialogVisible.value = false;
}
};
</script>

View File

@@ -66,6 +66,13 @@ import TaskDetail from '@/views/task/projectDetail/components/taskDetail.vue';
import { isNumber } from 'lodash-es';
import { getMemberListIds } from '@/utils/task';
const props = defineProps({
actionList: {
type: Array,
default: () => [],
},
});
const exeTableRef = ref();
const router = useRouter();
const loadingInterface = ref(false);
@@ -233,6 +240,7 @@ const actionList = ref<any>([
return !(row.exeStatus === TASK_PROCESS_STATUS.IN_PROGRESS);
},
},
...props.actionList,
{
title: '编辑',
type: 'primary',