/*   用于存放业务逻辑   */
import config from '../../utils/config';
import * as commonServices from '../../services/services';

/*   上一条、下一条、首条、末条从表刷新   */
export function setprops(props) {
  props.ref = '';
  return props;
}

export async function handleGetDataSetByName(params) {
  const { token, value } = params;
  const { mastersId, sModelsId } = value.paramsMap;
  // const url = `${config.server_host}business/getProData?sModelsId=${sModelsId}`;
  const url = `${config.server_host}treegrid/getTreeGridByPro/${mastersId}?sModelsId=${sModelsId}`;
  const oReturn = (await commonServices.postValueService(token, value, url)).data;
  const msgs = oReturn.msg;
  if (oReturn.code === 1) { /*   成功   */
    const { proData } = oReturn.dataset.rows[0].dataSet;
    for (const each of proData) {
      each.key = each.sId;
    }
    return { proData, msgs };
  } else { /*   失败   */
    return { undefined, msgs };
  }
}
