import React from 'react';
import { Field, Cell } from '@antmjs/vantui';
import { getIssueStatus } from '@/utils/biz';
import { getIssueProcess } from '@/services/taissue';

export default (props) => {

  const { issue } = props;
  const [bizStatus, setBizStatus] = React.useState();
  const [issueProcess, setIssueProcess] = React.useState();

  React.useEffect(() => {
    if (issue) {
      setBizStatus(getIssueStatus(issue));

      // 取最新的流程日志记录
      getIssueProcess({ pageSize: 1, issueId: issue.issueId }).then(res => {
        setIssueProcess((res.records || [])[0]);
      })
    }
  }, [issue]);

  return (
    <>
      <Cell title="状态" value={bizStatus?.label}></Cell>
      {
        issueProcess?.processResult && (
          <>
            <Cell title="审核意见" />
            <Field
              readonly
              type="textarea"
              autosize={{ minHeight: '120px' }}
              value={issueProcess.processResult}
            />
          </>
        )
      }
    </>
  )
}
