import 'antd/es/popconfirm/style';
import _Popconfirm from 'antd/es/popconfirm';
import 'antd/es/popover/style';
import _Popover from 'antd/es/popover';
import 'antd/es/input/style';
import _Input from 'antd/es/input';
import _size from 'lodash/size';
import _set from 'lodash/set';
import _map from 'lodash/map';
import _get from 'lodash/get';
import _cloneDeep from 'lodash/cloneDeep';
import { s as styleInject, f as __rest, b as __awaiter, c as __generator } from './index.js';
import { DeleteOutlined } from '@ant-design/icons';
import { formatTimeToStandard } from '@lm_fe/components_m';
import { request } from '@lm_fe/utils';
import classnames from 'classnames';
import React__default, { useState, useEffect, useMemo } from 'react';
import { r as requestMethods_further } from './diagnoses-week.js';
import '@lm_fe/env';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/orderBy';
import '@lm_fe/components';
import 'antd/es/collapse/style';
import 'antd/es/collapse';
import 'antd/es/badge/style';
import 'antd/es/badge';
import 'antd/es/button/style';
import 'antd/es/button';
import 'lodash/assign';
import '@lm_fe/service';
import '@lm_fe/pages';
var css_248z = ".diag-title-tip {\n  background-color: #515254;\n  color: #fff;\n  font-size: 14px;\n  display: flex;\n  flex-direction: column;\n}\n.diagnoses-container {\n  margin-bottom: 12px;\n  display: flex;\n  align-items: center;\n  padding-right: 20px;\n}\n.diagnoses-container:hover .delBtn {\n  display: inline;\n  float: right;\n}\n.diagnoses-container .diagnoses-item-content {\n  display: flex;\n  flex-direction: column;\n  padding-left: 30px;\n  position: relative;\n  flex: 1;\n  width: 100%;\n}\n.diagnoses-container .diagnoses-item-content .border {\n  width: 0px;\n  border-left: 2px dotted #d7dce7;\n  height: calc(100% - 30px);\n  position: absolute;\n  top: 20px;\n  left: 14px;\n  z-index: 1;\n}\n.diagnoses-container .diagnoses-item-content .border::after {\n  content: ' ';\n  height: 8px;\n  width: 8px;\n  border-radius: 50%;\n  background-color: #d7dce7;\n  position: absolute;\n  bottom: 0px;\n  left: -5px;\n}\n.diagnoses-container .diagnoses-item-content .item-number {\n  position: absolute;\n  top: 10px;\n  left: 5px;\n  border-radius: 50%;\n  width: 20px;\n  height: 20px;\n  line-height: 20px;\n  text-align: center;\n  border: 2px solid #d7dce7;\n  background-color: #fff;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  z-index: 2;\n  color: #333541;\n  font-weight: 400;\n}\n.diagnoses-container .diagnoses-item-content .note-content {\n  background-color: #f3f6fd;\n  border-radius: 4px;\n  line-height: 32px;\n  margin-top: 4px;\n  padding: 0 4px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n}\n.diagnoses-container .diagnoses-item-content .prenote-val-content {\n  background-color: #e7f4fe;\n  display: flex;\n  align-items: center;\n  line-height: 32px;\n  width: 100%;\n  border-radius: 4px;\n}\n.diagnoses-container .diagnoses-item-content .prenote-val-content .prenote {\n  width: 72px;\n  height: 20px;\n  font-size: 14px;\n  font-family: PingFangSC-Regular, PingFang SC;\n  font-weight: 400;\n  color: #535881;\n  line-height: 20px;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n  padding: 0 4px;\n}\n.diagnoses-container .diagnoses-item-content .prenote-val-content .diagnoses-val {\n  flex: 1;\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n  margin: 0px;\n  border-radius: 4px;\n}\n.diagnoses-container .diagnoses-item-content .prenote-val-content .highrisk {\n  background-color: #fcb9c5;\n}\n.diagnoses-container .diagnoses-item-content .diagnoses-val {\n  background-color: #e7f4fe;\n  color: #150f55;\n  font-size: 14px;\n  font-weight: 600;\n  line-height: 32px;\n  border-radius: 4px;\n  padding: 0 6px;\n}\n.diagnoses-container .diagnoses-item-content .margin {\n  margin: 4px 0;\n}\n.diagnoses-container .diagnoses-item-content .highrisk {\n  background-color: #fcb9c5;\n}\n.diagnoses-container .diagnoses-item-content .input-conetnt {\n  background-color: #f3f6fd;\n  border-radius: 4px;\n  display: flex;\n  align-items: center;\n}\n.diagnoses-container .diagnoses-item-content .input-conetnt .input-title {\n  color: #828c99;\n  font-weight: 600;\n  font-size: 14px;\n  width: 60px;\n}\n.diagnoses-container .diagnoses-item-content .input-conetnt .ant-input {\n  border: none;\n  background: #f3f6fd;\n  line-height: 32px;\n  padding: 0 6px;\n}\n.diagnoses-container .diagnoses-item-content .input-conetnt .ant-input:focus {\n  box-shadow: none;\n}\n.diagnoses-container .delBtn {\n  display: none;\n}\n.diagnoses-container input::-webkit-input-placeholder {\n  /* WebKit browsers */\n  color: #828c99;\n  font-weight: 400;\n  font-size: 14px;\n}\n.diagnoses-container input:-moz-placeholder {\n  /* Mozilla Firefox 4 to 18 */\n  color: #828c99;\n  font-weight: 400;\n  font-size: 14px;\n}\n.diagnoses-container input::-moz-placeholder {\n  /* Mozilla Firefox 19+ */\n  color: #828c99;\n  font-weight: 400;\n  font-size: 14px;\n}\n.diagnoses-container input:-ms-input-placeholder {\n  /* Internet Explorer 10+ */\n  color: #828c99;\n  font-weight: 400;\n  font-size: 14px;\n}\n.noedit {\n  margin-bottom: 6px;\n}\n";
styleInject(css_248z);
function DiagnosesItem(_a) {
  var _this = this;
  var updateNote = _a.updateNote,
    handleDelete = _a.handleDelete;
  _a.changeNote;
  var diagnose = _a.diagnose,
    index = _a.index,
    edit = _a.edit,
    props = __rest(_a, ["updateNote", "handleDelete", "changeNote", "diagnose", "index", "edit"]);
  var _b = useState(_get(diagnose, "note")),
    note = _b[0],
    setNote = _b[1];
  var _c = useState(_get(diagnose, "preNote")),
    preNote = _c[0],
    setPreNote = _c[1];
  var _d = useState(null),
    visibleId = _d[0],
    setVisibleId = _d[1];
  useEffect(function () {
    setNote(_get(diagnose, "note"));
    setPreNote(_get(diagnose, "preNote"));
  }, [diagnose]);
  function inputChange3(e) {
    setNote(e.target.value);
  }
  function inputChange2(e) {
    setPreNote(e.target.value);
  }
  function itemDelete() {
    handleDelete && handleDelete(diagnose, index);
  }
  function inputBlur(key) {
    return function () {
      updateNote && updateNote(key == 'note' ? note : preNote, index, key);
    };
  }
  var getTitle = useMemo(function () {
    var createdDate = diagnose.createdDate ? "\u8BCA\u65AD\u65F6\u95F4: ".concat(formatTimeToStandard(diagnose.createdDate), "\n") : '';
    var diagnosis = diagnose.diagnosis ? "\u8BCA\u65AD\u5168\u79F0: ".concat(diagnose.diagnosis, "\n") : '';
    var preNote = diagnose.preNote ? "\u524D\u5907\u6CE8: ".concat(diagnose.preNote, "\n") : '';
    var note = diagnose.note ? "\u540E\u5907\u6CE8: ".concat(diagnose.note, "\n") : '';
    var doctor = diagnose.doctor ? "\u8BCA\u65AD\u533B\u751F: ".concat(diagnose.doctor, "\n") : '';
    return "".concat(createdDate).concat(diagnosis).concat(preNote).concat(note).concat(doctor);
  }, [diagnose]);
  function changeHeaderInfo() {
    return __awaiter(this, void 0, void 0, function () {
      var headerInfo, saveHeaderInfo, res;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            headerInfo = props.headerInfo, saveHeaderInfo = props.saveHeaderInfo;
            return [4, request.get('/api/doctor/getOutpatientHeaderInfo?id=' + _get(headerInfo, "id"))];
          case 1:
            res = _a.sent();
            saveHeaderInfo(res.data);
            return [2];
        }
      });
    });
  }
  function handleVisibleChange(visible, i) {
    var diagnosesList = props.diagnosesList,
      setDiagnosesList = props.setDiagnosesList;
    var newList = _cloneDeep(diagnosesList);
    var item = newList[i];
    _map(newList, function (it, ind) {
      if (_get(it, "visible")) {
        _set(it, "visible", false);
      }
    });
    item.visible = visible;
    setDiagnosesList(newList);
  }
  var popoverContent = function popoverContent(item, i) {
    var diagnosesList = props.diagnosesList,
      setDiagnosesList = props.setDiagnosesList;
    var handleHighrisk = function handleHighrisk() {
      return __awaiter(_this, void 0, void 0, function () {
        var newList, postData;
        return __generator(this, function (_a) {
          switch (_a.label) {
            case 0:
              newList = _cloneDeep(diagnosesList);
              _set(newList, "[".concat(i, "].highrisk"), newList[i].highrisk ? false : true);
              postData = newList[i];
              return [4, requestMethods_further.newAddDiagnosis(postData)];
            case 1:
              _a.sent();
              setDiagnosesList(newList);
              changeHeaderInfo();
              return [2];
          }
        });
      });
    };
    var handleSortChange = function handleSortChange(n) {
      return __awaiter(_this, void 0, void 0, function () {
        var newList;
        return __generator(this, function (_a) {
          switch (_a.label) {
            case 0:
              newList = _cloneDeep(diagnosesList);
              item.visible = false;
              newList[i] = newList[i + n];
              newList[i + n] = item;
              newList.forEach(function (subItem, subIndex) {
                subItem.sort = subIndex + 1;
              });
              return [4, requestMethods_further.sortDiagnoses(newList)];
            case 1:
              _a.sent();
              setDiagnosesList(newList);
              return [2];
          }
        });
      });
    };
    return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement("span", {
      className: "diagHandle",
      onClick: function onClick() {
        return handleHighrisk();
      }
    }, item.highrisk === true ? '取消高危诊断' : '标记高危诊断')), i ? /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement("span", {
      className: "diagHandle",
      onClick: function onClick() {
        return handleSortChange(-1);
      }
    }, "\u4E0A \u79FB")) : null, i + 1 < _size(diagnosesList) ? /*#__PURE__*/React__default.createElement("p", null, /*#__PURE__*/React__default.createElement("span", {
      className: "diagHandle",
      onClick: function onClick() {
        return handleSortChange(1);
      }
    }, "\u4E0B \u79FB")) : null);
  };
  return /*#__PURE__*/React__default.createElement("div", {
    id: edit ? "edit".concat(index) : "noedit".concat(index),
    className: classnames('diagnoses-container', {
      noedit: !edit
    }),
    title: getTitle
  }, edit && /*#__PURE__*/React__default.createElement("div", {
    className: "diagnoses-item-content"
  }, /*#__PURE__*/React__default.createElement("span", {
    className: "item-number"
  }, index + 2), /*#__PURE__*/React__default.createElement("div", {
    className: "border"
  }), /*#__PURE__*/React__default.createElement("div", {
    className: "input-conetnt"
  }, /*#__PURE__*/React__default.createElement(_Input, {
    placeholder: "\u8BF7\u8F93\u5165\u524D\u5907\u6CE8",
    onChange: inputChange2,
    onBlur: inputBlur('preNote'),
    className: "my-input pre-input",
    value: preNote
  })), /*#__PURE__*/React__default.createElement(_Popover, {
    className: "diag-popover2",
    trigger: "click",
    content: popoverContent(diagnose, index),
    visible: _get(diagnose, "id") == visibleId,
    onVisibleChange: function onVisibleChange(visible) {
      return setTimeout(function () {
        if (visible) {
          setVisibleId(_get(diagnose, "id"));
        } else {
          setVisibleId(null);
        }
      }, 200);
    }
  }, /*#__PURE__*/React__default.createElement("div", {
    className: classnames('diagnoses-val margin', {
      highrisk: _get(diagnose, "highrisk")
    })
  }, _get(diagnose, "diagnosis"))), /*#__PURE__*/React__default.createElement("div", {
    className: "input-conetnt"
  }, /*#__PURE__*/React__default.createElement(_Input, {
    placeholder: "\u8BF7\u8F93\u5165\u540E\u5907\u6CE8",
    onChange: inputChange3,
    onBlur: inputBlur('note'),
    className: "my-input",
    value: note
  }))), !edit && /*#__PURE__*/React__default.createElement("div", {
    className: "diagnoses-item-content"
  }, /*#__PURE__*/React__default.createElement("span", {
    className: "item-number"
  }, index + 2), /*#__PURE__*/React__default.createElement(_Popover, {
    className: "diag-popover2",
    trigger: "click",
    content: popoverContent(diagnose, index),
    visible: !props.isShowDiagnosesTemplate && !!diagnose.visible,
    onVisibleChange: function onVisibleChange(visible) {
      return setTimeout(function () {
        handleVisibleChange(visible, index);
      }, 200);
    }
  }, /*#__PURE__*/React__default.createElement("div", {
    className: classnames('prenote-val-content', {
      highrisk: _get(diagnose, "highrisk")
    })
  }, preNote && /*#__PURE__*/React__default.createElement("div", {
    className: "prenote"
  }, preNote), /*#__PURE__*/React__default.createElement("div", {
    className: classnames('diagnoses-val', {
      highrisk: _get(diagnose, "highrisk")
    })
  }, _get(diagnose, "diagnosis")))), note && /*#__PURE__*/React__default.createElement("div", {
    className: "note-content"
  }, note)), /*#__PURE__*/React__default.createElement(_Popconfirm, {
    placement: "topRight",
    title: '你确定要删除这个诊断吗？',
    onConfirm: itemDelete,
    okText: "\u786E\u5B9A",
    cancelText: "\u53D6\u6D88"
  }, /*#__PURE__*/React__default.createElement(DeleteOutlined, {
    size: 6,
    className: "delBtn",
    type: "icon-cacncel"
  })));
}
export { DiagnosesItem as default };
//# sourceMappingURL=prenatal-visit.pregnancy.doctor-end18.js.map
