/**
 * long description for the file
 *
 * @summary 登录
 * @author wu <308822989@qq.com>
 *
 * Created at     : 2018-08-27 14:56:41
 * Last modified  : 2018-08-29 08:51:35
 */

import axios from '@/config/axios.js';
import { setCookie, getCookie, dgTree } from '@/utils/util.js';
import moment from 'moment';
import { proPath } from '@/config/config.js';

const state = {
  //  输入用户岗位列表
  postIdItems: []
}

const getters = {
  //  选择的登录日期 单位毫秒
  workDate () {
    return getCookie('workDate') ? getCookie('workDate') : moment(new Date()).format('YYYY-MM-DD HH:mm');
  }
}

const mutations = {
  // //  更新岗位列表
  postIdItems (state, items) {
    state.postIdItems = items;
  }
}
const actions = {
  //  登录
  login ({ commit, state }, oParam) {
    let res = axios.post(proPath + 'auth/login', oParam, {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    });
    res.then(res => {
      console.log(res);
    });
    return res;
  }
//   //  根据anme查询角色
//   findByName ({ commit, state }, name) {
//     let res = axios.get(proPath + 'v1/sysposts/list/user?name=' + name);
//     res.then(res => {
//       if (res.code === '0') {
//         console.log(res.data);
//         commit('postIdItems', res.data);
//       }
//     });
//     return res;
//   }
}

//
export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions
}
