import conditionObjectBase from '../condition-object-base.js'
import {
  treeList
} from '@/api/webApi/webQue.js'

export default {
  ...conditionObjectBase,
  key: 'chapterId',
  title: '章节',
  template: 'chapter-tree-picker',
  dependentKeys: ['seniorGradeId'],
  modelAsParam: true,
  isDependencyReady(params) {
    return params.seniorGradeId
  },
  getList: function(param) {
    return new Promise((resolve, reject) => {
      treeList({
        subjectId: param.subjectId,
        editionId: param.editionId,
        gradeId: param.seniorGradeId
      }).then((res) => {
        resolve(res.data)
      }).catch(e => reject(e))
    })
  }
}
