deason 6 жил өмнө
parent
commit
3856347c98

+ 5 - 0
src/modules/print/view/CourseStatistic.vue

@@ -96,6 +96,7 @@
               type="primary"
               icon="el-icon-menu"
               @click="openAllotAllDialog"
+              :disabled="!hasPermit"
               >分配待指定试卷
             </el-button>
 
@@ -647,6 +648,10 @@ export default {
     },
     openAllotDialog(row) {
       /* 试卷状态为"已有"时,打开试卷指定弹窗 */
+      if (!this.hasPermit) {
+        console.log("no permit.");
+        return;
+      }
       if (row.paperStatus > 0) {
         this.allotDialog = true;
         this.allotForm.id = row.id;

+ 90 - 21
src/modules/print/view/ProjectTemplate.vue

@@ -59,16 +59,32 @@
           style="width:100%;"
           border
         >
-          <el-table-column type="selection" width="55"></el-table-column>
+          <el-table-column label="序号" type="index" width="50">
+          </el-table-column>
           <el-table-column label="类别" prop="typeName" />
           <el-table-column label="上传">
             <template slot-scope="scope">
-              <el-button
-                size="mini"
-                icon="el-icon-upload"
-                @click="upload(scope.row);"
-                >上传
-              </el-button>
+              <el-upload
+                :action="uploadAction"
+                :headers="uploadHeaders"
+                :file-list="fileList"
+                :disabled="!hasPermit"
+                :on-success="
+                  (response, file, fileList) =>
+                    uploadSuccess(response, file, fileList, scope.row)
+                "
+                :on-error="uploadError"
+                :show-file-list="false"
+                :auto-upload="true"
+                :multiple="false"
+              >
+                <el-button
+                  size="mini"
+                  icon="el-icon-upload"
+                  :disabled="!hasPermit"
+                  >上传</el-button
+                >
+              </el-upload>
             </template>
           </el-table-column>
           <el-table-column label="下载">
@@ -76,6 +92,7 @@
               <el-button
                 size="mini"
                 icon="el-icon-download"
+                :disabled="isEmptyStr(scope.row.fileName)"
                 @click="download(scope.row);"
                 >下载
               </el-button>
@@ -86,6 +103,7 @@
               <el-button
                 size="mini"
                 icon="el-icon-view"
+                :disabled="isEmptyStr(scope.row.fileUrl)"
                 @click="preview(scope.row);"
                 >预览
               </el-button>
@@ -115,6 +133,18 @@ export default {
       tableData: [],
       orgList: [],
       examList: [],
+      templateForm: {
+        orgId: "",
+        examId: "",
+        templateType: "",
+        fileUrl: ""
+      },
+      fileList: [],
+      uploadAction: PRINT_API + "/common/upload",
+      uploadHeaders: {
+        key: "",
+        token: ""
+      },
       rules: {}
     };
   },
@@ -165,29 +195,63 @@ export default {
         });
       }
     },
-    upload(row) {
+    uploadSuccess(response, file, fileList, row) {
       /* 上传模板 */
-      console.log(row);
+      if (response.code == "PRT-000200") {
+        this.templateForm.orgId = this.formSearch.orgId;
+        this.templateForm.examId = this.formSearch.examId;
+        this.templateForm.templateType = row.templateType;
+        this.templateForm.fileUrl = response.data;
+        this.$http
+          .post(PRINT_API + "/project/template/save", this.templateForm)
+          .then(
+            () => {
+              this.$notify({
+                message: "上传模板成功!",
+                type: "success"
+              });
+              this.searchRecords();
+            },
+            () => {
+              this.$notify({
+                message: "上传模板失败!",
+                type: "error"
+              });
+            }
+          );
+      }
+    },
+    uploadError(response, file, fileList) {
+      console.log(response);
       this.$notify({
-        message: "Todo...",
-        type: "warning"
+        message: "上传文件失败!",
+        type: "error"
       });
     },
     preview(row) {
       /* 预览模板 */
-      console.log(row);
-      this.$notify({
-        message: "Todo...",
-        type: "warning"
-      });
+      let url = row.fileUrl;
+      if (!url) {
+        this.$notify({
+          message: "当前模板不存在!",
+          type: "warning"
+        });
+        return;
+      }
+      window.open(url);
     },
     download(row) {
       /* 下载模板 */
-      console.log(row);
-      this.$notify({
-        message: "Todo...",
-        type: "warning"
-      });
+      let filePath = row.fileName;
+      if (!filePath) {
+        this.$notify({
+          message: "当前模板不存在!",
+          type: "warning"
+        });
+        return;
+      }
+      let url = PRINT_API + "/common/download?filePath=" + filePath;
+      window.location.href = url;
     }
   },
   computed: {
@@ -203,6 +267,11 @@ export default {
     } else {
       this.hasPermit = false;
     }
+
+    this.uploadHeaders = {
+      key: this.user.key,
+      token: this.user.token
+    };
   }
 };
 </script>