<template>
  <div class="allPage" v-loading="loading">
    <homePage
      ref="homePageRef"
      @cutPage="cutPage"
      :page="page"
      v-show="page == 1"
      :baseMessageLoading="baseMessageLoading"
      :classList="classList"
      :tid="tid"
      :bmData="bmData"
      :imageList="imageList"
      :actionTypesMap="actionTypesMap"
    ></homePage>
    <bindFrom
      ref="bindFromRef"
      @cutPage="cutPage"
      :page="page"
      v-if="page == 2"
      :testData="bmData.jsonData.testData ? bmData.jsonData.testData : {}"
    ></bindFrom>
    <classInfo
      ref="classInfoRef"
      @cutPage="cutPage"
      :page="page"
      :tid="tid"
      v-if="page == 3"
      v-loading="baseMessageLoading"
      :bmData="bmData"
      :imageList="imageList"
    ></classInfo>
    <stencilled
      ref="stencilledRef"
      @cutPage="cutPage"
      :page="page"
      :analysisList="analysisList"
      v-if="page == 5 && userId"
    ></stencilled>
    <editTel ref="editTelRef" @cutPage="cutPage" :dataList="dataList" :page="page" v-if="page == 6"></editTel>
    <!-- <addTel ref="addTelRef" @cutPage="cutPage" :page="page" v-if="page == 7"></addTel> -->
    <outcome
      ref="outcomeRef"
      @cutPage="cutPage"
      :page="page"
      v-show="page == 8"
      :bmData="bmData"
      :loading="[currencyLoading, scienceLoading, extendLoading]"
      :dialogTagList="dialogTagList"
      :analysisList="analysisList"
      :fileId="fileId"
      :dataList="dataList"
      :tid="tid"
    />
    <aiChat ref="aiChatRef" @cutPage="cutPage" :fileId="fileId" :tid="tid" v-if="page == 9" />
  </div>
</template>

<script>
import homePage from './homePage'
import bindFrom from './bindFrom'
import classInfo from './classInfo'
import stencilled from './stencilled'
import editTel from './editTel'
import addTel from './addTel'
import outcome from './outcome.vue'
import aiChat from './aiChat.vue'
import { v4 as uuidv4 } from 'uuid'
import _ from 'lodash'
import { mapGetters } from 'vuex'
import {
  updateObsRequest,
  getCourseListRequest,
  getObsRequest,
  delClassRequest,
  delObsRequest,
  getClassroomDefaultRequest,
  insertNewClassRoomRequest,
  insertNewObsRequest,
  getSModelList
} from '@/api/classObserve'

