|
|
@@ -110,7 +110,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { computed, onMounted, ref, reactive } from 'vue';
|
|
|
+ import { computed, onMounted, ref, reactive, watch } from 'vue';
|
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import type { FormInstance } from 'element-plus';
|
|
|
@@ -119,6 +119,7 @@
|
|
|
saveWorkPlan,
|
|
|
updateWorkPlan,
|
|
|
queryWorkPlanDetail,
|
|
|
+ queryWorkPlanDepartmentDetail,
|
|
|
reviewWorkPlan,
|
|
|
type SaveWorkPlanRequest,
|
|
|
} from '@/api/safety-system-construction-work-plan';
|
|
|
@@ -138,14 +139,14 @@
|
|
|
|
|
|
const isCreateMode = computed(() => operate.value === 'work-plan-create');
|
|
|
const isEditMode = computed(() => operate.value === 'work-plan-edit');
|
|
|
- const isViewMode = computed(() => operate.value === 'work-plan-view');
|
|
|
-
|
|
|
+ const isViewMode = computed(() => operate.value === 'work-plan-view' || operate.value === 'view-work-content-of-sender');
|
|
|
+ const isViewWorkContentOfSender = computed(() => operate.value === 'view-work-content-of-sender');
|
|
|
const form = reactive<SaveWorkPlanRequest>({
|
|
|
workContent: '',
|
|
|
categoryName: '',
|
|
|
trainingPlanName: '',
|
|
|
- responsibleDeptIds: '',
|
|
|
- cooperateDeptIds: '',
|
|
|
+ responsibleDeptIds: [] as number[],
|
|
|
+ cooperateDeptIds: [] as number[],
|
|
|
executGroupIds: '',
|
|
|
plannedComplateTime: '',
|
|
|
fileUrl: '',
|
|
|
@@ -219,42 +220,7 @@
|
|
|
|
|
|
const attachmentFileList = computed(() => convertAttachmentJsonToFileItems(form.fileUrl || ''));
|
|
|
|
|
|
- async function handleAttachmentUploadSuccess(files: FileItem[]) {
|
|
|
- if (!files?.length) {
|
|
|
- form.fileUrl = '';
|
|
|
- return;
|
|
|
- }
|
|
|
- try {
|
|
|
- const list = await formatAttachmentList(files);
|
|
|
- const jsonArr = (list || [])
|
|
|
- .map((r) => ({
|
|
|
- file_name: r.fileName,
|
|
|
- url: r.fileUrl || '',
|
|
|
- }))
|
|
|
- .filter((x) => x.url);
|
|
|
- form.fileUrl = JSON.stringify(jsonArr);
|
|
|
- handleSubmit();
|
|
|
- } catch (e) {
|
|
|
- console.error('附件上传失败:', e);
|
|
|
- ElMessage.error('附件上传失败,请重试');
|
|
|
- }
|
|
|
- }
|
|
|
const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
|
|
|
- const handlePreview = (url: string) => {
|
|
|
- if (url) {
|
|
|
- // 根据文件扩展名判断文件类型
|
|
|
- const extension = url.split('.').pop()?.toLowerCase() || '';
|
|
|
- let fileType: 'pdf' | 'word' | 'excel' | 'ppt' = 'pdf';
|
|
|
- if (extension === 'doc' || extension === 'docx') {
|
|
|
- fileType = 'word';
|
|
|
- } else if (extension === 'xls' || extension === 'xlsx') {
|
|
|
- fileType = 'excel';
|
|
|
- } else if (extension === 'ppt' || extension === 'pptx') {
|
|
|
- fileType = 'ppt';
|
|
|
- }
|
|
|
- previewOnlineRef.value?.open(url, fileType);
|
|
|
- }
|
|
|
- };
|
|
|
|
|
|
const previewOnline = (url: string | undefined, type) => {
|
|
|
if (url) {
|
|
|
@@ -298,7 +264,26 @@
|
|
|
return false;
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+ const getDeptDetail = async () => {
|
|
|
+ if (!currentId.value) return;
|
|
|
+ try {
|
|
|
+ const res = await queryWorkPlanDepartmentDetail(currentId.value);
|
|
|
+ if (res) {
|
|
|
+ // 映射接口字段到表单字段
|
|
|
+ const cooperateDeptIdsArray = parseDeptIds(res.cooperateDeptIds);
|
|
|
+ const responsibleDeptIdsArray = parseDeptIds(res.responsibleDeptIds);
|
|
|
+ Object.assign(form, {
|
|
|
+ ...res,
|
|
|
+ cooperateDeptIds: cooperateDeptIdsArray,
|
|
|
+ responsibleDeptIds: responsibleDeptIdsArray,
|
|
|
+ fileUrl: JSON.parse(res.fileUrl || '[]'),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (e) {
|
|
|
+ console.error('获取详情失败:', e);
|
|
|
+ ElMessage.error('获取详情失败');
|
|
|
+ }
|
|
|
+ };
|
|
|
const getDetail = async () => {
|
|
|
if (!currentId.value) return;
|
|
|
try {
|
|
|
@@ -314,7 +299,6 @@
|
|
|
fileUrl: JSON.parse(res.fileUrl || '[]'),
|
|
|
});
|
|
|
}
|
|
|
- // cloneRuleFormData();
|
|
|
} catch (e) {
|
|
|
console.error('获取详情失败:', e);
|
|
|
ElMessage.error('获取详情失败');
|
|
|
@@ -357,17 +341,32 @@
|
|
|
ElMessage.error('保存失败,请重试');
|
|
|
}
|
|
|
};
|
|
|
+ // 强制触发组件重新匹配label, 解决视图无法匹配label问题
|
|
|
+watch(deptTree, () => {
|
|
|
+ if (isEditMode.value || isViewMode.value) {
|
|
|
+ form.cooperateDeptIds = [...parseDeptIds(form.cooperateDeptIds)];
|
|
|
+ form.responsibleDeptIds = [...parseDeptIds(form.responsibleDeptIds)];
|
|
|
+ }
|
|
|
+});
|
|
|
+ onMounted(async () => {
|
|
|
+ await loadDeptTreeData();
|
|
|
|
|
|
- onMounted(() => {
|
|
|
- loadDeptTreeData();
|
|
|
- // cloneRuleFormData();
|
|
|
- // beforeRouteLeave();
|
|
|
if (isEditMode.value || isViewMode.value) {
|
|
|
- getDetail();
|
|
|
+ if (isViewWorkContentOfSender.value) {
|
|
|
+ await getDeptDetail();
|
|
|
+ }else{
|
|
|
+ await getDetail();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
@use '@/styles/page-details-layout.scss' as *;
|
|
|
+ .view-text {
|
|
|
+ padding: 8px 0;
|
|
|
+ color: #333;
|
|
|
+ line-height: 1.6;
|
|
|
+}
|
|
|
</style>
|