lct
Your Name
2022-08-15 87edc55a377c3fca459ab48010a9716b0311c4a8
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">
@@ -94,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>
@@ -157,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;
@@ -167,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();
@@ -292,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) => {
@@ -327,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) => {
@@ -380,6 +394,7 @@
      };
      const closeDialog = (formEl: FormInstance | undefined) => {
         formEl.resetFields();
         fileList.value = []
         console.log(ruleForm);
         isShowDialog.value = false;
      };
@@ -459,7 +474,7 @@
         getTreeList,
         newTreeList,
         closeDialog,
         fileListDemo,
         successUploader
      };
   },
});