import 'antd/es/message/style';
import _message from 'antd/es/message';
import _get from 'lodash/get';
import { b as __awaiter, c as __generator } from './index.js';
import { OkButton, formatTimeToDate } from '@lm_fe/components_m';
import { mchcLogger, APP_CONFIG } from '@lm_fe/env';
import { MyBaseList } from '@lm_fe/pages';
import { request } from '@lm_fe/utils';
import React__default from 'react';
import 'antd/es/tabs/style';
import 'antd/es/tabs';
import 'lodash/size';
import 'lodash/orderBy';
import 'lodash/map';
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 '@ant-design/icons';
import '@lm_fe/service';
var req_url = {
  1: "/api/prenatal-visit-logs/apppointmentRemind",
  2: "/api/prenatal-visit-logs/timeoutRemind",
  3: ""
};
function RemindRecord(prop) {
  var _this = this;
  var remindType = prop.remindType;
  var url = req_url[remindType];
  return /*#__PURE__*/React__default.createElement(MyBaseList, {
    name: "/api/prenatal-visit-logs",
    searchParams: {
      'remindType.equals': remindType
    },
    needChecked: true,
    useListSourceCount: true,
    initialSearchValue: {},
    searchConfig: [{
      label: '就诊卡号',
      name: 'prenatalVisitCriteria.pregnancy.outpatientNO',
      inputType: 'Input'
    }, {
      label: '姓名',
      name: 'prenatalVisitCriteria.pregnancy.name',
      inputType: 'Input'
    }, {
      label: '预约时间',
      name: 'appointmentDate',
      inputType: 'rangeDate'
    }, {
      label: '提醒方式',
      name: 'remindWay',
      inputType: 'MS',
      inputProps: {
        options: '短信,微信'
      }
    }, {
      label: '发送状态',
      name: 'sendStatus',
      inputType: 'MS',
      inputProps: {
        options: '成功,失败'
      }
    }],
    showAction: false,
    showAdd: false,
    RenderBtns: function RenderBtns(ctx) {
      var selectRows = ctx.getCheckRows();
      return /*#__PURE__*/React__default.createElement(OkButton, {
        primary: true,
        disabled: !selectRows.length,
        onClick: function onClick() {
          return __awaiter(_this, void 0, void 0, function () {
            var q, remindWay, prenatalVisitIds, params;
            return __generator(this, function (_a) {
              switch (_a.label) {
                case 0:
                  q = ctx.getSearchParams();
                  mchcLogger.log('qq', {
                    q: q,
                    selectRows: selectRows
                  });
                  remindWay = _get(q, 'remindWay.equals');
                  if (!remindWay) {
                    _message.info('请选择提醒方式...');
                    return [2];
                  }
                  prenatalVisitIds = selectRows.map(function (_) {
                    return _get(_, 'prenatalVisit.id');
                  });
                  params = {
                    remindWay: remindWay,
                    prenatalVisitIds: prenatalVisitIds
                  };
                  return [4, request.post(url, params)];
                case 1:
                  _a.sent();
                  _message.info('批量发送操作成功，详情请看发送记录~！');
                  ctx.handleSearch();
                  return [2];
              }
            });
          });
        }
      }, "\u91CD\u65B0\u53D1\u9001");
    },
    genColumns: function genColumns(ctx) {
      return [{
        title: '姓名',
        dataIndex: ['prenatalVisit', 'pregnancy', 'name'],
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        showSorter: false,
        align: 'center'
      }, {
        title: '就诊卡号',
        dataIndex: ['prenatalVisit', 'pregnancy', 'outpatientNO'],
        width: APP_CONFIG.CELL_WIDTH_SMALL
      }, {
        title: '预产期',
        dataIndex: ['prenatalVisit', 'pregnancy', 'edd'],
        width: APP_CONFIG.CELL_WIDTH_SMALL
      }, {
        title: '当前孕周',
        dataIndex: ['prenatalVisit', 'pregnancy', 'currentGestationalWeek'],
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        showSorter: false,
        showFilter: false
      }, {
        title: '上次就诊时间',
        dataIndex: 'lastVisitDate',
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        render: function render(value) {
          return formatTimeToDate(value);
        }
      }, {
        title: '复诊预约日期',
        dataIndex: ['prenatalVisit', 'appointmentDate'],
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        render: function render(value) {
          return formatTimeToDate(value);
        }
      }, {
        title: '提醒方式',
        dataIndex: 'remindWay',
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        render: function render(text) {
          var index = text ? text : 0;
          var state = ['', '短信', '微信', '电话'];
          return state[index];
        }
      }, {
        title: '发送时间',
        dataIndex: 'sendTime',
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        render: function render(value) {
          return formatTimeToDate(value);
        }
      }, {
        title: '发送状态',
        dataIndex: 'sendStatus',
        width: APP_CONFIG.CELL_WIDTH_SMALL,
        render: function render(text) {
          var index = text ? text : 0;
          var state = ['', '成功', '失败', '未知'];
          return state[index];
        }
      }, {
        title: '异常提示',
        dataIndex: 'errorMsg',
        width: APP_CONFIG.CELL_WIDTH_SMALL
      }, {
        title: '发送内容',
        dataIndex: 'content',
        width: APP_CONFIG.CELL_WIDTH_LARGE
      }, {
        title: '操作',
        dataIndex: 'content',
        width: APP_CONFIG.CELL_WIDTH_LARGE,
        render: function render(a, record) {
          return /*#__PURE__*/React__default.createElement(OkButton, {
            size: "small",
            primary: true,
            onClick: function onClick() {
              return __awaiter(_this, void 0, void 0, function () {
                var id, params;
                return __generator(this, function (_a) {
                  switch (_a.label) {
                    case 0:
                      id = _get(record, 'prenatalVisit.id');
                      params = {
                        remindWay: record.remindWay,
                        prenatalVisitIds: [id]
                      };
                      return [4, request.post(url, params)];
                    case 1:
                      _a.sent();
                      _message.info('发送操作成功，详情请看发送记录~');
                      ctx.handleSearch();
                      return [2];
                  }
                });
              });
            }
          }, "\u53D1\u9001");
        }
      }];
    }
  });
}
export { RemindRecord as default };
//# sourceMappingURL=pages.visit-management.remind-record2.js.map
