From 87edc55a377c3fca459ab48010a9716b0311c4a8 Mon Sep 17 00:00:00 2001
From: Your Name <123456>
Date: Mon, 15 Aug 2022 09:21:54 +0800
Subject: [PATCH] lct
---
src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue | 74 +++++++++++++++++++++++++------------
1 files changed, 50 insertions(+), 24 deletions(-)
diff --git a/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue b/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue
index 50a59d7..4e7f072 100644
--- a/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue
+++ b/src/views/accidentManagementSystem/accidentExpress/component/openAdd.vue
@@ -1,6 +1,7 @@
<template>
<div class="system-edit-user-container">
- <el-dialog :title="titles" v-model="isShowDialog" width="50%" draggable :fullscreen="full" @close="closeDialog(ruleFormRef)">
+ <el-dialog :title="titles" v-model="isShowDialog" width="50%" draggable :fullscreen="full"
+ destroy-on-close @close="closeDialog(ruleFormRef)">
<el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
<el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" size="default" label-width="140px">
<el-row :gutter="35">
@@ -53,7 +54,8 @@
<el-radio :label="true">是</el-radio>
<el-radio :label="false">否</el-radio>
</el-radio-group>
- <el-button v-if="ruleForm.casualties" type="primary" style="margin-left: 20px" :icon="Edit" @click="openDai" round plain />
+ <el-button v-if="ruleForm.casualties" type="primary" style="margin-left: 20px"
+ :icon="Edit" @click="openDai" round plain />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
@@ -93,7 +95,8 @@
<el-form-item label="事故照片" prop="fileList">
<!--<el-input v-model="ruleForm.fileList" :disabled="disabled"-->
<!--type="textarea" placeholder="请填写应急防范措施" maxlength="150"></el-input>-->
- <uploaderImg :fileList="fileListDemo"></uploaderImg>
+ <uploaderImg :fileList="fileList" :disabled="disabled"
+ :systemName="'INCIDENT_MANAGE'" @successUploader="successUploader"></uploaderImg>
</el-form-item>
</el-col>
</el-row>
@@ -101,7 +104,8 @@
<template #footer>
<span class="dialog-footer">
<el-button @click="resetForm(ruleFormRef)" size="default">关闭</el-button>
- <el-button size="default" v-if="disabled == true ? false : true" type="primary" @click="submitForm(titles, ruleFormRef)">确定</el-button>
+ <el-button size="default" v-if="disabled == true ? false : true" type="primary"
+ @click="submitForm(titles, ruleFormRef)">确定</el-button>
</span>
</template>
</el-dialog>
@@ -155,7 +159,7 @@
const titles = ref();
const disabled = ref();
// 打开弹窗
- const openDialog = (title: string, id: number, type: boolean) => {
+ const openDialog = async (title: string, id: number, type: boolean) => {
isShowDialog.value = true;
titles.value = title;
disabled.value = type;
@@ -165,24 +169,39 @@
.then((res) => {
if (res.data.code == 200) {
ruleForm.value = res.data.data;
+ fileList.value = (res.data.data.fileList?res.data.data.fileList:[])
+ initFileListData()
}
});
}
};
+ const initFileListData = async () => {
+ for(var a = 0;a<fileList.value.length;a++){
+ await goalManagementApi()
+ .searchFile(fileList.value[a].fileName)
+ .then((res) => {
+ fileList.value[a].url = res.data
+ })
+ }
+ }
//日期选择器
const value1 = ref('');
// 上传附件
- const fileList = ref<UploadUserFile[]>([]);
- const fileListDemo = ref<UploadUserFile[]>([
- {
- name: 'food.jpeg',
- url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
- },
- {
- name: 'food.jpeg',
- url: 'https://fuss10.elemecdn.com/3/63/4e7f3a15429bfda99bce42a18cdd1jpeg.jpeg?imageMogr2/thumbnail/360x360/format/webp/quality/100',
- },
- ]);
+ const fileList = ref([]);
+ // 上传成功组装数据
+ 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 treeSelect = ref();
@@ -290,6 +309,9 @@
// const emit=defineEmits(['myAdd'])
// 表单提交验证必填项
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) => {
@@ -325,12 +347,6 @@
await formEl.validate((valid, fields) => {
if (valid) {
isShowDialog.value = false;
- ruleForm.value.fileList = [
- // {
- // fileUrl: 'url',
- // fileName: 'name',
- // },
- ];
accidentManagementSystemApi()
.accidentView(ruleForm.value)
.then((res) => {
@@ -378,6 +394,7 @@
};
const closeDialog = (formEl: FormInstance | undefined) => {
formEl.resetFields();
+ fileList.value = []
console.log(ruleForm);
isShowDialog.value = false;
};
@@ -387,7 +404,16 @@
};
const ShowUser = ref();
const openDai = () => {
- ShowUser.value.openDialog(ruleForm.value.id, disabled.value);
+ if(ruleForm.value.id==null||ruleForm.value.id==''){
+ ElMessage({
+ showClose: true,
+ message: '请先添加事故快报',
+ type: 'info',
+ });
+ }else {
+ ShowUser.value.openDialog(ruleForm.value.id, disabled.value);
+ }
+
};
// 应急队伍弹窗
const Shows = ref();
@@ -448,7 +474,7 @@
getTreeList,
newTreeList,
closeDialog,
- fileListDemo,
+ successUploader
};
},
});
--
Gitblit v1.9.2