import { getTagKeyMap } from '@/utils/enum/node';
import { DEMAND_STATUS, DEMAND_STATUS_MAP, TASK_CALCULATE_STATUS_OPTIONS, TASK_PROCESS_STATUS_OPTIONS } from '@/utils/enum/task';
import { getUserId } from '@/utils/user';

export const disposeAttentionParams = (uuid:string, isAttention:boolean) => {
  const addList = [];
  const cancelList = [];
  if (isAttention) {
    addList.push(getUserId());
  } else {
    cancelList.push(getUserId());
  }
  return {
    taskId: uuid,
    addUserIdList: addList,
    cancelUserIdList: cancelList,
  };
};

export const setTaskSearchOptions = (tableRef:any) => {
  // console.log('tableRef setTaskSearchOptions', tableRef);
  // console.log('TASK_PROCESS_STATUS_OPTIONS', TASK_PROCESS_STATUS_OPTIONS);
  // console.log('TASK_CALCULATE_STATUS_OPTIONS', TASK_CALCULATE_STATUS_OPTIONS);
  tableRef.setOptionsFun('exeStatus', TASK_PROCESS_STATUS_OPTIONS);
  tableRef.setOptionsFun('achieveStatus', TASK_CALCULATE_STATUS_OPTIONS);
};

export const setDemandSearchOptions = (tableRef:any) => {
  console.log('tableRef setDemandSearchOptions', tableRef);
  tableRef.setOptionsFun('demandStatus', [{ label: DEMAND_STATUS_MAP[DEMAND_STATUS.NO_SEND], value: DEMAND_STATUS.NO_SEND }, ...TASK_PROCESS_STATUS_OPTIONS]);
  tableRef.setOptionsFun('achieveStatus', TASK_CALCULATE_STATUS_OPTIONS);
};

export const disposeTagName = (row:any, nodeType:string) => {
  const tagMap = getTagKeyMap();
  // console.log('row, nodeType', row, nodeType, tagMap.get(nodeType));
  return row[tagMap.get(nodeType)] || '--';
};
