import _typeof from "@babel/runtime/helpers/typeof";
import 'antd/es/steps/style';
import _Steps from 'antd/es/steps';
import 'antd/es/message/style';
import _message from 'antd/es/message';
import { s as styleInject, a as __spreadArray, d as __assign, b as __awaiter, c as __generator } from './index.js';
import React__default, { useRef, useState, Fragment, useEffect } from 'react';
import 'antd/es/list/style';
import _List from 'antd/es/list';
import 'antd/es/card/style';
import _Card from 'antd/es/card';
import { EditOutlined, CopyOutlined, DeleteOutlined, PieChartOutlined, CloseCircleOutlined, StarOutlined, CheckCircleOutlined, BorderOutlined, CaretDownOutlined, MobileOutlined, DesktopOutlined, TabletOutlined } from '@ant-design/icons';
import { mchcEnv } from '@lm_fe/env';
import 'antd/es/row/style';
import _Row from 'antd/es/row';
import 'antd/es/button/style';
import _Button from 'antd/es/button';
import 'antd/es/tabs/style';
import _Tabs from 'antd/es/tabs';
import 'antd/es/form/style';
import _Form from 'antd/es/form';
import 'antd/es/input/style';
import _Input from 'antd/es/input';
import 'antd/es/col/style';
import _Col from 'antd/es/col';
import { mchcEnums, SMchc_Questionnaire } from '@lm_fe/service';
import 'antd/es/input-number/style';
import _InputNumber from 'antd/es/input-number';
import { LazyAntd, SimpleForm } from '@lm_fe/components';
import 'antd/es/checkbox/style';
import _Checkbox from 'antd/es/checkbox';
import 'antd/es/rate/style';
import _Rate from 'antd/es/rate';
import 'antd/es/radio/style';
import _Radio from 'antd/es/radio';
import 'antd/es/space/style';
import _Space from 'antd/es/space';
import 'lodash/size';
import 'lodash/get';
import '@lm_fe/utils';
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/components_m';
import '@lm_fe/pages';
var css_248z$3 = ".step1-module_questionnaire-steps__tVCBT {\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.step1-module_questionnaire-steps-content__eFPGF {\n  padding: 16px;\n  background-color: white;\n}\n.step1-module_follow-up-step1__xlcv7 .ant-col {\n  height: 100% !important;\n}\n.step1-module_follow-up-step1__xlcv7 .ant-list-item {\n  height: 100%;\n  border-radius: 4px;\n}\n.step1-module_follow-up-step1__xlcv7 .ant-list-item .step1-module_ant-card-meta-detail__ZT-VV .step1-module_ant-card-meta-description__cX5KE,\n.step1-module_follow-up-step1__xlcv7 .ant-list-item .step1-module_ant-card-meta-detail__ZT-VV .step1-module_ant-card-actions__-RQUA,\n.step1-module_follow-up-step1__xlcv7 .ant-list-item .step1-module_ant-card-meta-detail__ZT-VV .step1-module_ant-card-meta-title__K1g1r {\n  color: #333;\n}\n.step1-module_follow-up-step1__xlcv7 .ant-list-item .step1-module_ant-card-actions__-RQUA > li {\n  color: #333;\n}\n.step1-module_follow-up-step1__xlcv7 .step1-module_item-top__ai1OV {\n  text-align: center;\n}\n.step1-module_follow-up-step1__xlcv7 .step1-module_item-top-img__t15PZ {\n  height: 100px;\n  width: auto;\n  margin: 10px 0;\n}\n.step1-module_follow-up-new-item__69jcy {\n  width: 100%;\n  height: 94%;\n  padding-top: 20px;\n  color: #5050e8;\n  background-color: #fff;\n  border-color: red;\n  border-radius: 2px;\n  display: flex;\n  align-items: center;\n  flex-direction: column;\n  background-image: url('/lm_imgs/qn/questionnaire-item-bg.png');\n  background-repeat: no-repeat;\n  background-size: cover;\n  background-position: center;\n  cursor: pointer;\n}\n.step1-module_follow-up-new-item__69jcy:hover {\n  border-color: transparent;\n  box-shadow: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);\n}\n.step1-module_follow-up-new-item__69jcy span {\n  display: block;\n  font-weight: bold;\n  font-size: 18px;\n}\n.step1-module_follow-up-new-item__69jcy .step1-module_anticon__sOqE7 {\n  font-size: 56px;\n}\n";
var styles$3 = {
  "questionnaire-steps": "step1-module_questionnaire-steps__tVCBT",
  "questionnaire-steps-content": "step1-module_questionnaire-steps-content__eFPGF",
  "follow-up-step1": "step1-module_follow-up-step1__xlcv7",
  "ant-card-meta-detail": "step1-module_ant-card-meta-detail__ZT-VV",
  "ant-card-meta-description": "step1-module_ant-card-meta-description__cX5KE",
  "ant-card-actions": "step1-module_ant-card-actions__-RQUA",
  "ant-card-meta-title": "step1-module_ant-card-meta-title__K1g1r",
  "item-top": "step1-module_item-top__ai1OV",
  "item-top-img": "step1-module_item-top-img__t15PZ",
  "follow-up-new-item": "step1-module_follow-up-new-item__69jcy",
  "anticon": "step1-module_anticon__sOqE7"
};
styleInject(css_248z$3);
var itemBgColors = ['#FFEFDD', '#FBDDDD', '#DDF3FB', '#DDFBE4', '#E8DDFB'];
function Step1(props) {
  var handleInitQuestions = props.handleInitQuestions,
    templateList = props.templateList,
    onDeleteTemplate = props.onDeleteTemplate;
  function handleNewTemplate() {
    handleInitQuestions({});
  }
  return /*#__PURE__*/React__default.createElement("div", {
    className: styles$3["follow-up-step1"]
  }, /*#__PURE__*/React__default.createElement(_List, {
    rowKey: function rowKey(item) {
      return (item === null || item === void 0 ? void 0 : item.id) || -1;
    },
    grid: {
      gutter: 24,
      column: 4
    },
    dataSource: __spreadArray([null], templateList, true),
    renderItem: function renderItem(item) {
      return item ? /*#__PURE__*/React__default.createElement(_List.Item, {
        key: item.id
      }, /*#__PURE__*/React__default.createElement(_Card, {
        hoverable: true,
        bodyStyle: {
          paddingBottom: 20
        },
        onClick: function onClick() {
          handleInitQuestions(item);
        },
        cover: /*#__PURE__*/React__default.createElement("div", {
          className: styles$3["item-top"],
          style: {
            backgroundColor: itemBgColors[Math.round(Math.random() * 5)] || '#FFEFDD'
          }
        }, /*#__PURE__*/React__default.createElement("img", {
          className: styles$3["item-top-img"],
          src: mchcEnv.gs(function (_) {
            return _.lm_imgs.qn['questionnaire-item-top.png'];
          }),
          alt: ""
        })),
        actions: [/*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(EditOutlined, {
          key: "edit"
        }), "\u7F16\u8F91"), /*#__PURE__*/React__default.createElement("div", {
          onClick: function onClick(e) {
            e.stopPropagation();
            handleInitQuestions(item, true);
          }
        }, /*#__PURE__*/React__default.createElement(CopyOutlined, {
          key: "copy"
        }), "\u590D\u5236"), /*#__PURE__*/React__default.createElement("div", {
          onClick: function onClick(e) {
            e.stopPropagation();
            onDeleteTemplate(item);
          }
        }, /*#__PURE__*/React__default.createElement(DeleteOutlined, {
          key: "delete"
        }), "\u5220\u9664"), /*#__PURE__*/React__default.createElement("div", {
          onClick: function onClick(e) {
            e.stopPropagation();
            handleInitQuestions(item, false, 3);
          }
        }, /*#__PURE__*/React__default.createElement(PieChartOutlined, {
          key: "delete"
        }), "\u7EDF\u8BA1")]
      }, /*#__PURE__*/React__default.createElement(_Card.Meta, {
        style: {
          cursor: 'pointer'
        },
        title: item.questionnaireTitle,
        description: /*#__PURE__*/React__default.createElement("div", {
          title: item.description,
          style: {
            overflow: 'hidden',
            textOverflow: 'ellipsis',
            whiteSpace: 'nowrap'
          }
        }, item.description)
      }))) : /*#__PURE__*/React__default.createElement(_List.Item, null, /*#__PURE__*/React__default.createElement("div", {
        className: styles$3["follow-up-new-item"],
        onClick: handleNewTemplate
      }, /*#__PURE__*/React__default.createElement("span", null, "\u65B0\u5EFA\u8C03\u67E5\u95EE\u5377")));
    }
  }));
}
var QuestionTypeEnums = mchcEnums.Questionnaire.type;
var chooseArray = [{
  title: '单选题',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['radio.png'];
  })
}, {
  title: '多选题',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['checkbox.png'];
  })
}, {
  title: '下拉题',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['select.png'];
  })
}, {
  title: '填空题',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['vacancy.png'];
  })
}];
var starArray = [{
  title: '打分题',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['stars.png'];
  })
}];
var descArray = [{
  title: '段落说明',
  iconImg: mchcEnv.gs(function (_) {
    return _.lm_imgs.qn['description.png'];
  })
}];
var labelsArray = __spreadArray(__spreadArray(__spreadArray([], chooseArray, true), starArray, true), descArray, true);
var labelsArrayMapping = labelsArray.reduce(function (a, b) {
  var _a;
  return Object.assign(a, (_a = {}, _a[b.title] = b, _a));
}, {});
var defaultSelectOptions = [{
  optionIndex: 1000,
  optionScore: 0,
  optionTitle: '选项1'
}, {
  optionIndex: 1001,
  optionScore: 0,
  optionTitle: '选项2'
}];
var defaultOtherOptions = [{
  optionIndex: 1000,
  optionScore: 0,
  optionTitle: 'contain'
}];
var initQuestionMap = {
  '单选题': {
    questionOptionList: defaultSelectOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('单选题')
  },
  '多选题': {
    questionOptionList: defaultSelectOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('多选题')
  },
  '下拉题': {
    questionOptionList: defaultSelectOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('下拉题')
  },
  '填空题': {
    questionOptionList: defaultOtherOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('填空题')
  },
  '打分题': {
    questionOptionList: defaultOtherOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('打分题')
  },
  '段落说明': {
    questionOptionList: defaultOtherOptions,
    questionTitle: '',
    questionType: QuestionTypeEnums.getValue('段落说明')
  }
};
function getTargetQuestionInGroup(allQuestions, groupIndex, group) {
  if (typeof groupIndex !== 'number' || !group) return undefined;
  var allIdx = allQuestions.map(function (_) {
    return _.questionIndex;
  });
  var list = group.questionIndexList.filter(function (_) {
    return allIdx.includes(_);
  });
  var realQuestionIndex = list[groupIndex];
  var activeQuestion = typeof realQuestionIndex === 'number' ? allQuestions.find(function (_) {
    return _.questionIndex === realQuestionIndex;
  }) : undefined;
  return activeQuestion;
}
function getQuestionsInGroup(allQuestions, groups) {
  var _a;
  var data = ((_a = groups === null || groups === void 0 ? void 0 : groups.questionIndexList) === null || _a === void 0 ? void 0 : _a.map(function (_) {
    return allQuestions.find(function (q) {
      return q.questionIndex === _;
    });
  }).filter(function (_) {
    return !!_;
  })) || [];
  return data;
}
var css_248z$2 = ".step2-module_questionnaire-steps__2fRCr {\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.step2-module_questionnaire-steps-content__uzsSb {\n  padding: 16px;\n  background-color: white;\n}\n.step2-module_question-step-two__panel-question__Oydc6 {\n  height: auto;\n  position: fixed;\n  width: 15%;\n}\n.step2-module_question-step-two__panel-question-card__KXAYi {\n  font-size: 16px;\n}\n.step2-module_question-step-two__panel-question-card-item__ZHOVW {\n  display: flex;\n  border-bottom: 1px solid #edeef5;\n  margin: 16px 0;\n}\n.step2-module_question-step-two__panel-question-card-item__title__lBYEW {\n  display: block;\n  font-weight: 400;\n  flex: 1;\n}\n.step2-module_question-step-two__panel-question-card-item__btns__HSN3o {\n  display: flex;\n  flex: 2;\n  flex-flow: column wrap;\n  justify-content: space-between;\n  margin-left: 8px;\n}\n.step2-module_question-step-two__panel-question-card-item__btns-btn__Mg2vz {\n  margin: 8px 0;\n  display: flex;\n  cursor: pointer;\n}\n.step2-module_question-step-two__panel-question-card-item__btns-btn__Mg2vz img {\n  width: 24px;\n  height: 24px;\n  margin-right: 8px;\n}\n.step2-module_question-step-two__panel-question-card-item__btns-btn__Mg2vz:first-child {\n  margin-top: 0;\n}\n.step2-module_question-step-two__panel-preview__Cm3Hv {\n  border: 1px solid #d9d9d9;\n}\n.step2-module_question-step-two__panel-preview-top__nd9Qh {\n  background-color: white;\n  padding: 24px 8px;\n  margin-bottom: 12px;\n}\n.step2-module_question-step-two__panel-preview-top__desc__X8iJG {\n  margin-top: 8px;\n}\n.step2-module_question-step-two__panel-preview-middle__start__TUt0d {\n  height: 250px;\n  line-height: 250px;\n  border: 1px dotted skyblue;\n  text-align: center;\n}\n.step2-module_question-step-two__panel-preview-middle__question__ELZqX {\n  background-color: white;\n  padding: 16px 8px;\n  margin-bottom: 8px;\n  border-top: 4px solid transparent;\n  border-bottom: 4px solid transparent;\n  border-bottom: 1px solid #d9d9d9;\n}\n.step2-module_question-step-two__panel-preview-middle__question__ELZqX:hover {\n  background-color: #eee;\n}\n.step2-module_question-step-two__panel-preview-middle__question-tip__6jWsd {\n  font-size: 12px;\n  color: #5050e8;\n}\n.step2-module_question-step-two__panel-preview-middle__question-title__l1gIU {\n  margin-bottom: 4px;\n  display: flex;\n  flex-flow: row wrap;\n  justify-content: space-between;\n}\n.step2-module_question-step-two__panel-preview-middle__question-title-icon-delete__YHSIy {\n  display: none;\n  cursor: pointer;\n}\n.step2-module_question-step-two__panel-preview-middle__question-title-icon-delete__YHSIy:hover {\n  color: red;\n}\n.step2-module_question-step-two__panel-preview-middle__question-options__MIHIk {\n  margin: 4px 0;\n  display: flex;\n  flex-flow: row nowrap;\n  align-items: center;\n}\n.step2-module_question-step-two__panel-preview-middle__question-options-input__LLOjS {\n  width: 100% !important;\n}\n.step2-module_question-step-two__panel-preview-middle__question-options-delete__4SiWC {\n  display: none;\n  width: 10%;\n  cursor: pointer;\n}\n.step2-module_question-step-two__panel-preview-middle__question-options-delete__4SiWC:hover {\n  color: red;\n}\n.step2-module_question-step-two__panel-preview-middle__question-options__MIHIk:hover .step2-module_question-step-two__panel-preview-middle__question-options-delete__4SiWC {\n  display: block;\n}\n.step2-module_question-step-two__panel-preview-middle__question__ELZqX:hover .step2-module_question-step-two__panel-preview-middle__question-title-icon-delete__YHSIy {\n  display: block;\n}\n.step2-module_question-step-two__panel-preview-middle__question-border-top__hrodO {\n  border-top: 2px solid red;\n}\n.step2-module_question-step-two__panel-preview-middle__question-border-bottom__YEiln {\n  border-bottom: 2px solid red;\n}\n.step2-module_question-step-two__panel-preview-bottom__GKkv2 {\n  background-color: white;\n  padding: 16px 8px;\n  margin-top: 8px;\n}\n.step2-module_question-step-two__panel-preview-bottom__title__KiD9q {\n  text-align: center;\n  padding-bottom: 8px;\n}\n.step2-module_question-step-two__panel-preview-bottom__btns__VzVPE {\n  display: flex;\n  justify-content: center;\n  flex-flow: row nowrap;\n  margin-top: 16px;\n}\n.step2-module_question-step-two__panel-preview-bottom__btns-btn__f8m28 {\n  margin: 0 8px;\n}\n.step2-module_question-step-two__panel-func__oTmv1 {\n  background-color: white;\n  padding: 24px 14px;\n  height: auto;\n  width: 20%;\n  position: fixed;\n}\n.step2-module_question-step-two__panel-func__title__Qlx59 {\n  padding: 2px 4px;\n  background-color: black;\n  color: white;\n  border-radius: 2px;\n  display: inline-block;\n}\n.step2-module_question-step-two__panel-func__item__lcayS {\n  display: flex;\n  flex-flow: row nowrap;\n  justify-content: space-between;\n  margin: 16px 0;\n}\n.step2-module_question-step-two__panel-func__item__lcayS span,\n.step2-module_question-step-two__panel-func__item__lcayS a {\n  display: block;\n}\n.step2-module_question-step-two__panel-func__item-btn__YOh8s {\n  width: 40% !important;\n}\n";
var styles$2 = {
  "questionnaire-steps": "step2-module_questionnaire-steps__2fRCr",
  "questionnaire-steps-content": "step2-module_questionnaire-steps-content__uzsSb",
  "question-step-two__panel-question": "step2-module_question-step-two__panel-question__Oydc6",
  "question-step-two__panel-question-card": "step2-module_question-step-two__panel-question-card__KXAYi",
  "question-step-two__panel-question-card-item": "step2-module_question-step-two__panel-question-card-item__ZHOVW",
  "question-step-two__panel-question-card-item__title": "step2-module_question-step-two__panel-question-card-item__title__lBYEW",
  "question-step-two__panel-question-card-item__btns": "step2-module_question-step-two__panel-question-card-item__btns__HSN3o",
  "question-step-two__panel-question-card-item__btns-btn": "step2-module_question-step-two__panel-question-card-item__btns-btn__Mg2vz",
  "question-step-two__panel-preview": "step2-module_question-step-two__panel-preview__Cm3Hv",
  "question-step-two__panel-preview-top": "step2-module_question-step-two__panel-preview-top__nd9Qh",
  "question-step-two__panel-preview-top__desc": "step2-module_question-step-two__panel-preview-top__desc__X8iJG",
  "question-step-two__panel-preview-middle__start": "step2-module_question-step-two__panel-preview-middle__start__TUt0d",
  "question-step-two__panel-preview-middle__question": "step2-module_question-step-two__panel-preview-middle__question__ELZqX",
  "question-step-two__panel-preview-middle__question-tip": "step2-module_question-step-two__panel-preview-middle__question-tip__6jWsd",
  "question-step-two__panel-preview-middle__question-title": "step2-module_question-step-two__panel-preview-middle__question-title__l1gIU",
  "question-step-two__panel-preview-middle__question-title-icon-delete": "step2-module_question-step-two__panel-preview-middle__question-title-icon-delete__YHSIy",
  "question-step-two__panel-preview-middle__question-options": "step2-module_question-step-two__panel-preview-middle__question-options__MIHIk",
  "question-step-two__panel-preview-middle__question-options-input": "step2-module_question-step-two__panel-preview-middle__question-options-input__LLOjS",
  "question-step-two__panel-preview-middle__question-options-delete": "step2-module_question-step-two__panel-preview-middle__question-options-delete__4SiWC",
  "question-step-two__panel-preview-middle__question-border-top": "step2-module_question-step-two__panel-preview-middle__question-border-top__hrodO",
  "question-step-two__panel-preview-middle__question-border-bottom": "step2-module_question-step-two__panel-preview-middle__question-border-bottom__YEiln",
  "question-step-two__panel-preview-bottom": "step2-module_question-step-two__panel-preview-bottom__GKkv2",
  "question-step-two__panel-preview-bottom__title": "step2-module_question-step-two__panel-preview-bottom__title__KiD9q",
  "question-step-two__panel-preview-bottom__btns": "step2-module_question-step-two__panel-preview-bottom__btns__VzVPE",
  "question-step-two__panel-preview-bottom__btns-btn": "step2-module_question-step-two__panel-preview-bottom__btns-btn__f8m28",
  "question-step-two__panel-func": "step2-module_question-step-two__panel-func__oTmv1",
  "question-step-two__panel-func__title": "step2-module_question-step-two__panel-func__title__Qlx59",
  "question-step-two__panel-func__item": "step2-module_question-step-two__panel-func__item__lcayS",
  "question-step-two__panel-func__item-btn": "step2-module_question-step-two__panel-func__item-btn__YOh8s"
};
styleInject(css_248z$2);
LazyAntd.Tree;
LazyAntd.TreeSelect;
var Select$3 = LazyAntd.Select;
LazyAntd.Table;
LazyAntd.Dropdown;
LazyAntd.Pagination;
function QuestionItem(props) {
  var _a;
  var _b, _c;
  var index = props.index,
    question = props.question,
    onChangeIndex = props.onChangeIndex,
    onQuestionClick = props.onQuestionClick,
    onQuestionItemDelete = props.onQuestionItemDelete,
    onQuesionChange = props.onQuesionChange,
    groupQuestions = props.groupQuestions;
  var questionType = question.questionType,
    _d = question.questionOptionList,
    questionOptionList = _d === void 0 ? [] : _d;
  var ref = useRef(null);
  var _e = useState(''),
    hoverTargetQuestionPlace = _e[0],
    setHoverTargetQuestionPlace = _e[1];
  var bind = (_b = question.logic) === null || _b === void 0 ? void 0 : _b.bind;
  var handleQuestionDragOver = function handleQuestionDragOver(e) {
    var _a = ref.current.getBoundingClientRect(),
      y = _a.y,
      height = _a.height;
    var normalClientY = y + height / 2;
    var clientY = e.clientY;
    if (clientY) {
      var hoverTargetQuestionPlace_1 = 'Bottom';
      var newQuestionIndex = index + 1;
      if (clientY < normalClientY) {
        hoverTargetQuestionPlace_1 = 'Top';
        newQuestionIndex = index;
      }
      setHoverTargetQuestionPlace(hoverTargetQuestionPlace_1);
      onChangeIndex(newQuestionIndex);
    }
  };
  var handleQuestionDragLeave = function handleQuestionDragLeave() {
    setHoverTargetQuestionPlace('');
  };
  var renderQuestionInput = function renderQuestionInput() {
    var typeLabel = QuestionTypeEnums.getLabel(questionType);
    if (typeLabel === '单选题' || typeLabel === '多选题' || typeLabel === '下拉题') {
      var icons_1 = {
        '单选题': /*#__PURE__*/React__default.createElement(CheckCircleOutlined, null),
        '多选题': /*#__PURE__*/React__default.createElement(BorderOutlined, null),
        '下拉题': /*#__PURE__*/React__default.createElement(CaretDownOutlined, null)
      };
      return questionOptionList.map(function (option, optionIndex) {
        return /*#__PURE__*/React__default.createElement(_Row, {
          key: optionIndex,
          className: styles$2["question-step-two__panel-preview-middle__question-options"]
        }, /*#__PURE__*/React__default.createElement(_Col, {
          span: 14
        }, /*#__PURE__*/React__default.createElement(_Input, {
          className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
          addonBefore: icons_1[typeLabel],
          value: option.optionTitle,
          onChange: function onChange(e) {
            questionOptionList.splice(optionIndex, 1, __assign(__assign({}, option), {
              optionTitle: e.target.value
            }));
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          size: "small"
        })), /*#__PURE__*/React__default.createElement(_Col, {
          span: 7,
          offset: 1,
          style: {
            display: 'flex'
          }
        }, /*#__PURE__*/React__default.createElement("div", {
          style: {
            width: 80
          }
        }, "\u5206\u503C\uFF1A"), /*#__PURE__*/React__default.createElement(_InputNumber, {
          className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
          value: option.optionScore,
          onChange: function onChange(score) {
            questionOptionList.splice(optionIndex, 1, __assign(__assign({}, option), {
              optionScore: score
            }));
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          size: "small"
        })), /*#__PURE__*/React__default.createElement(_Col, {
          span: 1,
          offset: 1
        }, /*#__PURE__*/React__default.createElement(CloseCircleOutlined, {
          onClick: function onClick(e) {
            e.stopPropagation();
            questionOptionList.splice(optionIndex, 1);
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          className: styles$2["question-step-two__panel-preview-middle__question-options-delete"]
        })));
      });
    }
    if (typeLabel === '填空题') {
      return /*#__PURE__*/React__default.createElement("div", {
        className: styles$2["question-step-two__panel-preview-middle__question-completion"]
      }, /*#__PURE__*/React__default.createElement(_Input, {
        className: styles$2["question-step-two__panel-preview-middle__question-completion-input"],
        size: "small",
        style: {
          marginTop: 4
        }
      }), questionOptionList.map(function (option, optionIndex) {
        return /*#__PURE__*/React__default.createElement(_Row, {
          key: optionIndex,
          className: styles$2["question-step-two__panel-preview-middle__question-options"]
        }, /*#__PURE__*/React__default.createElement(_Col, {
          span: 6,
          style: {
            display: 'flex'
          }
        }, /*#__PURE__*/React__default.createElement("div", {
          style: {
            width: '100%'
          }
        }, "\u8BA1\u5206\u89C4\u5219\uFF1A"), /*#__PURE__*/React__default.createElement(Select$3, {
          className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
          value: option.optionTitle,
          onSelect: function onSelect(value) {
            questionOptionList.splice(optionIndex, 1, __assign(__assign({}, option), {
              optionTitle: value
            }));
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          dropdownMatchSelectWidth: true,
          size: "small"
        }, /*#__PURE__*/React__default.createElement(Select$3.Option, {
          value: "equal"
        }, "\u76F8\u7B49"), /*#__PURE__*/React__default.createElement(Select$3.Option, {
          value: "contain"
        }, "\u5305\u542B"))), /*#__PURE__*/React__default.createElement(_Col, {
          span: 7,
          offset: 1,
          style: {
            display: 'flex'
          }
        }, /*#__PURE__*/React__default.createElement("div", {
          style: {
            width: '100%'
          }
        }, "\u6807\u51C6\u7B54\u6848\uFF1A"), /*#__PURE__*/React__default.createElement(_Input, {
          className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
          value: option.fillTemplate,
          onChange: function onChange(e) {
            questionOptionList.splice(optionIndex, 1, __assign(__assign({}, option), {
              fillTemplate: e.target.value
            }));
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          size: "small"
        })), /*#__PURE__*/React__default.createElement(_Col, {
          span: 7,
          offset: 1,
          style: {
            display: 'flex'
          }
        }, /*#__PURE__*/React__default.createElement("div", {
          style: {
            width: 80
          }
        }, "\u5206\u503C\uFF1A"), /*#__PURE__*/React__default.createElement(_InputNumber, {
          className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
          value: option.optionScore,
          onChange: function onChange(score) {
            questionOptionList.splice(optionIndex, 1, __assign(__assign({}, option), {
              optionScore: score
            }));
            onQuesionChange(__assign(__assign({}, question), {
              questionOptionList: __spreadArray([], questionOptionList, true)
            }));
          },
          size: "small"
        })));
      }));
    }
    if (typeLabel === '段落说明') {
      return /*#__PURE__*/React__default.createElement("div", {
        className: styles$2["question-step-two__panel-preview-middle__question-options"]
      });
    }
    if (typeLabel === '打分题') {
      return /*#__PURE__*/React__default.createElement("div", {
        className: styles$2["question-step-two__panel-preview-middle__question-options"]
      }, /*#__PURE__*/React__default.createElement(StarOutlined, null), /*#__PURE__*/React__default.createElement(StarOutlined, null), /*#__PURE__*/React__default.createElement(StarOutlined, null), /*#__PURE__*/React__default.createElement(StarOutlined, null), /*#__PURE__*/React__default.createElement(StarOutlined, null));
    }
    return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
  };
  var renderBottomBtns = function renderBottomBtns() {
    if (QuestionTypeEnums.getValues(['单选题', '多选题', '下拉题']).includes(question.questionType)) {
      return /*#__PURE__*/React__default.createElement("div", {
        style: {
          marginTop: 20
        }
      }, /*#__PURE__*/React__default.createElement(_Button, {
        size: "small",
        onClick: function onClick(e) {
          onQuesionChange(__assign(__assign({}, question), {
            questionOptionList: __spreadArray(__spreadArray([], questionOptionList, true), [{
              optionTitle: '新增选项',
              optionIndex: questionOptionList.reduce(function (a, b) {
                return Math.max(a, b.optionIndex);
              }, 1000) + 1,
              optionScore: 0,
              questionType: question.questionType
            }], false)
          }));
        }
      }, "\u6DFB\u52A0\u9009\u9879"));
    }
  };
  return /*#__PURE__*/React__default.createElement("div", {
    style: hoverTargetQuestionPlace ? (_a = {}, _a["border".concat(hoverTargetQuestionPlace)] = '4px solid #ff0000', _a) : {},
    ref: ref,
    className: styles$2["question-step-two__panel-preview-middle__question"],
    onDragOver: handleQuestionDragOver,
    onDragLeave: handleQuestionDragLeave,
    onClick: function onClick() {
      onQuestionClick(__assign(__assign({}, question), {
        questionIndex: index
      }));
    }
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$2["question-step-two__panel-preview-middle__question-title"]
  }, /*#__PURE__*/React__default.createElement("h4", null, index + 1, ".", labelsArrayMapping[QuestionTypeEnums.getLabel(question.questionType)].title), /*#__PURE__*/React__default.createElement(DeleteOutlined, {
    onClick: function onClick(e) {
      e.stopPropagation();
      onQuestionItemDelete();
    },
    className: styles$2["question-step-two__panel-preview-middle__question-title-icon-delete"]
  })), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(_Input, {
    className: styles$2["question-step-two__panel-preview-middle__question-options-input"],
    value: question.questionTitle,
    size: "small",
    placeholder: "\u8BF7\u8F93\u5165\u6807\u9898",
    onChange: function onChange(e) {
      onQuesionChange(__assign(__assign({}, question), {
        questionTitle: e.target.value
      }));
    }
  }), renderQuestionInput()), !!((_c = question.logic) === null || _c === void 0 ? void 0 : _c.selectOption.length) && groupQuestions.findIndex(function (_) {
    return _.questionIndex === bind;
  }) > -1 && /*#__PURE__*/React__default.createElement("div", {
    className: styles$2["question-step-two__panel-preview-middle__question-tip"]
  }, "\u4F9D\u8D56\u4E8E\u7B2C", groupQuestions.findIndex(function (_) {
    var _a;
    return _.questionIndex === ((_a = question.logic) === null || _a === void 0 ? void 0 : _a.bind);
  }) + 1, "\u9898\u7684\u7B2C", question.logic.selectOption.map(function (value) {
    return value + 1;
  }).join('、'), "\u9009\u9879"), renderBottomBtns());
}
LazyAntd.Tree;
LazyAntd.TreeSelect;
var Select$2 = LazyAntd.Select;
LazyAntd.Table;
LazyAntd.Dropdown;
LazyAntd.Pagination;
function Step2Right(props) {
  var _a, _b, _c;
  var groupQuestions = props.groupQuestions,
    activeQuestion = props.activeQuestion,
    onQuesionChange = props.onQuesionChange;
  props.activeGroup;
  props.index;
  var bind = (_a = activeQuestion.logic) === null || _a === void 0 ? void 0 : _a.bind;
  var realIndex = groupQuestions.findIndex(function (_) {
    return _.questionIndex === activeQuestion.questionIndex;
  });
  var selectQuestions = groupQuestions.filter(function (q, idx) {
    return idx < realIndex;
  });
  var targetBind = groupQuestions.find(function (_) {
    return _.questionIndex === bind;
  });
  console.log('aax', bind, targetBind);
  var boxOptions = (targetBind === null || targetBind === void 0 ? void 0 : targetBind.questionOptionList) || [];
  function _onChange(selectOption, bind) {
    var _a;
    if (bind === void 0) {
      bind = (_a = activeQuestion.logic) === null || _a === void 0 ? void 0 : _a.bind;
    }
    onQuesionChange(__assign(__assign({}, activeQuestion), {
      logic: {
        selectOption: selectOption,
        bind: bind
      }
    }));
  }
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("span", null, "\u5F53\u524D\u9898\u76EE\uFF1A"), /*#__PURE__*/React__default.createElement("span", null, activeQuestion.questionTitle)), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(_Form.Item, {
    label: "\u5173\u8054\u9898\u76EE\uFF1A"
  }, /*#__PURE__*/React__default.createElement(Select$2, {
    style: {
      width: 300
    },
    dropdownMatchSelectWidth: 300,
    allowClear: true,
    placeholder: "\u8BF7\u9009\u62E9",
    value: (_b = activeQuestion.logic) === null || _b === void 0 ? void 0 : _b.bind,
    onChange: function onChange(value) {
      _onChange([], value);
    },
    options: selectQuestions.map(function (_, index) {
      return {
        label: "".concat(index + 1, ".").concat(_.questionTitle),
        value: _.questionIndex,
        disabled: !QuestionTypeEnums.getValues(['多选题', '单选题', '下拉题']).includes(_.questionType)
      };
    })
  })), targetBind && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", null, "\u5F53\u201C\u5173\u8054\u9898\u76EE\u201D\u9009\u62E9\u4E0B\u9762\u7684\u9009\u9879\uFF1A"), /*#__PURE__*/React__default.createElement(_Checkbox.Group, {
    value: ((_c = activeQuestion.logic) === null || _c === void 0 ? void 0 : _c.selectOption) || [],
    onChange: function onChange(value) {
      return _onChange(value);
    }
  }, boxOptions.map(function (option, index) {
    return /*#__PURE__*/React__default.createElement(Fragment, {
      key: index
    }, /*#__PURE__*/React__default.createElement(_Checkbox, {
      key: index,
      value: index
    }, option.optionTitle), /*#__PURE__*/React__default.createElement("br", null));
  })), /*#__PURE__*/React__default.createElement("div", null, "\u4E2D\u7684\u4EFB\u610F\u4E00\u4E2A\u65F6\uFF0C\u201C\u5F53\u524D\u9898\u76EE\u201D\u624D\u51FA\u73B0"))), /*#__PURE__*/React__default.createElement(_Form.Item, {
    label: "\u662F\u5426\u5168\u5C4F\u663E\u793A"
  }, /*#__PURE__*/React__default.createElement(_Checkbox, {
    checked: activeQuestion.fullscreen,
    onChange: function onChange(e) {
      onQuesionChange(__assign(__assign({}, activeQuestion), {
        fullscreen: e.target.checked
      }));
    }
  })));
}
var btns = [{
  id: 1,
  title: '选择填空',
  value: chooseArray
}, {
  id: 2,
  title: '评分题',
  value: starArray
}, {
  id: 3,
  title: '文字说明',
  value: descArray
}];
function Step2(props) {
  var _a;
  var data = props.data,
    onPreview = props.onPreview,
    onChangeStep = props.onChangeStep;
  props.onEditorUpload;
  var _b = useState(data.questionnaireTitle),
    questionnaireTitle = _b[0],
    setQuestionnaireTitle = _b[1];
  var _c = useState(data.questionList || []),
    questions = _c[0],
    setQuestions = _c[1];
  var _d = useState(data.description),
    description = _d[0],
    setDescription = _d[1];
  var _e = useState(),
    dragItemType = _e[0],
    setDragItemType = _e[1];
  var _f = useState(data.groupVOList || [{
      groupIndex: 0,
      groupDescription: '',
      code: '',
      groupTitle: '第一组',
      questionIndexList: ((_a = data.questionList) === null || _a === void 0 ? void 0 : _a.map(function (_) {
        return _.questionIndex;
      })) || []
    }]),
    groups = _f[0],
    setGroups = _f[1];
  var _g = useState(0),
    activeGroupIdx = _g[0],
    setActiveGroupIdx = _g[1];
  var _h = useState(-1),
    activeQuestionIndexInGroup = _h[0],
    setActiveQuestionIndexInGroup = _h[1];
  var activeGroup = groups.find(function (_) {
    return _.groupIndex === activeGroupIdx;
  });
  var activeQuestion = getTargetQuestionInGroup(questions, activeQuestionIndexInGroup, activeGroup);
  var groupQuestions = getQuestionsInGroup(questions, activeGroup);
  console.log('idx', activeQuestionIndexInGroup, activeQuestion);
  var indexRef = useRef(0);
  function generateQuestionByType(type) {
    return initQuestionMap[type];
  }
  function handleBtnClick(type) {
    return function () {
      addQuesion(type, questions.length);
    };
  }
  function handleChangeIndex(idx) {
    indexRef.current = idx;
  }
  function addQuesion(t, idx) {
    var maxIndex = questions.reduce(function (a, b) {
      return Math.max(a, b.questionIndex);
    }, 1000) + 1;
    var newQuestions = JSON.parse(JSON.stringify(questions));
    var newItem = generateQuestionByType(t);
    newItem.questionIndex = maxIndex;
    var targetGroup = groups.find(function (_) {
      return _.groupIndex === activeGroupIdx;
    });
    if (targetGroup === null || targetGroup === void 0 ? void 0 : targetGroup.questionIndexList) {
      targetGroup.questionIndexList.splice(idx, 0, maxIndex);
    }
    newQuestions.push(newItem);
    setQuestions(newQuestions);
    setGroups(__spreadArray([], groups, true));
  }
  function handleDragEnd() {
    if (!dragItemType) return;
    addQuesion(dragItemType, indexRef.current);
  }
  function modifyQuestion(item) {
    var idx = questions.findIndex(function (_) {
      return _.questionIndex === item.questionIndex;
    });
    questions[idx] = item;
    setQuestions(__spreadArray([], questions, true));
  }
  function renderQuestions(q) {
    return q.map(function (question, index) {
      var lastQuestion = questions[questions.length - 1];
      return /*#__PURE__*/React__default.createElement(QuestionItem, {
        groupQuestions: groupQuestions,
        key: index,
        index: index,
        question: question,
        lastQuestion: lastQuestion,
        onChangeIndex: handleChangeIndex,
        onQuestionClick: function onQuestionClick() {
          return setActiveQuestionIndexInGroup(index);
        },
        onQuesionChange: modifyQuestion,
        onQuestionItemDelete: function onQuestionItemDelete() {
          var _a, _b;
          if (!activeGroup) return;
          var logicBindIds = [];
          questions.forEach(function (question) {
            var _a;
            typeof ((_a = question.logic) === null || _a === void 0 ? void 0 : _a.bind) === 'number' && logicBindIds.push(question.logic.bind);
          });
          if (logicBindIds.indexOf(question.questionIndex) > -1) {
            _message.error('该题有逻辑关联，无法删除');
            return;
          }
          var realIndex = questions.findIndex(function (_) {
            return _.questionIndex === question.questionIndex;
          });
          questions.splice(realIndex, 1);
          var indexOfGroup = (_a = activeGroup.questionIndexList) === null || _a === void 0 ? void 0 : _a.indexOf(question.questionIndex);
          if (typeof indexOfGroup === 'number' && indexOfGroup > -1) {
            (_b = activeGroup.questionIndexList) === null || _b === void 0 ? void 0 : _b.splice(indexOfGroup, 1);
            groups.splice(activeGroupIdx, 1, __assign({}, activeGroup));
          }
          setQuestions(__spreadArray([], questions, true));
        }
      });
    });
  }
  function renderBtns() {
    return /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-question"]
    }, /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-question-card"]
    }, btns.map(function (btn, index) {
      return /*#__PURE__*/React__default.createElement("div", {
        key: index,
        className: styles$2["question-step-two__panel-question-card-item"]
      }, /*#__PURE__*/React__default.createElement("span", {
        className: styles$2["question-step-two__panel-question-card-item__title"]
      }, btn.title), /*#__PURE__*/React__default.createElement("div", {
        className: styles$2["question-step-two__panel-question-card-item__btns"]
      }, btn.value.map(function (item) {
        return /*#__PURE__*/React__default.createElement("div", {
          key: item.title,
          className: styles$2["question-step-two__panel-question-card-item__btns-btn"],
          draggable: true,
          onDragStart: function onDragStart() {
            setDragItemType(item.title);
          },
          onDragEnd: handleDragEnd,
          onClick: handleBtnClick(item.title)
        }, /*#__PURE__*/React__default.createElement("img", {
          src: item.iconImg,
          alt: ""
        }), /*#__PURE__*/React__default.createElement("div", null, item.title));
      })));
    })));
  }
  function renderLogicEdit() {
    return activeQuestion && /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-func"]
    }, /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-func__title"]
    }, "\u9898\u76EE", activeQuestionIndexInGroup + 1, "\u8BBE\u7F6E"), activeGroup && activeQuestion && /*#__PURE__*/React__default.createElement(Step2Right, {
      activeGroup: activeGroup,
      onQuesionChange: modifyQuestion,
      index: activeQuestionIndexInGroup,
      groupQuestions: groupQuestions,
      activeQuestion: activeQuestion
    }));
  }
  function setCurrentGroup(key, value) {
    if (activeGroup) {
      activeGroup[key] = value;
      groups.splice(activeGroupIdx, 1, __assign({}, activeGroup));
      setGroups(__spreadArray([], groups, true));
    }
  }
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(_Row, {
    className: styles$2["question-step-two__panel"]
  }, /*#__PURE__*/React__default.createElement(_Col, {
    span: 4
  }, renderBtns()), /*#__PURE__*/React__default.createElement(_Col, {
    span: 12,
    offset: 1,
    className: styles$2["question-step-two__panel-preview"]
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$2["question-step-two__panel-preview-top"]
  }, /*#__PURE__*/React__default.createElement(_Input, {
    className: styles$2["question-step-two__panel-preview-top__title"],
    value: questionnaireTitle,
    placeholder: "\u8BF7\u8F93\u5165\u6807\u9898",
    onChange: function onChange(e) {
      setQuestionnaireTitle(e.target.value);
    }
  }), /*#__PURE__*/React__default.createElement(_Input.TextArea, {
    className: styles$2["question-step-two__panel-preview-top__title"],
    value: description,
    style: {
      marginTop: 12
    },
    placeholder: "\u8BF7\u8F93\u5165\u63CF\u8FF0",
    onChange: function onChange(e) {
      setDescription(e.target.value);
    }
  })), /*#__PURE__*/React__default.createElement(_Tabs, {
    type: "editable-card",
    activeKey: activeGroupIdx.toString(),
    onChange: function onChange(e) {
      return setActiveGroupIdx(+e);
    },
    onEdit: function onEdit(key, action) {
      if (action === 'add') {
        groups.push({
          groupIndex: groups.length,
          groupTitle: "\u7B2C".concat(groups.length + 1, "\u7EC4"),
          questionIndexList: [],
          groupDescription: '',
          code: ''
        });
      } else {
        groups.splice(+key, 1);
      }
      setGroups(__spreadArray([], groups, true));
    }
  }, groups.map(function (_, idx) {
    var active = _.groupIndex === activeGroupIdx;
    var q = getQuestionsInGroup(questions, _);
    return /*#__PURE__*/React__default.createElement(_Tabs.TabPane, {
      tab: _.groupTitle,
      key: _.groupIndex
    }, /*#__PURE__*/React__default.createElement(_Form.Item, {
      label: "\u6807\u9898",
      wrapperCol: {
        span: 17
      },
      style: {
        padding: '0 8px'
      }
    }, /*#__PURE__*/React__default.createElement(_Input, {
      size: "small",
      value: activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.groupTitle,
      onChange: function onChange(e) {
        setCurrentGroup('groupTitle', e.target.value);
      }
    })), /*#__PURE__*/React__default.createElement(_Form.Item, {
      label: "\u63CF\u8FF0",
      wrapperCol: {
        span: 17
      },
      style: {
        padding: '0 8px'
      }
    }, /*#__PURE__*/React__default.createElement(_Input, {
      size: "small",
      value: activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.groupDescription,
      onChange: function onChange(e) {
        setCurrentGroup('groupDescription', e.target.value);
      }
    })), /*#__PURE__*/React__default.createElement(_Form.Item, {
      label: "\u89C4\u5219",
      wrapperCol: {
        span: 17
      },
      style: {
        padding: '0 8px'
      }
    }, /*#__PURE__*/React__default.createElement(_Input.TextArea, {
      size: "small",
      placeholder: "\u4F8B\u5982\uFF1A".concat(JSON.stringify([["[9,13)", "轻度"], ["[13,~)", "中重度"]])),
      value: activeGroup === null || activeGroup === void 0 ? void 0 : activeGroup.code,
      onChange: function onChange(e) {
        setCurrentGroup('code', e.target.value);
      }
    })), /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-preview-middle"]
    }, !q.length ? /*#__PURE__*/React__default.createElement("div", {
      className: styles$2["question-step-two__panel-preview-middle__start"]
    }, "\u70B9\u51FB\u9898\u578B \u6216\u8005 \u5C06\u9898\u578B\u62D6\u5165\u6B64\u533A\u57DF") : active && renderQuestions(q)));
  })), /*#__PURE__*/React__default.createElement("div", {
    className: styles$2["question-step-two__panel-preview-bottom"]
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$2["question-step-two__panel-preview-bottom__btns"]
  }, /*#__PURE__*/React__default.createElement(_Button, {
    className: styles$2["question-step-two__panel-preview-bottom__btns-btn"],
    onClick: function onClick() {
      onChangeStep(0);
    }
  }, "\u4E0A\u4E00\u6B65"), /*#__PURE__*/React__default.createElement(_Button, {
    type: "primary",
    className: styles$2["question-step-two__panel-preview-bottom__btns-btn"],
    onClick: function onClick() {
      onPreview(__assign(__assign({}, data), {
        groupVOList: groups,
        questionnaireTitle: questionnaireTitle,
        description: description,
        questionList: questions
      }));
    }
  }, "\u4E0B\u4E00\u6B65")))), /*#__PURE__*/React__default.createElement(_Col, {
    span: 6,
    offset: 1
  }, !!questions.length && renderLogicEdit())));
}
var css_248z$1 = ".step3-module_questionnaire-steps__hnLCy {\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.step3-module_questionnaire-steps-content__gsy1y {\n  padding: 16px;\n  background-color: white;\n}\n.step3-module_question-step-three__panel__a5-8F {\n  width: 100%;\n  padding: 16px 8px;\n}\n.step3-module_question-step-three__panel-bottom__-9TeF {\n  width: 100%;\n  display: flex;\n  justify-content: center;\n  margin-top: 50px;\n}\n.step3-module_question-step-three__panel-radio__RVwTz {\n  text-align: center;\n}\n.step3-module_question-step-three__panel-mobile__-2KHO {\n  display: flex;\n  margin-top: 16px;\n  justify-content: center;\n}\n.step3-module_question-step-three__panel-mobile-preview__RP20Y {\n  height: 640px;\n  width: 360px;\n  background-size: contain;\n  background-image: url('/lm_imgs/qn/phone.jpg');\n  background-repeat: no-repeat;\n  background-position: center;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl {\n  height: 100%;\n  padding: 72px 44px 74px 45px;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form {\n  padding: 8px;\n  overflow-y: scroll;\n  height: 100%;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form .step3-module_questions-title__z76Ew {\n  text-align: center;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form .step3-module_questions-desc__NkpDu {\n  margin: 8px 0;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form .ant-form-item {\n  padding: 8px;\n  border: 1px solid #d9d9d9;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form .ant-form-item:last-child {\n  width: 100%;\n  border: none;\n}\n.step3-module_question-step-three__panel-mobile-preview_content__HP1rl .ant-form .ant-form-item:last-child button {\n  width: 100%;\n}\n.step3-module_question-step-three__panel-compute__peaG8 {\n  margin: 10px auto;\n  background-image: url('/lm_imgs/qn/mackbook.png');\n  background-size: contain;\n  background-repeat: no-repeat;\n  background-position: center;\n  display: flex;\n  justify-content: center;\n  padding: 70px 0 100px 0;\n  height: 600px;\n  width: 1000px;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .step3-module_questions-title__z76Ew {\n  text-align: center;\n  font-size: 20px;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .step3-module_questions-desc__NkpDu {\n  margin: 10px;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form {\n  padding: 8px;\n  overflow-y: scroll;\n  height: 100%;\n  width: 60%;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form .step3-module_questions-title__z76Ew {\n  text-align: center;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form .step3-module_questions-desc__NkpDu {\n  margin: 8px 0;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form .ant-form-item {\n  padding: 8px;\n  border: 1px solid #d9d9d9;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form .ant-form-item:last-child {\n  width: 100%;\n  border: none;\n}\n.step3-module_question-step-three__panel-compute__peaG8 .ant-form .ant-form-item:last-child button {\n  width: 100%;\n}\n.step3-module_question-step-three__panel-tablet__bztKK {\n  margin: 10px auto;\n  background-image: url('/lm_imgs/qn/tablet.png');\n  background-size: contain;\n  background-repeat: no-repeat;\n  background-position: center;\n  display: flex;\n  justify-content: center;\n  padding: 70px 0 100px 0;\n  height: 500px;\n  width: 800px;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .step3-module_questions-title__z76Ew {\n  text-align: center;\n  font-size: 20px;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .step3-module_questions-desc__NkpDu {\n  margin: 10px;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form {\n  padding: 8px;\n  overflow-y: scroll;\n  height: 100%;\n  width: 60%;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form .step3-module_questions-title__z76Ew {\n  text-align: center;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form .step3-module_questions-desc__NkpDu {\n  margin: 8px 0;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form .ant-form-item {\n  padding: 8px;\n  border: 1px solid #d9d9d9;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form .ant-form-item:last-child {\n  width: 100%;\n  border: none;\n}\n.step3-module_question-step-three__panel-tablet__bztKK .ant-form .ant-form-item:last-child button {\n  width: 100%;\n}\n";
var styles$1 = {
  "questionnaire-steps": "step3-module_questionnaire-steps__hnLCy",
  "questionnaire-steps-content": "step3-module_questionnaire-steps-content__gsy1y",
  "question-step-three__panel": "step3-module_question-step-three__panel__a5-8F",
  "question-step-three__panel-bottom": "step3-module_question-step-three__panel-bottom__-9TeF",
  "question-step-three__panel-radio": "step3-module_question-step-three__panel-radio__RVwTz",
  "question-step-three__panel-mobile": "step3-module_question-step-three__panel-mobile__-2KHO",
  "question-step-three__panel-mobile-preview": "step3-module_question-step-three__panel-mobile-preview__RP20Y",
  "question-step-three__panel-mobile-preview_content": "step3-module_question-step-three__panel-mobile-preview_content__HP1rl",
  "questions-title": "step3-module_questions-title__z76Ew",
  "questions-desc": "step3-module_questions-desc__NkpDu",
  "question-step-three__panel-compute": "step3-module_question-step-three__panel-compute__peaG8",
  "question-step-three__panel-tablet": "step3-module_question-step-three__panel-tablet__bztKK"
};
styleInject(css_248z$1);
LazyAntd.Tree;
LazyAntd.TreeSelect;
var Select$1 = LazyAntd.Select;
LazyAntd.Table;
LazyAntd.Dropdown;
LazyAntd.Pagination;
var Step3 = function Step3(props) {
  var _a = useState('mobile'),
    device = _a[0],
    setDevice = _a[1];
  var _b = useState([]),
    globalLogic = _b[0],
    setGlobalLogic = _b[1];
  var data = props.data,
    onChangeStep = props.onChangeStep;
  console.log('data', data);
  var _c = data.questionList,
    questionList = _c === void 0 ? [] : _c;
  data.questionnaireTitle;
  data.description;
  var _d = data.groupVOList,
    groupVOList = _d === void 0 ? [] : _d;
  var form = _Form.useForm()[0];
  function handleSave() {
    return __awaiter(this, void 0, void 0, function () {
      var method;
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            method = 'post';
            if (typeof data.id === 'number') {
              method = 'put';
            }
            return [4, SMchc_Questionnaire[method](data)];
          case 1:
            _a.sent();
            _message.success('保存问卷成功');
            onChangeStep(0);
            return [2];
        }
      });
    });
  }
  useEffect(function () {
    var newGlobalLogic = __spreadArray([], globalLogic, true);
    questionList.map(function (question, index) {
      var logic = question.logic;
      if (logic) {
        newGlobalLogic.push({
          bindIndex: logic.bind,
          index: index
        });
      }
    });
    setGlobalLogic(newGlobalLogic);
  }, []);
  var handleValuesChange = function handleValuesChange(values, allValues) {
    var changedKey = Object.keys(values)[0];
    globalLogic.map(function (_a) {
      var _b;
      var bindIndex = _a.bindIndex,
        index = _a.index;
      if (changedKey == bindIndex) {
        form.setFieldsValue((_b = {}, _b[index] = undefined, _b));
      }
    });
  };
  var renderFormItem = function renderFormItem(question, index) {
    var logic = question.logic,
      _a = question.questionOptionList,
      questionOptionList = _a === void 0 ? [] : _a,
      questionTitle = question.questionTitle,
      questionType = question.questionType;
    var itemStyle = {};
    var Component = /*#__PURE__*/React__default.createElement(Fragment, null);
    var bindIndex = logic === null || logic === void 0 ? void 0 : logic.bind;
    var bindIndexSelectOption = (logic === null || logic === void 0 ? void 0 : logic.selectOption) || [];
    var formItemValue = form.getFieldValue(bindIndex);
    if (logic) {
      itemStyle = {
        display: 'none'
      };
      if (Array.isArray(formItemValue)) {
        formItemValue.map(function (itemOption) {
          if ((bindIndexSelectOption === null || bindIndexSelectOption === void 0 ? void 0 : bindIndexSelectOption.indexOf(itemOption)) > -1) {
            itemStyle = {};
          }
        });
      } else {
        if ((bindIndexSelectOption === null || bindIndexSelectOption === void 0 ? void 0 : bindIndexSelectOption.indexOf(formItemValue)) > -1) {
          itemStyle = {};
        }
      }
    }
    switch (QuestionTypeEnums.getLabel(questionType)) {
      case '单选题':
        Component = /*#__PURE__*/React__default.createElement(_Radio.Group, null, questionOptionList.map(function (option, key) {
          return /*#__PURE__*/React__default.createElement(_Radio, {
            style: {
              display: 'block'
            },
            key: key,
            value: key
          }, option.optionTitle);
        }));
        break;
      case '多选题':
        Component = /*#__PURE__*/React__default.createElement(_Checkbox.Group, null, questionOptionList.map(function (option, key) {
          return /*#__PURE__*/React__default.createElement(_Checkbox, {
            style: {
              display: 'block',
              margin: 0
            },
            key: key,
            value: key
          }, option.optionTitle);
        }));
        break;
      case '下拉题':
        Component = /*#__PURE__*/React__default.createElement(Select$1, null, questionOptionList.map(function (option, key) {
          return /*#__PURE__*/React__default.createElement(Select$1.Option, {
            key: key,
            value: key
          }, option.optionTitle);
        }));
        break;
      case '打分题':
        Component = /*#__PURE__*/React__default.createElement(_Rate, null);
        break;
      case '段落说明':
        break;
      default:
        Component = /*#__PURE__*/React__default.createElement(_Input, null);
        break;
    }
    return /*#__PURE__*/React__default.createElement(_Form.Item, {
      style: itemStyle,
      name: index,
      label: "".concat(index + 1, ".").concat(questionTitle)
    }, Component);
  };
  var renderMobileShow = function renderMobileShow() {
    return /*#__PURE__*/React__default.createElement(_Form, {
      autoComplete: "off",
      form: form,
      layout: "vertical",
      onValuesChange: handleValuesChange
    }, groupVOList.map(function (g) {
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
        className: styles$1["questions-title"]
      }, g.groupTitle), /*#__PURE__*/React__default.createElement("div", {
        className: styles$1["questions-desc"],
        dangerouslySetInnerHTML: {
          __html: g.groupDescription
        }
      }), getQuestionsInGroup(questionList, g).map(function (question, index) {
        return /*#__PURE__*/React__default.createElement(Fragment, {
          key: index
        }, renderFormItem(question, index));
      }));
    }));
  };
  var renderComputeShow = function renderComputeShow() {
    return /*#__PURE__*/React__default.createElement(_Form, {
      autoComplete: "off",
      form: form,
      layout: "vertical",
      onValuesChange: handleValuesChange
    }, groupVOList.map(function (g) {
      return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
        className: styles$1["questions-title"]
      }, g.groupTitle), /*#__PURE__*/React__default.createElement("div", {
        className: styles$1["questions-desc"],
        dangerouslySetInnerHTML: {
          __html: g.groupTitle
        }
      }), getQuestionsInGroup(questionList, g).map(function (question, index) {
        return /*#__PURE__*/React__default.createElement(Fragment, {
          key: index
        }, renderFormItem(question, index));
      }));
    }));
  };
  return /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel"]
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-radio"]
  }, /*#__PURE__*/React__default.createElement(_Radio.Group, {
    onChange: function onChange(e) {
      return setDevice(e.target.value);
    },
    value: device
  }, /*#__PURE__*/React__default.createElement(_Radio.Button, {
    value: "mobile"
  }, /*#__PURE__*/React__default.createElement(MobileOutlined, {
    style: {
      marginRight: 5
    }
  }), "\u624B\u673A"), /*#__PURE__*/React__default.createElement(_Radio.Button, {
    value: "compute"
  }, /*#__PURE__*/React__default.createElement(DesktopOutlined, {
    style: {
      marginRight: 5
    }
  }), "\u7535\u8111"), /*#__PURE__*/React__default.createElement(_Radio.Button, {
    value: "tablet"
  }, /*#__PURE__*/React__default.createElement(TabletOutlined, {
    style: {
      marginRight: 5
    },
    rotate: 270
  }), "\u5E8A\u5934\u5C4F"))), device === 'mobile' && /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-mobile"]
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-mobile-preview"]
  }, /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-mobile-preview_content"]
  }, renderMobileShow()))), device === 'tablet' && /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-tablet"]
  }, renderComputeShow()), device === 'compute' && /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-compute"]
  }, renderComputeShow()), /*#__PURE__*/React__default.createElement("div", {
    className: styles$1["question-step-three__panel-bottom"]
  }, /*#__PURE__*/React__default.createElement(_Button, {
    style: {
      marginRight: 8
    },
    onClick: function onClick() {
      onChangeStep(1);
    }
  }, "\u4E0A\u4E00\u6B65"), /*#__PURE__*/React__default.createElement(_Button, {
    type: "primary",
    style: {
      marginRight: 8
    },
    onClick: handleSave
  }, "\u63D0\u4EA4")));
};
var fakeData = {
  id: 2,
  questionnaireTitle: "测试问卷2------",
  questionList: [],
  groupVOList: []
};
LazyAntd.Tree;
LazyAntd.TreeSelect;
var Select = LazyAntd.Select,
  Table = LazyAntd.Table;
