import 'antd/es/switch/style';
import _Switch from 'antd/es/switch';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import { d as __assign, a as __spreadArray } from './index.js';
import { QrcodeOutlined } from '@ant-design/icons';
import { QRCode } from '@lm_fe/components';
import { mchcEvent, mchcEnv } from '@lm_fe/env';
import { BF_Wrap2, MyBaseList, mchcModal__ } from '@lm_fe/pages';
import { request } from '@lm_fe/utils';
import React__default, { useEffect } from 'react';
function List(props) {
  var which_type = props.which_type;
  var type = which_type === '孕妇学校' ? 1 : 2;
  var _a = BF_Wrap2({
      default_conf: {
        title: "".concat(which_type, "-\u8BFE\u7A0B\u5217\u8868"),
        tableColumns: function tableColumns() {
          return import('./pages.pregnant-school.lessons2.js');
        },
        name: '/api/courses',
        searchParams: {
          'course.type.equals': type
        },
        searchConfig: [{
          name: 'courseDate',
          label: '开课日期',
          inputType: 'rangeDate'
        }, {
          label: '课程标题',
          inputType: 'input',
          name: 'name'
        }]
      }
    }),
    Wrap = _a.Wrap,
    config = _a.config;
  useEffect(function () {
    var rm = mchcEvent.on_rm('custom_msg', function (e) {
      var rowData = e.data;
      if (e.type === 'courses.reserveNum') {
        openFuckModal(rowData);
      }
    });
    return rm;
  }, []);
  return /*#__PURE__*/React__default.createElement(Wrap, null, /*#__PURE__*/React__default.createElement(MyBaseList, {
    name: config === null || config === void 0 ? void 0 : config.name,
    searchParams: config === null || config === void 0 ? void 0 : config.searchParams,
    useListSourceCount: true,
    initialSearchValue: {},
    showCopy: true,
    beforeSubmit: function beforeSubmit(v) {
      return __assign(__assign({}, v), {
        type: type
      });
    },
    searchConfig: config === null || config === void 0 ? void 0 : config.searchConfig,
    ActionAddonBefore: function ActionAddonBefore(ctx) {
      return /*#__PURE__*/React__default.createElement(_Button, {
        size: "small",
        onClick: function onClick() {
          handleQrcodeView(ctx.rowData);
        },
        icon: /*#__PURE__*/React__default.createElement(QrcodeOutlined, null)
      });
    },
    genColumns: function genColumns(ctx) {
      var _a;
      return __spreadArray(__spreadArray([], (_a = config === null || config === void 0 ? void 0 : config.tableColumns) !== null && _a !== void 0 ? _a : [], true), [{
        dataIndex: 'status',
        title: '发布',
        layout: '1/1',
        inputType: 'MC',
        width: 50,
        inputProps: {
          marshal: 0,
          options: mchcEnv.get_other_options('nyOptions')
        },
        render: function render(status, rowData) {
          return /*#__PURE__*/React__default.createElement(_Switch, {
            size: "small",
            checked: status,
            onChange: function onChange() {
              request.put('/api/courses', __assign(__assign({}, rowData), {
                status: !rowData.status
              })).then(function () {
                ctx.handleSearch();
              });
            }
          });
        }
      }, ctx.actionCol], false);
    }
  }));
}
function handleQrcodeView(rowData) {
  mchcModal__.open('test', {
    title: '患者手机端-首页-扫一扫-进行扫码签到',
    width: 400,
    bodyStyle: {
      height: 400
    },
    modal_data: {
      content: /*#__PURE__*/React__default.createElement(QRCode, {
        value: "courseid~".concat(rowData.id, "~").concat(rowData.name),
        size: 380
      })
    }
  });
}
function openFuckModal(rowData) {
  mchcModal__.open('test', {
    title: '已预约列表',
    modal_data: {
      content: /*#__PURE__*/React__default.createElement(MyBaseList, {
        name: "/api/courses/reservations",
        search: true,
        showAdd: false,
        showAction: false,
        searchParams: {
          courseId: rowData.id
        },
        tableColumns: [{
          title: '患者姓名',
          dataIndex: ['pregnancy', 'name'],
          width: 200,
          align: 'center'
        }, {
          title: '身份证号：',
          dataIndex: ['pregnancy', 'idNO'],
          width: 200,
          align: 'center'
        }]
      })
    }
  });
}
export { List as L };
//# sourceMappingURL=index4.js.map
