<template>
  <div>
    <Modal v-model="showTypeModal" :mask-closable="false" :width="700">
      <p slot="header">{{modalTitle}}</p>
      <div class="sys_service_radio">
        <el-radio-group v-model="radio" size="large" @on-change="_radio">
          <el-radio v-for="item in radioList" :key="item.code" :label="item.code">
            <span>{{item.name}}</span>
          </el-radio>
        </el-radio-group>
      </div>
      <div slot="footer" class="btn-width">
        <el-button @click="_cancel" type="default" style="margin-left: 8px">取消</el-button>
        <el-button @click="_ok" type="primary">确定</el-button>
      </div>
    </Modal>
  </div>
</template>
<script>
import Global from '../../../api/config'
import { sysResource } from '../../../api'

export default {
  data() {
    return {
      modalTitle: '选择服务类型',
      showTypeModal: false,
      radio: '',
      radioList: []
    }
  },
  methods: {
    _open: async function() {
      this.showTypeModal = true
      const result = await sysResource.getNavMenu()
      const radioList = []
      for (let i = 0; i < result.length; i++) {
        if (result[i].code !== 'home') {
          radioList.push(result[i])
        }
      }
      this.radioList = radioList
      this.radio = this.radioList[0].code
    },
    _radio(data) {
      this.radio = data
    },
    _cancel() {
      this.showTypeModal = false
    },
    _ok() {
      window.open(Global.baseURL + '/' + this.radio + '/report/designer')
      this._cancel()
    }
  }
}
</script>
<style>
.sys_service_radio .ivu-radio-large .ivu-radio-wrapper {
  width: 20% !important;
}
</style>
