import React from 'react';

import classNames from 'classnames';

import commonStyles from '../common.less';
import styles from './index.less';

//"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 goPath = (item) => {
    debugger
    confirmRead(false,[message.id]);
    const messageType = item.messType;
    let label = '', widgetID = '';
    switch(messageType) {
      case "任务派发":
        label = "任务派发";
        widgetID = "widget_city_综合运营_二供管理_维修管理_工单办理";
        break;
      case "任务驳回":
        label = "任务驳回";
        widgetID = "widget_city_综合运营_二供管理_维修管理_工单办理";
        _tab = "任务驳回";
        break;
      default:
        label = "工单办理";
        widgetID = "widget_city_综合运营_二供管理_维修管理_工单办理";
        break;                        
    }
    const webPath = item.webPath || "product/maintenance/CaseManage/CaseDoingBox/StardCaseDoingBoxView|isDelay=1";
    window.share.event.emit("listenerMointer", {
      widgetId: widgetID,
      label: label,
      url: webPath,
    });
  }
  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;

