import { IdNOButton, MyBaseList } from '@lm_fe/pages';
import React__default, { useEffect } from 'react';
import 'antd/es/popconfirm/style';
import _Popconfirm from 'antd/es/popconfirm';
import 'antd/es/divider/style';
import _Divider from 'antd/es/divider';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import 'antd/es/form/style';
import _Form from 'antd/es/form';
import { d as __assign, a as __spreadArray, b as __awaiter, c as __generator, s as styleInject } from './index.js';
import { EyeOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons';
import { useMyEffectSafe } from '@lm_fe/components';
import { mchcEvent, mchcDriver } from '@lm_fe/env';
import { downloadFile, request } from '@lm_fe/utils';
import { APP_CONFIG, idNOFuzzy, formatTimeToDate } from '@lm_fe/components_m';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/size';
import 'lodash/get';
import 'lodash/orderBy';
import 'lodash/map';
import 'antd/es/collapse/style';
import 'antd/es/collapse';
import 'antd/es/badge/style';
import 'antd/es/badge';
import 'lodash/assign';
import '@lm_fe/service';
var queryFormDescriptions = function queryFormDescriptions() {
  return [{
    name: 'inpatientNO',
    label: '住院号',
    inputType: 'input',
    filterType: ''
  }, {
    name: 'name',
    label: '孕妇姓名',
    inputType: 'input',
    filterType: ''
  }, {
    name: 'idNO',
    label: '证件号码',
    inputType: 'input',
    style: {
      width: 168
    }
  }, {
    name: 'state',
    label: '状态',
    inputType: 'select',
    filterType: 'equals',
    inputProps: {
      options: [{
        label: '住院',
        value: 1
      }, {
        label: '已出院',
        value: 2
      }, {
        label: '全部',
        value: ''
      }]
    }
  }];
};
var tableColumns = [{
  title: '住院号',
  dataIndex: 'inpatientNO',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '病区号',
  dataIndex: 'areaNO',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '房号',
  dataIndex: 'roomNO',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '床号',
  dataIndex: 'bedNO',
  key: 'bedNO',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '孕妇姓名',
  dataIndex: 'name',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '证件号码',
  dataIndex: 'idNO',
  key: 'idNO',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_MIDDLE,
  render: function render(text) {
    return idNOFuzzy(text);
  }
}, {
  title: '孕妇年龄',
  dataIndex: 'age',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '出生日期',
  dataIndex: 'dob',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '预产期',
  dataIndex: 'edd',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL
}, {
  title: '住院日期',
  dataIndex: 'adminDate',
  align: 'center',
  width: APP_CONFIG.CELL_WIDTH_SMALL,
  render: function render(value) {
    return formatTimeToDate(value);
  }
}];
var baseTableConfig = {
  baseTitle: '孕册',
  name: '/admissions',
  tableColumns: tableColumns,
  searchConfig: queryFormDescriptions()
};
function useTableConfig(props) {
  var history = props.history;
  var form = _Form.useForm()[0];
  useEffect(function () {
    return mchcEvent.on_rm('my_form', function (e) {
      if (e.type === 'onSearch' && e.name === "outpatientNO") ;
    });
  }, []);
  useEffect(function () {}, []);
  useMyEffectSafe(props)(function () {
    return mchcDriver.on_rm('data', function (e) {
      if (e.type === 'ReadCard') {
        var res = e.data;
        form.setFieldsValue({
          idNO: res.idNO,
          name: res.name
        });
        form.submit();
      }
    });
  }, []);
  function handleView(rowData) {
    var id = rowData.id;
    history.push("/deliver-management-v2/admission/deliver-edit?id=".concat(id));
  }
  function handleEdit(rowData) {
    var id = rowData.id;
    history.push("/deliver-management-v2/admission/edit?id=".concat(id));
  }
  function handleExport(params) {
    return __awaiter(this, void 0, void 0, function () {
      var res;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            return [4, request.get('/api/export/admissions', {
              responseType: 'blob',
              params: params
            })];
          case 1:
            res = _a.sent().data;
            downloadFile(res.data, '导出数据.xls', 'application/vnd.ms-excel');
            return [2];
        }
      });
    });
  }
  function handleDoubleClickRow(record) {
    var id = record.id,
      recordstate = record.recordstate;
    if (recordstate === '1' || recordstate === '6') {
      history.push("/prenatal-visit/pregnancy/nurse-end?id=".concat(id));
    }
    if (recordstate === '0') {
      history.push("/prenatal-visit/pregnancy/check?id=".concat(id));
    }
  }
  function onAdd() {
    history.push('/deliver-management-v2/admission/add');
  }
  var config = __assign(__assign({}, baseTableConfig), {
    effect_ctx: props,
    searchForm: form,
    handleDoubleClickRow: handleDoubleClickRow,
    RenderSearchBtns: function RenderSearchBtns(_a) {
      _a.handleSearch;
      _a.getSearchParams;
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
    },
    RenderBtns: function RenderBtns(_a) {
      return /*#__PURE__*/React__default.createElement(IdNOButton, null);
    },
    onExport: function onExport(_a) {
      var getSearchParams = _a.getSearchParams;
      handleExport(getSearchParams());
    },
    onAdd: onAdd,
    genColumns: function genColumns(_a) {
      var handleDelete = _a.handleDelete,
        tableColumns = _a.tableColumns;
      return __spreadArray(__spreadArray([], tableColumns, true), [{
        align: 'center',
        title: '操作',
        fixed: 'right',
        width: 198,
        render: function render(recordstate, rowData) {
          return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Button, {
            type: "link",
            size: "small",
            icon: /*#__PURE__*/React__default.createElement(EyeOutlined, {
              className: "global-table-action-icon"
            }),
            onClick: function onClick() {
              return handleView(rowData);
            }
          }, "\u67E5\u770B"), /*#__PURE__*/React__default.createElement(_Divider, {
            type: "vertical"
          }), /*#__PURE__*/React__default.createElement(_Button, {
            type: "link",
            size: "small",
            icon: /*#__PURE__*/React__default.createElement(EditOutlined, {
              className: "global-table-action-icon"
            }),
            onClick: function onClick() {
              return handleEdit(rowData);
            }
          }, "\u7F16\u8F91"), /*#__PURE__*/React__default.createElement(_Divider, {
            type: "vertical"
          }), /*#__PURE__*/React__default.createElement(_Popconfirm, {
            title: "\u786E\u5B9A\u8981\u5220\u9664\u5417?",
            onConfirm: function onConfirm() {
              return handleDelete(rowData);
            },
            okText: "\u786E\u5B9A",
            cancelText: "\u53D6\u6D88"
          }, /*#__PURE__*/React__default.createElement(_Button, {
            type: "link",
            size: "small",
            icon: /*#__PURE__*/React__default.createElement(DeleteOutlined, {
              className: "global-table-action-icon"
            })
          }, "\u5220\u9664")));
        }
      }], false);
    }
  });
  return [config];
}
var css_248z = ".egister_ {\n  border: 1px solid #ccc;\n  border-radius: 12px;\n  display: inline-block;\n  width: 70px;\n  height: 24.22px;\n  line-height: 22px;\n  cursor: pointer;\n}\n.egister_1 {\n  border-color: #828c99;\n  color: #828c99;\n  border: 1px solid #7f8c9a;\n}\n.egister_2 {\n  border-color: #21ac8d;\n  color: #21ac8d;\n}\n";
styleInject(css_248z);
function newList(props) {
  var config = useTableConfig(props)[0];
  return /*#__PURE__*/React__default.createElement(MyBaseList, config);
}
export { newList as default };
//# sourceMappingURL=deliver-management-v2.admission.list.js.map