export default {
  components: { homePage, bindFrom, classInfo, stencilled, editTel, addTel, outcome, aiChat },
  data() {
    return {
      userId: this.$store.state.user.id,
      page: 1,
      loading: false,
      currencyLoading: true,
      baseMessageLoading: true,
      scienceLoading: true,
      extendLoading: true,
      classList: [],
      bmData: {
        id: '',
        tId: '',
        tIndex: 0,
        jsonData: {
          activity_methods: '',
          activity_structure: '',
          classroom_resources: '',
          courseName: '',
          name: '',
          studentNum: 0,
          subject: '',
          textbook: '',
          transcriptionData: '',
          editorBarData: {
            type: '0',
            content: '',
            url: ''
          }
        }
      },
      imageList: {},
      dataList: [],
      tid: '',
      fileId: '',
      fileIdId: '',
      actionTypesMap: {},
      analysisList: [],
      dialogTagList: [
        { value: 0, name: '通用课堂分析', loading: false },
        { value: 1, name: '学科课堂分析', loading: false },
        { value: 2, name: '扩展分析', loading: false }
      ]
    }
  },
  computed: {
    ...mapGetters(['userinfo'])
  },
  methods: {
    cutPage(val) {
      this.page = val
    },
    // 获取课堂列表
    getCourseList() {
      this.loading = true
      return new Promise((resolve, reject) => {
        getCourseListRequest({
          userid: this.userId
        })
          .then(res => {
            let _data = res.FunctionResponse.result
            let _result = []
            try {
              _result = _data ? JSON.parse(_data) : []
            } catch (error) {
              _result = []
            }

            if (_result.length <= 0) {
              this.loading = false
              resolve()
              return
            }
            let _optionData = _result.map(item => {
              item.jsonData = item.jsonData ? JSON.parse(item.jsonData) : {}
              return {
                label: item.jsonData.courseName ? item.jsonData.courseName : `${item.tId}课堂`,
                value: item.tId,
                id: item.id,
                newLabel: item.jsonData.courseName ? item.jsonData.courseName : `${item.tId}课堂`,
                show: false,
                edit: false
              }
            })
            _optionData = _optionData.filter(i => i.label != '' && i.tId != '')
            this.classList = _optionData
            this.loading = false
            // if (this.classList.length > 0 && !this.tid) {
            //   this.changeTid(this.classList[0].value)
            // }
            resolve()
          })
          .catch(e => {
            console.log(e)
            resolve()
            this.$message.error('获取课堂列表失败')
          })
      })
    },
    // 切换课堂
    async changeTid(newTid) {
      if (this.tid == newTid) return
      let _flag = this.tid !== newTid
      this.tid = newTid
      if (_flag) {
        this.getData().then(_ => {
          this.$refs.homePageRef.init()
        })
      }
      // 获取fileId
      this.getFileIdId()
      if (!this.tid) {
        this.actionTypesMap = undefined
        return
      }
      this.actionTypesMap = await this.loadActionTypesMap()
      if (!this.actionTypesMap) {
        await this.insertActionTypes()
        this.actionTypesMap = await this.loadActionTypesMap()
      }
    },
    //编辑课堂名称
    editClassName(item) {
      let _index = this.classList.findIndex(i => i.id == item.id)
      if (_index != -1) {
        if (this.tid == item.value) {
          //是现在预览的课堂
          this.$refs.homePageRef.historyListLoading = true
          this.bmData.jsonData.courseName = item.newLabel
          this.saveData(this.bmData).then(_ => {
            this.$refs.homePageRef.historyListLoading = false
            this.classList[_index].label = item.newLabel
            this.classList[_index].edit = false
            this.classList[_index].show = false
            this.loading = false
            this.$toast.success('修改成功')
          })
        } else {
          this.$refs.homePageRef.historyListLoading = true
          getObsRequest({ tid: item.value, type: 0 })
            .then(res => {
              let _data = res.FunctionResponse.result
              _data = JSON.parse(_data)
              let _bmData = _data.find(i => i.tIndex == 0)
              _bmData.jsonData = JSON.parse(_bmData.jsonData)
              _bmData.jsonData.courseName = item.newLabel
              this.saveData(_bmData).then(_ => {
                this.classList[_index].label = item.newLabel
                this.classList[_index].edit = false
                this.classList[_index].show = false
                this.loading = false
                this.$refs.homePageRef.historyListLoading = false
                this.$toast.success('修改成功')
              })
            })
            .catch(e => {
              console.log(e)
              this.$toast.fail('修改失败')
            })
        }
      }
    },
    //删除课堂
    delClass(item) {
      this.$refs.homePageRef.historyListLoading = true
      delClassRequest({ tid: item.id }).then(_ => {
        this.$toast.success('删除成功')
        this.getCourseList().then(_ => {
          if (item.value == this.tid) {
            this.tid = ''
            this.fileId = ''
            this.fileIdId = ''
            this.dataList = []
            this.bmData = {
              id: '',
              tId: '',
              tIndex: 0,
              jsonData: {
                activity_methods: '',
                activity_structure: '',
                classroom_resources: '',
                courseName: '',
                name: '',
                studentNum: 0,
                subject: '',
                textbook: '',
                transcriptionData: '',
                editorBarData: {
                  type: '0',
                  content: '',
                  url: ''
                }
              }
            }
            this.imageList = {}
          }
          this.$refs.homePageRef.historyListLoading = false
        })
      })
    },
    //保存分析数据
    saveData(params) {
      return new Promise((resolve, reject) => {
        updateObsRequest({
          id: params.id,
          json_data: JSON.stringify(params.jsonData)
        })
          .then(res => {
            resolve()
          })
          .catch(e => {
            console.log(e)
            console.log('保存失败')
            // this.$toast.fail('保存失败')
            resolve()
          })
      })
    },
    //获取通用分析与基本信息
    // getCurrencyAndBaseMessageData() {
    //   return new Promise(resolve => {
    //     if (!this.tid) return
    //     this.loading = true
    //     this.currencyLoading = true
    //     this.baseMessageLoading = true
    //     getObsRequest({ tid: this.tid, type: '0' })
    //       .then(res => {
    //         let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
    //         let _bmData = _data.find(i => i.tIndex == 0)
    //         // 基础信息
    //         _bmData.jsonData = JSON.parse(_bmData.jsonData)
    //         _bmData.jsonData.time ? '' : (_bmData.jsonData.time = '')
    //         _bmData.jsonData.editorBarData ? '' : (_bmData.jsonData.editorBarData = { type: '0', content: '', url: '' })
    //         _bmData.jsonData.transcriptionData ? '' : (_bmData.jsonData.transcriptionData = '')
    //         // 图片
    //         let _imageList = _data.find(i => i.tIndex == 1)
    //         _imageList.jsonData = JSON.parse(_imageList.jsonData)

    //         if (!_imageList.jsonData.videoList) {
    //           _imageList.jsonData.videoList = []
    //         }
    //         if (!_imageList.jsonData.NephogramList) {
    //           _imageList.jsonData.NephogramList = []
    //         }

    //         let currency = []
    //         for (let i = 2; i < _data.length; i++) {
    //           let _currency = _data[i]
    //           _currency.jsonData = JSON.parse(_currency.jsonData)
    //           currency.push(_currency)
    //         }
    //         // 赋值
    //         this.dataList.push(...currency)
    //         this.bmData = _bmData
    //         this.imageList = _imageList

    //         this.baseMessageLoading = false
    //         this.currencyLoading = false
    //         this.loading = false
    //         resolve()
    //       })
    //       .catch(e => {
    //         console.log(e)
    //         this.$toast.fail('获取通用分析失败')
    //         resolve()
    //       })
    //   })
    // },
    // //获取学科分析
    // getScienceData() {
    //   return new Promise(resolve => {
    //     if (!this.tid) return
    //     this.scienceLoading = true
    //     getObsRequest({ tid: this.tid, type: '1' })
    //       .then(res => {
    //         let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
    //         if (_data.length == 0) {
    //           return (this.scienceLoading = false)
    //         }
    //         let science = []
    //         for (let i = 0; i < _data.length; i++) {
    //           let _science = _data[i]
    //           _science.jsonData = JSON.parse(_science.jsonData)
    //           science.push(_science)
    //         }
    //         this.dataList.push(...science)
    //         this.scienceLoading = false
    //         resolve()
    //       })
    //       .catch(e => {
    //         console.log(e)
    //         this.$toast.fail('获取科学分析失败')
    //         resolve()
    //       })
    //   })
    // },
    // //获取扩展分析
    // getExtendData() {
    //   return new Promise(resolve => {
    //     if (!this.tid) return
    //     this.extendLoading = true
    //     getObsRequest({ tid: this.tid, type: '2' })
    //       .then(res => {
    //         let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
    //         if (_data.length == 0) {
    //           return (this.extendLoading = false)
    //         }
    //         let extent = []
    //         for (let i = 0; i < _data.length; i++) {
    //           let _extent = _data[i]
    //           _extent.jsonData = JSON.parse(_extent.jsonData)
    //           extent.push(_extent)
    //         }
    //         this.dataList.push(...extent)
    //         this.extendLoading = false
    //         resolve()
    //       })
    //       .catch(e => {
    //         console.log(e)
    //         this.$toast('获取扩展分析失败')
    //         resolve()
    //       })
    //   })
    // },
    getAnalysisData(type) {
      if (!this.tid) return
      let _copyTid = this.tid
      return new Promise(resolve => {
        let params = {
          tid: this.tid,
          type: type
        }
        this.dialogTagList.find(i => i.value == type)
          ? (this.dialogTagList.find(i => i.value == type).loading = true)
          : ''
        if (type == 0) {
          this.baseMessageLoading = true
          this.bmData = {
            id: '',
            tId: this.tid,
            tIndex: 0,
            jsonData: {
              activity_methods: '',
              activity_structure: '',
              classroom_resources: '',
              courseName: '',
              name: '',
              studentNum: 0,
              subject: '',
              textbook: '',
							editorBarData:{
								type: '0',
								content: '',
								url: ''
							},
							transcriptionData:"",
            }
          }
          this.imageList = {}
          this.dataList = []
          this.dialogTagList = [
            { value: 0, name: '通用课堂分析', loading: true },
            { value: 1, name: '学科课堂分析', loading: true },
            { value: 2, name: '扩展分析', loading: true }
          ]
        }
        getObsRequest(params)
          .then(res => {
            if (_copyTid != this.tid) return
            let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
            if (_data.length == 0) {
              return (this.dialogTagList.find(i => i.value == type).loading = false)
            }

            if (type == 0) {
              //第一个分析
              let _bmData = _data.find(i => i.tIndex == 0)
              let _dialogTagList = []
              _bmData.jsonData = JSON.parse(_bmData.jsonData)
              _bmData.jsonData.time ? '' : (_bmData.jsonData.time = '');
              _bmData.jsonData.editorBarData? '': (_bmData.jsonData.editorBarData = { type: '0', content: '', url: '' });
              _bmData.jsonData.transcriptionData ? '' : (_bmData.jsonData.transcriptionData = '');
              _dialogTagList = _bmData.jsonData.dialogTagList || [
                { value: 0, name: '通用课堂分析', loading: false },
                { value: 1, name: '学科课堂分析', loading: false },
                { value: 2, name: '扩展分析', loading: false }
              ]
              let _imageList = _data.find(i => i.tIndex == 1)
              _imageList.jsonData = JSON.parse(_imageList.jsonData)
              if (_imageList.jsonData.videoList) {
                _imageList.jsonData.videoList = []
              }
              if (_imageList.jsonData.NephogramList) {
                _imageList.jsonData.NephogramList = []
              }

              let currency = []
              for (let i = 2; i < _data.length; i++) {
                let _currency = _data[i]
                _currency.jsonData = JSON.parse(_currency.jsonData)
                currency.push(_currency)
              }

              this.dataList.push(...currency)
              this.bmData = _bmData
              this.dialogTagList = _dialogTagList
              this.baseMessageLoading = false
              this.dialogTagList.find(i => i.value == type)
                ? (this.dialogTagList.find(i => i.value == type).loading = false)
                : ''
              resolve()
            } else {
              if (_data.length == 0) {
                return (this.dialogTagList.find(i => i.value == type).loading = false)
              }
              let _analysisData = []
              for (let i = 0; i < _data.length; i++) {
                let _analysis = _data[i]
                _analysis.jsonData = JSON.parse(_analysis.jsonData)
                _analysisData.push(_analysis)
              }
              this.dataList.push(..._analysisData)
              this.dialogTagList.find(i => i.value == type)
                ? (this.dialogTagList.find(i => i.value == type).loading = false)
                : ''
              resolve()
            }
          })
          .catch(e => {
            console.log(e)
            this.$message.error('获取分析列表失败')
            resolve()
          })
      })
    },
    //获取全部的数据
    getData(arr = []) {
      return new Promise(resolve => {
        this.dataList = []
        this.$forceUpdate()
        this.loading = true
        if (this.tid) {
          return this.getAnalysisData(0).then(_ => {
            this.$nextTick(() => {
              let promises = []
							this.loading = false;
              this.$nextTick(() => {
                let forData = arr.length ? arr : this.dialogTagList
                this.dialogTagList = forData
                forData.forEach(i => {
                  if (i.value == 0) return
                  promises.push(this.getAnalysisData(i.value))
                })
                Promise.all(promises).then(_ => {
                  this.dataList.sort((a, b) => a.tIndex - b.tIndex)
                  this.dataList.sort((a, b) => a.Type - b.Type)
                  
                  resolve()
                })
              })
            })
          })
        }
      })

      // return new Promise(resolve => {
      //   Promise.all([this.getCurrencyAndBaseMessageData(), this.getScienceData(), this.getExtendData()]).then(_ => {
      //     console.log('所有分析获取完成')
      //     resolve()
      //   })
      // })
    },
    //删除分析
    delAnalysis(item) {
      if (!this.tid) return
      this.currencyLoading = true
      this.baseMessageLoading = true
      this.scienceLoading = true
      this.extendLoading = true
      delObsRequest({
        id: item.id,
        type: item.Type,
        tid: this.tid
      })
        .then(res => {
          this.dataList = this.dataList.filter(_item => _item.id != item.id)
          this.$toast.success('删除成功')
          this.currencyLoading = false
          this.baseMessageLoading = false
          this.scienceLoading = false
          this.extendLoading = false
        })
        .catch(e => {
          this.$toast.fail('删除失败')
          this.currencyLoading = false
          this.baseMessageLoading = false
          this.scienceLoading = false
          this.extendLoading = false
        })
    },
    //修改分析
    editAnalysis(item) {
      if (!this.tid) return
      this.baseMessageLoading = true
      this.scienceLoading = true
      this.extendLoading = true
      editObsRequest({
        id: item.id,
        type: item.Type,
        tid: this.tid
      }).then(res => {})
    },
    //获取默认模板并创建课堂
    addNewCourseByDefault() {
      // 通过用户ID获取默认的模板
      var OpenCC = require('opencc-js')
      let converter = OpenCC.Converter({
        from: 'hk',
        to: 'cn'
      })
      return new Promise((resolve, reject) => {
        let params = {
          uid: this.userId
        }
        this.loading = true
        getClassroomDefaultRequest(params).then(res => {
          let _data = res[0][0]
          if (_data) {
            this.loading = true
            _data.tips = JSON.parse(_data.tips)
            let _result = []
            _data.tips.forEach(i => {
              if (converter('词频词汇分析') == converter(i.jsonData.name)) return
              let _obj = {
                jsonData: i.jsonData,
                type: i.Type,
                index: i.tIndex
              }
              _result.push(_obj)
            })
            this.loading = false
            // console.log('👇要生成的模板')
            // console.log(_result)
            this.addNewCourseByTemplate(_result).then(_ => {
              resolve()
            })
          } else {
            this.loading = false
            this.$toast.fail('获取模板详细为空')
          }
        })
      })
    },
    //通过模板创建新的课堂
    addNewCourseByTemplate(json = []) {
      if (json.length <= 0) return
      var OpenCC = require('opencc-js')
      let converter = OpenCC.Converter({
        from: 'hk',
        to: 'cn'
      })
      // json = json.filter(i=>converter(i.jsonData.name)!=converter("词频词汇分析"))
      return new Promise((resolve, reject) => {
        this.loading = true
        const _newTid = uuidv4()
        let params = {
          tid: _newTid,
          userid: this.userId,
          template: json
        }
        insertNewClassRoomRequest(params).then(res => {
          let _data = res.FunctionResponse
          if (converter(_data.message) == converter('创建成功')) {
            // 设置新课堂的tid
            // this.tid = params.tid;
            this.changeTid(_newTid)
            insertNewObsRequest({
              tid: params.tid,
              type: 10,
              index: 0,
              json_data: JSON.stringify({ file_ids: '' }),
              userid: this.userId
            }).then(res2 => {
              let _data2 = res2.FunctionResponse
              if (converter(_data2.message) == converter('创建成功')) {
                this.loading = false
                this.$nextTick(() => {
                  this.getCourseList().then(_ => {})
                  // 	this.getCourseList().then((_) => {
                  this.getFileIdId()
                  // 		this.$refs.messageAreaRef.getData();
                  // 		this.$refs.chatAreaRef.getData();
                  // 		resolve();
                  // 	});
                  resolve()
                })
              } else {
                this.$toast.fail('创建fileIds失败')
              }
            })
          } else if (converter(_data.message) == converter('tid重复')) {
            this.$toast.fail('该课堂已存在')
            this.loading = false
          } else {
            this.$toast.fail('创建失败')
            this.loading = false
          }
        })
      })
    },
    // 获取修改fileId的ID
    getFileIdId() {
      if (!this.tid) return
      let pram = {
        tid: this.tid,
        type: '10'
      }
      this.fileIdId = ''
      this.fileId = ''
      getObsRequest(pram).then(res => {
        let _data = res.FunctionResponse.result.length ? JSON.parse(res.FunctionResponse.result) : []
        if (_data.length <= 0) return
        this.fileIdId = _data[0].id
        if (_data[0].jsonData != '') {
          this.fileId = JSON.parse(_data[0].jsonData).file_ids
        } else {
          this.fileId = ''
        }
      })
    },
    changeFileId(newFileId) {
      let params = {
        id: this.fileIdId,
        jsonData: { file_ids: newFileId }
      }
      this.saveData(params)
        .then(res => {
          console.log('更改并保存fileID成功')
          this.getFileIdId()
        })
        .catch(e => {
          console.log('更改并保存fileID失败', e)
        })
    },
    // 切换录音文件
    changeAudioUrl(data) {
      this.imageList.jsonData.fileList = []
      let audio = {
        name: data.key,
        status: 'success',
        uid: '1',
        url: data.Location
      }
      this.imageList.jsonData.fileList.push(audio)
      this.saveData(this.imageList).then(res => {
        this.$toast.success('更换录音文件成功')
      })
    },
    // 保存转录文稿和原文速览
    saveEditorBar(flag = false) {
      return new Promise(resolve => {
        if (!this.tid) return this.$toast.fail('请选择课堂')
        if (this.bmData.jsonData.editorBarData.type == '0' && flag && this.bmData.jsonData.editorBarData.content) {
          // 如果是文本则转成txt并保存
          let _result = JSON.parse(JSON.stringify(this.bmData.jsonData.editorBarData))
          var text = _result.content

          // 创建一个Blob实例
          var blob = new Blob([text], { type: 'text/plain;charset=utf-8' })
          blob.lastModifiedDate = new Date()
          blob.name = `${this.tid}-classroomObservation.txt`
          return this.$refs.homePageRef.uploadFile(blob, { changeText: false, flag: false })
        } else {
          // this.loading = true;
          // let div = document.createElement("div");
          // div.innerHTML = this.editorBarData.content;
          // return this.loading = false;

          let _sentence = 0
          let _words = 0
          let _editorBarDataContentRows = []
          let _actionTypes = []

          if (this.bmData.jsonData.editorBarData.type == 0) {
            let _data = this.bmData.jsonData.editorBarData.content
            let _div = document.createRange().createContextualFragment(_data)
            let _tableRows = _div.querySelectorAll(`table tbody tr`)
            _tableRows.forEach((i, index) => {
              while (i.cells.length > 7) {
                i.removeChild(i.lastElementChild)
              }
              const actionTypeCell = i.cells[6] && i.removeChild(i.cells[6])
              _editorBarDataContentRows.push(i.outerHTML)
              if (index == 0) return
              if (i.cells[3].textContent != '') {
                _sentence += 1
                _words += i.cells[3].textContent.length
              }
              _actionTypes.push(_.get(actionTypeCell, 'textContent', ''))
            })
          }
          const _editorBarDataContent = `<table
					border="0"
					width="100%"
					cellpadding="0"
					cellspacing="0"
					style="text-align: center"
				>
					<tbody>
						${_editorBarDataContentRows.join('')}
					</tbody>
				</table>
				`

          this.bmData.jsonData.editorBarData.sentenceNum = _sentence
          this.bmData.jsonData.editorBarData.wordsNum = _words
          let _saveWordData = this.dataList.find(i => i.Type == 0 && i.tIndex == 2)
          if (_saveWordData) {
            _saveWordData.jsonData.wordCountNum = _sentence
            _saveWordData.jsonData.wordNum = _words
            this.saveData(_saveWordData).then(_ => {
              console.log('词频词汇分析已保存')
            })
          }
          this.saveData(this.bmData).then(_ => {
            console.log('转录问稿已保存')
            this.loading = false
            resolve()
          })
          // // TODO 不同板块用id做key
          this.actionTypesMap.jsonData['default'] = _actionTypes
          this.saveActionTypesMap()
        }
      })
    },
    async loadActionTypesMap() {
      const res = await getObsRequest({ tid: this.tid, type: '11' })
      const result = _.get(res, ['FunctionResponse', 'result'], '[]')
      if (result instanceof Array) {
        return undefined
      }
      const data = _.get(JSON.parse(result), 0)
      return { ...data, jsonData: JSON.parse(data.jsonData) }
    },
    async insertActionTypes() {
      return await insertNewObsRequest({
        tid: this.tid,
        type: '11',
        json_data: JSON.stringify({ default: [] }),
        index: 0,
        userid: this.userId
      })
    },
    async saveActionTypesMap() {
      try {
        return await updateObsRequest({
          id: this.actionTypesMap.id,
          json_data: JSON.stringify(this.actionTypesMap.jsonData)
        })
      } catch (e) {
        console.error(e)
        this.$toast(e)
      }
    },
    getDialogTagDataList() {
      let params = {
        uid: this.userinfo.userid
      }

      getSModelList(params).then(res => {
        this.analysisList = res[0]
      })
    }
  },
  mounted() {
    this.getCourseList().then(_ => {
      // if(this.tid=="" && this.classList.length>0){
      // 	this.changeTid(this.classList[0].value);
      // }
      // this.getData()
    })
    this.getDialogTagDataList()
    // console.log(getClassList)
  }
}
</script>

<style lang="scss" scoped>
.allPage {
  height: 100vh;
}
</style>
