zhaoxiaohai 2 år sedan
förälder
incheckning
4d4fe81049

+ 10 - 14
src/HManagement/archives_ad/index.vue

@@ -3,9 +3,9 @@
         <list ref="list">
             <!-- 新增课程 -->
             <Header slot="add" v-if="tool.checkAuth($route.name, 'insert')">
-                <save slot="save" type="upload_image" @btnClick="uploadClick"></save>
-                <save slot="save" type="upload_video" @btnClick="uploadClick"></save>
-                <save slot="save" type="upload_fwb" @btnClick="uploadClick"></save>
+                <save slot="save" type="upload_image" />
+                <save slot="save" type="upload_video" />
+                <save slot="save" type="upload_fwb" />
             </Header>
             <!-- 详情 -->
             <template v-slot:detail="scope">
@@ -52,21 +52,17 @@ export default {
         onSuccess() {
             this.$refs.list.getList();
         },
-        uploadClick(type) {
-            window.sessionStorage.setItem('uploadType', type)
-            this.$router.push({
-                path: '/upload_archives',
-            })
-        },
+        /* 编辑素材 */
         editData(data) {
-            window.sessionStorage.setItem('uploadType', data.type)
+            window.sessionStorage.setItem('newMaterial', JSON.stringify(data));
             this.$router.push({
-                name: 'upload',
-                params: {
-                    data: JSON.stringify(data)
+                path: '/upload_archives',
+                query: {
+                    id: data.sat_sharematerialid
                 }
-            })
+            });
         },
+        
         async getAgentData() {
             const res = await this.$api.requested({
                 "classname": "webmanage.saletool.courseware.statistics.agent",

+ 1 - 1
src/HManagement/archives_ad/modules/delete.vue

@@ -22,7 +22,7 @@ export default {
         "classname": "webmanage.saletool.sharematerial.sharematerial",
         "method": "delete",
         "content": {
-          "sat_sharematerialid": this.data.sat_sharematerialid
+          "sat_sharematerialid": [this.data.sat_sharematerialid]
         }
       }).then(res => {
         this.tool.showMessage(res)

+ 18 - 2
src/HManagement/archives_ad/modules/list.vue

@@ -98,25 +98,41 @@ export default {
                 }
             }).then(res => {
                 if (res.msg != '成功') return this.$message.error(res.data);
-                console.log('获取分类', res)
                 this.selectList = res.data;
             })
         },
         /* 获取列表 */
         getList(init = false) {
+            let initID = '9999' + JSON.parse(window.sessionStorage.getItem("active_account")).userid;
             //初始化分页
             if (init) this.currentPage = 1;
             //是否分类筛选
             (this.selectClassId) ? this.params.content.where.sat_sharematerial_classid = this.selectClassId : delete (this.params.content.where.sat_sharematerial_classid);
             //发送请求
             this.$api.requested(this.params).then(res => {
-                console.log("列表", res)
+                console.log("素材列表", res)
                 if (res.msg != '成功') return this.$message.error(res.data);
+                let deleteList = [];
+                res.data.forEach(v => (initID == v.sat_sharematerial_classid && v.title == '') ? deleteList.push(v.sat_sharematerialid) : '');
+                if (deleteList.length != 0) this.handleDelete(deleteList);
                 this.list = res.data;
                 this.total = res.total;
                 this.params.content.pageNumber = res.pageNumber;
             })
         },
+        /* 处理批量删除 */
+        handleDelete(list) {
+            this.$api.requested({
+                "classname": "webmanage.saletool.sharematerial.sharematerial",
+                "method": "delete",
+                "content": {
+                    "sat_sharematerialid": list
+                }
+            }).then(res => {
+                console.log("处理删除", res);
+                if(res.msg=='成功') this.getList();
+            })
+        },
         /* 切换分页 */
         handleCurrentChange(e) {
             this.currentPage = e;

+ 8 - 9
src/SManagement/archives_ad/components/Edit.vue

@@ -9,25 +9,24 @@ export default {
     return {
     };
   },
-  computed:{
+  computed: {
   },
   props: ['fileData'],
-  watch:{
+  watch: {
   },
   methods: {
-    edit () {
-      window.sessionStorage.setItem('uploadType',this.fileData.type)      
+    edit() {
+      window.sessionStorage.setItem('newMaterial', JSON.stringify(this.fileData));
       this.$router.push({
-        name: 'upload',
-        params: {
-          data: JSON.stringify(this.fileData)
+        path: '/upload_archives',
+        query: {
+          id: this.fileData.sat_sharematerialid
         }
-      })
+      });
     }
   },
 };
 </script>
 
 <style scoped>
-
 </style>

+ 1 - 1
src/SManagement/archives_ad/components/delete.vue

@@ -31,7 +31,7 @@ export default {
         "classname": "webmanage.saletool.sharematerial.sharematerial",
         "method": "delete",
         "content": {
-          "sat_sharematerialid": this.data.sat_sharematerialid
+          "sat_sharematerialid": [this.data.sat_sharematerialid]
         }
       }
       this.$api.requested(param).then(res => {

+ 47 - 20
src/SManagement/archives_ad/index.vue

@@ -3,16 +3,18 @@
     <div class="normal-card">
       <div class="header-panl">
         <div class="left">
-          <search @searchActive="searchActive" @clearData="clearData()" v-if="tool.checkAuth($route.name,'read')"></search>
+          <search @searchActive="searchActive" @clearData="clearData()" v-if="tool.checkAuth($route.name, 'read')">
+          </search>
           <category-select label="素材分类" :selectList="selectList" @changeSelect="changeSelect"
-            @clearSelect="clearSelect()" v-if="tool.checkAuth($route.name,'read')">
+            @clearSelect="clearSelect()" v-if="tool.checkAuth($route.name, 'read')">
           </category-select>
         </div>
         <!--最新最热切换-->
-        <hot-new-control @sortTypeChange="sortTypeChange" v-if="tool.checkAuth($route.name,'read')"></hot-new-control>
+        <hot-new-control @sortTypeChange="sortTypeChange" v-if="tool.checkAuth($route.name, 'read')"></hot-new-control>
       </div>
       <!--素材列表-->
-      <list :fileData="fileData" @listItemClick="listItemClick" @itemEdit="itemEdit" :isHandle="false" v-if="tool.checkAuth($route.name,'read')">
+      <list :fileData="fileData" @listItemClick="listItemClick" @itemEdit="itemEdit" :isHandle="false"
+        v-if="tool.checkAuth($route.name, 'read')">
       </list>
       <pagination :total="total" :pageSize="params.content.pageSize" :currentPage="params.content.pageNumber"
         @pageChange="pageChange">
@@ -33,7 +35,7 @@ import Edit from '@/SManagement/archives_ad/components/Edit'
 import Pagination from '@/components/pagination/Pagination'
 export default {
   name: 'index',
-  data () {
+  data() {
     return {
       params: {
         "classname": "saletool.sharematerial.sharematerial",
@@ -78,56 +80,74 @@ export default {
   },
   computed: {
   },
-  created () {
+  created() {
     this.getFileList()
     this.getSelectList()
   },
   methods: {
     //获取文件数据
-    getFileList () {
+    getFileList() {
       this.$api.requested(this.params).then(res => {
         this.total = res.total
-        for(let i = 0; i < res.data.length; i++) {
+        for (let i = 0; i < res.data.length; i++) {
           let list = this.fileType.fileList(res.data[i].attinfos)
-          if(!list.length) continue;
+          if (!list.length) continue;
           let obj = list.find(item => item.fileType == 'image')
-          if(!obj) continue;
+          if (!obj) continue;
           res.data[i].cover = this.fileType.getSpecifiedImage(obj)
           res.data.attinfos = list
         }
+        let initID = '9999' + JSON.parse(window.sessionStorage.getItem("active_account")).userid;
+        let deleteList = [];
+        res.data.forEach(v => (initID == v.sat_sharematerial_classid && v.title == '') ? deleteList.push(v.sat_sharematerialid) : '');
+        if (deleteList.length != 0) this.handleDelete(deleteList);
         this.fileData = res.data
         this.params.content.sort = res.sort
       })
     },
+    /* 处理批量删除 */
+    handleDelete(list) {
+      console.log("处理删除")
+      this.$api.requested({
+        "classname": "webmanage.saletool.sharematerial.sharematerial",
+        "method": "delete",
+        "content": {
+          "sat_sharematerialid": list
+        }
+      }).then(res => {
+        console.log("处理删除", res);
+        if (res.msg == '成功') this.getList();
+      })
+    },
     //获取分类列表
-    getSelectList () {
+    getSelectList() {
       this.$api.requested(this.select).then(res => {
         this.selectList = res.data
       })
     },
     //查询
-    searchActive (result) {
+    searchActive(result) {
       if (!result) return
       this.params.content.where.condition = result
       this.getFileList()
     },
-    sortTypeChange (name) {
+    sortTypeChange(name) {
       for (let i = 0; i < this.params.content.sort.length; i++) {
         this.params.content.sort[i].sorted = this.params.content.sort[i].sortname == name ? 1 : 0
       }
       this.getFileList()
     },
     //赛选
-    changeSelect (id) {
+    changeSelect(id) {
       this.params.content.where.sat_sharematerial_classid = id[id.length - 1]
       this.getFileList()
     },
     //清空赛选
-    clearSelect () {
+    clearSelect() {
       this.getFileList()
     },
     //列表单击事件
-    listItemClick (data) {
+    listItemClick(data) {
       let param = {
         "classname": "saletool.sharematerial.sharematerial",
         "method": "selectDetail",
@@ -144,22 +164,23 @@ export default {
         })
       })
     },
-    itemEdit (data) {
+    itemEdit(data) {
+      return console.log("应该没有用到")
       this.$router.push({
         path: '/upload_archives',
         params: JSON.stringify(data)
       })
     },
-    clearData () {
+    clearData() {
       this.params.content.where.condition = ''
       this.getFileList()
     },
-    uploadClick () {
+    uploadClick() {
       this.$router.push({
         path: '/upload_archives'
       })
     },
-    pageChange (n) {
+    pageChange(n) {
       this.params.content.pageNumber = n
       this.getFileList()
     }
@@ -173,26 +194,32 @@ export default {
   box-sizing: border-box;
   position: relative;
 }
+
 .normal-card .header-panl {
   display: flex;
   justify-content: space-between;
   margin: 20px 0 30px 0;
 }
+
 .normal-card .header-panl .left {
   display: flex;
   align-items: center;
 }
+
 .normal-card .header-panl .left .select {
   margin-right: 16px;
   display: flex;
   align-items: center;
 }
+
 .normal-card .header-panl .left .select span {
   margin-right: 8px;
 }
+
 /deep/ .input-with-select {
   height: 34px;
 }
+
 .el-pagination {
   position: absolute;
   right: 16px;

+ 106 - 108
src/SManagement/archives_admag/index.vue

@@ -1,45 +1,39 @@
 <template>
-<div style="height:100%">
-  <Header v-if="tool.checkAuth($route.name,'insert')">
-    <save slot="save" type="upload_image" @btnClick="uploadClick"></save>
-    <save slot="save" type="upload_video" @btnClick="uploadClick"></save>
-    <save slot="save" type="upload_fwb" @btnClick="uploadClick"></save>
-  </Header>
-  <div class="normal-card">
+  <div style="height:100%">
+    <Header v-if="tool.checkAuth($route.name, 'insert')">
+      <save slot="save" type="upload_image"></save>
+      <save slot="save" type="upload_video"></save>
+      <save slot="save" type="upload_fwb"></save>
+    </Header>
+    <div class="normal-card">
       <div class="header-panl">
         <div class="left">
-          <search @searchActive="searchActive" @clearData="clearData()" v-if="tool.checkAuth($route.name,'read')"></search>
-          <category-select  label="素材分类" 
-                            :selectList="selectList" 
-                            @changeSelect="changeSelect"
-                            @clearSelect="clearSelect()"
-                            v-if="tool.checkAuth($route.name,'read')">
-          </category-select> 
+          <search @searchActive="searchActive" @clearData="clearData()" v-if="tool.checkAuth($route.name, 'read')">
+          </search>
+          <category-select label="素材分类" :selectList="selectList" @changeSelect="changeSelect"
+            @clearSelect="clearSelect()" v-if="tool.checkAuth($route.name, 'read')">
+          </category-select>
         </div>
         <!--最新最热切换-->
-        <hot-new-control @sortTypeChange="sortTypeChange" v-if="tool.checkAuth($route.name,'read')"></hot-new-control>
+        <hot-new-control @sortTypeChange="sortTypeChange" v-if="tool.checkAuth($route.name, 'read')"></hot-new-control>
       </div>
       <!--素材列表-->
-      <list :fileData="fileData" 
-            @listItemClick="listItemClick"
-            :isHandle="true"
-            v-if="tool.checkAuth($route.name,'read')">
-            <template v-slot:edit="scope">
-              <Edit :fileData="scope.data"  v-if="tool.checkAuth($route.name,'update')"></Edit>
-            </template>
-            <template v-slot:delete="scope">
-              <Delete :data="scope.data" @removeSuccess="getFileList" v-if="tool.checkAuth($route.name,'delete')"></Delete>
-            </template>
+      <list :fileData="fileData" @listItemClick="listItemClick" :isHandle="true"
+        v-if="tool.checkAuth($route.name, 'read')">
+        <template v-slot:edit="scope">
+          <Edit :fileData="scope.data" v-if="tool.checkAuth($route.name, 'update')"></Edit>
+        </template>
+        <template v-slot:delete="scope">
+          <Delete :data="scope.data" @removeSuccess="getFileList" v-if="tool.checkAuth($route.name, 'delete')"></Delete>
+        </template>
       </list>
-      <pagination 
-            :total="total"
-            :pageSize="params.content.pageSize"
-            :currentPage="params.content.pageNumber"
-            @pageChange="pageChange">
+      <pagination :total="total" :pageSize="params.content.pageSize" :currentPage="params.content.pageNumber"
+        @pageChange="pageChange">
       </pagination>
-      <detail ref="detail" v-if="currentFile && tool.checkAuth($route.name,'read')" :currentSelectFile="currentFile"></detail>
+      <detail ref="detail" v-if="currentFile && tool.checkAuth($route.name, 'read')" :currentSelectFile="currentFile">
+      </detail>
+    </div>
   </div>
-</div>
 </template>
 
 <script>
@@ -62,16 +56,16 @@ export default {
   data() {
     return {
       params: {
-          "classname": "saletool.sharematerial.sharematerial",
-          "method": "selectMyList",
-          "content": {
-              "pageNumber": 1,
-              "pageSize": 12,
-              "where": {
-                  "condition": "",
-                  "sat_sharematerial_classid": null
-              }
+        "classname": "saletool.sharematerial.sharematerial",
+        "method": "selectMyList",
+        "content": {
+          "pageNumber": 1,
+          "pageSize": 12,
+          "where": {
+            "condition": "",
+            "sat_sharematerial_classid": null
           }
+        }
       },
       //分类配置
       select: {
@@ -79,15 +73,15 @@ export default {
         "classname": "saletool.sharematerial.sharematerial",
         "method": "select",
         "content": {
-            "parentid": 0
+          "parentid": 0
         }
       },
-      fileData:[],
+      fileData: [],
       //列表数据
       list: [],
       //分类列表
       selectList: [],
-      total:20,
+      total: 20,
       //当前查看的素材
       currentFile: ''
     };
@@ -104,7 +98,7 @@ export default {
     Header,
     save
   },
-  computed:{
+  computed: {
   },
   created() {
     this.getFileList()
@@ -117,30 +111,30 @@ export default {
         this.total = res.total
         this.fileData = res.data
         this.fileData.forEach((item) => {
-          item.attinfos = matchingFileType.fileList(item.attinfos)          
+          item.attinfos = matchingFileType.fileList(item.attinfos)
         })
         this.params.content.sort = res.sort
       })
     },
     //获取分类列表
     getSelectList() {
-      this.$api.requested(this.select).then( res => {
+      this.$api.requested(this.select).then(res => {
         this.selectList = res.data
       })
     },
     //查询
     searchActive(result) {
-      if(!result) return
+      if (!result) return
       this.params.content.where.condition = result
       this.$api.requested(this.params).then(res => {
         this.fileData = res.data
         this.fileData.forEach((item) => {
-          item.attinfos = matchingFileType.fileList(item.attinfos)          
+          item.attinfos = matchingFileType.fileList(item.attinfos)
         })
       })
     },
     sortTypeChange(name) {
-      for(let i=0;i<this.params.content.sort.length;i++) {
+      for (let i = 0; i < this.params.content.sort.length; i++) {
         this.params.content.sort[i].sorted = this.params.content.sort[i].sortname == name ? 1 : 0
       }
       this.getFileList()
@@ -148,7 +142,7 @@ export default {
     //赛选
     changeSelect(id) {
       this.params.content.where.sat_sharematerial_classid = id[id.length - 1]
-      this.getFileList()      
+      this.getFileList()
     },
     //清空赛选
     clearSelect() {
@@ -157,13 +151,13 @@ export default {
     //列表单击事件
     listItemClick(data) {
       let param = {
-          "classname": "saletool.sharematerial.sharematerial",
-          "method": "selectDetail",
-          "content": {
-              "sat_sharematerialid":data.sat_sharematerialid
-          }
+        "classname": "saletool.sharematerial.sharematerial",
+        "method": "selectDetail",
+        "content": {
+          "sat_sharematerialid": data.sat_sharematerialid
+        }
       }
-      this.$api.requested(param).then( res => {
+      this.$api.requested(param).then(res => {
         res.data.content = atob(res.data.content)
         res.data.attinfos = this.fileType.fileList(res.data.attinfos)
         this.currentFile = res.data
@@ -174,20 +168,14 @@ export default {
     },
     itemEdit(data) {
       this.$router.push({
-        path:'/upload_archives',
-        params:JSON.stringify(data)
+        path: '/upload_archives',
+        params: JSON.stringify(data)
       })
     },
     clearData() {
       this.params.content.where.condition = ''
       this.getFileList()
     },
-    uploadClick(type) {
-      window.sessionStorage.setItem('uploadType',type)
-      this.$router.push({
-        path:'/upload_archives',
-      })
-    },
     pageChange(n) {
       this.params.content.pageNumber = n
       this.getFileList()
@@ -197,49 +185,59 @@ export default {
 </script>
 
 <style scoped>
-*{
+* {
+  box-sizing: border-box;
+}
+
+.normal-card {
+  min-height: 100%;
   box-sizing: border-box;
+  position: relative;
+}
+
+.normal-card .header-panl {
+  display: flex;
+  justify-content: space-between;
+  margin: 20px 0 30px 0;
+}
+
+.normal-card .header-panl .left {
+  display: flex;
+  align-items: center;
+}
+
+.normal-card .header-panl .left .select {
+  margin-right: 16px;
+  display: flex;
+  align-items: center;
+}
+
+.normal-card .header-panl .left .select span {
+  margin-right: 8px;
+}
+
+.normal-card .header-panl .left .search {
+  height: 36px;
+}
+
+/deep/ .input-with-select {
+  height: 34px;
+}
+
+.el-button {
+  width: 180px;
+  border-radius: 4px 4px 4px 4px;
+  border: 1px solid #3874F6;
+}
+
+/deep/.el-button span {
+  transform: translateX(-5px) !important;
+}
+
+.el-pagination {
+  position: absolute;
+  right: 16px;
+  bottom: 0;
+  margin-top: 16px;
 }
-  .normal-card {
-    min-height: 100%;
-    box-sizing: border-box;
-    position: relative;
-  }
-  .normal-card .header-panl {
-    display: flex;
-    justify-content: space-between;
-    margin: 20px 0 30px 0;
-  }
-  .normal-card .header-panl .left {
-    display: flex;
-    align-items: center;
-  }
-  .normal-card .header-panl .left .select {
-    margin-right: 16px;
-    display: flex;
-    align-items: center;
-  }
-  .normal-card .header-panl .left .select span {
-    margin-right: 8px;
-  }
-  .normal-card .header-panl .left .search {
-    height: 36px;
-  }
-  /deep/ .input-with-select {
-    height: 34px;
-  }
-  .el-button {
-    width: 180px;
-    border-radius: 4px 4px 4px 4px;
-    border: 1px solid #3874F6;
-  }
-  /deep/.el-button span {
-    transform: translateX(-5px) !important;
-  }
-  .el-pagination {
-    position: absolute;
-    right: 16px;
-    bottom: 0;
-    margin-top: 16px;
-  }
 </style>

+ 49 - 60
src/SManagement/archives_upload/components/FileList.vue

@@ -6,38 +6,24 @@
         <slot name="upload"></slot>
       </div>
     </div>
-    <el-table
-      :data="attinfos"
-      border
-      style="width: 100%"
-      :header-cell-style="{background:'#EEEEEE'}">
-      <el-table-column
-        prop="document"
-        label="文件名称"
-        width="500">
+    <el-table :data="attinfos" border style="width: 100%" :header-cell-style="{ background: '#EEEEEE' }">
+      <el-table-column prop="document" label="文件名称" width="500">
         <template slot-scope="scope">
           <div class="editor-handle">
-            <span>{{scope.row.document.substr(0,scope.row.document.indexOf('.'))}}</span>
+            <span>{{ scope.row.document.substr(0, scope.row.document.indexOf('.')) }}</span>
             <!-- <img src="@/assets/edit.png" alt="" style="vertical-align: middle;margin-left:10px;cursor:pointer" @click="isShow = true"> -->
             <!-- <el-input @blur="inputFocus()" v-if="isShow" v-model="text"></el-input> -->
           </div>
         </template>
       </el-table-column>
-      <el-table-column
-        prop="createdate"
-        label="上传时间"
-        width="250">
+      <el-table-column prop="createdate" label="上传时间" width="250">
       </el-table-column>
-      <el-table-column
-        prop="contentlength"
-        label="文件大小">
+      <el-table-column prop="contentlength" label="文件大小">
         <template slot-scope="scope">
-          <span>{{(scope.row.contentlength / 1024 / 1024).toFixed(2)}}M</span>
+          <span>{{ (scope.row.contentlength / 1024 / 1024).toFixed(2) }}M</span>
         </template>
       </el-table-column>
-      <el-table-column
-        label="操作"
-        width="150">
+      <el-table-column label="操作" width="150">
         <template slot-scope="scope">
           <div class="handle">
             <slot name="download" :data="scope.row"></slot>
@@ -54,15 +40,15 @@ export default {
   name: 'FileList',
   data() {
     return {
-      tableData:[],
-      isShow:false,
+      tableData: [],
+      isShow: false,
       text: ''
     };
   },
-  props:['attinfos'],
-  computed:{
+  props: ['attinfos'],
+  computed: {
   },
-  watch:{
+  watch: {
   },
   filters: {
 
@@ -72,45 +58,48 @@ export default {
   methods: {
     inputFocus() {
       this.isShow = false
-      this.$emit('titleUpdata',this.text)
-    },
+      this.$emit('titleUpdata', this.text)
+    }
   },
 };
 </script>
 
 <style scoped>
-  .file-list {
-    padding: 16px 16px;
-    background: #ffffff;
-    margin-top: 10px;
-  }
-  .file-list .title {
-    font-size: 14px;
-    font-weight: bold;
-    color: #333333;
-    margin-bottom: 30px;
-  }
-  .file-list .header1 {
-    display: flex;
-    justify-content: space-between;
-    align-items: center;
-  }
-  .file-list .header1 .el-button {
-    width: 84px;
-    height: 36px;
-  }
-  .editor-handle {
-    position: relative;
-  }
-  .editor-handle .span {
+.file-list {
+  padding: 16px 16px;
+  background: #ffffff;
+  margin-top: 10px;
+}
 
-  }
-  .editor-handle img {
+.file-list .title {
+  font-size: 14px;
+  font-weight: bold;
+  color: #333333;
+  margin-bottom: 30px;
+}
 
-  }
-  .editor-handle .el-input {
-    position: absolute;
-    left: 0;
-    top: 0;
-  }
+.file-list .header1 {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.file-list .header1 .el-button {
+  width: 84px;
+  height: 36px;
+}
+
+.editor-handle {
+  position: relative;
+}
+
+.editor-handle .span {}
+
+.editor-handle img {}
+
+.editor-handle .el-input {
+  position: absolute;
+  left: 0;
+  top: 0;
+}
 </style>

+ 44 - 16
src/SManagement/archives_upload/components/save.vue

@@ -7,15 +7,15 @@
     <img src="@/assets/upload2.png" alt="">
     上传
   </el-button>
-  <el-button type="primary" size="small" @click="btnClick(1)" v-else-if="type == 'upload_image'">
+  <el-button type="primary" size="small" @click="add(1)" v-else-if="type == 'upload_image'">
     <img src="@/assets/upload2.png" alt="">
     上传图片
   </el-button>
-  <el-button type="primary" size="small" @click="btnClick(2)" v-else-if="type == 'upload_video'">
+  <el-button type="primary" size="small" @click="add(2)" v-else-if="type == 'upload_video'">
     <img src="@/assets/upload2.png" alt="">
     上传视频
   </el-button>
-  <el-button type="primary" size="small" @click="btnClick(3)" v-else-if="type == 'upload_fwb'">
+  <el-button type="primary" size="small" @click="add(3)" v-else-if="type == 'upload_fwb'">
     <img src="@/assets/upload2.png" alt="">
     上传图文
   </el-button>
@@ -35,28 +35,56 @@ export default {
       }
     }
   },
-  computed:{
+  computed: {
   },
-  watch:{
+  watch: {
   },
   methods: {
-    btnClick(type) {
-      this.$emit('btnClick',type)
+    /* 新增并编辑素材 */
+    add(type) {
+      let classid = '9999' + JSON.parse(window.sessionStorage.getItem("active_account")).userid;
+      this.$api.requested({
+        "classname": "webmanage.saletool.sharematerial.sharematerial",
+        "method": "insertOrUpdate",
+        "content": {
+          "title": "",
+          "sat_sharematerial_classid": classid,
+          "notes": "",
+          "tag": [],
+          "canfiledownload": 1,
+          "content": "",
+          "sat_sharematerialid": 0,
+          type
+        }
+      }).then(res => {
+        if (res.msg != '成功') return this.$message.error(res.data);
+        window.sessionStorage.setItem('newMaterial', JSON.stringify(res.data));
+        this.$router.push({
+          path: '/upload_archives',
+          query: {
+            id: res.data.sat_sharematerialid
+          }
+        });
+      })
+    },
+    btnClick(){
+      this.$emit("btnClick")
     }
   },
 };
 </script>
 
 <style scoped>
-*{
+* {
   box-sizing: border-box;
 }
-  /deep/span {
-    display: flex;
-    align-items: center;
-  }
-  img {
-    padding-right: 5px;
-  }
-  
+
+/deep/span {
+  display: flex;
+  align-items: center;
+}
+
+img {
+  padding-right: 5px;
+}
 </style>

+ 33 - 44
src/SManagement/archives_upload/index.vue

@@ -7,7 +7,6 @@
 
     <el-row>
       <el-col :span="14">
-        <!-- 基础功能 -->
         <!--标题 分类-->
         <Set ref="set" @setSelectChange="selectChange" @setTitleChange="titleChange" />
         <!--文件列表-->
@@ -29,7 +28,7 @@
       </el-col>
       <!-- 授权范围 -->
       <el-col :span="10">
-        <scopeOfauth :defaultData="defaultData" appid="sat_sharematerialid" @onChecked="onChecked" />
+        <scopeOfauth style="margin-left:10px;" :defaultData="defaultData" appid="sat_sharematerialid" @onChecked="onChecked" />
       </el-col>
     </el-row>
   </div>
@@ -73,10 +72,10 @@ export default {
         }
       },
       //上传的初始数据
-      uploadCacheData: '',
+      uploadCacheData: {},
       //创建素材模板的id
       create_sat_sharematerialid: 0,
-      uploadType: window.sessionStorage.getItem('uploadType'),
+      uploadType: null,
       /* 授权使用 */
       defaultData: {},
       authData: {},
@@ -99,20 +98,40 @@ export default {
   },
   watch: {
   },
-  created() {
-    this.getFileCache()
+  mounted() {
+    //获取上传模板
+    this.uploadData(JSON.parse(window.sessionStorage.getItem("newMaterial")))
   },
   beforeDestroy() {
     this.removeAllData()
   },
   methods: {
+    //获取素材模板
+    uploadData(data) {
+      this.cacheInfo.content.sat_sharematerialid = data.sat_sharematerialid;
+      this.cacheInfo.content.title = data.title;
+      this.cacheInfo.content.sat_sharematerial_classid = data.sat_sharematerial_classid;
+      this.cacheInfo.content.content = data.content;
+      this.uploadType = data.type;
+      console.log("type", this.uploadType)
+      this.$refs.set.ruleForm.title = data.title;
+      this.$refs.set.ruleForm.category = data.sat_sharematerial_classid;
+      this.uploadCacheData.sat_sharematerialid = data.sat_sharematerialid;
+      this.uploadCacheData.attinfos = data.attinfos;
+      this.uploadCacheData.status = "完成";
+      this.query_auth();
+    },
     //保存
     save() {
+      console.log('保存')
       this.$refs.set.$refs.form.validate((val) => {
         var that = this
         if (val) {
           if (this.uploadType == '3') this.cacheInfo.content.content = weBtoa(this.$refs.editor.editor.getHtml())
-          this.cacheInfo.content.type = this.uploadType
+          this.cacheInfo.content.type = this.uploadType;
+          console.log(this.cacheInfo.content)
+          //判断所属ID是否为初始ID
+          if (this.cacheInfo.content.sat_sharematerial_classid == '9999' + JSON.parse(window.sessionStorage.getItem("active_account")).userid) return this.$message.error('请选择素材分类');
           this.$api.requested(this.cacheInfo).then(res => {
             let param = {
               "classname": "webmanage.saletool.sharematerial.sharematerial",
@@ -142,7 +161,6 @@ export default {
             type: 'error'
           })
         }
-
       })
     },
     // 查询授权信息
@@ -164,8 +182,6 @@ export default {
         "content": this.authData
       };
       const res = await this.$api.requested(p)
-      console.log("新增授权范围", res)
-      console.log("新增授权范围", p)
       res.code === 0 ? this.$notify({
         title: '失败',
         message: res.data,
@@ -176,32 +192,7 @@ export default {
     onChecked(param) {
       this.authData = param
     },
-    //获取上传数据模板
-    getFileCache() {
-      this.$api.requested(this.cacheInfo).then(res => {
-        this.uploadCacheData = res.data
-        this.create_sat_sharematerialid = this.uploadCacheData.sat_sharematerialid
-        this.cacheInfo.content.sat_sharematerialid = this.uploadCacheData.sat_sharematerialid
-        this.query_auth();
-        this.isEditFile()
-      })
-    },
-    //走编辑逻辑
-    isEditFile() {
-      if (this.$route.params.data) {
-        let data = JSON.parse(this.$route.params.data)
-        this.cacheInfo.content.sat_sharematerialid = data.sat_sharematerialid
-        this.cacheInfo.content.title = data.title
-        this.cacheInfo.content.sat_sharematerial_classid = data.sat_sharematerial_classid
-        this.cacheInfo.content.content = data.content
 
-        this.$refs.set.ruleForm.title = data.title
-        this.$refs.set.ruleForm.category = data.sat_sharematerial_classid
-        this.uploadCacheData.sat_sharematerialid = data.sat_sharematerialid
-        this.uploadCacheData.attinfos = data.attinfos
-        this.uploadCacheData.status = "完成"
-      }
-    },
     //文件上传成功
     onSuccess(id) {
       let param = {
@@ -217,15 +208,13 @@ export default {
         }
       }
       this.$api.requested(param).then(res => {
-        if (res.msg != '成功') {
-          this.$notify({
-            title: '提示',
-            message: '上传失败',
-            type: 'error'
-          })
-        } else {
-          this.uploadCacheData.attinfos = this.uploadCacheData.attinfos.concat(res.data[0]);
-        }
+        if (res.msg != '成功') return this.$notify({
+          title: '提示',
+          message: '上传失败',
+          type: 'error'
+        })
+
+        this.uploadCacheData.attinfos = this.uploadCacheData.attinfos.concat(res.data);
       })
 
     },