You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2318 lines
100 KiB
2318 lines
100 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[10799],{
|
|
|
|
/***/ 53055:
|
|
/*!************************************************************************!*\
|
|
!*** ./src/pages/User/Detail/Topics/Poll/Detail/index.tsx + 5 modules ***!
|
|
\************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
// ESM COMPAT FLAG
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
"default": function() { return /* binding */ Detail; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
|
|
var toConsumableArray = __webpack_require__(93923);
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(11006);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(27161);
|
|
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
// EXTERNAL MODULE: ./src/.umi-production/exports.ts + 8 modules
|
|
var _umi_production_exports = __webpack_require__(7181);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/form/index.js + 19 modules
|
|
var es_form = __webpack_require__(78241);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
var message = __webpack_require__(8591);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/divider/index.js + 1 modules
|
|
var divider = __webpack_require__(28103);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/breadcrumb/index.js + 6 modules
|
|
var breadcrumb = __webpack_require__(66104);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/row/index.js
|
|
var row = __webpack_require__(95237);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/col/index.js
|
|
var col = __webpack_require__(43604);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
var modal = __webpack_require__(43418);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tabs/index.js + 24 modules
|
|
var tabs = __webpack_require__(99313);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tooltip/index.js + 3 modules
|
|
var tooltip = __webpack_require__(6848);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/input/index.js + 5 modules
|
|
var input = __webpack_require__(1056);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
var es_button = __webpack_require__(3113);
|
|
// EXTERNAL MODULE: ./src/service/polls.ts
|
|
var service_polls = __webpack_require__(65469);
|
|
// EXTERNAL MODULE: ./src/service/user.ts
|
|
var service_user = __webpack_require__(43916);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/checkbox/index.js + 3 modules
|
|
var es_checkbox = __webpack_require__(24905);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/select/index.js
|
|
var es_select = __webpack_require__(57809);
|
|
// EXTERNAL MODULE: ./src/components/RenderHtml/index.tsx + 1 modules
|
|
var RenderHtml = __webpack_require__(32666);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/components/editor.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var editormodules = ({"flex_box_center":"flex_box_center___ZXamY","flex_space_between":"flex_space_between___OhehO","flex_box_vertical_center":"flex_box_vertical_center___JcdoD","flex_box_center_end":"flex_box_center_end___BQR8z","flex_box_column":"flex_box_column___ZtKH_","wrap":"wrap___ucM4I","modal":"modal___Snz7U","titleWrap":"titleWrap___GoOJH","required":"required___hcR9L","title":"title___Fk25W","colorGray":"colorGray___s_7Rh","choiceWrap":"choiceWrap___Km9CZ","answer":"answer___nCBKN","activeAnswer":"activeAnswer___pykZr","deleteIcon":"deleteIcon___FtIV6","addIcon":"addIcon___pjZkR","editorWrap":"editorWrap___VTBdJ","htmlWrap":"htmlWrap___Cqe4T","radio":"radio___Uahep","color333":"color333___NsMb3","color999":"color999___qJjRp","questionType":"questionType___BC_py","questionChoices":"questionChoices____TjNP"});
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/components/MultipleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["problemset", "globalSetting", "loading", "dispatch", "showAnswerTip", "onRef", "editData", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var tagList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
var SingleEditor = function SingleEditor(_ref, ref) {
|
|
var problemset = _ref.problemset,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
dispatch = _ref.dispatch,
|
|
_ref$showAnswerTip = _ref.showAnswerTip,
|
|
showAnswerTip = _ref$showAnswerTip === void 0 ? true : _ref$showAnswerTip,
|
|
_ref$onRef = _ref.onRef,
|
|
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
|
|
editData = _ref.editData,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
props = objectWithoutProperties_default()(_ref, _excluded);
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
questionChoiceList = _useState2[0],
|
|
setQuestionChoiceList = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
activeEditor = _useState4[0],
|
|
setActiveEditor = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
activeAnswer = _useState6[0],
|
|
setActiveAnswer = _useState6[1];
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
title = _useState8[0],
|
|
setTitle = _useState8[1];
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(0),
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
score = _useState10[0],
|
|
setScore = _useState10[1];
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(true),
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
isNecessary = _useState12[0],
|
|
setIsNecessary = _useState12[1];
|
|
var _useState13 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
other = _useState14[0],
|
|
setOther = _useState14[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
var _useState15 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState16 = slicedToArray_default()(_useState15, 2),
|
|
maxChoices = _useState16[0],
|
|
setMaxChoices = _useState16[1];
|
|
var _useState17 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState18 = slicedToArray_default()(_useState17, 2),
|
|
minChoices = _useState18[0],
|
|
setMinChoices = _useState18[1];
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3, _editData$question4, _editData$question5, _editData$question6, _editData$question7;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setQuestionChoiceList([{
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}]);
|
|
setIsNecessary(true);
|
|
setTitle('');
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setMaxChoices(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.max_choices);
|
|
setMinChoices(editData === null || editData === void 0 || (_editData$question3 = editData.question) === null || _editData$question3 === void 0 ? void 0 : _editData$question3.min_choices);
|
|
setTitle(editData === null || editData === void 0 || (_editData$question4 = editData.question) === null || _editData$question4 === void 0 ? void 0 : _editData$question4.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question5 = editData.question) !== null && _editData$question5 !== void 0 && _editData$question5.is_necessary));
|
|
setQuestionChoiceList(editData === null || editData === void 0 || (_editData$question6 = editData.question) === null || _editData$question6 === void 0 ? void 0 : _editData$question6.answers.map(function (item) {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === '其它' ? true : false
|
|
};
|
|
}));
|
|
setOther(!!(editData !== null && editData !== void 0 && (_editData$question7 = editData.question) !== null && _editData$question7 !== void 0 && (_editData$question7 = _editData$question7.answers) !== null && _editData$question7 !== void 0 && _editData$question7.find(function (item) {
|
|
return item.answer_text === '其它';
|
|
})));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question8;
|
|
var findNotAnswerIndex, res, bodyData, d;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
if (!(maxChoices && !minChoices || !maxChoices && minChoices)) {
|
|
_context.next = 3;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info('可选:最小和最大限制须同时为数值或者“--"');
|
|
return _context.abrupt("return");
|
|
case 3:
|
|
if (!(minChoices > maxChoices)) {
|
|
_context.next = 6;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info('可选的最大限制不能小于最小限制');
|
|
return _context.abrupt("return");
|
|
case 6:
|
|
if (title) {
|
|
_context.next = 9;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("请您输入题目");
|
|
return _context.abrupt("return", false);
|
|
case 9:
|
|
findNotAnswerIndex = questionChoiceList.findIndex(function (item) {
|
|
return !item.value;
|
|
});
|
|
if (!(findNotAnswerIndex > -1)) {
|
|
_context.next = 13;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9"));
|
|
return _context.abrupt("return", false);
|
|
case 13:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 2,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary),
|
|
"max_choices": maxChoices,
|
|
"min_choices": minChoices,
|
|
"question_answers": questionChoiceList.map(function (item) {
|
|
return item.value;
|
|
})
|
|
};
|
|
if (!((_editData$question8 = editData.question) !== null && _editData$question8 !== void 0 && _editData$question8.id)) {
|
|
_context.next = 20;
|
|
break;
|
|
}
|
|
_context.next = 17;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 17:
|
|
res = _context.sent;
|
|
_context.next = 23;
|
|
break;
|
|
case 20:
|
|
_context.next = 22;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 22:
|
|
res = _context.sent;
|
|
case 23:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 30;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 28;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 28:
|
|
d = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callback('addContinue', objectSpread2_default()({
|
|
type: 2,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 1
|
|
}, bodyData), d.questions);
|
|
}
|
|
case 30:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question9, _editData$question10, _editData$question11, _editData$question$an;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "font16",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u591A\u9009\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10 mr10",
|
|
children: (editData === null || editData === void 0 || (_editData$question9 = editData.question) === null || _editData$question9 === void 0 ? void 0 : _editData$question9.is_necessary) === 0 ? "选答" : "必答"
|
|
}), "\u53EF\u9009", editData === null || editData === void 0 || (_editData$question10 = editData.question) === null || _editData$question10 === void 0 ? void 0 : _editData$question10.min_choices, "-", editData === null || editData === void 0 || (_editData$question11 = editData.question) === null || _editData$question11 === void 0 ? void 0 : _editData$question11.max_choices, "\u9879"]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mt5",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
|
|
value: editData.question.question_title
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
disabled: true,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_text
|
|
})
|
|
}, index)
|
|
})
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
var showEdit = function showEdit() {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-blue",
|
|
children: "\u591A\u9009\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
className: editormodules.choiceWrap,
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16",
|
|
children: "\u9009\u9879"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
className: editormodules.editorWrap,
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
value: questionChoiceList[index]['value'],
|
|
rows: 1,
|
|
disabled: item.disabled ? true : false,
|
|
onChange: function onChange(e) {
|
|
questionChoiceList[index]['value'] = e.target.value;
|
|
setQuestionChoiceList(toConsumableArray_default()(questionChoiceList));
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u5220\u9664",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"),
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
|
|
return key !== index;
|
|
}));
|
|
if (item.disabled) setOther(false);
|
|
}
|
|
})
|
|
})
|
|
})]
|
|
}, index);
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: "\u53EF\u9009"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(es_select["default"], {
|
|
value: minChoices || '',
|
|
style: {
|
|
width: 120
|
|
},
|
|
onChange: function onChange(value) {
|
|
return setMinChoices(value);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: "",
|
|
children: "--"
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: String(index + 2),
|
|
children: index + 2
|
|
});
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "ml10 mr10",
|
|
children: "~"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(es_select["default"], {
|
|
style: {
|
|
width: 120
|
|
},
|
|
value: maxChoices || '',
|
|
onChange: function onChange(value) {
|
|
return setMaxChoices(value);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: "",
|
|
children: "--"
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_select["default"].Option, {
|
|
value: String(index + 2),
|
|
children: index + 2
|
|
});
|
|
})]
|
|
})]
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
if (questionChoiceList.find(function (i) {
|
|
return i.value === '其它';
|
|
})) {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList.filter(function (i) {
|
|
return i.value !== '其它';
|
|
})), [{
|
|
value: ''
|
|
}, {
|
|
value: '其它',
|
|
disabled: true
|
|
}]));
|
|
} else {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
value: ''
|
|
}]));
|
|
}
|
|
},
|
|
children: "\u65B0\u589E\u9009\u9879"
|
|
}), !other && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
className: "ml20",
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
disabled: true,
|
|
value: "其它"
|
|
}]));
|
|
setOther(true);
|
|
},
|
|
children: "\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question12;
|
|
if ((_editData$question12 = editData.question) !== null && _editData$question12 !== void 0 && _editData$question12.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && showEdit()]
|
|
});
|
|
};
|
|
/* harmony default export */ var MultipleEditor = ((0,_umi_production_exports.connect)(function (_ref3) {
|
|
var problemset = _ref3.problemset,
|
|
loading = _ref3.loading,
|
|
globalSetting = _ref3.globalSetting;
|
|
return {
|
|
problemset: problemset,
|
|
globalSetting: globalSetting,
|
|
loading: loading.effects
|
|
};
|
|
}, null, null, {
|
|
forwardRef: true
|
|
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SingleEditor)));
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
|
|
var es_radio = __webpack_require__(5112);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/components/SingleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SingleEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "editKey", "callback", "showAnswerTip"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SingleEditor_tagList = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
|
var SingleEditor_SingleEditor = function SingleEditor(_ref, ref) {
|
|
var problemset = _ref.problemset,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
dispatch = _ref.dispatch,
|
|
_ref$onRef = _ref.onRef,
|
|
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
|
|
editData = _ref.editData,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
_ref$showAnswerTip = _ref.showAnswerTip,
|
|
showAnswerTip = _ref$showAnswerTip === void 0 ? true : _ref$showAnswerTip,
|
|
props = objectWithoutProperties_default()(_ref, SingleEditor_excluded);
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
questionChoiceList = _useState2[0],
|
|
setQuestionChoiceList = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
activeEditor = _useState4[0],
|
|
setActiveEditor = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
activeAnswer = _useState6[0],
|
|
setActiveAnswer = _useState6[1];
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
title = _useState8[0],
|
|
setTitle = _useState8[1];
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(0),
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
score = _useState10[0],
|
|
setScore = _useState10[1];
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
isNecessary = _useState12[0],
|
|
setIsNecessary = _useState12[1];
|
|
var _useState13 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
other = _useState14[0],
|
|
setOther = _useState14[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3, _editData$question4, _editData$question5;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setQuestionChoiceList([{
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}, {
|
|
disabled: false,
|
|
value: ""
|
|
}]);
|
|
setIsNecessary(false);
|
|
setTitle('');
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setTitle(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question3 = editData.question) !== null && _editData$question3 !== void 0 && _editData$question3.is_necessary));
|
|
setQuestionChoiceList(editData === null || editData === void 0 || (_editData$question4 = editData.question) === null || _editData$question4 === void 0 ? void 0 : _editData$question4.answers.map(function (item) {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === '其它' ? true : false
|
|
};
|
|
}));
|
|
setOther(!!(editData !== null && editData !== void 0 && (_editData$question5 = editData.question) !== null && _editData$question5 !== void 0 && (_editData$question5 = _editData$question5.answers) !== null && _editData$question5 !== void 0 && _editData$question5.find(function (item) {
|
|
return item.answer_text === '其它';
|
|
})));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question6;
|
|
var findNotAnswerIndex, res, bodyData, d;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
if (title) {
|
|
_context.next = 3;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("请您输入题目");
|
|
return _context.abrupt("return", false);
|
|
case 3:
|
|
findNotAnswerIndex = questionChoiceList.findIndex(function (item) {
|
|
return !item.value;
|
|
});
|
|
if (!(findNotAnswerIndex > -1)) {
|
|
_context.next = 7;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("\u8BF7\u5148\u8F93\u5165 ".concat(SingleEditor_tagList[findNotAnswerIndex], " \u9009\u9879\u7684\u5185\u5BB9"));
|
|
return _context.abrupt("return", false);
|
|
case 7:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 1,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary),
|
|
"question_answers": questionChoiceList.map(function (item) {
|
|
return item.value;
|
|
})
|
|
};
|
|
if (!((_editData$question6 = editData.question) !== null && _editData$question6 !== void 0 && _editData$question6.id)) {
|
|
_context.next = 14;
|
|
break;
|
|
}
|
|
_context.next = 11;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 11:
|
|
res = _context.sent;
|
|
_context.next = 17;
|
|
break;
|
|
case 14:
|
|
_context.next = 16;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 16:
|
|
res = _context.sent;
|
|
case 17:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 24;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 22;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 22:
|
|
d = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callback('addContinue', objectSpread2_default()({
|
|
type: 1,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 1
|
|
}, bodyData), d.questions);
|
|
}
|
|
case 24:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var actionArr = [{
|
|
name: "删除",
|
|
icon: "iconfont c-light-black ml30 icon-shanchu current",
|
|
id: "del"
|
|
}, {
|
|
name: "上移",
|
|
icon: "iconfont c-green ml30 icon-xiangshangyi current",
|
|
id: "up"
|
|
}, {
|
|
name: "下移",
|
|
icon: "iconfont c-green ml30 icon-xiangxiayi current",
|
|
id: "down"
|
|
}, {
|
|
name: "添加",
|
|
icon: "iconfont c-green ml30 icon-tianjia current",
|
|
id: "add"
|
|
}, {
|
|
name: "编辑",
|
|
icon: "iconfont c-green ml30 icon-bianjidaibeijing current",
|
|
id: "edit"
|
|
}];
|
|
var actionClick = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
var _editData$question8, _editData$question9;
|
|
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
case 0:
|
|
_context3.t0 = item.id;
|
|
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : _context3.t0 === "add" ? 11 : 13;
|
|
break;
|
|
case 3:
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: '确认要删除这个问题吗?',
|
|
onOk: function onOk() {
|
|
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _editData$question7;
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
case 0:
|
|
_context2.next = 2;
|
|
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question7 = editData.question) === null || _editData$question7 === void 0 ? void 0 : _editData$question7.id
|
|
});
|
|
case 2:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}))();
|
|
}
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 5:
|
|
_context3.next = 7;
|
|
return (0,service_polls/* exerciseBanksMoveUpDown */.vf)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question8 = editData.question) === null || _editData$question8 === void 0 ? void 0 : _editData$question8.id,
|
|
opr: item.id
|
|
});
|
|
case 7:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 9:
|
|
callback('edit', editData.key);
|
|
return _context3.abrupt("break", 13);
|
|
case 11:
|
|
callback('add', {
|
|
type: 1,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question9 = editData.question) === null || _editData$question9 === void 0 ? void 0 : _editData$question9.id,
|
|
question_type: 1
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 13:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
return function actionClick(_x2) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question10, _editData$question$an;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "font16",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u5355\u9009\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10",
|
|
children: (editData === null || editData === void 0 || (_editData$question10 = editData.question) === null || _editData$question10 === void 0 ? void 0 : _editData$question10.is_necessary) === 0 ? "选答" : "必答"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mt5",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
|
|
value: editData.question.question_title
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
disabled: true
|
|
}, index)
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_text
|
|
})
|
|
})]
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
var showEdit = function showEdit() {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-blue",
|
|
children: "\u5355\u9009\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), questionChoiceList.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
className: editormodules.choiceWrap,
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16",
|
|
children: "\u9009\u9879"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
className: editormodules.editorWrap,
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
value: questionChoiceList[index]['value'],
|
|
rows: 1,
|
|
disabled: questionChoiceList[index]['value'] === '其它' ? true : false,
|
|
onChange: function onChange(e) {
|
|
questionChoiceList[index]['value'] = e.target.value;
|
|
setQuestionChoiceList(toConsumableArray_default()(questionChoiceList));
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: index > 1 && /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u5220\u9664",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("i", {
|
|
className: "".concat(editormodules.deleteIcon, " iconfont icon-htmal5icon19"),
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList(questionChoiceList.filter(function (_, key) {
|
|
return key !== index;
|
|
}));
|
|
if (item.disabled) setOther(false);
|
|
}
|
|
})
|
|
})
|
|
})]
|
|
}, index);
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
if (questionChoiceList.find(function (i) {
|
|
return i.value === '其它';
|
|
})) {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList.filter(function (i) {
|
|
return i.value !== '其它';
|
|
})), [{
|
|
value: ''
|
|
}, {
|
|
value: '其它',
|
|
disabled: true
|
|
}]));
|
|
} else {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
value: ''
|
|
}]));
|
|
}
|
|
新增选项;
|
|
}
|
|
}), !other && /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
className: "ml20",
|
|
onClick: function onClick() {
|
|
setQuestionChoiceList([].concat(toConsumableArray_default()(questionChoiceList), [{
|
|
disabled: true,
|
|
value: "其它"
|
|
}]));
|
|
setOther(true);
|
|
},
|
|
children: "\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question11;
|
|
if ((_editData$question11 = editData.question) !== null && _editData$question11 !== void 0 && _editData$question11.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && showEdit()]
|
|
});
|
|
};
|
|
/* harmony default export */ var components_SingleEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
|
|
var problemset = _ref4.problemset,
|
|
loading = _ref4.loading,
|
|
globalSetting = _ref4.globalSetting;
|
|
return {
|
|
problemset: problemset,
|
|
globalSetting: globalSetting,
|
|
loading: loading.effects
|
|
};
|
|
}, null, null, {
|
|
forwardRef: true
|
|
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SingleEditor_SingleEditor)));
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/components/SubjectiveEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
var SubjectiveEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "showAnswerTip", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SubjectiveEditor_tagList = (/* unused pure expression or super */ null && (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']));
|
|
var SubjectiveEditor_SingleEditor = function SingleEditor(_ref, ref) {
|
|
var problemset = _ref.problemset,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
dispatch = _ref.dispatch,
|
|
_ref$onRef = _ref.onRef,
|
|
onRef = _ref$onRef === void 0 ? function () {} : _ref$onRef,
|
|
editData = _ref.editData,
|
|
_ref$showAnswerTip = _ref.showAnswerTip,
|
|
showAnswerTip = _ref$showAnswerTip === void 0 ? true : _ref$showAnswerTip,
|
|
editKey = _ref.editKey,
|
|
callback = _ref.callback,
|
|
props = objectWithoutProperties_default()(_ref, SubjectiveEditor_excluded);
|
|
var _useState = (0,_react_17_0_2_react.useState)(''),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
title = _useState2[0],
|
|
setTitle = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(true),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
isNecessary = _useState4[0],
|
|
setIsNecessary = _useState4[1];
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _editData$question, _editData$question2, _editData$question3;
|
|
if (!(editData !== null && editData !== void 0 && (_editData$question = editData.question) !== null && _editData$question !== void 0 && _editData$question.question_title)) {
|
|
setIsNecessary(true);
|
|
setTitle('');
|
|
return;
|
|
}
|
|
setTitle(editData === null || editData === void 0 || (_editData$question2 = editData.question) === null || _editData$question2 === void 0 ? void 0 : _editData$question2.question_title);
|
|
setIsNecessary(!!(editData !== null && editData !== void 0 && (_editData$question3 = editData.question) !== null && _editData$question3 !== void 0 && _editData$question3.is_necessary));
|
|
}, [editData]);
|
|
(0,_react_17_0_2_react.useImperativeHandle)(ref, function () {
|
|
return {
|
|
onSave: onSave
|
|
};
|
|
});
|
|
var onSave = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(status) {
|
|
var _editData$question4;
|
|
var res, bodyData, d;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
if (title) {
|
|
_context.next = 3;
|
|
break;
|
|
}
|
|
message/* default */.ZP.info("请您输入题目");
|
|
return _context.abrupt("return", false);
|
|
case 3:
|
|
bodyData = {
|
|
"question_title": title,
|
|
"question_type": 3,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary)
|
|
};
|
|
if (!((_editData$question4 = editData.question) !== null && _editData$question4 !== void 0 && _editData$question4.id)) {
|
|
_context.next = 10;
|
|
break;
|
|
}
|
|
_context.next = 7;
|
|
return (0,service_polls/* putPollBankQuestions */.wo)(objectSpread2_default()({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
case 7:
|
|
res = _context.sent;
|
|
_context.next = 13;
|
|
break;
|
|
case 10:
|
|
_context.next = 12;
|
|
return (0,service_polls/* addPollBankQuestions */.Fd)(objectSpread2_default()({
|
|
"exercise_bank_id": params.topicId
|
|
}, bodyData));
|
|
case 12:
|
|
res = _context.sent;
|
|
case 13:
|
|
if (!(res.status === 0)) {
|
|
_context.next = 20;
|
|
break;
|
|
}
|
|
message/* default */.ZP.success("保存成功");
|
|
callback('edit', -1);
|
|
_context.next = 18;
|
|
return dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 18:
|
|
d = _context.sent;
|
|
if (status) {
|
|
callback('addContinue', objectSpread2_default()({
|
|
type: 3,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 1
|
|
}, bodyData), d.questions);
|
|
}
|
|
case 20:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function onSave(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var actionArr = [{
|
|
name: "删除",
|
|
icon: "iconfont c-light-black ml30 icon-shanchu current",
|
|
id: "del"
|
|
}, {
|
|
name: "上移",
|
|
icon: "iconfont c-green ml30 icon-xiangshangyi current",
|
|
id: "up"
|
|
}, {
|
|
name: "下移",
|
|
icon: "iconfont c-green ml30 icon-xiangxiayi current",
|
|
id: "down"
|
|
}, {
|
|
name: "添加",
|
|
icon: "iconfont c-green ml30 icon-tianjia current",
|
|
id: "add"
|
|
}, {
|
|
name: "编辑",
|
|
icon: "iconfont c-green ml30 icon-bianjidaibeijing current",
|
|
id: "edit"
|
|
}];
|
|
var actionClick = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3(item) {
|
|
var _editData$question6, _editData$question7;
|
|
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
case 0:
|
|
_context3.t0 = item.id;
|
|
_context3.next = _context3.t0 === "del" ? 3 : _context3.t0 === "up" ? 5 : _context3.t0 === "down" ? 5 : _context3.t0 === "edit" ? 9 : _context3.t0 === "add" ? 11 : 13;
|
|
break;
|
|
case 3:
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: '确认要删除这个问题吗?',
|
|
onOk: function onOk() {
|
|
return asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _editData$question5;
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
case 0:
|
|
_context2.next = 2;
|
|
return (0,service_polls/* deleteExerciseBanksQuestion */.x$)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question5 = editData.question) === null || _editData$question5 === void 0 ? void 0 : _editData$question5.id
|
|
});
|
|
case 2:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 3:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}))();
|
|
}
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 5:
|
|
_context3.next = 7;
|
|
return (0,service_polls/* exerciseBanksMoveUpDown */.vf)({
|
|
pollsId: editData === null || editData === void 0 || (_editData$question6 = editData.question) === null || _editData$question6 === void 0 ? void 0 : _editData$question6.id,
|
|
opr: item.id
|
|
});
|
|
case 7:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 9:
|
|
callback('edit', editData.key);
|
|
return _context3.abrupt("break", 13);
|
|
case 11:
|
|
callback('add', {
|
|
type: 3,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question7 = editData.question) === null || _editData$question7 === void 0 ? void 0 : _editData$question7.id,
|
|
question_type: 3
|
|
});
|
|
return _context3.abrupt("break", 13);
|
|
case 13:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
return function actionClick(_x2) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var showList = function showList() {
|
|
var _editData$question8, _editData$question$an;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "font16",
|
|
children: ["\u7B2C", editData.key, "\u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-light-black ml10",
|
|
children: "\u4E3B\u89C2\u9898"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "tag-grey-eae ml10 mr10",
|
|
children: (editData === null || editData === void 0 || (_editData$question8 = editData.question) === null || _editData$question8 === void 0 ? void 0 : _editData$question8.is_necessary) === 0 ? "选答" : "必答"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: "mt5",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(RenderHtml/* default */.Z, {
|
|
value: editData.question.question_title
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mt15",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
placeholder: "\u5728\u6B64\u586B\u5165\u7B54\u6848",
|
|
rows: 5,
|
|
disabled: true
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionChoices,
|
|
children: editData === null || editData === void 0 || (_editData$question$an = editData.question.answers) === null || _editData$question$an === void 0 ? void 0 : _editData$question$an.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(row/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
disabled: true,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-black font14",
|
|
children: item.answer_text
|
|
})
|
|
}, index)
|
|
})
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
var showEdit = function showEdit() {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: editormodules.questionType,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 c-blue",
|
|
children: "\u4E3B\u89C2\u9898"
|
|
}), " ", /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
checked: isNecessary ? true : false,
|
|
className: "ml10",
|
|
onChange: function onChange(e) {
|
|
return setIsNecessary(e.target.checked);
|
|
},
|
|
children: "\u5FC5\u7B54"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
autoSize: {
|
|
maxRows: 5
|
|
},
|
|
rows: 1,
|
|
value: title,
|
|
placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE",
|
|
onChange: function onChange(e) {
|
|
return setTitle(e.target.value);
|
|
}
|
|
})
|
|
}), showAnswerTip ? /*#__PURE__*/(0,jsx_runtime.jsxs)("p", {
|
|
className: editormodules.titleWrap,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: editormodules.required,
|
|
children: "*"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: editormodules.title,
|
|
children: ["\u7B54\u6848\u9009\u9879\uFF1A", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: editormodules.colorGray,
|
|
children: "\u70B9\u51FB\u9009\u9879\u53EF\u8BBE\u7F6E\u6B63\u786E\u7B54\u6848"
|
|
})]
|
|
})]
|
|
}) : null, /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
gutter: [12, 12],
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "tl",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "default",
|
|
onClick: function onClick() {
|
|
var _editData$question9;
|
|
if ((_editData$question9 = editData.question) !== null && _editData$question9 !== void 0 && _editData$question9.id) {
|
|
callback('edit', -1);
|
|
} else {
|
|
callback('del', editData.key);
|
|
}
|
|
},
|
|
children: "\u53D6\u6D88"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
className: "ml20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return onSave(true);
|
|
},
|
|
children: "\u4FDD\u5B58\u5E76\u7EE7\u7EED"
|
|
})]
|
|
})]
|
|
})]
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: editormodules.wrap,
|
|
children: [editKey !== editData.key && showList(), editKey === editData.key && showEdit()]
|
|
});
|
|
};
|
|
/* harmony default export */ var SubjectiveEditor = ((0,_umi_production_exports.connect)(function (_ref4) {
|
|
var problemset = _ref4.problemset,
|
|
loading = _ref4.loading,
|
|
globalSetting = _ref4.globalSetting;
|
|
return {
|
|
problemset: problemset,
|
|
globalSetting: globalSetting,
|
|
loading: loading.effects
|
|
};
|
|
}, null, null, {
|
|
forwardRef: true
|
|
})( /*#__PURE__*/(0,_react_17_0_2_react.forwardRef)(SubjectiveEditor_SingleEditor)));
|
|
// EXTERNAL MODULE: ./src/components/NoData/index.tsx
|
|
var NoData = __webpack_require__(31917);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var Detailmodules = ({"flex_box_center":"flex_box_center___IqikW","flex_space_between":"flex_space_between___H4npu","flex_box_vertical_center":"flex_box_vertical_center___pxWg2","flex_box_center_end":"flex_box_center_end___fI1p7","flex_box_column":"flex_box_column___uFxAf","bg":"bg___Emql5","containerTitle":"containerTitle___fmYJh","containerDesc":"containerDesc___CC8H4","listItem":"listItem___zg_9F","info":"info___RsS8d","title":"title___w3IkP","titleLeft":"titleLeft___IS2Mw","titleRight":"titleRight____welO","acitons":"acitons___np4Mm","export":"export___atwjg"});
|
|
// EXTERNAL MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx + 2 modules
|
|
var SendToClassModal = __webpack_require__(50160);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Detail/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Detail_excluded = ["polls", "globalSetting", "loading", "user", "dispatch"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ShixunsListPage = function ShixunsListPage(_ref) {
|
|
var _polls$exerciseBanks5, _polls$exerciseBanks6, _polls$exerciseBanks7, _polls$exerciseBanks8, _polls$exerciseBanks9, _polls$exerciseBanks10, _polls$exerciseBanks11, _polls$exerciseBanks12, _polls$exerciseBanks13;
|
|
var polls = _ref.polls,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
user = _ref.user,
|
|
dispatch = _ref.dispatch,
|
|
props = objectWithoutProperties_default()(_ref, Detail_excluded);
|
|
var params = (0,_umi_production_exports.useParams)();
|
|
var userInfo = user.userInfo;
|
|
var _Form$useForm = es_form/* default */.Z.useForm(),
|
|
_Form$useForm2 = slicedToArray_default()(_Form$useForm, 1),
|
|
form = _Form$useForm2[0];
|
|
var _useState = (0,_react_17_0_2_react.useState)([]),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
editData = _useState2[0],
|
|
setEditData = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
isEdit = _useState4[0],
|
|
setIsEdit = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)(-1),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
editKey = _useState6[0],
|
|
setEditKey = _useState6[1];
|
|
var questionType = [{
|
|
name: "单选题",
|
|
id: 1
|
|
}, {
|
|
name: "多选题",
|
|
id: 2
|
|
}, {
|
|
name: "主观题",
|
|
id: 3
|
|
}];
|
|
var childrenRef = (0,_react_17_0_2_react.useRef)();
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
var _polls$exerciseBanks;
|
|
if ((_polls$exerciseBanks = polls.exerciseBanks) !== null && _polls$exerciseBanks !== void 0 && _polls$exerciseBanks.questions) {
|
|
var _polls$exerciseBanks2, _polls$exerciseBanks3, _polls$exerciseBanks4;
|
|
setEditData(toConsumableArray_default()((_polls$exerciseBanks2 = polls.exerciseBanks) === null || _polls$exerciseBanks2 === void 0 ? void 0 : _polls$exerciseBanks2.questions));
|
|
form.setFieldsValue({
|
|
exercise_name: (_polls$exerciseBanks3 = polls.exerciseBanks) === null || _polls$exerciseBanks3 === void 0 || (_polls$exerciseBanks3 = _polls$exerciseBanks3.poll) === null || _polls$exerciseBanks3 === void 0 ? void 0 : _polls$exerciseBanks3.name,
|
|
exercise_description: (_polls$exerciseBanks4 = polls.exerciseBanks) === null || _polls$exerciseBanks4 === void 0 || (_polls$exerciseBanks4 = _polls$exerciseBanks4.poll) === null || _polls$exerciseBanks4 === void 0 ? void 0 : _polls$exerciseBanks4.description
|
|
});
|
|
}
|
|
}, [polls.exerciseBanks]);
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
}, [params.categoryId]);
|
|
var save = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee() {
|
|
var value;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
_context.next = 2;
|
|
return form.validateFields();
|
|
case 2:
|
|
value = form.getFieldValue();
|
|
value.is_md = true;
|
|
value.topicId = params.topicId;
|
|
setIsEdit(false);
|
|
_context.next = 8;
|
|
return (0,service_polls/* putExerciseBanks */.hO)(objectSpread2_default()({}, value));
|
|
case 8:
|
|
dispatch({
|
|
type: "polls/getExerciseBanks",
|
|
payload: objectSpread2_default()({}, params)
|
|
});
|
|
case 9:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function save() {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var addQuestion = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2(type) {
|
|
var d;
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
case 0:
|
|
d = childrenRef === null || childrenRef === void 0 ? void 0 : childrenRef.current;
|
|
if (!(editKey !== -1)) {
|
|
_context2.next = 4;
|
|
break;
|
|
}
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return _context2.abrupt("return");
|
|
case 4:
|
|
setEditKey(editData.length + 1);
|
|
setEditData([].concat(toConsumableArray_default()(editData), [{
|
|
question: {
|
|
question_type: type
|
|
}
|
|
}]));
|
|
case 6:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}));
|
|
return function addQuestion(_x) {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
var handleSend = function handleSend() {
|
|
dispatch({
|
|
type: 'userDetail/setActionTabs',
|
|
payload: {
|
|
key: 'UserDetail-SendToClass',
|
|
params: {
|
|
object_id: [params.topicId],
|
|
object_type: 'poll'
|
|
}
|
|
}
|
|
});
|
|
};
|
|
var callback = function callback(key, data, allData) {
|
|
switch (key) {
|
|
case "edit":
|
|
setEditKey(data);
|
|
break;
|
|
case "add":
|
|
if (editKey != -1) {
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return;
|
|
}
|
|
editData.splice((data === null || data === void 0 ? void 0 : data.key) + 1, 0, {
|
|
insert_id: data === null || data === void 0 ? void 0 : data.insert_id,
|
|
question: objectSpread2_default()({}, data)
|
|
}).slice();
|
|
setEditData(toConsumableArray_default()(editData));
|
|
setEditKey((data === null || data === void 0 ? void 0 : data.key) + 1);
|
|
break;
|
|
case "addContinue":
|
|
allData.splice(data === null || data === void 0 ? void 0 : data.key, 0, {
|
|
insert_id: data === null || data === void 0 ? void 0 : data.insert_id,
|
|
question: objectSpread2_default()({}, data)
|
|
}).slice();
|
|
setEditData(toConsumableArray_default()(allData));
|
|
setEditKey((data === null || data === void 0 ? void 0 : data.key) + 1);
|
|
break;
|
|
case "del":
|
|
editData.splice(data - 1, 1);
|
|
setEditData(toConsumableArray_default()(editData));
|
|
setEditKey(-1);
|
|
break;
|
|
}
|
|
};
|
|
var renderQuestion = function renderQuestion() {
|
|
return editData === null || editData === void 0 ? void 0 : editData.map(function (v, k) {
|
|
var _v$question;
|
|
v.key = k + 1;
|
|
v.len = editData.length;
|
|
if (v.question.question_type === 1) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(components_SingleEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
});
|
|
}
|
|
if (v.question.question_type === 2) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(MultipleEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
});
|
|
}
|
|
if (((_v$question = v.question) === null || _v$question === void 0 ? void 0 : _v$question.question_type) === 3) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(SubjectiveEditor, {
|
|
ref: childrenRef,
|
|
editKey: editKey,
|
|
callback: callback,
|
|
editData: v
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(divider/* default */.Z, {})]
|
|
});
|
|
}
|
|
});
|
|
};
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: "edu-container",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: "animated fadeIn",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
className: "mt10",
|
|
children: userInfo && /*#__PURE__*/(0,jsx_runtime.jsxs)(breadcrumb/* default */.Z, {
|
|
separator: ">",
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
|
|
to: "/users/".concat(userInfo.login, "/topics/personal"),
|
|
children: "\u6211\u7684\u8BFE\u5802\u8D44\u6E90"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
|
|
children: "\u8BE6\u60C5"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
className: [Detailmodules.title, 'mt20'].join(' '),
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
style: {
|
|
width: "100%"
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
flex: "1",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("strong", {
|
|
className: "font20 ml5",
|
|
children: (_polls$exerciseBanks5 = polls.exerciseBanks) === null || _polls$exerciseBanks5 === void 0 || (_polls$exerciseBanks5 = _polls$exerciseBanks5.poll) === null || _polls$exerciseBanks5 === void 0 ? void 0 : _polls$exerciseBanks5.name
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {})]
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: [Detailmodules.bg, 'pl30', 'pr30', 'pb30', 'mt20', 'relative'].join(' '),
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: Detailmodules["export"],
|
|
children: [((_polls$exerciseBanks6 = polls.exerciseBanks) === null || _polls$exerciseBanks6 === void 0 ? void 0 : _polls$exerciseBanks6.authorize) && /*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
onClick: function onClick(e) {
|
|
e.preventDefault();
|
|
modal/* default */.Z.confirm({
|
|
centered: true,
|
|
okText: '确定',
|
|
cancelText: '取消',
|
|
title: "提示",
|
|
content: "是否确认删除?",
|
|
onOk: function () {
|
|
var _onOk = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee3() {
|
|
var res;
|
|
return regeneratorRuntime_default()().wrap(function _callee3$(_context3) {
|
|
while (1) switch (_context3.prev = _context3.next) {
|
|
case 0:
|
|
_context3.next = 2;
|
|
return (0,service_user/* deleteQuestionBanks */.Tv)({
|
|
object_type: "normal",
|
|
object_id: [params.topicId]
|
|
});
|
|
case 2:
|
|
res = _context3.sent;
|
|
if (res.status === 0) {
|
|
_umi_production_exports.history.push("/users/".concat(params.username, "/topics/personal"));
|
|
}
|
|
case 4:
|
|
case "end":
|
|
return _context3.stop();
|
|
}
|
|
}, _callee3);
|
|
}));
|
|
function onOk() {
|
|
return _onOk.apply(this, arguments);
|
|
}
|
|
return onOk;
|
|
}()
|
|
});
|
|
},
|
|
children: "\u5220\u9664"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
|
|
to: "/users/".concat(userInfo.login, "/topics/").concat(params.topicId, "/").concat(params.topictype, "/poll/edit"),
|
|
children: "\u7F16\u8F91"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("a", {
|
|
onClick: function onClick(e) {
|
|
e.preventDefault();
|
|
handleSend();
|
|
},
|
|
children: "\u53D1\u9001"
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z, {
|
|
className: Detailmodules.tabs,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z.TabPane, {
|
|
tab: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "font16 pt10 pb12",
|
|
children: "\u5185\u5BB9\u8BE6\u60C5"
|
|
}),
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "c-light-black",
|
|
children: (_polls$exerciseBanks7 = polls.exerciseBanks) === null || _polls$exerciseBanks7 === void 0 || (_polls$exerciseBanks7 = _polls$exerciseBanks7.poll) === null || _polls$exerciseBanks7 === void 0 ? void 0 : _polls$exerciseBanks7.description
|
|
})
|
|
}, "1")
|
|
}), !isEdit && /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: Detailmodules.containerDesc,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
children: (_polls$exerciseBanks8 = polls.exerciseBanks) === null || _polls$exerciseBanks8 === void 0 || (_polls$exerciseBanks8 = _polls$exerciseBanks8.poll) === null || _polls$exerciseBanks8 === void 0 ? void 0 : _polls$exerciseBanks8.name
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
title: "\u7F16\u8F91",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
return setIsEdit(true);
|
|
},
|
|
className: "iconfont c-green ml30 icon-bianjidaibeijing"
|
|
})
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "c-light-black",
|
|
children: (_polls$exerciseBanks9 = polls.exerciseBanks) === null || _polls$exerciseBanks9 === void 0 || (_polls$exerciseBanks9 = _polls$exerciseBanks9.poll) === null || _polls$exerciseBanks9 === void 0 ? void 0 : _polls$exerciseBanks9.description
|
|
})]
|
|
}), isEdit && /*#__PURE__*/(0,jsx_runtime.jsxs)(es_form/* default */.Z, {
|
|
layout: "vertical",
|
|
form: form,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
name: "exercise_name",
|
|
label: "\u95EE\u5377\u6807\u9898\uFF1A",
|
|
rules: [{
|
|
required: true,
|
|
message: "请填写问卷标题"
|
|
}],
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z, {
|
|
maxLength: 60,
|
|
placeholder: "\u95EE\u5377\u6807\u9898\uFF0C\u6700\u5927\u9650\u523660\u4E2A\u5B57\u7B26"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
label: "\u95EE\u5377\u987B\u77E5\uFF1A",
|
|
name: "exercise_description",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(input/* default */.Z.TextArea, {
|
|
rows: 6,
|
|
placeholder: "\u8BF7\u5728\u6B64\u8F93\u5165\u672C\u6B21\u95EE\u5377\u7B54\u9898\u7684\u76F8\u5173\u8BF4\u660E\uFF0C\u6700\u5927\u9650\u5236100\u4E2A\u5B57\u7B26"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_form/* default */.Z.Item, {
|
|
className: "tr",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_button/* default */.ZP, {
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
save();
|
|
},
|
|
children: "\u4FDD\u5B58"
|
|
})
|
|
})]
|
|
})]
|
|
}), editData != '' && /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
className: "mt20",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)(row/* default */.Z, {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
flex: 1,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black mr20",
|
|
children: ["\u5355\u9009\u9898 ", (_polls$exerciseBanks10 = polls.exerciseBanks) === null || _polls$exerciseBanks10 === void 0 || (_polls$exerciseBanks10 = _polls$exerciseBanks10.question_types) === null || _polls$exerciseBanks10 === void 0 ? void 0 : _polls$exerciseBanks10.q_singles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black mr20",
|
|
children: ["\u591A\u9009\u9898 ", (_polls$exerciseBanks11 = polls.exerciseBanks) === null || _polls$exerciseBanks11 === void 0 || (_polls$exerciseBanks11 = _polls$exerciseBanks11.question_types) === null || _polls$exerciseBanks11 === void 0 ? void 0 : _polls$exerciseBanks11.q_doubles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black",
|
|
children: ["\u4E3B\u89C2\u9898 ", (_polls$exerciseBanks12 = polls.exerciseBanks) === null || _polls$exerciseBanks12 === void 0 || (_polls$exerciseBanks12 = _polls$exerciseBanks12.question_types) === null || _polls$exerciseBanks12 === void 0 ? void 0 : _polls$exerciseBanks12.q_mains, " \u9898"]
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)(col/* default */.Z, {
|
|
className: "c-light-black",
|
|
children: ["\u5408\u8BA1 ", /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
className: "c-orange",
|
|
children: (_polls$exerciseBanks13 = polls.exerciseBanks) === null || _polls$exerciseBanks13 === void 0 || (_polls$exerciseBanks13 = _polls$exerciseBanks13.question_types) === null || _polls$exerciseBanks13 === void 0 ? void 0 : _polls$exerciseBanks13.q_counts
|
|
}), " \u9898"]
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: [Detailmodules.bg, 'pt30', 'pl20', 'pr20', 'pb20', 'mt20'].join(' '),
|
|
children: [editData != '' && renderQuestion(), editData == '' && /*#__PURE__*/(0,jsx_runtime.jsx)(NoData/* default */.Z, {})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(SendToClassModal/* default */.Z, {})]
|
|
});
|
|
};
|
|
/* harmony default export */ var Detail = ((0,_umi_production_exports.connect)(function (_ref4) {
|
|
var polls = _ref4.polls,
|
|
loading = _ref4.loading,
|
|
user = _ref4.user,
|
|
globalSetting = _ref4.globalSetting;
|
|
return {
|
|
polls: polls,
|
|
globalSetting: globalSetting,
|
|
user: user,
|
|
loading: loading.effects
|
|
};
|
|
})(ShixunsListPage));
|
|
|
|
/***/ }),
|
|
|
|
/***/ 50160:
|
|
/*!**********************************************************************************!*\
|
|
!*** ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx + 2 modules ***!
|
|
\**********************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
// EXPORTS
|
|
__webpack_require__.d(__webpack_exports__, {
|
|
Z: function() { return /* binding */ components_SendToClassModal; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(26801);
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(10574);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(39343);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(11006);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(27161);
|
|
var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/index.js
|
|
var _react_17_0_2_react = __webpack_require__(59301);
|
|
// EXTERNAL MODULE: ./src/.umi-production/exports.ts + 8 modules
|
|
var _umi_production_exports = __webpack_require__(7181);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/message/index.js + 4 modules
|
|
var message = __webpack_require__(8591);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/modal/index.js + 16 modules
|
|
var modal = __webpack_require__(43418);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/tabs/index.js + 24 modules
|
|
var tabs = __webpack_require__(99313);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/skeleton/index.js + 12 modules
|
|
var skeleton = __webpack_require__(59981);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/radio/index.js + 5 modules
|
|
var es_radio = __webpack_require__(5112);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var SendToClassModalmodules = ({"title":"title___XAxiE","radioWrap":"radioWrap___k0pOB","radio":"radio___x9kMt","colorFF0000":"colorFF0000___IMgd0","pagination":"pagination___ou2ht","checkboxWrapper":"checkboxWrapper___kF7xI"});
|
|
// EXTERNAL MODULE: ./src/utils/util.tsx
|
|
var util = __webpack_require__(87885);
|
|
// EXTERNAL MODULE: ./src/components/ui-customization/index.tsx + 34 modules
|
|
var ui_customization = __webpack_require__(56782);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.2@@babel/runtime/helpers/toConsumableArray.js
|
|
var toConsumableArray = __webpack_require__(93923);
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/spin/index.js + 1 modules
|
|
var spin = __webpack_require__(71418);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/checkbox/index.js + 3 modules
|
|
var es_checkbox = __webpack_require__(24905);
|
|
// EXTERNAL MODULE: ./src/service/user.ts
|
|
var user = __webpack_require__(43916);
|
|
// EXTERNAL MODULE: ./node_modules/_react-infinite-scroller@1.2.4@react-infinite-scroller/index.js
|
|
var _react_infinite_scroller_1_2_4_react_infinite_scroller = __webpack_require__(26724);
|
|
var _react_infinite_scroller_1_2_4_react_infinite_scroller_default = /*#__PURE__*/__webpack_require__.n(_react_infinite_scroller_1_2_4_react_infinite_scroller);
|
|
// EXTERNAL MODULE: ./node_modules/_react@17.0.2@react/jsx-runtime.js
|
|
var jsx_runtime = __webpack_require__(37712);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToSubject.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SendToSubject = function SendToSubject(_ref) {
|
|
var username = _ref.username,
|
|
setStages = _ref.setStages,
|
|
stages = _ref.stages,
|
|
hasError = _ref.hasError,
|
|
setHasError = _ref.setHasError;
|
|
var _useState = (0,_react_17_0_2_react.useState)(''),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
searchValue = _useState2[0],
|
|
setSearchValue = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(1),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
page = _useState4[0],
|
|
setPage = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
subjectList = _useState6[0],
|
|
setSubjectList = _useState6[1];
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
listLoading = _useState8[0],
|
|
setListLoading = _useState8[1];
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(0),
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
totalCount = _useState10[0],
|
|
setTotalCount = _useState10[1];
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
getSubjectList({
|
|
page: 1,
|
|
search: ''
|
|
}, true);
|
|
}, []);
|
|
var getSubjectList = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(params, reset) {
|
|
var res;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
setListLoading(true);
|
|
_context.next = 3;
|
|
return (0,user/* getPaths */.w3)({
|
|
username: username,
|
|
category: 'manage',
|
|
page: params.page,
|
|
search: params.search
|
|
});
|
|
case 3:
|
|
res = _context.sent;
|
|
setListLoading(false);
|
|
setSubjectList(function (pre) {
|
|
return reset ? res === null || res === void 0 ? void 0 : res.subjects : [].concat(toConsumableArray_default()(pre), toConsumableArray_default()(res === null || res === void 0 ? void 0 : res.subjects));
|
|
});
|
|
setTotalCount(res === null || res === void 0 ? void 0 : res.count);
|
|
case 7:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function getSubjectList(_x, _x2) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var scrollElementRef = (0,_react_17_0_2_react.useRef)();
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: SendToClassModalmodules.wrap,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mb10",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ui_customization/* CustomInput */.t7, {
|
|
placeholder: "\u8BF7\u8F93\u5165\u5B9E\u8DF5\u8BFE\u7A0B\u540D\u79F0\u7684\u5173\u952E\u5B57\u8FDB\u884C\u641C\u7D22",
|
|
value: searchValue,
|
|
style: {
|
|
width: 500
|
|
},
|
|
onChange: function onChange(value) {
|
|
setSearchValue(value);
|
|
setPage(1);
|
|
scrollElementRef.current.scrollTo({
|
|
behavior: 'smooth',
|
|
top: 0
|
|
});
|
|
getSubjectList({
|
|
page: 1,
|
|
search: value
|
|
}, true);
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(spin/* default */.Z, {
|
|
spinning: listLoading,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: SendToClassModalmodules.radioWrap,
|
|
ref: scrollElementRef,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)((_react_infinite_scroller_1_2_4_react_infinite_scroller_default()), {
|
|
initialLoad: false,
|
|
pageStart: 1,
|
|
threshold: 6,
|
|
loadMore: function loadMore() {
|
|
setPage(page + 1);
|
|
getSubjectList({
|
|
page: page + 1,
|
|
search: searchValue
|
|
}, false);
|
|
},
|
|
hasMore: subjectList.length < totalCount,
|
|
useWindow: false,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Group */.ZP.Group, {
|
|
value: stages.subjectId,
|
|
onChange: function onChange(e) {
|
|
setStages({
|
|
subjectId: e.target.value,
|
|
stage_ids: []
|
|
});
|
|
setHasError(false);
|
|
},
|
|
children: subjectList.map(function (item) {
|
|
var options = item.stages.map(function (stage) {
|
|
return {
|
|
label: stage.name,
|
|
value: stage.id
|
|
};
|
|
});
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
className: SendToClassModalmodules.radio,
|
|
value: item.id,
|
|
children: item.name
|
|
}), item.id === stages.subjectId && /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: SendToClassModalmodules.checkboxWrapper,
|
|
children: [options.length > 0 && /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z, {
|
|
indeterminate: stages.stage_ids.length > 0 && stages.stage_ids.length < options.length,
|
|
onChange: function onChange(e) {
|
|
setStages({
|
|
subjectId: item.id,
|
|
stage_ids: e.target.checked ? options.map(function (option) {
|
|
return option.value;
|
|
}) : []
|
|
});
|
|
},
|
|
checked: stages.stage_ids.length === options.length,
|
|
children: "\u5168\u9009"
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(es_checkbox/* default */.Z.Group, {
|
|
options: options,
|
|
value: stages.stage_ids,
|
|
onChange: function onChange(checkedValue) {
|
|
return setStages({
|
|
subjectId: item.id,
|
|
stage_ids: checkedValue
|
|
});
|
|
}
|
|
})]
|
|
})]
|
|
}, item.id);
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}), hasError && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: SendToClassModalmodules.colorFF0000,
|
|
children: "\u8BF7\u5148\u9009\u62E9\u5B9E\u8DF5\u8BFE\u7A0B\u53CA\u7AE0\u8282"
|
|
})]
|
|
});
|
|
};
|
|
/* harmony default export */ var components_SendToSubject = (SendToSubject);
|
|
// EXTERNAL MODULE: ./src/components/ui-customization/reset.less?modules
|
|
var resetmodules = __webpack_require__(42175);
|
|
// EXTERNAL MODULE: ./src/service/account.ts
|
|
var account = __webpack_require__(50969);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/components/SendToClassModal.tsx
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["userDetail", "globalSetting", "loading", "user", "dispatch"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SendToClassModal = function SendToClassModal(_ref) {
|
|
var _userDetail$actionTab4, _user$userInfo2, _userDetail$actionTab5;
|
|
var userDetail = _ref.userDetail,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
user = _ref.user,
|
|
dispatch = _ref.dispatch,
|
|
props = objectWithoutProperties_default()(_ref, _excluded);
|
|
var _useState = (0,_react_17_0_2_react.useState)('course'),
|
|
_useState2 = slicedToArray_default()(_useState, 2),
|
|
activeKey = _useState2[0],
|
|
setActiveKey = _useState2[1];
|
|
var _useState3 = (0,_react_17_0_2_react.useState)(''),
|
|
_useState4 = slicedToArray_default()(_useState3, 2),
|
|
searchValue = _useState4[0],
|
|
setSearchValue = _useState4[1];
|
|
var _useState5 = (0,_react_17_0_2_react.useState)([]),
|
|
_useState6 = slicedToArray_default()(_useState5, 2),
|
|
courseList = _useState6[0],
|
|
setCourseList = _useState6[1];
|
|
var _useState7 = (0,_react_17_0_2_react.useState)(),
|
|
_useState8 = slicedToArray_default()(_useState7, 2),
|
|
radioValue = _useState8[0],
|
|
setRadioValue = _useState8[1];
|
|
var _useState9 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState10 = slicedToArray_default()(_useState9, 2),
|
|
listLoading = _useState10[0],
|
|
setListLoading = _useState10[1];
|
|
var _useState11 = (0,_react_17_0_2_react.useState)(false),
|
|
_useState12 = slicedToArray_default()(_useState11, 2),
|
|
hasError = _useState12[0],
|
|
setHasError = _useState12[1];
|
|
(0,_react_17_0_2_react.useEffect)(function () {
|
|
if (userDetail.actionTabs.key === 'UserDetail-SendToClass') {
|
|
getCourseList(searchValue);
|
|
}
|
|
}, [userDetail.actionTabs.key]);
|
|
var getCourseList = /*#__PURE__*/function () {
|
|
var _ref2 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee(value) {
|
|
var res;
|
|
return regeneratorRuntime_default()().wrap(function _callee$(_context) {
|
|
while (1) switch (_context.prev = _context.next) {
|
|
case 0:
|
|
setListLoading(true);
|
|
_context.next = 3;
|
|
return dispatch({
|
|
type: 'userDetail/topicGetCourseList',
|
|
payload: {
|
|
search: value
|
|
}
|
|
});
|
|
case 3:
|
|
res = _context.sent;
|
|
if (res) {
|
|
setCourseList((res === null || res === void 0 ? void 0 : res.courses) || []);
|
|
}
|
|
setListLoading(false);
|
|
case 6:
|
|
case "end":
|
|
return _context.stop();
|
|
}
|
|
}, _callee);
|
|
}));
|
|
return function getCourseList(_x) {
|
|
return _ref2.apply(this, arguments);
|
|
};
|
|
}();
|
|
var _useState13 = (0,_react_17_0_2_react.useState)({
|
|
subjectId: '',
|
|
stage_ids: []
|
|
}),
|
|
_useState14 = slicedToArray_default()(_useState13, 2),
|
|
stages = _useState14[0],
|
|
setStages = _useState14[1];
|
|
var handleOk = /*#__PURE__*/function () {
|
|
var _ref3 = asyncToGenerator_default()( /*#__PURE__*/regeneratorRuntime_default()().mark(function _callee2() {
|
|
var _userDetail$actionTab, res, _userDetail$actionTab2, urlMapping, _userDetail$actionTab3, _user$userInfo, _res;
|
|
return regeneratorRuntime_default()().wrap(function _callee2$(_context2) {
|
|
while (1) switch (_context2.prev = _context2.next) {
|
|
case 0:
|
|
if (!(activeKey === 'course')) {
|
|
_context2.next = 11;
|
|
break;
|
|
}
|
|
if (radioValue) {
|
|
_context2.next = 4;
|
|
break;
|
|
}
|
|
setHasError(true);
|
|
return _context2.abrupt("return");
|
|
case 4:
|
|
_context2.next = 6;
|
|
return dispatch({
|
|
type: 'userDetail/topicSendToClass',
|
|
payload: objectSpread2_default()({
|
|
course_id: radioValue
|
|
}, (_userDetail$actionTab = userDetail.actionTabs) === null || _userDetail$actionTab === void 0 ? void 0 : _userDetail$actionTab.params)
|
|
});
|
|
case 6:
|
|
res = _context2.sent;
|
|
dispatch({
|
|
type: 'userDetail/setActionTabs',
|
|
payload: {}
|
|
});
|
|
if (res && res.status === 0) {
|
|
urlMapping = {
|
|
'normal': 'common_homework',
|
|
'group': 'group_homework',
|
|
'exercise': 'exercise',
|
|
'poll': 'poll',
|
|
'videos': 'video'
|
|
};
|
|
(0,util/* openNewWindow */.xg)("/classrooms/".concat(radioValue, "/").concat(urlMapping[(_userDetail$actionTab2 = userDetail.actionTabs) === null || _userDetail$actionTab2 === void 0 || (_userDetail$actionTab2 = _userDetail$actionTab2.params) === null || _userDetail$actionTab2 === void 0 ? void 0 : _userDetail$actionTab2.object_type]));
|
|
}
|
|
_context2.next = 18;
|
|
break;
|
|
case 11:
|
|
if (!(!stages.subjectId || !stages.stage_ids.length)) {
|
|
_context2.next = 14;
|
|
break;
|
|
}
|
|
setHasError(true);
|
|
return _context2.abrupt("return");
|
|
case 14:
|
|
_context2.next = 16;
|
|
return (0,account/* createSubjectVideo */.nI)({
|
|
id: (_userDetail$actionTab3 = userDetail.actionTabs) === null || _userDetail$actionTab3 === void 0 || (_userDetail$actionTab3 = _userDetail$actionTab3.params) === null || _userDetail$actionTab3 === void 0 ? void 0 : _userDetail$actionTab3.object_id,
|
|
login: (_user$userInfo = user.userInfo) === null || _user$userInfo === void 0 ? void 0 : _user$userInfo.login
|
|
}, {
|
|
stage_ids: stages.stage_ids
|
|
});
|
|
case 16:
|
|
_res = _context2.sent;
|
|
if (_res.status === 0) {
|
|
message/* default */.ZP.success('发送成功');
|
|
dispatch({
|
|
type: 'userDetail/setActionTabs',
|
|
payload: {}
|
|
});
|
|
(0,util/* openNewWindow */.xg)("/paths/".concat(stages.subjectId));
|
|
}
|
|
case 18:
|
|
case "end":
|
|
return _context2.stop();
|
|
}
|
|
}, _callee2);
|
|
}));
|
|
return function handleOk() {
|
|
return _ref3.apply(this, arguments);
|
|
};
|
|
}();
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(modal/* default */.Z, {
|
|
centered: true,
|
|
keyboard: false,
|
|
closable: false,
|
|
destroyOnClose: true,
|
|
open: userDetail.actionTabs.key === 'UserDetail-SendToClass',
|
|
title: "\u53D1\u9001",
|
|
okText: "\u786E\u5B9A",
|
|
cancelText: "\u53D6\u6D88",
|
|
confirmLoading: loading['userDetail/sendToClass'],
|
|
width: 600,
|
|
afterClose: function afterClose() {
|
|
setHasError(false);
|
|
setCourseList([]);
|
|
setStages({
|
|
subjectId: '',
|
|
stage_ids: []
|
|
});
|
|
setSearchValue('');
|
|
},
|
|
onOk: handleOk,
|
|
wrapClassName: resetmodules/* default */.Z.CustomCss,
|
|
onCancel: function onCancel() {
|
|
dispatch({
|
|
type: 'userDetail/setActionTabs',
|
|
payload: {}
|
|
});
|
|
},
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(tabs/* default */.Z, {
|
|
activeKey: activeKey,
|
|
onChange: function onChange(key) {
|
|
setHasError(false);
|
|
setActiveKey(key);
|
|
},
|
|
items: [{
|
|
label: '课堂',
|
|
key: 'course',
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: SendToClassModalmodules.wrap,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: "mb10",
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(ui_customization/* CustomInput */.t7, {
|
|
placeholder: "\u8BF7\u8F93\u5165\u8BFE\u5802\u540D\u79F0\u7684\u5173\u952E\u5B57\u8FDB\u884C\u641C\u7D22",
|
|
value: searchValue,
|
|
style: {
|
|
width: 500
|
|
},
|
|
onChange: function onChange(value) {
|
|
setSearchValue(value);
|
|
getCourseList(value);
|
|
}
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(skeleton/* default */.Z, {
|
|
active: true,
|
|
loading: listLoading,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: SendToClassModalmodules.radioWrap,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default.Group */.ZP.Group, {
|
|
value: radioValue,
|
|
onChange: function onChange(e) {
|
|
setRadioValue(e.target.value);
|
|
setHasError(false);
|
|
},
|
|
children: courseList.map(function (item, key) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(es_radio/* default */.ZP, {
|
|
className: SendToClassModalmodules.radio,
|
|
value: item.course_id,
|
|
children: item.course_name
|
|
}, item.course_id);
|
|
})
|
|
})
|
|
})
|
|
}), ((_userDetail$actionTab4 = userDetail.actionTabs) === null || _userDetail$actionTab4 === void 0 || (_userDetail$actionTab4 = _userDetail$actionTab4.params) === null || _userDetail$actionTab4 === void 0 ? void 0 : _userDetail$actionTab4.object_type) !== 'videos' && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: SendToClassModalmodules.title,
|
|
children: "\u6E29\u99A8\u63D0\u793A\uFF1A\u9009\u62E9\u7684\u9898\u5C06\u4F1A\u53D1\u9001\u5230\u6307\u5B9A\u8BFE\u5802"
|
|
}), hasError && /*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
className: SendToClassModalmodules.colorFF0000,
|
|
children: "\u8BF7\u5148\u9009\u62E9\u8BFE\u5802"
|
|
})]
|
|
}),
|
|
show: true
|
|
}, {
|
|
label: '实践课程',
|
|
key: 'subject',
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(components_SendToSubject, {
|
|
username: (_user$userInfo2 = user.userInfo) === null || _user$userInfo2 === void 0 ? void 0 : _user$userInfo2.login,
|
|
stages: stages,
|
|
setStages: setStages,
|
|
hasError: hasError,
|
|
setHasError: setHasError
|
|
}),
|
|
show: ((_userDetail$actionTab5 = userDetail.actionTabs) === null || _userDetail$actionTab5 === void 0 || (_userDetail$actionTab5 = _userDetail$actionTab5.params) === null || _userDetail$actionTab5 === void 0 ? void 0 : _userDetail$actionTab5.object_type) === 'videos'
|
|
}].filter(function (item) {
|
|
return item.show;
|
|
})
|
|
})
|
|
});
|
|
};
|
|
/* harmony default export */ var components_SendToClassModal = ((0,_umi_production_exports.connect)(function (_ref4) {
|
|
var userDetail = _ref4.userDetail,
|
|
loading = _ref4.loading,
|
|
globalSetting = _ref4.globalSetting,
|
|
user = _ref4.user;
|
|
return {
|
|
userDetail: userDetail,
|
|
globalSetting: globalSetting,
|
|
loading: loading.effects,
|
|
user: user
|
|
};
|
|
})(SendToClassModal));
|
|
|
|
/***/ }),
|
|
|
|
/***/ 42175:
|
|
/*!************************************************************!*\
|
|
!*** ./src/components/ui-customization/reset.less?modules ***!
|
|
\************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__) {
|
|
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ __webpack_exports__.Z = ({"flex_box_center":"flex_box_center___vG4eV","flex_space_between":"flex_space_between___qVVxe","flex_box_vertical_center":"flex_box_vertical_center___P8Z8s","flex_box_center_end":"flex_box_center_end___VMme3","flex_box_column":"flex_box_column___VMHwm","dropdownmenus":"dropdownmenus___oVzoj","popupClassNames":"popupClassNames___OcZq7","selectdown":"selectdown___mmcA8"});
|
|
|
|
/***/ })
|
|
|
|
}]); |