From 2d75d3ed9435050e37ea5cf28252f8c849adec57 Mon Sep 17 00:00:00 2001
From: ZhangXianQiang <1135831638@qq.com>
Date: 星期四, 16 五月 2024 17:33:44 +0800
Subject: [PATCH] fix:修改upload prop

---
 src/views/onlineStudy/file.vue |  214 +++++++++++++++++++++++------------------------------
 1 files changed, 93 insertions(+), 121 deletions(-)

diff --git a/src/views/onlineStudy/file.vue b/src/views/onlineStudy/file.vue
index 14945bb..38764a1 100644
--- a/src/views/onlineStudy/file.vue
+++ b/src/views/onlineStudy/file.vue
@@ -7,11 +7,7 @@
         </el-form-item>
         <el-form-item label="瀛︿範绫诲瀷">
           <el-select v-model="searchForm.belongType" clearable @clear="page" @change="page" placeholder="瀛︿範绫诲瀷">
-            <el-option
-              v-for="type in typeList"
-              :key="type.id"
-              :label="type.typeName"
-              :value="type.id">
+            <el-option v-for="type in typeList" :key="type.id" :label="type.typeName" :value="type.id">
             </el-option>
           </el-select>
         </el-form-item>
@@ -24,69 +20,45 @@
         <el-button type="danger" @click="batchRemove" size="small" style="margin-left: 5px">鍒犻櫎</el-button>
       </div>
     </div>
-    <el-table
-      :data="tableData"
-      border
-      @selection-change="handleSelectionChange"
-      style="width: 100%">
-      <el-table-column
-        type="selection"
-        width="55">
+    <el-table :data="tableData" border @selection-change="handleSelectionChange" style="width: 100%">
+      <el-table-column type="selection" width="55">
       </el-table-column>
-      <el-table-column
-        fixed
-        prop="subject"
-        label="涓婚 ">
+      <el-table-column fixed prop="subject" label="涓婚 ">
       </el-table-column>
-      <el-table-column
-        prop="typeName"
-        label="瀛︿範绫诲瀷">
+      <el-table-column prop="typeName" label="瀛︿範绫诲瀷">
       </el-table-column>
-      <el-table-column
-        prop="contentType"
-        :formatter="typeFormatter"
-        label="鏂囦欢绫诲瀷">
+      <el-table-column prop="contentType" :formatter="typeFormatter" label="鏂囦欢绫诲瀷">
       </el-table-column>
-      <el-table-column
-        label="鏂囦欢鍐呭"
-      >
+      <el-table-column label="鏂囦欢鍐呭">
         <template slot-scope="scope">
-          <video v-if="scope.row.contentType === 'video'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent"/>
-          <img v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent"/>
-          <el-link type="primary" v-if="scope.row.contentType === 'pdf'" :src="'/api/files/' + scope.row.contentUrl.url" class="showContent">鐐瑰嚮鏌ョ湅</el-link>
+          <video v-if="scope.row.contentType === 'video'" :src="'/api/files/' + scope.row.contentUrl.url"
+            class="showContent" />
+          <img v-if="scope.row.contentType === 'img'" :src="'/api/files/' + scope.row.contentUrl.url"
+            class="showContent" />
+          <el-link type="primary" v-if="scope.row.contentType === 'pdf'" :src="'/api/files/' + scope.row.contentUrl.url"
+            class="showContent">鐐瑰嚮鏌ョ湅</el-link>
         </template>
       </el-table-column>
-      <el-table-column
-        prop="attachment"
-        label="闄勪欢">
+      <el-table-column prop="attachment" label="闄勪欢">
         <template slot-scope="scope">
-          <el-link type="primary" v-for="item in scope.row.attachment">{{item.name}}</el-link>
+          <el-link type="primary" v-for="item in scope.row.attachment">{{ item.name }}</el-link>
         </template>
       </el-table-column>
-      <el-table-column
-        fixed="right"
-        label="鎿嶄綔"
-        width="140">
+      <el-table-column fixed="right" label="鎿嶄綔" width="140">
         <template slot-scope="scope">
-          <el-button @click="handleUpdate(scope.row)" type="primary" size="small" style="margin-right: 5px">淇敼</el-button>
+          <el-button @click="handleUpdate(scope.row)" type="primary" size="small"
+            style="margin-right: 5px">淇敼</el-button>
 