LazyAntd.Dropdown;
LazyAntd.Pagination;
function download(content, filename) {
  if (filename === void 0) {
    filename = '问卷答题情况.xlsx';
  }
  var eleLink = document.createElement('a');
  eleLink.download = filename;
  eleLink.style.display = 'none';
  var blob = typeof content === 'string' ? new Blob([content]) : content;
  console.log(_typeof(content), blob);
  eleLink.href = URL.createObjectURL(blob);
  document.body.appendChild(eleLink);
  eleLink.click();
  document.body.removeChild(eleLink);
}
var d = fakeData;
var L = function L(props) {
  var _a = props.value,
    value = _a === void 0 ? [] : _a,
    _onChange2 = props.onChange,
    questions = props.questions;
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(_Button, {
    block: true,
    onClick: function onClick(e) {
      return _onChange2 === null || _onChange2 === void 0 ? void 0 : _onChange2(__spreadArray(__spreadArray([], value, true), [{}], false));
    }
  }, "\u65B0\u589E"), value === null || value === void 0 ? void 0 : value.map(function (_, idx) {
    var _a, _b, _c;
    var target = questions.find(function (q) {
      return q.id === _.questionId;
    });
    return /*#__PURE__*/React__default.createElement(_Row, {
      key: idx,
      style: {
        marginTop: 6
      },
      gutter: 8
    }, /*#__PURE__*/React__default.createElement(_Col, {
      span: 6
    }, /*#__PURE__*/React__default.createElement(Select, {
      value: _.questionId,
      options: questions === null || questions === void 0 ? void 0 : questions.map(function (q) {
        return {
          label: q.questionTitle,
          value: q.id,
          disabled: value.some(function (v) {
            return v.questionId === q.id;
          })
        };
      }),
      onChange: function onChange(id) {
        var selectTarget = questions.find(function (_) {
          return _.id === id;
        });
        value.splice(idx, 1, __assign(__assign({}, _), {
          questionId: id,
          questionType: selectTarget === null || selectTarget === void 0 ? void 0 : selectTarget.questionType,
          optionIndex: ''
        }));
        _onChange2 === null || _onChange2 === void 0 ? void 0 : _onChange2(__spreadArray([], value, true));
      }
    })), /*#__PURE__*/React__default.createElement(_Col, {
      span: 16
    }, /*#__PURE__*/React__default.createElement(Select, {
      value: (_b = (_a = _.optionIndex) === null || _a === void 0 ? void 0 : _a.split(',')) === null || _b === void 0 ? void 0 : _b.filter(function (_) {
        return !!_;
      }),
      mode: "multiple",
      options: (_c = target === null || target === void 0 ? void 0 : target.questionOptionList) === null || _c === void 0 ? void 0 : _c.map(function (q) {
        var _a;
        return {
          label: q.optionTitle,
          value: (_a = q.optionIndex) === null || _a === void 0 ? void 0 : _a.toString()
        };
      }),
      onChange: function onChange(id) {
        value.splice(idx, 1, __assign(__assign({}, _), {
          optionIndex: id === null || id === void 0 ? void 0 : id.toString()
        }));
        _onChange2 === null || _onChange2 === void 0 ? void 0 : _onChange2(__spreadArray([], value, true));
      }
    })), /*#__PURE__*/React__default.createElement(_Col, {
      span: 2
    }, /*#__PURE__*/React__default.createElement(_Button, {
      block: true,
      style: {
        marginLeft: 0
      },
      danger: true,
      onClick: function onClick(e) {
        value.splice(idx, 1);
        _onChange2 === null || _onChange2 === void 0 ? void 0 : _onChange2(__spreadArray([], value, true));
      }
    }, "\u5220\u9664")));
  }));
};
var Step4 = function Step4(_a) {
  var _b;
  var onChangeStep = _a.onChangeStep,
    _c = _a.data,
    data = _c === void 0 ? d : _c;
  var form = _Form.useForm()[0];
  var _d = useState([]),
    list = _d[0],
    setList = _d[1];
  function getReqData() {
    return __assign({
      questionnaireId: data.id
    }, form.getFieldsValue());
  }
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
    style: {
      display: 'flex',
      justifyContent: 'space-between',
      alignItems: 'center',
      padding: '0 12px',
      marginBottom: 12
    }
  }, /*#__PURE__*/React__default.createElement("span", {
    style: {
      fontSize: 20,
      fontWeight: 'bold'
    }
  }, data.questionnaireTitle), /*#__PURE__*/React__default.createElement(_Space, null, /*#__PURE__*/React__default.createElement(_Button, {
    type: "primary",
    onClick: function onClick() {
      return SMchc_Questionnaire.fk_downloadResult(getReqData()).then(download);
    }
  }, "\u5BFC\u51FA"), /*#__PURE__*/React__default.createElement(_Button, {
    type: "primary",
    onClick: function onClick() {
      return onChangeStep(0);
    }
  }, "\u8FD4\u56DE"))), /*#__PURE__*/React__default.createElement(SimpleForm, {
    onValuesChange: function onValuesChange(v) {
      return console.log('xxd', v);
    },
    form: form,
    blocks: [{
      title: '搜索条件',
      rows: [{
        itemsInRow: [{
          type: 'Input',
          outerOptions: {
            name: 'outpatientNo',
            label: '就诊卡号'
          }
        }, {
          type: 'RangePicker',
          outerOptions: {
            name: 'fillDate',
            label: '提交日期'
          },
          innerOptions: {
            placeholder: ['请选择', '请选择']
          }
        }, {
          type: 'InputNumber',
          outerOptions: {
            name: 'beginTotalScore',
            label: '最小分数'
          },
          innerOptions: {}
        }, {
          type: 'InputNumber',
          outerOptions: {
            name: 'endTotalScore',
            label: '最大分数'
          },
          innerOptions: {}
        }],
        layoutType: 6
      }, {
        itemsInRow: [{
          type: 'Custom',
          layoutType: 24,
          innerOptions: {
            CustomedComponent: L,
            questions: data.questionList
          },
          outerOptions: {
            name: 'questionOptionList',
            label: '题目'
          }
        }]
      }, {
        itemsInRow: [{
          customNode: /*#__PURE__*/React__default.createElement(_Button, {
            type: "primary",
            block: true,
            style: {
              marginLeft: 0
            },
            onClick: function onClick(e) {
              SMchc_Questionnaire.fk_getResult(getReqData()).then(setList);
            }
          }, "\u641C\u7D22")
        }],
        layoutType: 24
      }]
    }]
  }), /*#__PURE__*/React__default.createElement(Table, {
    sticky: true,
    scroll: {
      x: 1500
    },
    bordered: true,
    dataSource: list,
    style: {
      marginTop: 24
    },
    columns: __spreadArray(__spreadArray([{
      dataIndex: 'outpatientNo',
      title: '就诊卡号',
      ellipsis: true,
      fixed: true,
      width: 160
    }, {
      title: '姓名',
      width: 160,
      render: function render(a, b) {
        return b.name;
      }
    }, {
      title: '年龄',
      width: 160,
      render: function render(a, b) {
        return b.age;
      }
    }, {
      title: '孕周',
      width: 160,
      render: function render(a, b) {
        return b.expandField1;
      }
    }, {
      title: '预产期',
      width: 160,
      render: function render(a, b) {
        return b.expandField2;
      }
    }, {
      title: '手机号',
      width: 160,
      render: function render(a, b) {
        return b.telephone;
      }
    }, {
      title: '居住地址',
      width: 160,
      render: function render(a, b) {
        return b.residenceAddress;
      }
    }, {
      title: '提交日期',
      width: 160,
      render: function render(a, b) {
        return b.fillDate;
      }
    }], ((_b = data.groupVOList) === null || _b === void 0 ? void 0 : _b.map(function (g) {
      var _a;
      var questionList = (_a = data.questionList) === null || _a === void 0 ? void 0 : _a.filter(function (q) {
        var _a;
        return (_a = g.questionIndexList) === null || _a === void 0 ? void 0 : _a.includes(q.questionIndex);
      });
      return {
        title: g.groupTitle,
        children: questionListMapColumn(questionList)
      };
    })) || [], true), [{
      title: '总分',
      width: 160,
      render: function render(a, b) {
        return b.totalScore;
      }
    }], false)
  }));
};
function questionListMapColumn(list) {
  if (list === void 0) {
    list = [];
  }
  return list.map(function (q) {
    return {
      title: q.questionTitle,
      align: 'center',
      width: 140,
      ellipsis: true,
      render: function render(a, b) {
        var _a, _b, _c, _d;
        var target = b.writeDetailList.find(function (_) {
          return _.questionId === q.id;
        });
        var optionIdxArr = ((_b = (_a = target === null || target === void 0 ? void 0 : target.optionIndex) === null || _a === void 0 ? void 0 : _a.split(',')) === null || _b === void 0 ? void 0 : _b.filter(function (_) {
          return !!_;
        })) || [];
        var displayStr = (_c = q.questionOptionList) === null || _c === void 0 ? void 0 : _c.filter(function (_) {
          var _a;
          return optionIdxArr.includes((_a = _.optionIndex) === null || _a === void 0 ? void 0 : _a.toString());
        });
        return /*#__PURE__*/React__default.createElement("div", null, ((_d = displayStr === null || displayStr === void 0 ? void 0 : displayStr.map(function (_) {
          return _.optionTitle;
        })) === null || _d === void 0 ? void 0 : _d.join('、')) || (target === null || target === void 0 ? void 0 : target.questionResult));
      }
    };
  }) || [];
}
var css_248z = ".index-module_questionnaire-steps__o68A9 {\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.index-module_questionnaire-steps-content__rcPcJ {\n  padding: 16px;\n  background-color: white;\n}\n";
var styles = {
  "questionnaire-steps": "index-module_questionnaire-steps__o68A9",
  "questionnaire-steps-content": "index-module_questionnaire-steps-content__rcPcJ"
};
styleInject(css_248z);
var Questionnaire = function Questionnaire(props) {
  var onEditorUpload = props.onEditorUpload;
  var _a = useState(0),
    current = _a[0],
    setCurrent = _a[1];
  var _b = useState(),
    data = _b[0],
    setData = _b[1];
  var _c = useState([]),
    templateList = _c[0],
    setTemplateList = _c[1];
  function fetchTemplateList() {
    SMchc_Questionnaire.fk_list().then(setTemplateList);
  }
  function onDeleteTemplate(data) {
    return __awaiter(this, void 0, void 0, function () {
      return __generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            return [4, SMchc_Questionnaire.del(data.id)];
          case 1:
            _a.sent();
            _message.success('删除问卷成功');
            fetchTemplateList();
            return [2];
        }
      });
    });
  }
  useEffect(function () {
    current || fetchTemplateList();
  }, [current]);
  var handleChangeStep = function handleChangeStep(target) {
    setCurrent(target);
  };
  var handlePreview = function handlePreview(data) {
    setData(data);
    handleChangeStep(2);
  };
  var handleInitQuestions = function handleInitQuestions(data_1) {
    var args_1 = [];
    for (var _i = 1; _i < arguments.length; _i++) {
      args_1[_i - 1] = arguments[_i];
    }
    return __awaiter(void 0, __spreadArray([data_1], args_1, true), void 0, function (data, isCopy, step) {
      var _data;
      var _a;
      if (isCopy === void 0) {
        isCopy = false;
      }
      if (step === void 0) {
        step = 1;
      }
      return __generator(this, function (_b) {
        switch (_b.label) {
          case 0:
            if (!(typeof data.id === 'number')) return [3, 2];
            return [4, SMchc_Questionnaire.fk_byId(data.id)];
          case 1:
            _data = _b.sent();
            if (isCopy && _data) {
              delete _data.id;
              _data.questionList = (_a = _data.questionList) === null || _a === void 0 ? void 0 : _a.map(function (q) {
                var _a;
                delete q.id;
                q.questionOptionList = (_a = q.questionOptionList) === null || _a === void 0 ? void 0 : _a.map(function (o) {
                  delete o.id;
                  return o;
                });
                return q;
              });
            }
            return [3, 3];
          case 2:
            _data = data;
            _b.label = 3;
          case 3:
            console.log('qqq', {
              _data: _data,
              data: data,
              isCopy: isCopy
            });
            setData(_data);
            handleChangeStep(step);
            return [2];
        }
      });
    });
  };
  return /*#__PURE__*/React__default.createElement("div", {
    className: styles["questionnaire"]
  }, /*#__PURE__*/React__default.createElement(_Steps, {
    current: current,
    className: styles["questionnaire-steps"]
  }, /*#__PURE__*/React__default.createElement(_Steps.Step, {
    title: "\u9009\u62E9\u95EE\u53771"
  }), /*#__PURE__*/React__default.createElement(_Steps.Step, {
    title: "\u7F16\u8F91\u95EE\u5377"
  }), /*#__PURE__*/React__default.createElement(_Steps.Step, {
    title: "\u9884\u89C8\u95EE\u5377"
  }), /*#__PURE__*/React__default.createElement(_Steps.Step, {
    title: "\u7EDF\u8BA1\u95EE\u5377"
  })), /*#__PURE__*/React__default.createElement("div", {
    className: styles["questionnaire-steps-content"]
  }, current === 0 && /*#__PURE__*/React__default.createElement(Step1, {
    handleInitQuestions: handleInitQuestions,
    templateList: templateList,
    onDeleteTemplate: onDeleteTemplate
  }), current === 1 && data && /*#__PURE__*/React__default.createElement(Step2, {
    onChangeStep: handleChangeStep,
    onPreview: handlePreview,
    data: data,
    onEditorUpload: onEditorUpload
  }), current === 2 && data && /*#__PURE__*/React__default.createElement(Step3, {
    onChangeStep: handleChangeStep,
    data: data
  }), current === 3 && data && /*#__PURE__*/React__default.createElement(Step4, {
    onChangeStep: handleChangeStep,
    data: data
  })));
};
function questionnaire2() {
  return /*#__PURE__*/React__default.createElement("div", {
    style: {
      overflow: 'auto',
      height: '100%'
    }
  }, /*#__PURE__*/React__default.createElement(Questionnaire, null));
}
export { questionnaire2 as default };
//# sourceMappingURL=pages.follow-up.questionnaire3.js.map
