import { Button, Row, Col, Form, Input,Select,Checkbox,Modal,Transfer,Spin ,Table,DatePicker,InputNumber,message,Upload,Icon} from 'antd';
import ShowModal from '../../components/common/ShowModal'
//用户列表页
export default {
  checkConfirm: ({ record, close, loadData, login, dispatch, btn }) => {
    return {
      onBtnDisabled:(r)=>{
        return r.IS_CONFIRM
      }, 
    }
  },
  acceptOnDeviation: ({ record, close,loadData, login, dispatch, btn,setState,getState }) => {
  const acceptSubmit=()=>{
    var reason=getState("acceptReason");
    if(!reason || reason==""){
      message.error('请先填写特采原因');
      return;
    }
    const json={OrgId:login.OrgId, Keyword:record.ID,Parameter1:login.userId,Parameter2:reason};
    dispatch({
      type: 'app/getDataByPost',
      url:"MM/ReworkPdtOrder/AcceptDeviation",
      payload:json,
      onComplete: (ret) => {
        if(ret) {
          message.success('特采已通过');
          close()
          loadData()
        }
      }
    })
  }
  const onChange=(e)=>{
    setState({"acceptReason":e.target.value})
  }
  return {
    content:
    record.IS_CONFIRM?
    <div>
     <Form>
         <Row style={{marginTop:'10px'}}>
         <span style={{fontSize:'14px'}}>特采原因:   </span>
          <Input placeholder="" value={record.REMARK} disabled style={{width:'50%'}} />
         </Row>
         <Row style={{marginBottom:'20px',float:'right',marginRight:'20px'}}>
          <Button type="primary" key={record ? (record.ID + btn.ID) : btn.ID}  title={'让步接收'} disabled={record.IS_CONFIRM} onClick={acceptSubmit}>提交</Button>
         </Row>
      </Form>
   </div>
 :
    <div>
      <Form>
            <Row style={{marginTop:'10px'}}>
            <span style={{fontSize:'14px'}}>特采原因:   </span>
             <Input placeholder="" onChange={onChange} style={{width:'50%'}} />
            </Row>
            <Row style={{marginBottom:'20px',float:'right',marginRight:'20px'}}>
             <Button type="primary" key={record ? (record.ID + btn.ID) : btn.ID}  title={'让步接收'} disabled={record.IS_CONFIRM} onClick={acceptSubmit}>提交</Button>
            </Row>
       </Form>
    </div>
  };
  },
  btnReSendQc: ({ record, loadData, login, dispatch, btn }) => {
    const confirm = () => {
      const json = { Keyword: (record ? record.ID : ''), OrgId: login.OrgId,Parameter1:login.userId};
      dispatch({
        type: 'app/getDataByPost',
        url:"MM/ReworkPdtOrder/ReSendQc",
        payload:json,
        onComplete: (ret) => {
          if(ret) {
            message.success('执行成功！请到客户端执行重新送检');
            loadData();
          }
        }
      })
    };
    return {
      content: <Button type={'default'} key={record ? (record.ID + btn.ID) : btn.ID} icon={btn.ICON} size="small" disabled={record.IS_CONFIRM?true:false} title={'重新送检'} onClick={() => confirm()} ></Button>
    };
  }
}
