lsc 1 vuosi sitten
vanhempi
commit
79a64c8c18

+ 1 - 1
dist/index.html

@@ -32,7 +32,7 @@
       width: 100%;
       background: #e6eaf0;
       font-family: 'Source Han Sans SC', sans-serif;
-    }</style><link href=./static/css/app.1d237152956a72daf88230dbeaf6aa51.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.11d8a4dfbebdec332b5f.js></script><script type=text/javascript src=./static/js/app.8466b6788c4eb8cc5065.js></script></body></html><script>function stopSafari() {
+    }</style><link href=./static/css/app.ccf0b50d6aed0399e1a9a9dc8f341556.css rel=stylesheet></head><body><div id=app></div><script type=text/javascript src=./static/js/manifest.571c38d63f24b1ae9e16.js></script><script type=text/javascript src=./static/js/vendor.11d8a4dfbebdec332b5f.js></script><script type=text/javascript src=./static/js/app.b1311e10f474d0353efd.js></script></body></html><script>function stopSafari() {
     //阻止safari浏览器双击放大功能
     let lastTouchEnd = 0  //更新手指弹起的时间
     document.documentElement.addEventListener("touchstart", function (event) {

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/css/app.1d237152956a72daf88230dbeaf6aa51.css


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/css/app.1d237152956a72daf88230dbeaf6aa51.css.map


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/css/app.ccf0b50d6aed0399e1a9a9dc8f341556.css


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/css/app.ccf0b50d6aed0399e1a9a9dc8f341556.css.map


BIN
dist/static/img/inviteLoginSZBG.d335a60.png


BIN
dist/static/img/inviteLoginSZImage.71812e5.png


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/js/app.b1311e10f474d0353efd.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/js/app.b1311e10f474d0353efd.js.map


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 0
dist/static/js/manifest.571c38d63f24b1ae9e16.js.map


BIN
src/assets/icon/sourceFile/icon_no_active.png


+ 1 - 1
src/components/pages/inviteLogin/inviteLogin.vue

@@ -189,7 +189,7 @@ export default {
     padding: 0 5px;
     overflow: hidden;
     background: rgb(225, 237, 255);
-    margin: 10px 9px 0;
+    margin: 10px 8px 0;
     color: rgb(37 124 255);
     border-radius: 5px;
     box-sizing: border-box;

+ 12 - 2
src/components/pages/library.vue

@@ -59,7 +59,7 @@
     </div>
     <div class="l_file_box">
       <div class="l_none" v-if="pid != 'wu' && pid.split('-').length == 1">请添加二级分类</div>
-      <fileBox :userid="userid" :typeArray="typeArray" :pid="pid" v-else></fileBox>
+      <fileBox :userid="userid" :typeArray="typeArray" :pid="pid" :type='type' @addFile="addFile" v-else></fileBox>
     </div>
   </div>
 </template>
@@ -70,6 +70,12 @@ export default {
   components: {
     fileBox,
   },
+  props: {
+    type: {
+      type: String,
+      default: '1'
+    },
+  },
   data() {
     return {
       userid: this.$route.query.userid,
@@ -346,6 +352,9 @@ export default {
         })
         .catch(() => {
         });
+    },
+    addFile(file){
+      this.$emit('addFile', file)
     }
   },
   beforeDestroy() {
@@ -488,7 +497,8 @@ export default {
   background-image: url('../../assets/icon/sourceFile/icon_no.png');
 }
 
-.l_type_box>.nav>.nav_b>.nav_box.active>.no {
+
+.l_type_box>.nav>.nav_b>.nav_box.active1>.no {
   background-image: url('../../assets/icon/sourceFile/icon_no_active.png');
 }
 

+ 23 - 4
src/components/pages/library/fileBox.vue

@@ -2,14 +2,17 @@
     <div class="f_box">
         <div class="f_box_top">
             <div class="f_box_top_left">
-                <div class="btn" @click="addImg($event)">
+                <div class="btn" @click="addImg($event)" v-if="type == '1'">
                     上传本地文件
                     <input type="file" accept="*" style="display: none" multiple="multiple"
                         @change="beforeUpload($event)" />
                 </div>
-                <div class="btn2" v-if="checkArray.length" @click="openMoveBox">移动到</div>
-                <div class="btn2" v-if="checkArray.length" @click="downPan">下载</div>
-                <div class="delBtn" v-if="checkArray.length" @click="deleteFile"></div>
+                <div class="btn" @click="addFileToTest()" :style="{opacity: checkArray.length ? 1 : .5}" v-if="type == '2'">
+                    添加至表单
+                </div>
+                <div class="btn2" v-if="checkArray.length && type == '1'" @click="openMoveBox">移动到</div>
+                <div class="btn2" v-if="checkArray.length && type == '1'" @click="downPan">下载</div>
+                <div class="delBtn" v-if="checkArray.length && type == '1'" @click="deleteFile"></div>
             </div>
             <div class="f_box_top_right">
                 <div class="input">
@@ -219,6 +222,9 @@ export default {
         pid: {
             type: String,
         },
+        type: {
+            type: String
+        }
     },
     watch: {
         pid: {
@@ -786,6 +792,19 @@ export default {
                 });
             });
         },
+        addFileToTest(){
+            if(!this.checkArray.length){
+                return
+            }
+            let file = []
+            for(let i = 0; i < this.fileArray.length; i++){
+                if(this.checkArray.includes(this.fileArray[i].id)){
+                    file.push(this.fileArray[i])
+                }
+            }
+            this.$emit('addFile', file)
+            this.checkArray = []
+        }
     },
     mounted() {
         this.getData();

+ 115 - 18
src/components/pages/test/add/edit/check/file.vue

@@ -14,13 +14,32 @@
                 <!-- + `(${option[checkJson.type].name})` -->
                 <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
                 <span>{{ checkJson.title }}</span>
-                <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' + checkJson.score +
-                    '分' }})</span>
+                <span style="color: #efa030;min-width: fit-content;" v-if="checkJson.score">({{ '分值:' + checkJson.score
+            +
+            '分' }})</span>
                 <!-- </div><div v-html="checkJson.title"></div> -->
             </div>
-            <div class="detail" v-if="checkJson.detail" v-html="checkJson.detail" style="color: #00000099;margin-top: 5px;">
+            <div class="detail" v-if="checkJson.detail" v-html="checkJson.detail"
+                style="color: #00000099;margin-top: 5px;">
             </div>
             <div class="choices">
+                <div class="uploadBtn">
+                    <div class="btn" @click.stop="addImg($event)">
+                        <span>添加本地文件</span>
+                        <input type="file" accept="*" style="display: none" multiple="multiple"
+                            @change="beforeUpload($event)" />
+                    </div>
+                    <div class="btn" @click="openFileBox()">
+                        <span>从资源库添加</span>
+                    </div>
+                    <div class="switch">
+                        <el-switch
+                            active-color="#3681fc"
+                            v-model="isTong">
+                        </el-switch>
+                        <span @click="isTong = !isTong">同步至资源库</span>
+                    </div>
+                </div>
                 <div class="binfo_input">
                     <div class="fileBox" v-if="checkJson.file && checkJson.file.length">
                         <div class="fileC">
@@ -29,7 +48,8 @@
                                 <img class="del" src="../../../../../../assets/icon/fileIcon/deleteworks.png"
                                     @click.stop="delFile(index)" />
                                 <img class="download" src="../../../../../../assets/icon/fileIcon/download.png"
-                                    @click.stop="downloadFile(item)" :style="{ right: checktype != 1 ? '10px' : '45px' }" />
+                                    @click.stop="downloadFile(item)"
+                                    :style="{ right: checktype != 1 ? '10px' : '45px' }" />
                                 <img class="img" :src="wordIcon" alt="" v-if="item.type == 1" />
                                 <img class="img" :src="videoIcon" alt="" v-if="item.type == 2" />
                                 <img class="img" :src="item.url" alt="" v-if="item.type == 3" />
@@ -43,15 +63,15 @@
                             </div>
                         </div>
                         <!-- @click.stop="addImg($event)" -->
-                        <div class="btn" @click.stop="openFileBox()">
+                        <!-- <div class="btn" @click.stop="openFileBox()">
                             <span>点击添加文件</span>
                             <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload($event)" />
-                        </div>
+                        </div> -->
                     </div>
-                    <!-- @click.stop="addImg($event)" -->
-                    <div class="uploadQ" @click.stop="openFileBox()" v-else>
-                        <span>点击添加文件</span>
-                        <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload($event)" />
+                    <!-- @click.stop="addImg($event)"  @click.stop="addImg($event)" -->
+                    <div class="uploadQ" v-else>
+                        <span>填写者上传区</span>
+                        <!-- <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload($event)" /> -->
                     </div>
                     <div v-if="proVisible" class="mask">
                         <div class="progressBox">
@@ -124,6 +144,7 @@ export default {
             option: {
                 1: { name: '附件' },
             },
+            userid: this.$route.query.userid,
             checkJson: undefined,
             progress: 0,
             isFinishSize: 0,
@@ -137,6 +158,7 @@ export default {
             dialogVisibleOffice: false,
             dialogVisiblefile: false,
             wurl: "",
+            isTong: false
         }
     },
     watch: {
@@ -165,7 +187,7 @@ export default {
             let cfindex2 = 0;
             for (var cfindex = 0; cfindex < event.target.files.length; cfindex++) {
                 file = event.target.files[cfindex];
-            
+
                 var credentials = {
                     accessKeyId: "AKIATLPEDU37QV5CHLMH",
                     secretAccessKey: "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",
@@ -180,6 +202,8 @@ export default {
                 _this.proVisible = true;
                 // _this.isFinishSize = 0;
                 // _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
+                let _name = file.name
+                let size = file.size;
                 _this.$forceUpdate();
                 if (file) {
                     var params = {
@@ -219,10 +243,10 @@ export default {
                             // }, 1000);
                             setTimeout(() => {
                                 if (
-                                cfindex2 == event.target.files.length - 1 ||
-                                cfindex2 > event.target.files.length - 1
+                                    cfindex2 == event.target.files.length - 1 ||
+                                    cfindex2 > event.target.files.length - 1
                                 ) {
-                                _this.proVisible = false;
+                                    _this.proVisible = false;
                                 }
                             }, 1000);
                             // loading.close();
@@ -328,18 +352,27 @@ export default {
                                 }
                                 if (_this.checkJson.file) {
                                     _this.checkJson.file.push({
-                                        name: file.name,
+                                        name: _name,
                                         url: data.Location,
                                         type: _type,
                                     });
                                 } else {
                                     _this.checkJson.file = []
                                     _this.checkJson.file.push({
-                                        name: file.name,
+                                        name: _name,
                                         url: data.Location,
                                         type: _type,
                                     });
                                 }
+                                if(_this.isTong){
+                                    let _file = {
+                                        name: _name,
+                                        url: data.Location,
+                                        type: _type,
+                                        size: _this.formatFileSize(size)
+                                    }
+                                    _this.addSource(_file)
+                                }
                                 _this.$forceUpdate();
 
                                 console.log(_this.checkJson);
@@ -349,6 +382,37 @@ export default {
                 }
             }
         },
+        addSource(file) {
+            let params = [{
+                n: encodeURIComponent(file.name),
+                file: encodeURIComponent(file.url),
+                type: file.type,
+                pid: '0',
+                uid: this.userid,
+                size: file.size,
+            }];
+            this.ajax
+                .post(this.$store.state.api + "addSourceFile", params)
+                .then((res) => {
+                    // if (_ctype == 2) {
+                    //     this.$message.success('上传成功');
+                    // }
+                })
+                .catch((err) => {
+                    console.error(err);
+                });
+        },
+        formatFileSize(bytes) {
+            if (bytes < 1024) {
+                return bytes + "B";
+            } else if (bytes < 1048576) {
+                return (bytes / 1024).toFixed(2) + "KB";
+            } else if (bytes < 1073741824) {
+                return (bytes / 1048576).toFixed(2) + "MB";
+            } else {
+                return (bytes / 1073741824).toFixed(2) + "GB";
+            }
+        },
         setCheckJson(name, url, type) {
             if (this.checkJson.file) {
                 this.checkJson.file.push({
@@ -485,13 +549,13 @@ export default {
 }
 
 .binfo_input>.uploadQ {
-    border: 1.5px dashed #dfdfdf;
+    /* border: 1.5px dashed #dfdfdf; */
     height: 120px;
     width: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
-    background: rgb(249, 250, 251);
+    background: #f9fafb;
     color: rgb(124, 124, 124);
     border-radius: 5px;
     cursor: pointer;
@@ -632,4 +696,37 @@ export default {
     justify-content: center;
     cursor: pointer;
 }
+
+.uploadBtn {
+    display: flex;
+    margin-bottom: 10px;
+    align-items: center;
+    width: 100%;
+    justify-content: flex-end;
+}
+
+.uploadBtn .btn {
+    display: flex;
+    cursor: pointer;
+    align-items: center;
+    height: 30px;
+    padding: 0 8px;
+    background: #fff;
+    color: #3681FC;
+    border: 1px solid #3681FC;
+    box-sizing: border-box;
+    border-radius: 4px;
+    font-size: 14px;
+    align-items: center;
+    margin-right: 10px;
+}
+
+.uploadBtn .switch{
+    display: flex;
+    align-items: center;
+    cursor: pointer;
+}
+.uploadBtn .switch > span{
+    margin-left: 5px;
+}
 </style>

+ 1 - 1
src/components/pages/test/check/index.vue

@@ -65,7 +65,7 @@
             <div class="right">
               <span :class="{ active: stype == 1 }" @click="checkDataType(1)">按题目查看</span>
               <span :class="{ active: stype == 2 }" @click="checkDataType(2)">按人员查看</span>
-              <span :class="{ active: stype == 3 }" @click="checkDataType(3)">按数量查看</span>
+              <span :class="{ active: stype == 3 }" @click="checkDataType(3)" v-show="false">按数量查看</span>
             </div>
             <div class="left">
               <div style="margin-right: 10px;position: relative;" v-if="stype == 2 || stype == 3">

+ 18 - 679
src/components/pages/test/file/checkfile.vue

@@ -1,133 +1,18 @@
 <template>
-    <el-dialog title="上传文件" :visible.sync="dialogVisiblefile" :append-to-body="true" width="600px"
+    <el-dialog title="素材库" :visible.sync="dialogVisiblefile" :append-to-body="true" width="100%"
         :before-close="handleClose" class="dialog_diy">
-        <div class="fileCss">
-            <div>
-                <button class="info_btn" @click="addImg($event)">
-                    选择本地文件
-                    <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload" />
-                </button>
-                <div class="spanName">选择本地文件</div>
-            </div>
-            <!-- <div>
-                <el-button @click="openFile">选择素材库文件</el-button>
-                <div class="spanName">选择素材库文件</div>
-            </div> -->
+        <div style="width: 100%;height: 100%;">
+            <fileBox type="2" @addFile="addFile"></fileBox>
         </div>
-        <div v-if="proVisible" class="mask">
-            <div class="progressBox">
-                <div class="lbox">
-                    <img src="../../../../assets/loading.gif" />上传中,请稍后
-                </div>
-                <!-- <div style="margin-bottom: 10px">
-                    <span>{{
-                        isFinishSize
-                    }}M</span>
-                    /
-                    <span>{{
-                        isAllSize
-                    }}M</span>
-                </div>
-                <el-progress :text-inside="true" :stroke-width="20" :percentage="progress
-                    ? progress
-                    : 0
-                    " style="width: 80%"></el-progress> -->
-            </div>
-        </div>
-        <el-dialog title="选择素材库文件" :visible.sync="dialogVisiblefile2" :append-to-body="true" width="710px"
-            :before-close="handleClose2" class="dialog_diy">
-            <div class="file_box">
-                <div class="student_head">
-                    <div class="three">
-                        <div :class="choose == 0 ? 'choose' : ''" @click="sMtl(0)">图片</div>
-                        <div :class="choose == 1 ? 'choose' : ''" @click="sMtl(1)">视频</div>
-                        <div :class="choose == 2 ? 'choose' : ''" @click="sMtl(2)">附件</div>
-                    </div>
-                </div>
-                <div class="student_table" v-loading="isLoading">
-                    <div v-if="this.choose == 0" class="boxCss">
-                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
-                            <div class="tup">
-                                <img :src="item.chapdataInfo ? JSON.parse(item.chapdataInfo).url : mtp
-                                    " alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
-                                <div class="deleteWord">
-                                    <img src="../../../../assets/icon/delete.png" alt="" />
-                                </div>
-                            </div>
-                            <div class="bottom_box">
-                                <el-tooltip :content="item.chapdataInfo
-                                    ? JSON.parse(item.chapdataInfo).name
-                                    : '暂无名称'" placement="top" effect="dark">
-                                    <div>
-                                        {{
-                                            item.chapdataInfo
-                                            ? JSON.parse(item.chapdataInfo).name
-                                            : "暂无名称"
-                                        }}
-                                    </div>
-                                </el-tooltip>
-                            </div>
-                        </div>
-                    </div>
-                    <div v-if="this.choose == 1" class="boxCss">
-                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
-                            <div class="tup">
-                                <img :src="msp" alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
-                                <div class="deleteWord">
-                                    <img src="../../../../assets/icon/delete.png" alt="" />
-                                </div>
-                            </div>
-                            <div class="bottom_box">
-                                <el-tooltip :content="item.chapdataInfo
-                                    ? JSON.parse(item.chapdataInfo).name
-                                    : '暂无名称'" placement="top" effect="dark">
-                                    <div>
-                                        {{
-                                            item.chapdataInfo
-                                            ? JSON.parse(item.chapdataInfo).name
-                                            : "暂无名称"
-                                        }}
-                                    </div>
-                                </el-tooltip>
-                            </div>
-                        </div>
-                    </div>
-                    <div v-if="this.choose == 2" class="boxCss">
-                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
-                            <div class="tup">
-                                <img :src="mfj" alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
-                                <div class="deleteWord">
-                                    <img src="../../../../assets/icon/delete.png" alt="" />
-                                </div>
-                            </div>
-                            <div class="bottom_box">
-                                <el-tooltip :content="item.chapdataInfo
-                                    ? JSON.parse(item.chapdataInfo).name
-                                    : '暂无名称'" placement="top" effect="dark">
-                                    <div>
-                                        {{
-                                            item.chapdataInfo
-                                            ? JSON.parse(item.chapdataInfo).name
-                                            : "暂无名称"
-                                        }}
-                                    </div>
-                                </el-tooltip>
-                            </div>
-                        </div>
-                    </div>
-                </div>
-                <div class="student_page">
-                    <el-pagination background layout="prev, pager, next" :page-size="10" :total="total"
-                        v-if="page && chapInfo.length" @current-change="handleCurrentChange">
-                    </el-pagination>
-                </div>
-            </div>
-        </el-dialog>
-    </el-dialog>
+    </el-dialog>    
 </template>
   
 <script>
+import fileBox from '../../library.vue';
 export default {
+    components: {
+        fileBox,
+    },
     props: {
         dialogVisiblefile: {
             type: Boolean,
@@ -163,347 +48,23 @@ export default {
         close() {
             this.$emit("update:dialogVisiblefile", false);
         },
-        openFile() {
-            this.dialogVisiblefile2 = true
-            this.selectMtl();
-        },
-        sMtl(choose) {
-            this.choose = choose
-            this.page = 1
-            this.selectMtl()
-        },
-        handleCurrentChange(val) {
-            this.page = val
-            this.selectMtl()
-        },
-        selectMtl() {
-            this.isLoading = true;
-            let params = {
-                t: this.choose,
-                uid: this.userid,
-                page: this.page,
-            };
-            this.ajax
-                .get(this.$store.state.api + "selectMtl2", params)
-                .then((res) => {
-                    this.isLoading = false;
-                    this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
-                    this.chapInfo = res.data[0];
-                })
-                .catch((err) => {
-                    this.isLoading = false;
-                    console.error(err);
-                });
-        },
-        addImg(e) {
-            var el = e.currentTarget;
-            el.getElementsByTagName("input")[0].click();
-            e.target.value = "";
-        },
-        beforeUpload(event, type) {
-            // const loading = this.openLoading();
-            let cfindex2 = 0;
-            for (var cfindex = 0; cfindex < event.target.files.length; cfindex++) {
-                let file = event.target.files[cfindex];
-                var credentials = {
-                    accessKeyId: "AKIATLPEDU37QV5CHLMH",
-                    secretAccessKey: "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",
-                }; //秘钥形式的登录上传
-                window.AWS.config.update(credentials);
-                window.AWS.config.region = "cn-northwest-1"; //设置区域
-
-                var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
-                var _this = this;
-
-                // _this.progress = 0;
-                _this.proVisible = true;
-                // _this.isFinishSize = 0;
-                // _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
-                _this.$forceUpdate();
-                if (file) {
-                    var params = {
-                        Key:
-                            file.name.split(".")[0] +
-                            new Date().getTime() +
-                            "." +
-                            file.name.split(".")[file.name.split(".").length - 1],
-                        ContentType: file.type,
-                        Body: file,
-                        "Access-Control-Allow-Credentials": "*",
-                        ACL: "public-read",
-                    }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
-                    var options = {
-                        partSize: 2048 * 1024 * 1024,
-                        queueSize: 2,
-                        leavePartsOnError: true,
-                    };
-                    bucket
-                        .upload(params, options)
-                        .on("httpUploadProgress", function (evt) {
-                            //这里可以写进度条
-                            // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
-                            // _this.progress = parseInt((evt.loaded / evt.total) * 100);
-                            // _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
-                            // _this.$forceUpdate();
-                        })
-                        .send(function (err, data) {
-                            cfindex2++;
-
-                            // _this.progress = 100;
-                            // _this.isFinishSize = _this.isAllSize;
-                            // _this.$forceUpdate();
-                            // setTimeout(() => {
-                            //     _this.proVisible = false;
-                            //     _this.$forceUpdate();
-                            // }, 1000);
-                            setTimeout(() => {
-                                if (
-                                cfindex2 == event.target.files.length - 1 ||
-                                cfindex2 > event.target.files.length - 1
-                                ) {
-                                _this.proVisible = false;
-                                _this.close();
-                                }
-                            }, 1000);
-                            // loading.close();
-                            if (err) {
-                                _this.$message.error("上传失败");
-                            } else {
-                                let _type = 2;
-                                var imgA = [
-                                    "png",
-                                    "jpg",
-                                    "jpeg",
-                                    "bmp",
-                                    "gif",
-                                    "webp",
-                                    "psd",
-                                    "svg",
-                                    "tiff",
-                                ];
-                                var fileA = [
-                                    "DOC",
-                                    "DOCX",
-                                    "DOCM",
-                                    "DOTM",
-                                    "DOTX",
-                                    "PPTX",
-                                    "PPSX",
-                                    "PPT",
-                                    "PPS",
-                                    "PPTM",
-                                    "POTM",
-                                    "PPAM",
-                                    "POTX",
-                                    "PPSM",
-                                    "XLSX",
-                                    "XLS",
-                                ];
-                                var videoA = [
-                                    "AVI",
-                                    "NAVI",
-                                    "MPEG",
-                                    "ASF",
-                                    "MOV",
-                                    "WMV",
-                                    "3GP",
-                                    "RM",
-                                    "RMVB",
-                                    "FLV",
-                                    "F4V",
-                                    "H.264",
-                                    "H.265",
-                                    "REAL VIDEO",
-                                    "MKV",
-                                    "WebM",
-                                    "HDDVD",
-                                    "MP4",
-                                    "MPG",
-                                    "M4V",
-                                    "MGV",
-                                    "OGV",
-                                    "QTM",
-                                    "STR",
-                                    "AMC",
-                                    "DVX",
-                                    "EVO",
-                                    "DAT",
-                                    "OGG",
-                                    "OGM",
-                                ];
-                                if (
-                                    fileA.indexOf(
-                                        data.Location.split(".")[
-                                            data.Location.split(".").length - 1
-                                        ].toLocaleUpperCase()
-                                    ) != -1
-                                ) {
-                                    _type = 1; //word 文件
-                                } else if (
-                                    videoA.indexOf(
-                                        data.Location.split(".")[
-                                            data.Location.split(".").length - 1
-                                        ].toLocaleUpperCase()
-                                    ) != -1
-                                ) {
-                                    _type = 2; //视频
-                                } else if (
-                                    imgA.indexOf(
-                                        data.Location.split(".")[
-                                            data.Location.split(".").length - 1
-                                        ].toLocaleLowerCase()
-                                    ) != -1
-                                ) {
-                                    _type = 3; //图片
-                                } else if (
-                                    'pdf'.indexOf(
-                                        data.Location.split(".")[
-                                            data.Location.split(".").length - 1
-                                        ].toLocaleLowerCase()
-                                    ) != -1
-                                ) {
-                                    _type = 4; //pdf
-                                } else {
-                                    _type = 5; //文件
-                                }
-                                // if (_this.checkJson.file) {
-                                // _this.checkJson.file.push({
-                                //     name: file.name,
-                                //     url: data.Location,
-                                //     type: _type,
-                                // });
-                                // } else {
-                                //     _this.checkJson.file = []
-                                //     _this.checkJson.file.push({
-                                //         name: file.name,
-                                //         url: data.Location,
-                                //         type: _type,
-                                //     });
-                                // }
-                                _this.$emit("setCheckJson", file.name, data.Location, _type);
-                                _this.$forceUpdate();
-
-                                console.log(_this.checkJson);
-                                console.log(data.Location);
-                            }
-                        });
-                }
+        addFile(file){
+            for(var i = 0; i < file.length; i++){
+                this.$emit("setCheckJson", file[i].name, file[i].file, file[i].type);
             }
-        },
-        checkJson(json) {
-            let _type = 2;
-            let url = "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/"+encodeURIComponent(json.url.split(
-          "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/"
-        )[1]);
-            let name = json.name
-            var imgA = [
-                "png",
-                "jpg",
-                "jpeg",
-                "bmp",
-                "gif",
-                "webp",
-                "psd",
-                "svg",
-                "tiff",
-            ];
-            var fileA = [
-                "DOC",
-                "DOCX",
-                "DOCM",
-                "DOTM",
-                "DOTX",
-                "PPTX",
-                "PPSX",
-                "PPT",
-                "PPS",
-                "PPTM",
-                "POTM",
-                "PPAM",
-                "POTX",
-                "PPSM",
-                "XLSX",
-                "XLS",
-            ];
-            var videoA = [
-                "AVI",
-                "NAVI",
-                "MPEG",
-                "ASF",
-                "MOV",
-                "WMV",
-                "3GP",
-                "RM",
-                "RMVB",
-                "FLV",
-                "F4V",
-                "H.264",
-                "H.265",
-                "REAL VIDEO",
-                "MKV",
-                "WebM",
-                "HDDVD",
-                "MP4",
-                "MPG",
-                "M4V",
-                "MGV",
-                "OGV",
-                "QTM",
-                "STR",
-                "AMC",
-                "DVX",
-                "EVO",
-                "DAT",
-                "OGG",
-                "OGM",
-            ];
-            if (
-                fileA.indexOf(
-                    url.split(".")[
-                    url.split(".").length - 1
-                    ].toLocaleUpperCase()
-                ) != -1
-            ) {
-                _type = 1; //word 文件
-            } else if (
-                videoA.indexOf(
-                    url.split(".")[
-                    url.split(".").length - 1
-                    ].toLocaleUpperCase()
-                ) != -1
-            ) {
-                _type = 2; //视频
-            } else if (
-                imgA.indexOf(
-                    url.split(".")[
-                    url.split(".").length - 1
-                    ].toLocaleLowerCase()
-                ) != -1
-            ) {
-                _type = 3; //图片
-            } else if (
-                'pdf'.indexOf(
-                    url.split(".")[
-                    url.split(".").length - 1
-                    ].toLocaleLowerCase()
-                ) != -1
-            ) {
-                _type = 4; //pdf
-            } else {
-                _type = 5; //文件
-            }
-            this.$emit("setCheckJson", name, url, _type);
-            this.dialogVisiblefile2 = false
             this.close();
+            this.$message.success('添加成功');
+            // this.$emit("setCheckJson", name, url, _type);
         }
-    }
+
+    }   
 };
 </script>
   
 <style scoped>
 .dialog_diy>>>.el-dialog {
-    /* height: 100%; */
-    margin: 10vh auto !important;
+    height: 100%;
+    margin: 0 auto !important;
 }
 
 .dialog_diy>>>.el-dialog__header {
@@ -512,7 +73,7 @@ export default {
 }
 
 .dialog_diy>>>.el-dialog__body {
-    height: calc(100% - 124px);
+    height: calc(100% - 55px);
     box-sizing: border-box;
     padding: 0px;
 }
@@ -539,227 +100,5 @@ export default {
 }
 
 
-.fileCss {
-    width: 100%;
-    display: flex;
-    flex-direction: row;
-    flex-wrap: nowrap;
-    justify-content: space-around;
-    align-items: center;
-    padding: 40px 0;
-    box-sizing: border-box;
-}
-
-.fileCss>div {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-}
-
-.fileCss .spanName {
-    margin-top: 10px
-}
-
-
-.info_btn,
-.teacherWord {
-    color: #fff;
-    background-color: #0f7eff;
-    padding: 8px 24px;
-    font-size: 0.9375rem;
-    box-shadow: 0px 1px 3px 0px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%),
-        0px 3px 1px -2px rgb(0 0 0 / 12%);
-    min-width: 64px;
-    font-weight: 500;
-    border-radius: 4px;
-    box-sizing: border-box;
-    border: none;
-    cursor: pointer;
-}
-
-.mask {
-    background-color: rgb(0 0 0 / 30%);
-    /* position: fixed; */
-    position: absolute;
-    top: 0;
-    left: 0;
-    width: 100%;
-    height: 100%;
-    z-index: 90;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-}
-
-.progressBox {
-    width: 300px;
-    height: 150px;
-    background: #fff;
-    border-radius: 10px;
-    box-shadow: 0 0 6px 1px #bfbfbf;
-    display: flex;
-    align-items: center;
-    justify-content: center;
-    flex-direction: column;
-    position: relative;
-    color: #6c6c6c;
-}
-
-.progressBox>>>.el-progress-bar__outer {
-    background-color: #d1dfff !important;
-}
-
-.progressBox .lbox {
-    height: 50px;
-    font-size: 19px;
-    display: flex;
-    align-items: center;
-    color: #747474;
-}
-
-.progressBox .lbox img {
-    width: 40px;
-    margin-right: 20px;
-}
-
-.closeCss {
-    position: absolute;
-    top: 8px;
-    right: 8px;
-    cursor: pointer;
-    width: 20px;
-    height: 20px;
-}
-
-.closeCss>img {
-    width: 100%;
-    height: 100%;
-}
-
-.file_box {
-    width: 100%;
-    padding: 15px;
-    box-sizing: border-box;
-}
-
-.student_head>>>.el-button--primary {
-    background-color: #2268bc;
-}
-
-.student_head {
-    display: flex;
-    justify-content: space-between;
-}
-
-.three {
-    display: flex;
-    flex-direction: row;
-    justify-content: space-between;
-    width: 200px;
-    height: 30px;
-}
-
-.three>div {
-    cursor: pointer;
-}
-
-.choose {
-    border-bottom: 5px solid #3994fd;
-}
-
-.student_table {
-    width: 100%;
-    height: 100%;
-    background: #f2f2f2;
-    margin-top: 10px;
-}
-
-.tup {
-    width: calc(100% - 20px);
-    height: 120px;
-    margin: 0 auto;
-    position: relative;
-}
-
-.out_box:hover .deleteWord {
-    /* display: block; */
-}
-
-.deleteWord {
-    width: 25px;
-    height: 25px;
-    position: absolute;
-    right: -25px;
-    top: -10px;
-    cursor: pointer;
-    display: none;
-}
-
-.tup>img,
-.deleteWord>img {
-    width: 100%;
-    height: 100%;
-    object-fit: cover;
-}
-
-.out_box {
-    display: flex;
-    flex-direction: column;
-    flex-wrap: nowrap;
-    width: 216px;
-    padding: 10px 0;
-    background: #fff;
-    margin: 0 10px 10px 0;
-    height: fit-content;
-    cursor: pointer;
-}
-
-.out_box:nth-child(3n){
-    margin-right: 0;
-}
-
-.bottom_box {
-    display: flex;
-    text-align: center;
-    margin: 0 auto;
-    padding: 10px 0 5px 0;
-}
-
-.bottom_box>div:nth-child(1) {
-    white-space: nowrap;
-    text-overflow: ellipsis;
-    overflow: hidden;
-    word-break: break-all;
-    width: 200px;
-}
-
-.uploadThing {
-    background: #2268bc;
-    width: 90px;
-    height: 35px;
-    color: #fff;
-    font-size: 12px;
-    text-align: center;
-    line-height: 35px;
-    cursor: pointer;
-    border-radius: 4px;
-}
-
-.top {
-    display: flex;
-    justify-content: space-between;
-}
-
-.student_page {
-    margin-top: 30px;
-}
-
-.boxCss {
-    padding: 15px 5px;
-    display: flex;
-    flex-direction: row;
-    flex-wrap: wrap;
-    min-height: 250px;
-}
 </style>
   

+ 765 - 0
src/components/pages/test/file/checkfileJiu.vue

@@ -0,0 +1,765 @@
+<template>
+    <el-dialog title="上传文件" :visible.sync="dialogVisiblefile" :append-to-body="true" width="600px"
+        :before-close="handleClose" class="dialog_diy">
+        <div class="fileCss">
+            <div>
+                <button class="info_btn" @click="addImg($event)">
+                    选择本地文件
+                    <input type="file" accept="*" style="display: none" multiple="multiple" @change="beforeUpload" />
+                </button>
+                <div class="spanName">选择本地文件</div>
+            </div>
+            <!-- <div>
+                <el-button @click="openFile">选择素材库文件</el-button>
+                <div class="spanName">选择素材库文件</div>
+            </div> -->
+        </div>
+        <div v-if="proVisible" class="mask">
+            <div class="progressBox">
+                <div class="lbox">
+                    <img src="../../../../assets/loading.gif" />上传中,请稍后
+                </div>
+                <!-- <div style="margin-bottom: 10px">
+                    <span>{{
+                        isFinishSize
+                    }}M</span>
+                    /
+                    <span>{{
+                        isAllSize
+                    }}M</span>
+                </div>
+                <el-progress :text-inside="true" :stroke-width="20" :percentage="progress
+                    ? progress
+                    : 0
+                    " style="width: 80%"></el-progress> -->
+            </div>
+        </div>
+        <el-dialog title="选择素材库文件" :visible.sync="dialogVisiblefile2" :append-to-body="true" width="710px"
+            :before-close="handleClose2" class="dialog_diy">
+            <div class="file_box">
+                <div class="student_head">
+                    <div class="three">
+                        <div :class="choose == 0 ? 'choose' : ''" @click="sMtl(0)">图片</div>
+                        <div :class="choose == 1 ? 'choose' : ''" @click="sMtl(1)">视频</div>
+                        <div :class="choose == 2 ? 'choose' : ''" @click="sMtl(2)">附件</div>
+                    </div>
+                </div>
+                <div class="student_table" v-loading="isLoading">
+                    <div v-if="this.choose == 0" class="boxCss">
+                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
+                            <div class="tup">
+                                <img :src="item.chapdataInfo ? JSON.parse(item.chapdataInfo).url : mtp
+                                    " alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
+                                <div class="deleteWord">
+                                    <img src="../../../../assets/icon/delete.png" alt="" />
+                                </div>
+                            </div>
+                            <div class="bottom_box">
+                                <el-tooltip :content="item.chapdataInfo
+                                    ? JSON.parse(item.chapdataInfo).name
+                                    : '暂无名称'" placement="top" effect="dark">
+                                    <div>
+                                        {{
+                                            item.chapdataInfo
+                                            ? JSON.parse(item.chapdataInfo).name
+                                            : "暂无名称"
+                                        }}
+                                    </div>
+                                </el-tooltip>
+                            </div>
+                        </div>
+                    </div>
+                    <div v-if="this.choose == 1" class="boxCss">
+                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
+                            <div class="tup">
+                                <img :src="msp" alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
+                                <div class="deleteWord">
+                                    <img src="../../../../assets/icon/delete.png" alt="" />
+                                </div>
+                            </div>
+                            <div class="bottom_box">
+                                <el-tooltip :content="item.chapdataInfo
+                                    ? JSON.parse(item.chapdataInfo).name
+                                    : '暂无名称'" placement="top" effect="dark">
+                                    <div>
+                                        {{
+                                            item.chapdataInfo
+                                            ? JSON.parse(item.chapdataInfo).name
+                                            : "暂无名称"
+                                        }}
+                                    </div>
+                                </el-tooltip>
+                            </div>
+                        </div>
+                    </div>
+                    <div v-if="this.choose == 2" class="boxCss">
+                        <div class="out_box" v-for="(item, index) in chapInfo" :key="index">
+                            <div class="tup">
+                                <img :src="mfj" alt="" @click="checkJson(JSON.parse(item.chapdataInfo))" />
+                                <div class="deleteWord">
+                                    <img src="../../../../assets/icon/delete.png" alt="" />
+                                </div>
+                            </div>
+                            <div class="bottom_box">
+                                <el-tooltip :content="item.chapdataInfo
+                                    ? JSON.parse(item.chapdataInfo).name
+                                    : '暂无名称'" placement="top" effect="dark">
+                                    <div>
+                                        {{
+                                            item.chapdataInfo
+                                            ? JSON.parse(item.chapdataInfo).name
+                                            : "暂无名称"
+                                        }}
+                                    </div>
+                                </el-tooltip>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="student_page">
+                    <el-pagination background layout="prev, pager, next" :page-size="10" :total="total"
+                        v-if="page && chapInfo.length" @current-change="handleCurrentChange">
+                    </el-pagination>
+                </div>
+            </div>
+        </el-dialog>
+    </el-dialog>
+</template>
+  
+<script>
+export default {
+    props: {
+        dialogVisiblefile: {
+            type: Boolean,
+            default: false
+        },
+    },
+    data() {
+        return {
+            progress: 0,
+            isFinishSize: 0,
+            proVisible: false,
+            isAllSize: 0,
+            dialogVisiblefile2: false,
+            userid: this.$route.query.userid,
+            page: 1,
+            isLoading: false,
+            total: 0,
+            chapInfo: [],
+            choose: 0,
+            mtp: require("../../../../assets/tup1.png"),
+            msp: require("../../../../assets/icon/fileIcon/isVideo.png"),
+            mfj: require("../../../../assets/icon/fileIcon/word2.png"),
+        };
+    },
+    methods: {
+        handleClose(done) {
+            this.close();
+            done();
+        },
+        handleClose2(done) {
+            done();
+        },
+        close() {
+            this.$emit("update:dialogVisiblefile", false);
+        },
+        openFile() {
+            this.dialogVisiblefile2 = true
+            this.selectMtl();
+        },
+        sMtl(choose) {
+            this.choose = choose
+            this.page = 1
+            this.selectMtl()
+        },
+        handleCurrentChange(val) {
+            this.page = val
+            this.selectMtl()
+        },
+        selectMtl() {
+            this.isLoading = true;
+            let params = {
+                t: this.choose,
+                uid: this.userid,
+                page: this.page,
+            };
+            this.ajax
+                .get(this.$store.state.api + "selectMtl2", params)
+                .then((res) => {
+                    this.isLoading = false;
+                    this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
+                    this.chapInfo = res.data[0];
+                })
+                .catch((err) => {
+                    this.isLoading = false;
+                    console.error(err);
+                });
+        },
+        addImg(e) {
+            var el = e.currentTarget;
+            el.getElementsByTagName("input")[0].click();
+            e.target.value = "";
+        },
+        beforeUpload(event, type) {
+            // const loading = this.openLoading();
+            let cfindex2 = 0;
+            for (var cfindex = 0; cfindex < event.target.files.length; cfindex++) {
+                let file = event.target.files[cfindex];
+                var credentials = {
+                    accessKeyId: "AKIATLPEDU37QV5CHLMH",
+                    secretAccessKey: "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",
+                }; //秘钥形式的登录上传
+                window.AWS.config.update(credentials);
+                window.AWS.config.region = "cn-northwest-1"; //设置区域
+
+                var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
+                var _this = this;
+
+                // _this.progress = 0;
+                _this.proVisible = true;
+                // _this.isFinishSize = 0;
+                // _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
+                _this.$forceUpdate();
+                if (file) {
+                    var params = {
+                        Key:
+                            file.name.split(".")[0] +
+                            new Date().getTime() +
+                            "." +
+                            file.name.split(".")[file.name.split(".").length - 1],
+                        ContentType: file.type,
+                        Body: file,
+                        "Access-Control-Allow-Credentials": "*",
+                        ACL: "public-read",
+                    }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
+                    var options = {
+                        partSize: 2048 * 1024 * 1024,
+                        queueSize: 2,
+                        leavePartsOnError: true,
+                    };
+                    bucket
+                        .upload(params, options)
+                        .on("httpUploadProgress", function (evt) {
+                            //这里可以写进度条
+                            // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
+                            // _this.progress = parseInt((evt.loaded / evt.total) * 100);
+                            // _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
+                            // _this.$forceUpdate();
+                        })
+                        .send(function (err, data) {
+                            cfindex2++;
+
+                            // _this.progress = 100;
+                            // _this.isFinishSize = _this.isAllSize;
+                            // _this.$forceUpdate();
+                            // setTimeout(() => {
+                            //     _this.proVisible = false;
+                            //     _this.$forceUpdate();
+                            // }, 1000);
+                            setTimeout(() => {
+                                if (
+                                cfindex2 == event.target.files.length - 1 ||
+                                cfindex2 > event.target.files.length - 1
+                                ) {
+                                _this.proVisible = false;
+                                _this.close();
+                                }
+                            }, 1000);
+                            // loading.close();
+                            if (err) {
+                                _this.$message.error("上传失败");
+                            } else {
+                                let _type = 2;
+                                var imgA = [
+                                    "png",
+                                    "jpg",
+                                    "jpeg",
+                                    "bmp",
+                                    "gif",
+                                    "webp",
+                                    "psd",
+                                    "svg",
+                                    "tiff",
+                                ];
+                                var fileA = [
+                                    "DOC",
+                                    "DOCX",
+                                    "DOCM",
+                                    "DOTM",
+                                    "DOTX",
+                                    "PPTX",
+                                    "PPSX",
+                                    "PPT",
+                                    "PPS",
+                                    "PPTM",
+                                    "POTM",
+                                    "PPAM",
+                                    "POTX",
+                                    "PPSM",
+                                    "XLSX",
+                                    "XLS",
+                                ];
+                                var videoA = [
+                                    "AVI",
+                                    "NAVI",
+                                    "MPEG",
+                                    "ASF",
+                                    "MOV",
+                                    "WMV",
+                                    "3GP",
+                                    "RM",
+                                    "RMVB",
+                                    "FLV",
+                                    "F4V",
+                                    "H.264",
+                                    "H.265",
+                                    "REAL VIDEO",
+                                    "MKV",
+                                    "WebM",
+                                    "HDDVD",
+                                    "MP4",
+                                    "MPG",
+                                    "M4V",
+                                    "MGV",
+                                    "OGV",
+                                    "QTM",
+                                    "STR",
+                                    "AMC",
+                                    "DVX",
+                                    "EVO",
+                                    "DAT",
+                                    "OGG",
+                                    "OGM",
+                                ];
+                                if (
+                                    fileA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleUpperCase()
+                                    ) != -1
+                                ) {
+                                    _type = 1; //word 文件
+                                } else if (
+                                    videoA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleUpperCase()
+                                    ) != -1
+                                ) {
+                                    _type = 2; //视频
+                                } else if (
+                                    imgA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleLowerCase()
+                                    ) != -1
+                                ) {
+                                    _type = 3; //图片
+                                } else if (
+                                    'pdf'.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleLowerCase()
+                                    ) != -1
+                                ) {
+                                    _type = 4; //pdf
+                                } else {
+                                    _type = 5; //文件
+                                }
+                                // if (_this.checkJson.file) {
+                                // _this.checkJson.file.push({
+                                //     name: file.name,
+                                //     url: data.Location,
+                                //     type: _type,
+                                // });
+                                // } else {
+                                //     _this.checkJson.file = []
+                                //     _this.checkJson.file.push({
+                                //         name: file.name,
+                                //         url: data.Location,
+                                //         type: _type,
+                                //     });
+                                // }
+                                _this.$emit("setCheckJson", file.name, data.Location, _type);
+                                _this.$forceUpdate();
+
+                                console.log(_this.checkJson);
+                                console.log(data.Location);
+                            }
+                        });
+                }
+            }
+        },
+        checkJson(json) {
+            let _type = 2;
+            let url = "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/"+encodeURIComponent(json.url.split(
+          "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/"
+        )[1]);
+            let name = json.name
+            var imgA = [
+                "png",
+                "jpg",
+                "jpeg",
+                "bmp",
+                "gif",
+                "webp",
+                "psd",
+                "svg",
+                "tiff",
+            ];
+            var fileA = [
+                "DOC",
+                "DOCX",
+                "DOCM",
+                "DOTM",
+                "DOTX",
+                "PPTX",
+                "PPSX",
+                "PPT",
+                "PPS",
+                "PPTM",
+                "POTM",
+                "PPAM",
+                "POTX",
+                "PPSM",
+                "XLSX",
+                "XLS",
+            ];
+            var videoA = [
+                "AVI",
+                "NAVI",
+                "MPEG",
+                "ASF",
+                "MOV",
+                "WMV",
+                "3GP",
+                "RM",
+                "RMVB",
+                "FLV",
+                "F4V",
+                "H.264",
+                "H.265",
+                "REAL VIDEO",
+                "MKV",
+                "WebM",
+                "HDDVD",
+                "MP4",
+                "MPG",
+                "M4V",
+                "MGV",
+                "OGV",
+                "QTM",
+                "STR",
+                "AMC",
+                "DVX",
+                "EVO",
+                "DAT",
+                "OGG",
+                "OGM",
+            ];
+            if (
+                fileA.indexOf(
+                    url.split(".")[
+                    url.split(".").length - 1
+                    ].toLocaleUpperCase()
+                ) != -1
+            ) {
+                _type = 1; //word 文件
+            } else if (
+                videoA.indexOf(
+                    url.split(".")[
+                    url.split(".").length - 1
+                    ].toLocaleUpperCase()
+                ) != -1
+            ) {
+                _type = 2; //视频
+            } else if (
+                imgA.indexOf(
+                    url.split(".")[
+                    url.split(".").length - 1
+                    ].toLocaleLowerCase()
+                ) != -1
+            ) {
+                _type = 3; //图片
+            } else if (
+                'pdf'.indexOf(
+                    url.split(".")[
+                    url.split(".").length - 1
+                    ].toLocaleLowerCase()
+                ) != -1
+            ) {
+                _type = 4; //pdf
+            } else {
+                _type = 5; //文件
+            }
+            this.$emit("setCheckJson", name, url, _type);
+            this.dialogVisiblefile2 = false
+            this.close();
+        }
+    }
+};
+</script>
+  
+<style scoped>
+.dialog_diy>>>.el-dialog {
+    /* height: 100%; */
+    margin: 10vh auto !important;
+}
+
+.dialog_diy>>>.el-dialog__header {
+    background: #454545 !important;
+    padding: 15px 20px;
+}
+
+.dialog_diy>>>.el-dialog__body {
+    height: calc(100% - 124px);
+    box-sizing: border-box;
+    padding: 0px;
+}
+
+.dialog_diy>>>.el-dialog__title {
+    color: #fff;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn {
+    top: 19px;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close {
+    color: #fff;
+}
+
+.dialog_diy>>>.el-dialog__headerbtn .el-dialog__close:hover {
+    color: #fff;
+}
+
+.dialog_diy>>>.el-dialog__body,
+.dialog_diy>>>.el-dialog__footer {
+    background: #fafafa;
+}
+
+
+.fileCss {
+    width: 100%;
+    display: flex;
+    flex-direction: row;
+    flex-wrap: nowrap;
+    justify-content: space-around;
+    align-items: center;
+    padding: 40px 0;
+    box-sizing: border-box;
+}
+
+.fileCss>div {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+}
+
+.fileCss .spanName {
+    margin-top: 10px
+}
+
+
+.info_btn,
+.teacherWord {
+    color: #fff;
+    background-color: #0f7eff;
+    padding: 8px 24px;
+    font-size: 0.9375rem;
+    box-shadow: 0px 1px 3px 0px rgb(0 0 0 / 20%), 0px 2px 2px 0px rgb(0 0 0 / 14%),
+        0px 3px 1px -2px rgb(0 0 0 / 12%);
+    min-width: 64px;
+    font-weight: 500;
+    border-radius: 4px;
+    box-sizing: border-box;
+    border: none;
+    cursor: pointer;
+}
+
+.mask {
+    background-color: rgb(0 0 0 / 30%);
+    /* position: fixed; */
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: 100%;
+    height: 100%;
+    z-index: 90;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.progressBox {
+    width: 300px;
+    height: 150px;
+    background: #fff;
+    border-radius: 10px;
+    box-shadow: 0 0 6px 1px #bfbfbf;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    flex-direction: column;
+    position: relative;
+    color: #6c6c6c;
+}
+
+.progressBox>>>.el-progress-bar__outer {
+    background-color: #d1dfff !important;
+}
+
+.progressBox .lbox {
+    height: 50px;
+    font-size: 19px;
+    display: flex;
+    align-items: center;
+    color: #747474;
+}
+
+.progressBox .lbox img {
+    width: 40px;
+    margin-right: 20px;
+}
+
+.closeCss {
+    position: absolute;
+    top: 8px;
+    right: 8px;
+    cursor: pointer;
+    width: 20px;
+    height: 20px;
+}
+
+.closeCss>img {
+    width: 100%;
+    height: 100%;
+}
+
+.file_box {
+    width: 100%;
+    padding: 15px;
+    box-sizing: border-box;
+}
+
+.student_head>>>.el-button--primary {
+    background-color: #2268bc;
+}
+
+.student_head {
+    display: flex;
+    justify-content: space-between;
+}
+
+.three {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    width: 200px;
+    height: 30px;
+}
+
+.three>div {
+    cursor: pointer;
+}
+
+.choose {
+    border-bottom: 5px solid #3994fd;
+}
+
+.student_table {
+    width: 100%;
+    height: 100%;
+    background: #f2f2f2;
+    margin-top: 10px;
+}
+
+.tup {
+    width: calc(100% - 20px);
+    height: 120px;
+    margin: 0 auto;
+    position: relative;
+}
+
+.out_box:hover .deleteWord {
+    /* display: block; */
+}
+
+.deleteWord {
+    width: 25px;
+    height: 25px;
+    position: absolute;
+    right: -25px;
+    top: -10px;
+    cursor: pointer;
+    display: none;
+}
+
+.tup>img,
+.deleteWord>img {
+    width: 100%;
+    height: 100%;
+    object-fit: cover;
+}
+
+.out_box {
+    display: flex;
+    flex-direction: column;
+    flex-wrap: nowrap;
+    width: 216px;
+    padding: 10px 0;
+    background: #fff;
+    margin: 0 10px 10px 0;
+    height: fit-content;
+    cursor: pointer;
+}
+
+.out_box:nth-child(3n){
+    margin-right: 0;
+}
+
+.bottom_box {
+    display: flex;
+    text-align: center;
+    margin: 0 auto;
+    padding: 10px 0 5px 0;
+}
+
+.bottom_box>div:nth-child(1) {
+    white-space: nowrap;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    word-break: break-all;
+    width: 200px;
+}
+
+.uploadThing {
+    background: #2268bc;
+    width: 90px;
+    height: 35px;
+    color: #fff;
+    font-size: 12px;
+    text-align: center;
+    line-height: 35px;
+    cursor: pointer;
+    border-radius: 4px;
+}
+
+.top {
+    display: flex;
+    justify-content: space-between;
+}
+
+.student_page {
+    margin-top: 30px;
+}
+
+.boxCss {
+    padding: 15px 5px;
+    display: flex;
+    flex-direction: row;
+    flex-wrap: wrap;
+    min-height: 250px;
+}
+</style>
+  

+ 287 - 177
src/components/pages/testStudent/view/component/file.vue

@@ -30,6 +30,23 @@
             <div class="detail" v-if="checkJson.detail" v-html="checkJson.detail" style="color: #00000099;margin-top: 5px;">
             </div>
             <div class="choices">
+                <div class="uploadBtn">
+                    <div class="btn" @click.stop="addImg($event)">
+                        <span>添加本地文件</span>
+                        <input type="file" accept="*" style="display: none" multiple="multiple"
+                            @change="beforeUpload($event)" />
+                    </div>
+                    <div class="btn" @click="openFileBox()">
+                        <span>从资源库添加</span>
+                    </div>
+                    <div class="switch">
+                        <el-switch
+                            active-color="#3681fc"
+                            v-model="isTong">
+                        </el-switch>
+                        <span @click="isTong = !isTong">同步至资源库</span>
+                    </div>
+                </div>
                 <div class="binfo_input">
                     <div class="fileBox" v-if="checkJson.file && checkJson.file.length">
                         <div class="fileC">
@@ -51,14 +68,14 @@
                                 </div>
                             </div>
                         </div>
-                        <div class="btn" @click.stop="openFileBox()" v-if="checktype == 1">
+                        <!-- <div class="btn" @click.stop="openFileBox()" v-if="checktype == 1">
                             <span>点击添加文件</span>
                             <input type="file" accept="*" style="display: none" @change="beforeUpload($event)" />
-                        </div>
+                        </div> -->
                     </div>
-                    <div class="uploadQ" @click.stop="openFileBox()" v-else-if="checktype == 1">
-                        <span>点击添加文件</span>
-                        <input type="file" accept="*" style="display: none" @change="beforeUpload($event)" />
+                    <div class="uploadQ" v-else-if="checktype == 1">
+                        <span>填写者上传区</span>
+                        <!-- <input type="file" accept="*" style="display: none" @change="beforeUpload($event)" /> -->
                     </div>
                     <div class="uploadQ" v-else>
                         <span>暂无添加附件</span>
@@ -179,6 +196,7 @@ export default {
             option: {
                 1: { name: '附件' },
             },
+            userid: this.$route.query.userid,
             checkJson: undefined,
             progress: 0,
             isFinishSize: 0,
@@ -194,6 +212,7 @@ export default {
             dialogVisiblefile: false,
             wurl: "",
             isloading: false,
+            isTong: false
         }
     },
     watch: {
@@ -228,177 +247,234 @@ export default {
         },
         beforeUpload(event, type) {
             // const loading = this.openLoading();
-            var file = event.target.files[0];
-            var credentials = {
-                accessKeyId: "AKIATLPEDU37QV5CHLMH",
-                secretAccessKey: "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",
-            }; //秘钥形式的登录上传
-            window.AWS.config.update(credentials);
-            window.AWS.config.region = "cn-northwest-1"; //设置区域
-
-            var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
-            var _this = this;
-
-            _this.progress = 0;
-            _this.proVisible = true;
-            _this.isFinishSize = 0;
-            _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
-            _this.$forceUpdate();
-            if (file) {
-                var params = {
-                    Key:
-                        file.name.split(".")[0] +
-                        new Date().getTime() +
-                        "." +
-                        file.name.split(".")[file.name.split(".").length - 1],
-                    ContentType: file.type,
-                    Body: file,
-                    "Access-Control-Allow-Credentials": "*",
-                    ACL: "public-read",
-                }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
-                var options = {
-                    partSize: 2048 * 1024 * 1024,
-                    queueSize: 2,
-                    leavePartsOnError: true,
-                };
-                bucket
-                    .upload(params, options)
-                    .on("httpUploadProgress", function (evt) {
-                        //这里可以写进度条
-                        // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
-                        _this.progress = parseInt((evt.loaded / evt.total) * 100);
-                        _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
-                        _this.$forceUpdate();
-                    })
-                    .send(function (err, data) {
-                        _this.progress = 100;
-                        _this.isFinishSize = _this.isAllSize;
-                        _this.$forceUpdate();
-                        setTimeout(() => {
-                            _this.proVisible = false;
-                            _this.$forceUpdate();
-                        }, 1000);
-                        // loading.close();
-                        if (err) {
-                            _this.$message.error("上传失败");
-                        } else {
-                            let _type = 2;
-                            var imgA = [
-                                "png",
-                                "jpg",
-                                "jpeg",
-                                "bmp",
-                                "gif",
-                                "webp",
-                                "psd",
-                                "svg",
-                                "tiff",
-                            ];
-                            var fileA = [
-                                "DOC",
-                                "DOCX",
-                                "DOCM",
-                                "DOTM",
-                                "DOTX",
-                                "PPTX",
-                                "PPSX",
-                                "PPT",
-                                "PPS",
-                                "PPTM",
-                                "POTM",
-                                "PPAM",
-                                "POTX",
-                                "PPSM",
-                                "XLSX",
-                                "XLS",
-                            ];
-                            var videoA = [
-                                "AVI",
-                                "NAVI",
-                                "MPEG",
-                                "ASF",
-                                "MOV",
-                                "WMV",
-                                "3GP",
-                                "RM",
-                                "RMVB",
-                                "FLV",
-                                "F4V",
-                                "H.264",
-                                "H.265",
-                                "REAL VIDEO",
-                                "MKV",
-                                "WebM",
-                                "HDDVD",
-                                "MP4",
-                                "MPG",
-                                "M4V",
-                                "MGV",
-                                "OGV",
-                                "QTM",
-                                "STR",
-                                "AMC",
-                                "DVX",
-                                "EVO",
-                                "DAT",
-                                "OGG",
-                                "OGM",
-                            ];
-                            if (
-                                fileA.indexOf(
-                                    data.Location.split(".")[
-                                        data.Location.split(".").length - 1
-                                    ].toLocaleUpperCase()
-                                ) != -1
-                            ) {
-                                _type = 1; //word 文件
-                            } else if (
-                                videoA.indexOf(
-                                    data.Location.split(".")[
-                                        data.Location.split(".").length - 1
-                                    ].toLocaleUpperCase()
-                                ) != -1
-                            ) {
-                                _type = 2; //视频
-                            } else if (
-                                imgA.indexOf(
-                                    data.Location.split(".")[
-                                        data.Location.split(".").length - 1
-                                    ].toLocaleLowerCase()
-                                ) != -1
-                            ) {
-                                _type = 3; //图片
-                            } else if (
-                                'pdf'.indexOf(
-                                    data.Location.split(".")[
-                                        data.Location.split(".").length - 1
-                                    ].toLocaleLowerCase()
-                                ) != -1
-                            ) {
-                                _type = 4; //pdf
-                            } else {
-                                _type = 5; //文件
-                            }
-                            if (_this.checkJson.file) {
-                                _this.checkJson.file.push({
-                                    name: file.name,
-                                    url: data.Location,
-                                    type: _type,
-                                });
+            let file = "";
+            let cfindex2 = 0;
+            for (var cfindex = 0; cfindex < event.target.files.length; cfindex++) {
+                file = event.target.files[cfindex];
+
+                var credentials = {
+                    accessKeyId: "AKIATLPEDU37QV5CHLMH",
+                    secretAccessKey: "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",
+                }; //秘钥形式的登录上传
+                window.AWS.config.update(credentials);
+                window.AWS.config.region = "cn-northwest-1"; //设置区域
+
+                var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
+                var _this = this;
+
+                // _this.progress = 0;
+                _this.proVisible = true;
+                // _this.isFinishSize = 0;
+                // _this.isAllSize = (file.size / 1024 / 1024).toFixed(2);
+                let _name = file.name
+                let size = file.size;
+                _this.$forceUpdate();
+                if (file) {
+                    var params = {
+                        Key:
+                            file.name.split(".")[0] +
+                            new Date().getTime() +
+                            "." +
+                            file.name.split(".")[file.name.split(".").length - 1],
+                        ContentType: file.type,
+                        Body: file,
+                        "Access-Control-Allow-Credentials": "*",
+                        ACL: "public-read",
+                    }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
+                    var options = {
+                        partSize: 2048 * 1024 * 1024,
+                        queueSize: 2,
+                        leavePartsOnError: true,
+                    };
+                    bucket
+                        .upload(params, options)
+                        .on("httpUploadProgress", function (evt) {
+                            //这里可以写进度条
+                            // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
+                            // _this.progress = parseInt((evt.loaded / evt.total) * 100);
+                            // _this.isFinishSize = (evt.loaded / 1024 / 1024).toFixed(2);
+                            // _this.$forceUpdate();
+                        })
+                        .send(function (err, data) {
+                            cfindex2++;
+
+                            // _this.progress = 100;
+                            // _this.isFinishSize = _this.isAllSize;
+                            // _this.$forceUpdate();
+                            // setTimeout(() => {
+                            //     _this.proVisible = false;
+                            //     _this.$forceUpdate();
+                            // }, 1000);
+                            setTimeout(() => {
+                                if (
+                                    cfindex2 == event.target.files.length - 1 ||
+                                    cfindex2 > event.target.files.length - 1
+                                ) {
+                                    _this.proVisible = false;
+                                }
+                            }, 1000);
+                            // loading.close();
+                            if (err) {
+                                _this.$message.error("上传失败");
                             } else {
-                                _this.checkJson.file = []
-                                _this.checkJson.file.push({
-                                    name: file.name,
-                                    url: data.Location,
-                                    type: _type,
-                                });
+                                let _type = 2;
+                                var imgA = [
+                                    "png",
+                                    "jpg",
+                                    "jpeg",
+                                    "bmp",
+                                    "gif",
+                                    "webp",
+                                    "psd",
+                                    "svg",
+                                    "tiff",
+                                ];
+                                var fileA = [
+                                    "DOC",
+                                    "DOCX",
+                                    "DOCM",
+                                    "DOTM",
+                                    "DOTX",
+                                    "PPTX",
+                                    "PPSX",
+                                    "PPT",
+                                    "PPS",
+                                    "PPTM",
+                                    "POTM",
+                                    "PPAM",
+                                    "POTX",
+                                    "PPSM",
+                                    "XLSX",
+                                    "XLS",
+                                ];
+                                var videoA = [
+                                    "AVI",
+                                    "NAVI",
+                                    "MPEG",
+                                    "ASF",
+                                    "MOV",
+                                    "WMV",
+                                    "3GP",
+                                    "RM",
+                                    "RMVB",
+                                    "FLV",
+                                    "F4V",
+                                    "H.264",
+                                    "H.265",
+                                    "REAL VIDEO",
+                                    "MKV",
+                                    "WebM",
+                                    "HDDVD",
+                                    "MP4",
+                                    "MPG",
+                                    "M4V",
+                                    "MGV",
+                                    "OGV",
+                                    "QTM",
+                                    "STR",
+                                    "AMC",
+                                    "DVX",
+                                    "EVO",
+                                    "DAT",
+                                    "OGG",
+                                    "OGM",
+                                ];
+                                if (
+                                    fileA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleUpperCase()
+                                    ) != -1
+                                ) {
+                                    _type = 1; //word 文件
+                                } else if (
+                                    videoA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleUpperCase()
+                                    ) != -1
+                                ) {
+                                    _type = 2; //视频
+                                } else if (
+                                    imgA.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleLowerCase()
+                                    ) != -1
+                                ) {
+                                    _type = 3; //图片
+                                } else if (
+                                    'pdf'.indexOf(
+                                        data.Location.split(".")[
+                                            data.Location.split(".").length - 1
+                                        ].toLocaleLowerCase()
+                                    ) != -1
+                                ) {
+                                    _type = 4; //pdf
+                                } else {
+                                    _type = 5; //文件
+                                }
+                                if (_this.checkJson.file) {
+                                    _this.checkJson.file.push({
+                                        name: _name,
+                                        url: data.Location,
+                                        type: _type,
+                                    });
+                                } else {
+                                    _this.checkJson.file = []
+                                    _this.checkJson.file.push({
+                                        name: _name,
+                                        url: data.Location,
+                                        type: _type,
+                                    });
+                                }
+                                if(_this.isTong){
+                                    let _file = {
+                                        name: _name,
+                                        url: data.Location,
+                                        type: _type,
+                                        size: _this.formatFileSize(size)
+                                    }
+                                    _this.addSource(_file)
+                                }
+                                _this.$forceUpdate();
+
+                                console.log(_this.checkJson);
+                                console.log(data.Location);
                             }
-                            _this.$forceUpdate();
-
-                            console.log(_this.checkJson);
-                            console.log(data.Location);
-                        }
-                    });
+                        });
+                }
+            }
+        },
+        addSource(file) {
+            let params = [{
+                n: encodeURIComponent(file.name),
+                file: encodeURIComponent(file.url),
+                type: file.type,
+                pid: '0',
+                uid: this.userid,
+                size: file.size,
+            }];
+            this.ajax
+                .post(this.$store.state.api + "addSourceFile", params)
+                .then((res) => {
+                    // if (_ctype == 2) {
+                    //     this.$message.success('上传成功');
+                    // }
+                })
+                .catch((err) => {
+                    console.error(err);
+                });
+        },
+        formatFileSize(bytes) {
+            if (bytes < 1024) {
+                return bytes + "B";
+            } else if (bytes < 1048576) {
+                return (bytes / 1024).toFixed(2) + "KB";
+            } else if (bytes < 1073741824) {
+                return (bytes / 1048576).toFixed(2) + "MB";
+            } else {
+                return (bytes / 1073741824).toFixed(2) + "GB";
             }
         },
         downloadFile(f) {
@@ -576,13 +652,13 @@ export default {
 }
 
 .binfo_input>.uploadQ {
-    border: 1.5px dashed #dfdfdf;
+    /* border: 1.5px dashed #d1fdfdf; */
     height: 120px;
     width: 100%;
     display: flex;
     align-items: center;
     justify-content: center;
-    background: rgb(249, 250, 251);
+    background: #f9fafb;
     color: rgb(124, 124, 124);
     border-radius: 5px;
     cursor: pointer;
@@ -767,4 +843,38 @@ export default {
 .c_input>>>.el-input__inner {
     padding: 0 5px;
     text-align: right;
-}</style>
+}
+
+.uploadBtn {
+    display: flex;
+    margin-bottom: 10px;
+    align-items: center;
+    width: 100%;
+    justify-content: flex-end;
+}
+
+.uploadBtn .btn {
+    display: flex;
+    cursor: pointer;
+    align-items: center;
+    height: 30px;
+    padding: 0 8px;
+    background: #fff;
+    color: #3681FC;
+    border: 1px solid #3681FC;
+    box-sizing: border-box;
+    border-radius: 4px;
+    font-size: 14px;
+    align-items: center;
+    margin-right: 10px;
+}
+
+.uploadBtn .switch{
+    display: flex;
+    align-items: center;
+    cursor: pointer;
+}
+.uploadBtn .switch > span{
+    margin-left: 5px;
+}
+</style>

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä