Browse Source

素材上传

zhaoxiaohai 3 years ago
parent
commit
5ed8bc0d50

+ 60 - 54
src/SManagement/archives_upload/components/Set.vue

@@ -1,20 +1,13 @@
 <template>
   <div class="file-set">
     <p class="title">素材设置</p>
-    <el-form ref="form" 
-             :model="ruleForm" 
-             label-width="90px" 
-             label-position="left"
-             :rules="rules">
+    <el-form ref="form" :model="ruleForm" label-width="90px" label-position="left" :rules="rules">
       <el-form-item label="标题" prop="title">
         <el-input v-model="ruleForm.title" @input="titleChange"></el-input>
       </el-form-item>
       <el-form-item label="素材分类" prop="category">
-        <el-cascader :options="seleteList" 
-                     :show-all-levels="false" 
-                     v-model="ruleForm.category" 
-                     :props="props"
-                     @change="changeSelect">
+        <el-cascader :options="seleteList" :show-all-levels="false" v-model="ruleForm.category" :props="props"
+          @change="changeSelect">
         </el-cascader>
       </el-form-item>
     </el-form>
@@ -27,29 +20,35 @@ export default {
   name: 'Set',
   data() {
     return {
-      select:{
-          "accesstoken": "0b62a25619912a732160863854a9f19d",
-          "classname": "saletool.sharematerial.sharematerial",
-          "method": "select",
-          "content": {
-              "parentid": 0
-          }
-      },  
+      select: {
+        "accesstoken": "0b62a25619912a732160863854a9f19d",
+        "classname": "saletool.sharematerial.sharematerial",
+        "method": "select",
+        "content": {
+          "parentid": 0
+        }
+      },
       props: {
-        value:'sat_sharematerial_classid',
+        value: 'sat_sharematerial_classid',
         label: 'classname',
+        setTitleChange: {
+          type: Function
+        },
+        setSelectChange: {
+          type: Function
+        }
       },
-      ruleForm:{
+      ruleForm: {
         title: '',
         category: ''
       },
       rules: {
         title: [
-            { required: true, message: '请输入标题', trigger: 'blur' },
-          ],
-          category: [
-            { required: true, message: '请选择分类', trigger: 'blur' }
-          ],
+          { required: true, message: '请输入标题', trigger: 'blur' },
+        ],
+        category: [
+          { required: true, message: '请选择分类', trigger: 'blur' }
+        ],
       },
       seleteList: []
     };
@@ -57,23 +56,25 @@ export default {
   components: {
     CategorySelect
   },
-  computed:{
+  computed: {
   },
-  watch:{
+  watch: {
 
   },
   created() {
     this.getSeleteData()
   },
   methods: {
+    /* 修改分类 */
     changeSelect(id) {
-      this.$parent.cacheInfo.content.sat_sharematerial_classid = id[id.length - 1]
+      this.$emit("setSelectChange", id[id.length - 1])
     },
+    /* 修改标题 */
     titleChange(val) {
-      this.$parent.cacheInfo.content.title = val
+      this.$emit("setTitleChange", val)
     },
     getSeleteData() {
-      this.$api.requested(this.select).then( res => {
+      this.$api.requested(this.select).then(res => {
         this.seleteList = res.data
       })
     }
@@ -82,28 +83,33 @@ export default {
 </script>
 
 <style scoped>
-  *{
-    box-sizing: border-box;
-  }
-  .file-set {
-    padding: 16px 16px;
-    background: #ffffff;
-  }
-  .file-set .title {
-    font-size: 14px;
-    font-weight: bold;
-    color: #333333;
-    margin-bottom: 30px;
-  }
-  .file-set .el-input {
-    width: 400px;
-    height: 32px;
-    border-radius: 4px 4px 4px 4px;
-  }
-  .el-form {
-    display: flex;
-  }
-  .el-form-item {
-    margin-right: 50px;
-  }
+* {
+  box-sizing: border-box;
+}
+
+.file-set {
+  padding: 16px 16px;
+  background: #ffffff;
+}
+
+.file-set .title {
+  font-size: 14px;
+  font-weight: bold;
+  color: #333333;
+  margin-bottom: 30px;
+}
+
+.file-set .el-input {
+  width: 400px;
+  height: 32px;
+  border-radius: 4px 4px 4px 4px;
+}
+
+.el-form {
+  display: flex;
+}
+
+.el-form-item {
+  margin-right: 50px;
+}
 </style>

+ 86 - 21
src/SManagement/archives_upload/index.vue

@@ -4,27 +4,40 @@
     <Header>
       <save slot="save" @btnClick="save()"></save>
     </Header>
-    <!--标题 分类-->
-    <Set ref="set"></Set>
-    <!--文件列表-->
-    <file-list :attinfos="uploadCacheData.attinfos" v-if="uploadType == '1' || uploadType == '2'">
-      <upload slot="upload" @onSuccess="onSuccess" target="archives" :classType="uploadType"></upload>
-      <template v-slot:delete="scope">
-        <delete1 :data="scope.data"></delete1>
-      </template>
-      <template v-slot:download="scope">
-        <download :data="scope.data"></download>
-      </template>
-    </file-list>
-    <!--富文本-->
-    <file-text ref="text" v-if="uploadType == '3'">
-      <Editor ref="editor" slot="editor" :content="cacheInfo.content.content" :id="uploadCacheData.sat_sharematerialid">
-      </Editor>
-    </file-text>
+
+    <el-row>
+      <el-col :span="14">
+        <!-- 基础功能 -->
+        <!--标题 分类-->
+        <Set ref="set" @setSelectChange="selectChange" @setTitleChange="titleChange" />
+        <!--文件列表-->
+        <file-list :attinfos="uploadCacheData.attinfos" v-if="uploadType == '1' || uploadType == '2'">
+          <upload slot="upload" @onSuccess="onSuccess" target="archives" :classType="uploadType"></upload>
+          <template v-slot:delete="scope">
+            <delete1 :data="scope.data"></delete1>
+          </template>
+          <template v-slot:download="scope">
+            <download :data="scope.data"></download>
+          </template>
+        </file-list>
+        <!--富文本-->
+        <file-text ref="text" v-if="uploadType == '3'">
+          <Editor ref="editor" slot="editor" :content="cacheInfo.content.content"
+            :id="uploadCacheData.sat_sharematerialid">
+          </Editor>
+        </file-text>
+      </el-col>
+      <!-- 授权范围 -->
+      <el-col :span="10">
+        <scopeOfauth :defaultData="defaultData" appid="sat_sharematerialid" @onChecked="onChecked" />
+      </el-col>
+    </el-row>
   </div>
 </template>
 
 <script>
+import scopeOfauth from '@/components/scopeOfAuthority/index.vue'
+
 import Header from '@/SManagement/archives_upload/components/Header'
 import Set from '@/SManagement/archives_upload/components/Set'
 import FileList from '@/SManagement/archives_upload/components/FileList'
@@ -39,6 +52,7 @@ import Editor from '@/components/my-editor/Editor'
 
 import { weAtob, weBtoa } from "@/utils/weapp-jwt"
 import removeFile from '@/utils/removeFile'
+import { log } from '@antv/g2plot/lib/utils'
 export default {
   name: 'index',
   data() {
@@ -62,7 +76,10 @@ export default {
       uploadCacheData: '',
       //创建素材模板的id
       create_sat_sharematerialid: 0,
-      uploadType: window.sessionStorage.getItem('uploadType')
+      uploadType: window.sessionStorage.getItem('uploadType'),
+      /* 授权使用 */
+      defaultData: {},
+      authData: {},
     };
   },
   components: {
@@ -75,7 +92,8 @@ export default {
     reset,
     delete1,
     download,
-    Editor
+    Editor,
+    scopeOfauth
   },
   computed: {
   },
@@ -112,6 +130,7 @@ export default {
                   message: '上传成功',
                   type: 'success'
                 })
+                this.insertCoursewareauth();
                 this.$router.go(-1)
               }
             })
@@ -126,13 +145,44 @@ export default {
 
       })
     },
+    // 查询授权信息
+    async query_auth() {
+      const res = await this.$api.requested({
+        "classname": "webmanage.saletool.sharematerial.sharematerialAuth",
+        "method": "selectAuth",
+        "content": {
+          "sat_sharematerialid": this.uploadCacheData.sat_sharematerialid,
+        }
+      })
+      this.defaultData = res.data
+    },
+    // 新增授权范围
+    async insertCoursewareauth() {
+      let p = {
+        "classname": "webmanage.saletool.sharematerial.sharematerialAuth",
+        "method": "insertOrUpdate",
+        "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,
+        type: 'error'
+      }) : ''
+    },
+    // 获取保存授权范围数据
+    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()
       })
     },
@@ -208,10 +258,25 @@ export default {
       this.$refs.set.ruleForm.title = ''
       this.$refs.set.ruleForm.category = ''
       this.uploadCacheData.attinfos = []
-    }
+    },
+    /* set组件 分类选择回调 */
+    selectChange(id) {
+      this.cacheInfo.content.sat_sharematerial_classid = id;
+    },
+    /* set组件 title填写回调 */
+    titleChange(name) {
+      this.cacheInfo.content.title = name;
+      console.log(this.cacheInfo.content.title);
+    },
   },
 };
 </script>
 
 <style scoped>
+.mandate {
+  width: 732px;
+  height: 500px;
+  background: #fff;
+  margin-left: 16px;
+}
 </style>