import Axios from "axios/index";

import { mapGetters, mapState } from 'vuex'
/**
 * 负责所有页面通用方法初始化
 *
 *  version = "1.0.0";
 *  author = "徐飞";
 *  email = "xu.fei@data-u.com";
 * */
export default {
  data () {
    return {
      stringOptions: [
        {
          id: '1',
          name: '是'
        }, {
          id: '0',
          name: '否'
        }],
      // 数字类型的是否状态
      options: [
        {
          id: 1,
          name: '是'
        }, {
          id: 0,
          name: '否'
        }],
      // 启用停用状态
      statusOptions: [{
        id: 1,
        name: '已启用',
        color: 'green'
      }, {
        id: 0,
        name: '已停用',
        color: 'red'
      }],
    }
  },
  computed: {
    ...mapState({
      menuInfo: state => state.menu.menuInfo
    }),
    ...mapGetters('user', {
      userName: 'userName',
      userInfo: 'userInfo'
    })
  },
  methods: {
    // 取消
    goBack(){
      if(this.$route.meta.parentName){
        this.go(this.$route.meta.parentName)
      }else{
        this.$router.go(-1)
      }
    },
    // 默认通用方法
    go(where, params, query){
      this.$router.push(
        {
          name: where,
          params: params || {},
          query: query || {}
        }
      )
    },
  }
}
