import { extendRule, initFilter } from "../../utils/common";
import { message } from "antd/lib/index";
export default {
  btnClear: ({ props, login, dispatch, btnLoading, setformLoading, getSelectedRowKeys }) => {
    if (props.data.TreeSelected && props.data.TreeSelected.length > 0) {
      var keys = getSelectedRowKeys();
      var keystr=keys.join(',');
      let val = initFilter(login.OrgId, props.data.TreeSelected[0], '', 0, 0,keystr);
      btnLoading(true);
      setformLoading(true);
      dispatch({
        type: 'app/getDataByPost',
        payload: val,
        url: "FM/DepartmentScheduling/ClearRun",
        onComplete: (ret) => {
          if (ret) {
            dispatch({
              type: 'app/getDataByPost',
              payload: val,
              url: "PP/DepartmentCalendar/Running",
              onComplete: (ret) => {
                if (ret) {
                  message.success('执行成功');
                  setformLoading(false);
                  btnLoading(false);
                } else {
                  message.success('执行失败');
                  setformLoading(false);
                  btnLoading(false);
                }
              }
            });
          } else {
            message.success('数据清除失败');
            setformLoading(false);
            btnLoading(false);
          }
        }
      });

    }
  }
}