
import { Button } from 'antd'
import { message } from "antd/lib/index";

//用户列表页
export default {
  //返工处理
  btnRework: ({ record, loadData, login, dispatch, btn }) => {
    const confirm = () => {
      const json={OrgId:login.OrgId,Keyword:record.ID,Parameter1: 1};
      dispatch({
        type: 'app/getDataByPost',
        url:"QC/ReworkApply/ExamineResult",
        payload:json,
        onComplete: (ret) => {
          if(ret) {
            message.success('执行成功,请至返工管理列表维护返工工序');
            loadData();
          }
        }
      })
    };
    let disabled = record && record.EXAMINE_RESULT==0;
    return {
      content: <Button type={'default'} key={record ? (record.ID + btn.ID) : btn.ID} disabled={!disabled} icon={btn.ICON} size="small" title={'确认返工'} onClick={() => confirm()} ></Button>
    };
  },
  btnRelease: ({ record, loadData, login, dispatch, btn }) => {
    const confirm = () => {
      const json = { Keyword: (record ? record.ID : ''), OrgId: login.OrgId,Parameter1: 2};
      dispatch({
        type: 'app/getDataByPost',
        url:"QC/ReworkApply/ExamineResult",
        payload:json,
        onComplete: (ret) => {
          if(ret) {
            message.success('已撤销申请,SN已放行');
            loadData();
          }
        }
      })
    };
    let disabled = record && record.EXAMINE_RESULT==0;
    return {
      content: <Button type={'default'} key={record ? (record.ID + btn.ID) : btn.ID} disabled={!disabled} icon={btn.ICON} size="small" title={'撤销返工'} onClick={() => confirm()} ></Button>
    };
  }
}
