From f59373dccb4afb37e63f4fe655061d067244860c Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: 星期三, 16 十一月 2022 09:17:11 +0800
Subject: [PATCH] Default Changelist

---
 src/views/contingencyManagement/panManagement/component/openAdd.vue |   53 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 18 deletions(-)

diff --git a/src/views/contingencyManagement/panManagement/component/openAdd.vue b/src/views/contingencyManagement/panManagement/component/openAdd.vue
index 6a6bd50..4114bb7 100644
--- a/src/views/contingencyManagement/panManagement/component/openAdd.vue
+++ b/src/views/contingencyManagement/panManagement/component/openAdd.vue
@@ -106,17 +106,8 @@
 					</el-col>
 					<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
 						<el-form-item label="相关附件">
-							<el-upload
-								v-model:file-list="fileList"
-								class="upload-demo"
-								action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"
-								:on-change="handleChange"
-							>
-								<el-button type="primary">点击上传</el-button>
-								<template #tip>
-									<div class="el-upload__tip">添加相关附件</div>
-								</template>
-							</el-upload>
+							<uploaderFile :fileList="fileList" :systemName="'EMERGENCY'" :disabled="disabled"
+										  @successUploader="successUploader"></uploaderFile>
 						</el-form-item>
 					</el-col>
 					<!--          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">-->
@@ -158,13 +149,14 @@
 import RegionsDialog from '/@/components/regionsDialog/index.vue';
 import { emergencyPlanApi } from '/@/api/contingencyManagement/emergencyPlan';
 import { goalManagementApi } from '/@/api/goalManagement';
-
+import uploaderFile from '/@/components/uploaderFile/index.vue';
 export default defineComponent({
 	name: 'openAdd',
 	components: {
 		CheckTemplate,
 		DailogSearchUserManger,
 		RegionsDialog,
+		uploaderFile
 	},
 	setup(prop, { emit }) {
 		const isShowDialog = ref(false);
@@ -211,15 +203,35 @@
 									responsibleDepartment.value.push(res.data.data.deptList[a].departmentId)
 								}
 							}
-
+							fileList.value = (res.data.data.fileList?res.data.data.fileList:[])
+							initFileListData()
 						}
 					});
 			}
 		};
+		const initFileListData = async () => {
+			for(var a = 0;a<fileList.value.length;a++){
+				fileList.value[a].name = fileList.value[a].fileName
+			}
+		}
+		// 上传成功组装数据
+		const successUploader = (list) =>{
+			fileList.value = list
+			const formFileList = []
+			for(var a = 0;a<fileList.value.length;a++){
+				formFileList.push(
+						{
+							fileName:fileList.value[a].fileName,
+							fileUrl:''
+						}
+				)
+			}
+			ruleForm.value.fileList = formFileList
+		}
 		//日期选择器
 		const releaseDate = ref('');
 		// 上传附件
-		const fileList = ref<UploadUserFile[]>([]);
+		const fileList = ref([]);
 		//el-tree-select回显
 		const propse = {
 			label: 'depName',
@@ -272,6 +284,9 @@
 		const data = ref();
 
 		const submitForm = async (title: string, formEl: FormInstance | undefined) => {
+			if(!ruleForm.value.fileList){
+				ruleForm.value.fileList = []
+			}
 			if (title == '新建应急预案管理') {
 				if (!formEl) return;
 				await formEl.validate((valid, fields) => {
@@ -306,10 +321,9 @@
 				if (!formEl) return;
 				await formEl.validate((valid, fields) => {
 					if (valid) {
-            ruleForm.value.fileList=[]
-            isShowDialog.value = false;
-            delete ruleForm.value.teamName
-            emergencyPlanApi()
+						isShowDialog.value = false;
+						delete ruleForm.value.teamName
+						emergencyPlanApi()
 							.editEmergencyTeam(ruleForm.value)
 							.then((res) => {
 								if (res.data.code == 200) {
@@ -356,6 +370,7 @@
 			if (!formEl) return;
 			formEl.resetFields();
 			ruleForm.value = {};
+			fileList.value = []
 		};
 		// 应急队伍弹窗
 		const Shows = ref();
@@ -429,6 +444,8 @@
 			onUser,
 			newTreeList,
 			changeDepartment,
+			successUploader,
+			initFileListData
 		};
 	},
 });

--
Gitblit v1.9.2