
import { Button, Popconfirm } from 'antd'
import FormPage from '../../components/FormPage';
import {initFilter, initQueryFilter} from "../../utils/common";
import {message} from "antd/lib/index";

//用户列表页
export default {
  btnEdit:({record,close,loadData,login,dispatch})=> {
    const closeF=()=>{
      close();
      loadData();
    };
    const regClick= async function (){
      await dispatch({
        type: 'custom/save',
        payload: {
          ['userEditClick'+(record? record.ID:'')]:true
        },
      });
    };
    const data={
      id:(record? record.ID:''),
      close:closeF,
      userEditClick:login.userEditClick,
    };
    return {
      content: <FormPage formCode={'FM009'} data={data}/>,
      click: regClick
    }
  },
  reset :({record,close,loadData,getLoadParam,login,btn,dispatch})=>{
    let val = initQueryFilter(login.OrgId, 1, 100, "NUM", 0);
    val["Keyword"] = record.ID;
    const confirmRevert=()=> {
      dispatch({
        type: 'app/getDataByPost',
        payload: val,
        url: "FM/User/ReSetPwd",
        onComplete: (ret) => {
          if (ret) {
            message.success("重置成功");
          }
        }
      });
    };
    //console.log(btn);
    return {
      content: <Popconfirm title="是否确定重置密码?" onConfirm={confirmRevert}>
        <Button type={btn.CSS} icon={btn.ICON} size="small" title={btn.LABEL}/>
      </Popconfirm>
    }
  },

}
