<template>
  <div>
    <el-dialog title="编辑文件夹" :visible.sync="dialogFolderVisible">
      <div class="flex-align-center container">
        <p style="width:100px">文件夹名称</p>
        <el-input readonly size="small" v-model="folder.document"></el-input>
      </div>
      <scopeOfauth :scrollHeight="'200px'" :defaultData="defaultData" obiectName="sat_salematerial" :obiectId="folder.attachmentid" appidname="attachmentid"  :dataid="folder.attachmentid" @onChecked="onChecked">
        <p slot="title">授权文件夹</p>
      </scopeOfauth>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogFolderVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="insertCoursewareauth(folder)" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import scopeOfauth from '@/components/scopeOfAuthority/index.vue'
export default {
  props:['checklist'],
  components:{
    scopeOfauth,
  },
  data () {
    return {
      dialogFolderVisible:false,
      defaultData:{},
      folder:{
        document:''
      },
      params:{
        "classname": "system.attachment.MediaCenter",
        "method": "createFolder",
        "content": {
          "foldername": "文件夹名称",
          "parentid":  ''
        }
      }
    }
  },
  methods:{
    onShow () {
      this.folder = Object.assign({},this.folder,this.checklist[0])
      console.log(this.folder)
      this.dialogFolderVisible = true
      this.query_auth()
    },
     // 获取保存授权范围数据
    onChecked (param) {
      this.authData = param
    },
    // 新增授权范围
    async insertCoursewareauth () {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.salematerial.salematerialAuth",
        "method": "insertOrUpdate",
        "content": this.authData
      })
      this.tool.showMessage(res,e=>{this.dialogFolderVisible = false})
    },
    // 查询授权信息
    async query_auth () {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.salematerial.salematerialAuth",
        "method": "selectAuth",
        "content": {
          "attachmentid":this.checklist[0].attachmentid
        }
      })
      this.defaultData = res.data
    },
  }
}

</script>
<style>
</style>