import 'antd/es/tabs/style';
import _Tabs from 'antd/es/tabs';
import 'antd/es/form/style';
import _Form from 'antd/es/form';
import _map from 'lodash/map';
import _get from 'lodash/get';
import { b as __awaiter, c as __generator, d as __assign, s as styleInject } from './index.js';
import React__default, { useState, useEffect } from 'react';
import { C as ClosingArchives } from './index1.js';
import 'antd/es/message/style';
import _message from 'antd/es/message';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import 'lodash/set';
import { SaveOutlined } from '@ant-design/icons';
import { BaseEditPanelFormFC } from '@lm_fe/components_m';
import { SMchc_Doctor } from '@lm_fe/service';
import { getSearchParamsValue } from '@lm_fe/utils';
import { mchcEnv } from '@lm_fe/env';
import 'lodash/size';
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 'lodash/assign';
import '@lm_fe/pages';
var form_config$1 = function form_config$1() {
  return [{
    "key": "partnerName",
    "label": "姓名",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "partnerTelephone",
    "label": "手机号码",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "partnerPatientNO",
    "label": "就诊卡号",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "partnerIdType",
    "label": "证件类型",
    "inputType": "MS",
    "inputProps": {
      "optionKey": "证件类型",
      marshal: 0
    },
    "isNewRow": 1,
    layout: '1/3'
  }, {
    "key": "partnerIdNO",
    "label": "证件号码",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "partnerDob",
    "label": "出生日期",
    "inputType": "DatePicker",
    layout: '1/3'
  }, {
    "key": "partnerAge",
    "label": "年龄",
    "inputType": "input",
    "inputProps": {
      "type": "number"
    },
    layout: '1/3'
  }, {
    "key": "partnerNationality",
    "label": "国籍",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "partnerNativeplace",
    "label": "籍贯",
    "inputType": "MS",
    "inputProps": {
      "optionKey": "provinceMapping",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "partnerEthnic",
    "label": "民族",
    "inputType": "MS",
    "inputProps": {
      "optionKey": "民族s",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "partnerOccupation",
    "label": "职业",
    "inputType": "MS",
    "inputProps": {
      "optionKey": "职业s",
      marshal: 0
    },
    layout: '1/3'
  }, mchcEnv["in"](['建瓯']) ? {
    "key": "hfmh",
    "label": "家族史",
    "inputType": "checkbox_group_object",
    "inputProps": {
      optionKey: '家族史'
    },
    layout: '1/1',
    "isNewRow": 1
  } : null, {
    "key": "smoke__",
    "label": "烟",
    "inputType": "MyCheckbox",
    isNewRow: 1,
    "inputProps": {
      marshal: 1,
      options: [{
        value: false,
        label: '无'
      }, {
        value: true,
        label: '有',
        warning: true,
        inputType: 'Input'
      }]
    },
    layout: '1/3'
  }, {
    "key": "alcohol__",
    "label": "酒",
    "inputType": "MyCheckbox",
    "inputProps": {
      marshal: 1,
      options: [{
        value: false,
        label: '无'
      }, {
        value: true,
        label: '有',
        warning: true,
        inputType: 'Input'
      }]
    },
    layout: '1/3'
  }, {
    "key": "disease__",
    "label": "疾病史",
    "inputType": "MyCheckbox",
    "inputProps": {
      marshal: 1,
      options: [{
        value: false,
        label: '无'
      }, {
        value: true,
        label: '有',
        warning: true,
        inputType: 'Input'
      }]
    },
    layout: '1/3'
  }, {
    "key": "partnerPermanentResidenceAddress",
    "label": "户口地址",
    "inputType": "MyAddress",
    layout: '1/1'
  }, {
    "key": "partnerResidenceAddress",
    "label": "居住地址",
    "inputType": "MyAddress",
    layout: '1/1'
  }];
};
function HusbandInfo(_a) {
  var headerInfo = _a.headerInfo;
  _a.isSingle;
  var _b = _a.form,
    form = _b === void 0 ? _Form.useForm()[0] : _b;
  var _c = useState(),
    data = _c[0],
    setData = _c[1];
  useEffect(function () {
    var _a;
    var id = (_a = headerInfo === null || headerInfo === void 0 ? void 0 : headerInfo.id) !== null && _a !== void 0 ? _a : getSearchParamsValue('id');
    SMchc_Doctor.getHusbandBaseInfoOfOutpatient(id).then(function (res) {
      form.setFieldsValue(res);
      setData(res);
    });
    return function () {};
  }, []);
  function renderSubmitBtn() {
    return /*#__PURE__*/React__default.createElement(_Button, {
      size: "large",
      type: "primary",
      icon: /*#__PURE__*/React__default.createElement(SaveOutlined, null),
      htmlType: "submit",
      onClick: handleFinish
    }, "\u4FDD\u5B58");
  }
  function handleFinish() {
    return __awaiter(this, void 0, void 0, function () {
      var _this = this;
      return __generator(this, function (_a) {
        form.validateFields().then(function () {
          return __awaiter(_this, void 0, void 0, function () {
            var params, newData;
            return __generator(this, function (_a) {
              switch (_a.label) {
                case 0:
                  params = __assign(__assign({}, form.getFieldsValue()), {
                    id: _get(data, 'id')
                  });
                  return [4, SMchc_Doctor.updateHusbandBaseInfoOfOutpatient(params)];
                case 1:
                  newData = _a.sent();
                  _message.success("\u4FEE\u6539\u6210\u529F");
                  setData(newData);
                  return [2];
              }
            });
          });
        })["catch"](function (error) {
          _message.error(_get(error, 'errorFields.0.errors.0'));
          form.scrollToField(_get(error, 'errorFields.0.name.0'));
        });
        return [2];
      });
    });
  }
  return /*#__PURE__*/React__default.createElement(BaseEditPanelFormFC, {
    form: form,
    formDescriptions: form_config$1(),
    renderBtns: function renderBtns(form) {
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderSubmitBtn());
    }
  });
}
var css_248z = ".questionnaire-steps {\n  background-color: white;\n  height: 70px;\n  display: flex;\n  align-items: center;\n  padding: 0 15% !important;\n  margin-bottom: 8px;\n}\n.questionnaire-steps-content {\n  padding: 16px;\n  background-color: white;\n}\n.prenatal-visit-main_base {\n  height: 100%;\n  background-color: #fff;\n}\n.prenatal-visit-main_base .prenatal-visit-main_base-tabs {\n  height: 100%;\n}\n.prenatal-visit-main_base .prenatal-visit-main_base-tabs .ant-tabs-content-holder {\n  height: calc(100% - 34px);\n  overflow-y: auto;\n  border: 1px solid #5050e8;\n  border-top: none;\n}\n.prenatal-visit-main_base .prenatal-visit-main_base-tabs .ant-tabs-content-holder .ant-tabs-content {\n  min-width: 1200px;\n  padding: 12px 0;\n}\n.prenatal-visit-main_base .ant-tabs > .ant-tabs-nav .ant-tabs-nav-wrap,\n.prenatal-visit-main_base .ant-tabs > div > .ant-tabs-nav .ant-tabs-nav-wrap {\n  overflow: visible;\n}\n.prenatal-visit-main_base-tabs .ant-tabs-bar {\n  margin-bottom: 0;\n}\n.prenatal-visit-main_base-tabs .ant-tabs-nav-wrap {\n  border-bottom: 1px solid #5050e8;\n}\n.prenatal-visit-main_base-tabs .ant-tabs-nav {\n  background-color: #f8f8fb !important;\n  margin-bottom: 0;\n}\n.prenatal-visit-main_base-tabs .ant-tabs-tab {\n  height: 34px !important;\n  margin-right: 2px !important;\n  border-left-color: #fafafa !important;\n  background-color: #fff !important;\n  padding: 6px 16px !important;\n}\n.prenatal-visit-main_base-tabs .ant-tabs-tab.ant-tabs-tab-active {\n  transform: translateY(1px) !important;\n  color: #5050e8;\n  border-color: #5050e8 !important;\n  border-bottom: none !important;\n  border-radius: 6px 6px 0 0 !important;\n}\n.prenatal-visit-main_base-btns {\n  text-align: center;\n  margin-top: 100px;\n  margin-right: 100px;\n}\n";
styleInject(css_248z);
var form_config = function form_config() {
  return [{
    "key": "age",
    "label": "年龄",
    "inputType": "input",
    "rules": [{
      "required": true,
      "message": "年龄是必填项"
    }],
    "inputProps": {
      "type": "number"
    },
    layout: '1/3'
  }, {
    "key": "dob",
    "label": "出生日期",
    "inputType": "DatePicker",
    "rules": [{
      "required": true,
      "message": "出生日期是必填项"
    }],
    layout: '1/3'
  }, {
    "key": "validateDate",
    "label": "建档日期",
    "inputType": "DatePicker",
    "rules": [{
      "required": true,
      "message": "建档日期是必填项"
    }],
    layout: '1/3'
  }, {
    "key": "birthPermit",
    "label": "准生证号",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "outpatientNO",
    "label": "就诊卡号",
    "inputType": "input",
    "rules": [{
      "required": true,
      "message": "就诊卡号是必填项"
    }],
    layout: '1/3'
  }, {
    "key": "checkupNO",
    "label": "产检编号",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "nationality",
    "label": "国籍",
    "inputType": "country_select",
    "rules": [{
      "required": true,
      "message": "国籍是必填项"
    }],
    layout: '1/3'
  }, {
    "key": "nativeplace",
    "label": "籍贯",
    "inputType": "MS",
    "rules": [{
      "required": true,
      "message": "籍贯是必填项"
    }],
    "inputProps": {
      "optionKey": "provinceMapping",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "ethnic",
    "label": "民族",
    "inputType": "MS",
    "rules": [{
      "required": true,
      "message": "民族是必填项"
    }],
    "inputProps": {
      "optionKey": "民族s",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "occupation",
    "label": "职业",
    "inputType": "MS",
    "rules": [{
      "required": true,
      "message": "职业是必填项"
    }],
    "inputProps": {
      "optionKey": "职业s",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "telephone",
    "label": "手机号码",
    "inputType": "input",
    "rules": [{
      "required": true,
      "message": "手机号码是必填项"
    }],
    layout: '1/3'
  }, {
    "key": "workPhone",
    "label": "固定电话",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "idType",
    "label": "证件类型",
    "inputType": "MS",
    "rules": [{
      "required": true,
      "message": "证件类型是必填项"
    }],
    "inputProps": {
      "optionKey": "证件类型",
      marshal: 0
    },
    layout: '1/3'
  }, {
    "key": "idNO",
    "label": "证件号码",
    "inputType": "input",
    layout: '1/3'
  }, {
    "key": "permanentResidenceAddress",
    "label": "户口地址",
    "inputType": "MyAddress",
    "rules": [{
      "required": true,
      "message": "户口地址是必填项"
    }],
    layout: '1/1'
  }, {
    "key": "residenceAddress",
    "label": "居住地地址",
    "inputType": "MyAddress",
    "rules": [{
      "required": true,
      "message": "居住地地址是必填项"
    }],
    layout: '1/1'
  }, {
    "key": "postpartumAddress",
    "label": "产休地址",
    "inputType": "MyAddress",
    "rules": [{
      "required": true,
      "message": "产休地址是必填项"
    }],
    layout: '1/1'
  }];
};
function PregnancyBase(_a) {
  var headerInfo = _a.headerInfo;
  _a.isSingle;
  var _b = _a.form,
    form = _b === void 0 ? _Form.useForm()[0] : _b;
  var _c = useState(),
    data = _c[0],
    setData = _c[1];
  useEffect(function () {
    var _a;
    var id = (_a = headerInfo === null || headerInfo === void 0 ? void 0 : headerInfo.id) !== null && _a !== void 0 ? _a : getSearchParamsValue('id');
    SMchc_Doctor.getPregnancyBaseInfoOfOutpatient(id).then(function (res) {
      form.setFieldsValue(res);
      setData(res);
    });
    return function () {};
  }, []);
  function renderSubmitBtn() {
    return /*#__PURE__*/React__default.createElement(_Button, {
      size: "large",
      type: "primary",
      icon: /*#__PURE__*/React__default.createElement(SaveOutlined, null),
      htmlType: "submit",
      onClick: handleFinish
    }, "\u4FDD\u5B58");
  }
  function handleFinish() {
    return __awaiter(this, void 0, void 0, function () {
      var _this = this;
      return __generator(this, function (_a) {
        form.validateFields().then(function () {
          return __awaiter(_this, void 0, void 0, function () {
            var params, newData;
            return __generator(this, function (_a) {
              switch (_a.label) {
                case 0:
                  params = __assign(__assign({}, form.getFieldsValue()), {
                    id: _get(data, 'id')
                  });
                  return [4, SMchc_Doctor.updatePregnancyBaseInfoOfOutpatient(params)];
                case 1:
                  newData = _a.sent();
                  _message.success("\u4FEE\u6539\u6210\u529F");
                  setData(newData);
                  return [2];
              }
            });
          });
        })["catch"](function (error) {
          _message.error(_get(error, 'errorFields.0.errors.0'));
          form.scrollToField(_get(error, 'errorFields.0.name.0'));
        });
        return [2];
      });
    });
  }
  return /*#__PURE__*/React__default.createElement(BaseEditPanelFormFC, {
    form: form,
    formDescriptions: form_config(),
    renderBtns: function renderBtns(form) {
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, renderSubmitBtn());
    }
  });
}
function DoctorEnd_Base(props) {
  props.isAllPregnancies;
  var _a = useState([{
      key: 'tab-0',
      title: '孕妇信息',
      component: PregnancyBase,
      form: _Form.useForm()[0]
    }, {
      key: 'tab-1',
      title: '丈夫信息',
      component: HusbandInfo,
      form: _Form.useForm()[0]
    }, {
      key: 'tab-2',
      title: '结案管理',
      component: ClosingArchives,
      form: _Form.useForm()[0]
    }]),
    tabs = _a[0];
  _a[1];
  var _b = useState('tab-0'),
    step = _b[0],
    set_step = _b[1];
  useEffect(function () {}, []);
  function handleSubmit(next, bool) {
    return __awaiter(this, void 0, void 0, function () {
      var tab;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            tab = tabs.filter(function (item) {
              return item.key === step;
            })[0];
            return [4, tab.form.validateFields()];
          case 1:
            _a.sent();
            set_step(next);
            return [2];
        }
      });
    });
  }
  function tabsChange(key) {
    handleSubmit(key);
  }
  return /*#__PURE__*/React__default.createElement("div", {
    className: "prenatal-visit-main_base"
  }, /*#__PURE__*/React__default.createElement(_Tabs, {
    type: "card",
    className: "prenatal-visit-main_base-tabs",
    activeKey: step,
    onChange: tabsChange.bind(this)
  }, _map(tabs, function (item) {
    var Component = _get(item, 'component');
    var active = item.key === step;
    return /*#__PURE__*/React__default.createElement(_Tabs.TabPane, {
      tab: item.title,
      key: item.key
    }, active ? /*#__PURE__*/React__default.createElement(Component, props) : null);
  })));
}
export { DoctorEnd_Base as default };
//# sourceMappingURL=prenatal-visit.pregnancy.doctor-end3.js.map