-          <el-popconfirm
-            :title="getTitle(scope.row.typeName)"
-            @confirm="remove(scope.row.id)"
-          >
+          <el-popconfirm :title="getTitle(scope.row.typeName)" @confirm="remove(scope.row.id)">
             <el-button slot="reference" type="danger" size="small">鍒犻櫎</el-button>
           </el-popconfirm>
         </template>
       </el-table-column>
     </el-table>
-    <pagination v-show="total>0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
-                @pagination="page"/>
+    <pagination v-show="total > 0" :total="total" :page.sync="searchForm.pageNum" :limit.sync="searchForm.pageSize"
+      @pagination="page" />
 
-    <el-dialog
-      title="娣诲姞瀛︿範鍐呭"
-      :visible.sync="open"
-      width="600px"
-      :close-on-click-modal="false"
+    <el-dialog title="娣诲姞瀛︿範鍐呭" :visible.sync="open" width="600px" :close-on-click-modal="false"
       :before-close="handleClose">
       <el-form label-position="left" label-width="120px" ref="form" :rules="rules" :model="form">
         <el-form-item label="涓婚" prop="subject">
@@ -94,11 +66,7 @@
         </el-form-item>
         <el-form-item label="瀛︿範绫诲瀷" prop="belongType">
           <el-select v-model="form.belongType" placeholder="瀛︿範绫诲瀷">
-            <el-option
-              v-for="type in typeList"
-              :key="type.id"
-              :label="type.typeName"
-              :value="type.id">
+            <el-option v-for="type in typeList" :key="type.id" :label="type.typeName" :value="type.id">
             </el-option>
           </el-select>
         </el-form-item>
@@ -110,10 +78,12 @@
           </el-select>
         </el-form-item>
         <el-form-item label="涓婁紶鏂囦欢(涓�涓�)" prop="contentUrl">
-          <upload v-show="form.contentType" ref="upload" :fileUrl="fileContentUrl" :fileType="form.contentType" :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile"/>
+          <upload v-show="form.contentType" ref="upload" :fileUrl="fileContentUrl" :fileType="form.contentType"
+            :fileSizeLimitM="1024" :uploadNum="1" @getUploadUrl="getUploadUrl" @removeFile="removeFile" />
         </el-form-item>
         <el-form-item label="闄勪欢(鏈�澶�3涓�)" prop="attachment">
-          <upload :fileSizeLimitM="1024" :uploadNum="3" :fileUrl="form.attachment" @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile"/>
+          <upload :fileSizeLimitM="1024" :uploadNum="3" :fileUrl="form.attachment"
+            @getUploadUrl="getUploadAttachmentUrl" @removeFile="removeAttachmentFile" />
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
@@ -125,19 +95,19 @@
 </template>
 
 <script>
-import Pagination from '@/components/Pagination'
-import OnlineStudyAPI from '@/api/online-study'
-import StudyTypeAPI from '@/api/study-type'
-import Upload from '@/components/UploadC'
+import Pagination from '@/components/Pagination';
+import OnlineStudyAPI from '@/api/online-study';
+import StudyTypeAPI from '@/api/study-type';
+import Upload from '@/components/UploadC';
 export default {
   name: 'type',
-  components: {Upload, Pagination},
+  components: { Upload, Pagination },
   computed: {
-    fileContentUrl: function () {
-      return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : []
+    fileContentUrl: () => {
+      return this.form ? this.form.contentUrl ? [this.form.contentUrl] : [] : [];
     }
   },
-  data () {
+  data() {
     return {
       ids: [],
       typeList: [],
@@ -166,7 +136,7 @@
           { required: true, message: '璇烽�夋嫨鏂囦欢绫诲瀷', trigger: 'change' }
         ]
       }
-    }
+    };
   },
   methods: {
     handleSelectionChange(val) {
@@ -174,112 +144,112 @@
     },
     typeFormatter(row) {
       if (row.contentType === 'video') {
-        return "瑙嗛"
+        return "瑙嗛";
       }
       if (row.contentType === 'img') {
-        return "鍥剧墖"
+        return "鍥剧墖";
       }
       if (row.contentType === 'pdf') {
-        return "PDF"
+        return "PDF";
       }
     },
     clearFile() {
-      this.form.contentUrl = null
-      this.$refs.upload.clearFile()
+      this.form.contentUrl = null;
+      this.$refs.upload.clearFile();
     },
     removeFile() {
-      this.form.contentUrl = null
+      this.form.contentUrl = null;
     },
     removeAttachmentFile(fileList, fileName) {
-      console.log(fileList, fileName, "dddddddd")
-      this.form.attachment = fileList.filter(item => item.name !== fileName)
+      console.log(fileList, fileName, "dddddddd");
+      this.form.attachment = fileList.filter(item => item.name !== fileName);
     },
-    getUploadAttachmentUrl (uploadData) {
-      this.form.attachment = uploadData
+    getUploadAttachmentUrl(uploadData) {
+      this.form.attachment = uploadData;
     },
     getUploadUrl(uploadData) {
-      this.form.contentUrl = uploadData[0]
+      this.form.contentUrl = uploadData[0];
     },
-    remove (id) {
+    remove(id) {
       OnlineStudyAPI.remove([id]).then(res => {
         if (res.code === 1) {
-          this.$message.success('鍒犻櫎鎴愬姛')
+          this.$message.success('鍒犻櫎鎴愬姛');
         }
-      })
+      });
     },
-    batchRemove () {
+    batchRemove() {
       if (this.ids.length < 1) {
-        this.$message.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁")
+        this.$message.warning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
       }
       OnlineStudyAPI.remove(this.ids).then(res => {
         if (res.code === 1) {
-          this.$message.success('鍒犻櫎鎴愬姛')
-          this.ids = []
+          this.$message.success('鍒犻櫎鎴愬姛');
+          this.ids = [];
         }
-      })
+      });
     },
