import React from 'react';
import styles from './index.less';
import commonStyles from '../common.less';
import classNames from 'classnames';
import { useHistory } from 'react-router-dom';


//"caseType":"待办工单","flowName":"维修处理流程","nodeName":"审核关单","content":"请迅速到现场处理","time":"2020-11-03 09:11:12"
export class CaseContent {
  constructor({
    caseType,
    flowName,
    nodeName,
    content,
    time
  } = content) {
    this.caseType = caseType;
    this.flowName = flowName;
    this.nodeName = nodeName;
    this.content = content;
    this.time = time;
  }
}

const Case = ({ message, confirmRead }) => {
  let caseContent = message.infoContent;
  const history = useHistory();
  const goPath = (item) => {
    confirmRead(false,[message.id]);
    let path= item.webPath ? `/civweb4/${item.webPath}` : `/civweb4/product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=1`
    history.push(path);
  }
  return (
    <div  className={classNames(styles.case,commonStyles.messageContainer)} title="点击查看详情" onClick={()=> goPath(message)}>
      <div className={commonStyles.title}>
        <span>消息</span>
        <img
          className={commonStyles.confirm}
          title="点击标为已读"
          onClick={() => {
             confirmRead(false,[message.id]);
          }}
          src="https://panda-water.cn/Web4/assets/images/message/%E5%8B%BE%E6%B5%85.png"
        />
      </div>
      <div className={commonStyles.content}>
        <p>
          <i>{caseContent.caseType}</i>
          {caseContent.flowName}
        </p>
        <p>{caseContent.nodeName} : {caseContent.content}</p>
        <p className={commonStyles.messageTime}>{message.time}</p>
      </div>
    </div>
  );
};

export default Case;

