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.
1851 lines
80 KiB
1851 lines
80 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[75043],{
|
|
|
|
/***/ 16052:
|
|
/*!**********************************************************************!*\
|
|
!*** ./src/pages/User/Detail/Topics/Poll/Edit/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 */ Edit; }
|
|
});
|
|
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/regeneratorRuntime.js
|
|
var regeneratorRuntime = __webpack_require__(7557);
|
|
var regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(regeneratorRuntime);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/asyncToGenerator.js
|
|
var asyncToGenerator = __webpack_require__(41498);
|
|
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectSpread2.js
|
|
var objectSpread2 = __webpack_require__(82242);
|
|
var objectSpread2_default = /*#__PURE__*/__webpack_require__.n(objectSpread2);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/toConsumableArray.js
|
|
var toConsumableArray = __webpack_require__(37205);
|
|
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/slicedToArray.js
|
|
var slicedToArray = __webpack_require__(79800);
|
|
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
|
|
// EXTERNAL MODULE: ./node_modules/_@babel_runtime@7.23.6@@babel/runtime/helpers/objectWithoutProperties.js
|
|
var objectWithoutProperties = __webpack_require__(39647);
|
|
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
|
|
var _umi_production_exports = __webpack_require__(80184);
|
|
// 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/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__(10249);
|
|
// EXTERNAL MODULE: ./node_modules/_antd@5.9.0@antd/es/button/index.js
|
|
var es_button = __webpack_require__(3113);
|
|
// EXTERNAL MODULE: ./node_modules/_@ant-design_icons@5.6.1@@ant-design/icons/es/icons/PlusCircleOutlined.js + 1 modules
|
|
var PlusCircleOutlined = __webpack_require__(32134);
|
|
// EXTERNAL MODULE: ./src/service/polls.ts
|
|
var service_polls = __webpack_require__(6016);
|
|
// 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/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 + 2 modules
|
|
var RenderHtml = __webpack_require__(26404);
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/components/editor.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var editormodules = ({"flex_box_center":"flex_box_center___z7AIK","flex_space_between":"flex_space_between___zcbqj","flex_box_vertical_center":"flex_box_vertical_center___dTgjR","flex_box_center_end":"flex_box_center_end___z9WhB","flex_box_column":"flex_box_column___fDtsr","wrap":"wrap___fuJ7x","modal":"modal___Gq9oV","titleWrap":"titleWrap___T__HP","required":"required___CzJ8q","title":"title___PM33R","colorGray":"colorGray___jFiKo","choiceWrap":"choiceWrap___Htfyz","answer":"answer___AW61F","activeAnswer":"activeAnswer___Bt5i9","deleteIcon":"deleteIcon___mbWjv","addIcon":"addIcon___K4tkj","editorWrap":"editorWrap___RqcyT","htmlWrap":"htmlWrap___QqgN2","radio":"radio___UBWFG","color333":"color333___bOiTN","color999":"color999___ead_D","questionType":"questionType___VkggW","questionChoices":"questionChoices___Erma4"});
|
|
// 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/Edit/components/MultipleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _excluded = ["problemset", "globalSetting", "loading", "dispatch", "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$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, editRes, callbackEditData;
|
|
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:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 2,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 2
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
case 30:
|
|
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$question10, _editData$question11;
|
|
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$question9;
|
|
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$question9 = editData.question) === null || _editData$question9 === void 0 ? void 0 : _editData$question9.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$question10 = editData.question) === null || _editData$question10 === void 0 ? void 0 : _editData$question10.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: 2,
|
|
key: editData.key,
|
|
insert_id: editData === null || editData === void 0 || (_editData$question11 = editData.question) === null || _editData$question11 === void 0 ? void 0 : _editData$question11.id,
|
|
question_type: 2
|
|
});
|
|
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$question12, _editData$question13, _editData$question14, _editData$question$an;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("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$question12 = editData.question) === null || _editData$question12 === void 0 ? void 0 : _editData$question12.is_necessary) === 0 ? "选答" : "必答"
|
|
}), "\u53EF\u9009", editData === null || editData === void 0 || (_editData$question13 = editData.question) === null || _editData$question13 === void 0 ? void 0 : _editData$question13.min_choices, "-", editData === null || editData === void 0 || (_editData$question14 = editData.question) === null || _editData$question14 === void 0 ? void 0 : _editData$question14.max_choices, "\u9879"]
|
|
}), actionArr.map(function (item, index) {
|
|
if (item.id === "up" && editData.key === 1) return null;
|
|
if (item.id === "down" && editData.key === editData.len) return null;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
placement: "bottom",
|
|
title: item.name,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
return actionClick(item);
|
|
},
|
|
className: item.icon
|
|
})
|
|
}, index);
|
|
})]
|
|
}), /*#__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.jsx)("span", {
|
|
className: "font14 c-grey-999",
|
|
children: "\uFF08\u5B66\u751F\u7B54\u9898\u65F6\uFF0C\u7CFB\u7EDF\u5BF9\u5176\u9009\u62E9\u7684\u9009\u9879\u4E2A\u6570\u8FDB\u884C\u9650\u5236\uFF0C--\u8868\u793A\u4E0D\u9650\u5236\uFF09"
|
|
})]
|
|
})]
|
|
}), /*#__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$question15;
|
|
if ((_editData$question15 = editData.question) !== null && _editData$question15 !== void 0 && _editData$question15.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 (_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)));
|
|
// 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/Edit/components/SingleEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SingleEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "editKey", "callback"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
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, editRes, callbackEditData;
|
|
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:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map(function (item) {
|
|
return {
|
|
answer_text: item
|
|
};
|
|
});
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 1,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 1
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
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.jsxs)("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 ? "选答" : "必答"
|
|
})]
|
|
}), actionArr.map(function (item, index) {
|
|
if (item.id === "up" && editData.key === 1) return null;
|
|
if (item.id === "down" && editData.key === editData.len) return null;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
placement: "bottom",
|
|
title: item.name,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
return actionClick(item);
|
|
},
|
|
className: item.icon
|
|
})
|
|
}, index);
|
|
})]
|
|
}), /*#__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: 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.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$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/Edit/components/SubjectiveEditor/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var SubjectiveEditor_excluded = ["problemset", "globalSetting", "loading", "dispatch", "onRef", "editData", "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,
|
|
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, editRes, callbackEditData;
|
|
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:
|
|
editRes = _context.sent;
|
|
if (status) {
|
|
callbackEditData = [].concat(toConsumableArray_default()(editRes === null || editRes === void 0 ? void 0 : editRes.questions), [{
|
|
question: objectSpread2_default()({
|
|
type: 3,
|
|
insert_id: editData.question.id,
|
|
key: editData.key,
|
|
question_type: 3
|
|
}, bodyData)
|
|
}]);
|
|
callback('addContinue', {
|
|
editData: callbackEditData
|
|
});
|
|
}
|
|
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.jsxs)("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 ? "选答" : "必答"
|
|
})]
|
|
}), actionArr.map(function (item, index) {
|
|
if (item.id === "up" && editData.key === 1) return null;
|
|
if (item.id === "down" && editData.key === editData.len) return null;
|
|
return /*#__PURE__*/(0,jsx_runtime.jsx)(tooltip/* default */.Z, {
|
|
placement: "bottom",
|
|
title: item.name,
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)("span", {
|
|
onClick: function onClick() {
|
|
return actionClick(item);
|
|
},
|
|
className: item.icon
|
|
})
|
|
}, index);
|
|
})]
|
|
}), /*#__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);
|
|
}
|
|
})
|
|
}), /*#__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)));
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/index.less?modules
|
|
// extracted by mini-css-extract-plugin
|
|
/* harmony default export */ var Editmodules = ({"flex_box_center":"flex_box_center___jFb53","flex_space_between":"flex_space_between___eaFhb","flex_box_vertical_center":"flex_box_vertical_center___Rp5aN","flex_box_center_end":"flex_box_center_end___EpEQ2","flex_box_column":"flex_box_column___hEFHr","bg":"bg___Y7Bmz","containerTitle":"containerTitle___xdxGQ","containerDesc":"containerDesc___pXaV0","listItem":"listItem___P0Hq4","info":"info___nZ3vt","title":"title___p_v5i","titleLeft":"titleLeft___d8_hx","titleRight":"titleRight___xz4zW","acitons":"acitons___BCczQ"});
|
|
;// CONCATENATED MODULE: ./src/pages/User/Detail/Topics/Poll/Edit/index.tsx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var Edit_excluded = ["polls", "globalSetting", "loading", "user", "dispatch"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ShixunsListPage = function ShixunsListPage(_ref) {
|
|
var _polls$exerciseBanks5, _polls$exerciseBanks6, _polls$exerciseBanks7, _polls$exerciseBanks8, _polls$exerciseBanks9, _polls$exerciseBanks10;
|
|
var polls = _ref.polls,
|
|
globalSetting = _ref.globalSetting,
|
|
loading = _ref.loading,
|
|
user = _ref.user,
|
|
dispatch = _ref.dispatch,
|
|
props = objectWithoutProperties_default()(_ref, Edit_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 callback = function callback(key, data, allData) {
|
|
var _data$editData;
|
|
switch (key) {
|
|
case "edit":
|
|
if (data !== -1 && editKey !== -1 && data !== editKey) {
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return;
|
|
}
|
|
setEditKey(data);
|
|
return;
|
|
case "add":
|
|
if (editKey != -1) {
|
|
message/* default */.ZP.error("不能同时编辑两题");
|
|
return;
|
|
}
|
|
setEditKey(-1);
|
|
break;
|
|
case "addContinue":
|
|
setEditData(toConsumableArray_default()(data === null || data === void 0 ? void 0 : data.editData));
|
|
setEditKey(data === null || data === void 0 || (_data$editData = data.editData) === null || _data$editData === void 0 ? void 0 : _data$editData.length);
|
|
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, {})]
|
|
}, v.id);
|
|
}
|
|
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, {})]
|
|
}, v.id);
|
|
}
|
|
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, {})]
|
|
}, v.id);
|
|
}
|
|
});
|
|
};
|
|
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(params.username, "/").concat(params.topictype === 'personal' ? 'topics' : 'topicbank', "/").concat(params.topictype),
|
|
children: params.topictype === 'personal' ? '我的课堂资源' : '公共题库'
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
|
|
to: "/users/".concat(userInfo === null || userInfo === void 0 ? void 0 : userInfo.login, "/topics/").concat(params.topicId, "/").concat(params.topictype, "/poll/detail"),
|
|
children: "\u8BE6\u60C5"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(breadcrumb/* default */.Z.Item, {
|
|
children: "\u7F16\u8F91"
|
|
})]
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("aside", {
|
|
className: [Editmodules.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: "\u7F16\u8F91"
|
|
})
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)(col/* default */.Z, {
|
|
children: /*#__PURE__*/(0,jsx_runtime.jsx)(_umi_production_exports.Link, {
|
|
className: "font16 c-light-black",
|
|
to: "/users/".concat(userInfo.login, "/topics/").concat(params.topictype),
|
|
children: "\u8FD4\u56DE"
|
|
})
|
|
})]
|
|
})
|
|
})]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("section", {
|
|
className: [Editmodules.bg, 'pt30', 'pl30', 'pr30', 'pb30', 'mt20'].join(' '),
|
|
children: [!isEdit && /*#__PURE__*/(0,jsx_runtime.jsxs)("aside", {
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsxs)("div", {
|
|
className: Editmodules.containerDesc,
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)("div", {
|
|
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)("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$exerciseBanks6 = polls.exerciseBanks) === null || _polls$exerciseBanks6 === void 0 || (_polls$exerciseBanks6 = _polls$exerciseBanks6.poll) === null || _polls$exerciseBanks6 === void 0 ? void 0 : _polls$exerciseBanks6.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"
|
|
})
|
|
})]
|
|
})]
|
|
}), /*#__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$exerciseBanks7 = polls.exerciseBanks) === null || _polls$exerciseBanks7 === void 0 || (_polls$exerciseBanks7 = _polls$exerciseBanks7.question_types) === null || _polls$exerciseBanks7 === void 0 ? void 0 : _polls$exerciseBanks7.q_singles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black mr20",
|
|
children: ["\u591A\u9009\u9898 ", (_polls$exerciseBanks8 = polls.exerciseBanks) === null || _polls$exerciseBanks8 === void 0 || (_polls$exerciseBanks8 = _polls$exerciseBanks8.question_types) === null || _polls$exerciseBanks8 === void 0 ? void 0 : _polls$exerciseBanks8.q_doubles, " \u9898"]
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsxs)("span", {
|
|
className: "c-light-black",
|
|
children: ["\u4E3B\u89C2\u9898 ", (_polls$exerciseBanks9 = polls.exerciseBanks) === null || _polls$exerciseBanks9 === void 0 || (_polls$exerciseBanks9 = _polls$exerciseBanks9.question_types) === null || _polls$exerciseBanks9 === void 0 ? void 0 : _polls$exerciseBanks9.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$exerciseBanks10 = polls.exerciseBanks) === null || _polls$exerciseBanks10 === void 0 || (_polls$exerciseBanks10 = _polls$exerciseBanks10.question_types) === null || _polls$exerciseBanks10 === void 0 ? void 0 : _polls$exerciseBanks10.q_counts
|
|
}), " \u9898"]
|
|
})]
|
|
})
|
|
}), editData != '' && /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
className: [Editmodules.bg, 'pt30', 'pl20', 'pr20', 'pb20', 'mt20'].join(' '),
|
|
children: renderQuestion()
|
|
}), /*#__PURE__*/(0,jsx_runtime.jsx)("section", {
|
|
className: [Editmodules.bg, 'pt30', 'pl30', 'pr30', 'pb30', 'mt20'].join(' '),
|
|
children: questionType.map(function (item, index) {
|
|
return /*#__PURE__*/(0,jsx_runtime.jsxs)(es_button/* default */.ZP, {
|
|
className: "mr20",
|
|
type: "primary",
|
|
onClick: function onClick() {
|
|
return addQuestion(item.id);
|
|
},
|
|
children: [/*#__PURE__*/(0,jsx_runtime.jsx)(PlusCircleOutlined/* default */.Z, {
|
|
className: "mr5"
|
|
}), item.name]
|
|
});
|
|
})
|
|
})]
|
|
});
|
|
};
|
|
/* harmony default export */ var Edit = ((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));
|
|
|
|
/***/ })
|
|
|
|
}]); |