-    getTitle (typeName) {
-      return '纭畾瑕佸垹闄�' + typeName + '杩欎釜鏂囦欢鍚楋紵'
+    getTitle(typeName) {
+      return '纭畾瑕佸垹闄�' + typeName + '杩欎釜鏂囦欢鍚楋紵';
     },
-    handlerSubmit () {
+    handlerSubmit() {
       this.$refs['form'].validate((valid) => {
         if (valid) {
           if (this.form.id) {
             OnlineStudyAPI.update(this.form).then(res => {
               if (res.code === 1) {
-                this.$message.success('淇敼鎴愬姛')
-                this.open = false
-                this.page()
+                this.$message.success('淇敼鎴愬姛');
+                this.open = false;
+                this.page();
               }
-            })
+            });
           } else {
             OnlineStudyAPI.add(this.form).then(res => {
               if (res.code === 1) {
-                this.$message.success('娣诲姞鎴愬姛')
-                this.open = false
-                this.page()
+                this.$message.success('娣诲姞鎴愬姛');
+                this.open = false;
+                this.page();
               }
-            })
+            });
           }
         }
-      })
+      });
     },
-    handleClose () {
-      this.open = false
-      this.form = {}
+    handleClose() {
+      this.open = false;
+      this.form = {};
     },
-    handlerAdd () {
-      this.form = {}
-      this.open = true
+    handlerAdd() {
+      this.form = {};
+      this.open = true;
     },
-    page () {
+    page() {
       OnlineStudyAPI.page(this.searchForm).then(res => {
         if (res.code === 1) {
-          this.tableData = res.response
-          this.total = res.total
+          this.tableData = res.response;
+          this.total = res.total;
         }
-      })
+      });
     },
-    handleUpdate (row) {
-      this.form.id = row.id
-      this.form.contentType = row.contentType
-      this.form.contentUrl = row.contentUrl
-      this.form.attachment = row.attachment
-      this.form.subject = row.subject
-      this.form.belongType = row.belongType
-      console.log(row, "dfddddddd")
-      this.open = true
+    handleUpdate(row) {
+      this.form.id = row.id;
+      this.form.contentType = row.contentType;
+      this.form.contentUrl = row.contentUrl;
+      this.form.attachment = row.attachment;
+      this.form.subject = row.subject;
+      this.form.belongType = row.belongType;
+      console.log(row, "dfddddddd");
+      this.open = true;
     }
   },
-  mounted () {
-    this.page()
+  mounted() {
+    this.page();
     StudyTypeAPI.list().then(res => {
       if (res.code === 1) {
-        this.typeList = res.response
+        this.typeList = res.response;
       }
-    })
+    });
   }
-}
+};
 </script>
 
 <style scoped>
@@ -287,9 +257,11 @@
   width: 200px;
   height: 100px;
 }
+
 .warp {
   margin: 40px 10px;
 }
+
 .search {
   margin-top: 10px;
 }

--
Gitblit v1.8.0