浏览代码

医学术语静态知识维护

morphone1995 5 年之前
父节点
当前提交
772a3a6025
共有 3 个文件被更改,包括 55 次插入10 次删除
  1. 2 2
      src/api/index.js
  2. 51 6
      src/components/icss/AddMedicinePrompt.vue
  3. 2 2
      src/components/icss/MedicineInfoPg.vue

+ 2 - 2
src/api/index.js

@@ -1,10 +1,10 @@
 import axios from 'axios';
 import config from './config.js';
 
-axios.default.timeout = 5000;
+axios.default.timeout = 500000;
 axios.defaults.headers.post['Content-Type'] = "application/json;charset=utf-8";
 // axios.defaults.baseURL = 'http://192.168.2.236';
-// axios.defaults.baseURL = 'http://192.168.2.241';
+axios.defaults.baseURL = 'http://192.168.2.241';
 // axios.defaults.baseURL = 'http://192.168.3.117:5050';
 
 const urls = config.urls;

+ 51 - 6
src/components/icss/AddMedicinePrompt.vue

@@ -46,8 +46,8 @@
                 <el-form-item   v-if="upload" label="标题名称:" prop="fileTitle" label-width="160px">
                         <el-input v-model="form.fileTitle"></el-input>
                 </el-form-item>
-                 <el-form-item  v-if="upload" label="上传文件:" prop="fileList" label-width="160px">
-                      <el-upload
+                 <el-form-item  v-if="upload" label="上传文件:" ref="upload" prop="fileList" label-width="160px">
+                      <el-upload                         
                           class="upload-demo"
                           :action="config.urls.promptServer"
                           name="upfile"
@@ -64,6 +64,7 @@
                           <el-button size="small" type="primary" v-if="showUpLoad">点击上传</el-button>
                              <!-- <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div> -->
                       </el-upload>
+                      <!-- <el-button size="small" type="primary" >点击上传</el-button> -->
                 </el-form-item>
             </el-form>
             <div class="btn">
@@ -119,16 +120,24 @@
             { required: true, message: '请选择术语标签', trigger: 'change' }
           ],
            fileTitle: [
-            { required: true, message: '请输入段落标题', trigger: 'change' },
+            { required: true, message: '请输入标题名称', trigger: 'change' },
             { validator: (rule,value,callback)=>{
                 if(value.length>30){
-                  callback(new Error('段落标题不能超过30字'));
+                  callback(new Error('标题名称不能超过30字'));
                 }else{
                   callback();
                 }}, trigger: 'change' }
           ],
           fileList: [
-             { required: true, message: '请上传文件', trigger: 'change' }
+            //  { required: true, message: '请上传文件', trigger: 'change' }
+              { validator: (rule,value,callback)=>{
+                if(value.length < 1){
+                  callback(new Error('请上传文件'));
+                }else{
+                  callback()
+                }                
+                }, trigger: 'change' 
+              }
           ]
         },
         saveDisable: false,  //保存按钮禁止点击
@@ -138,6 +147,7 @@
         showFileList: false,
         upload: false,
         showConfirm: true,
+        isSuccessUpload: 0, //是否上传成功  0: 不在上传  1: 上传过程中  2: 上传成功
       }
     },
     /*watch:{
@@ -187,6 +197,25 @@
         });
       }
     },
+    beforeRouteLeave (to, from, next) {
+       if(this.isSuccessUpload === 1 ) {
+        this.$confirm('还有未保存的文件,是否确定返回?', '提示', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          cancelButtonClass:'cancel',
+          type: 'warning'
+        }).then(() => {
+           next()
+        }).catch(() => {
+                  
+        });
+        //  this.warning('还有未保存的文件,是否确定返回?');
+        
+       }else if(this.isSuccessUpload === 0 || this.isSuccessUpload === 2) {
+         next()
+       }
+
+    },
     methods: {
       changeWord(newVal){
         const name = newVal.nameType;
@@ -392,6 +421,8 @@
               
              this.form.fileTitle = response.data.title
            }
+           this.isSuccessUpload = 2 // 上传成功状态
+           this.$refs.upload.clearValidate()  // 清除校验
         }else{
           this.warning(response.msg||'上传失败')
           // this.form.fileList = []
@@ -401,10 +432,14 @@
         }
       },
       handleRemove(file, fileList) {
-         this.showUpLoad = true
+           this.showUpLoad = true
             this.form.fileList=[]
+            this.isSuccessUpload = 0
       },
       handleBeforeUpLoad(file){
+        // 上传过程中   上传按钮 隐藏
+        this.isSuccessUpload = 1  // 上传过程中
+        this.showUpLoad = false
         console.log('aaaaaaaaaa',file);
         if(file.size/1024/1024 >= 500){
            this.warning('文件上传失败,超出大小限制500MB')
@@ -469,7 +504,17 @@
       /deep/.el-upload-list__item .el-icon-close-tip{
         display: none !important;
       } 
+
+      /deep/.el-upload-list__item .el-upload-list__item-name {
+        max-width: 250px;
+        white-space:nowrap;
+        overflow:hidden;
+        text-overflow:ellipsis;
+      }
+
+
     }
+
  
 </style>
 

+ 2 - 2
src/components/icss/MedicineInfoPg.vue

@@ -106,10 +106,10 @@
             { required: true, message: '请选择显示位置', trigger: 'change' }
           ],
           title: [
-            { required: true, message: '请输入段落标题', trigger: 'change' },
+            { required: true, message: '请输入标题名称', trigger: 'change' },
             { validator: (rule,value,callback)=>{
                 if(value.length>30){
-                  callback(new Error('段落标题不能超过30字'));
+                  callback(new Error('标题名称不能超过30字'));
                 }else{
                   callback();
                 }}, trigger: 'change' }