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

export default {
  ...conditionObjectBase,
  key: 'editionId',
  title: '版本',
  dependentKeys: ['subjectId'],
  isDependencyReady(params) {
    return params.subjectId
  },
  getList: function(param) {
    return new Promise((resolve, reject) => {
      editionList({
        subjectId: param.subjectId
      }).then((res) => {
        const results = Object.keys(res.data).map(k => ({
          id: k,
          name: res.data[k]
        }))
        resolve(results)
      }).catch(e => reject(e))
    })
  }
}
