import webapi from "../webapi";

// 更新查询
export function userSearch(reduce, gf, fields) {
  return async (dispatch, getState) => {
    // 更新查询数据
    reduce("userSearchParam", { type: "update_search_param", data: fields });
    return [];
  };
}
// table数据
export function userData(reduce, gf, param) {
  return async (dispatch, getState) => {
    let data = [];
    let pager = {};
    param = gf(["userSearchParam"]);
    if (param) {
      let res = await webapi.userData(param);
      data = res.data;
      pager = res.pager;
    }
    console.log(param, "user提交的查询条件");
    reduce("userData", { type: "show-table", data: data });
    reduce("userSearchParam", { type: "update_search_page", data: pager });
  };
}
//取消授权用户
export function cancelUser(reduce, gf, data) {
  return async (dispatch, getState) => {
    const param=[]
    data.filter(item=>{
      param.push(item.name)
      return item.name
    })
    //取消授权用户接口。提交参数
    let res=await webapi.userData(param)
    reduce("userData", { type: "show-table", data: res.data });
    reduce("userSearchParam", { type: "update_search_page", data: res.pager });
  }
}
