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.
1053 lines
64 KiB
1053 lines
64 KiB
"use strict";
|
|
(self["webpackChunk"] = self["webpackChunk"] || []).push([[3164],{
|
|
|
|
/***/ 23960:
|
|
/*!******************************************************************************!*\
|
|
!*** ./src/pages/Classrooms/Lists/Polls/Edit/components/editor.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___JbEg0","flex_space_between":"flex_space_between___Kf6pN","flex_box_vertical_center":"flex_box_vertical_center___e4qgM","flex_box_center_end":"flex_box_center_end___p8QnY","flex_box_column":"flex_box_column___qCilW","wrap":"wrap___Gdnjm","modal":"modal___nL9rn","titleWrap":"titleWrap___ezuXc","required":"required___i8a7H","title":"title___FaxQL","colorGray":"colorGray___CO5Es","choiceWrap":"choiceWrap___pj0lT","answer":"answer___Aq1c0","activeAnswer":"activeAnswer___VIsVw","deleteIcon":"deleteIcon___Gsa5a","addIcon":"addIcon___Yr5Ku","editorWrap":"editorWrap____aGAd","htmlWrap":"htmlWrap___SKYBF","radio":"radio___wvdFS","color333":"color333___uuN3O","color999":"color999___prp8g","questionType":"questionType___FKxwP","questionChoices":"questionChoices___c0OQa","close_style":"close_style___NQVEE","save_style":"save_style___kq8NC","edit_title":"edit_title___W3elv","can_select_count":"can_select_count___F11WF"});
|
|
|
|
/***/ }),
|
|
|
|
/***/ 93163:
|
|
/*!***********************************************************************************!*\
|
|
!*** ./src/pages/Classrooms/Lists/Polls/Edit/components/MultipleEditor/index.tsx ***!
|
|
\***********************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var umi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! umi */ 23852);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! antd */ 8591);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! antd */ 43418);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 6848);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 95237);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 43604);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! antd */ 24905);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! antd */ 78673);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! antd */ 20008);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! antd */ 57809);
|
|
/* harmony import */ var _service_polls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/service/polls */ 74051);
|
|
/* harmony import */ var _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../editor.less?modules */ 23960);
|
|
/* harmony import */ var _components_ui_customization__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/ui-customization */ 20473);
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __objRest = (source, exclude) => {
|
|
var target = {};
|
|
for (var prop in source)
|
|
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
target[prop] = source[prop];
|
|
if (source != null && __getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(source)) {
|
|
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
target[prop] = source[prop];
|
|
}
|
|
return target;
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const 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"
|
|
];
|
|
const SingleEditor = (_a, ref) => {
|
|
var _b = _a, {
|
|
problemset,
|
|
globalSetting,
|
|
loading,
|
|
dispatch,
|
|
onRef = () => {
|
|
},
|
|
editData,
|
|
editKey,
|
|
callback,
|
|
polls_status,
|
|
isadd
|
|
} = _b, props = __objRest(_b, [
|
|
"problemset",
|
|
"globalSetting",
|
|
"loading",
|
|
"dispatch",
|
|
"onRef",
|
|
"editData",
|
|
"editKey",
|
|
"callback",
|
|
"polls_status",
|
|
"isadd"
|
|
]);
|
|
const [questionChoiceList, setQuestionChoiceList] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]);
|
|
const [title, setTitle] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
const [isNecessary, setIsNecessary] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true);
|
|
const [other, setOther] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
|
|
const params = (0,umi__WEBPACK_IMPORTED_MODULE_1__.useParams)();
|
|
const [maxChoices, setMaxChoices] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
const [minChoices, setMinChoices] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
if (!((_a2 = editData == null ? void 0 : editData.question) == null ? void 0 : _a2.question_title)) {
|
|
setQuestionChoiceList([{ disabled: false, value: "" }, { disabled: false, value: "" }, { disabled: false, value: "" }, { disabled: false, value: "" }]);
|
|
setIsNecessary(true);
|
|
setTitle("");
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setMaxChoices((_b2 = editData == null ? void 0 : editData.question) == null ? void 0 : _b2.max_choices);
|
|
setMinChoices((_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.min_choices);
|
|
setTitle((_d = editData == null ? void 0 : editData.question) == null ? void 0 : _d.question_title);
|
|
setIsNecessary(!!((_e = editData == null ? void 0 : editData.question) == null ? void 0 : _e.is_necessary));
|
|
if (!isadd) {
|
|
setQuestionChoiceList((_f = editData == null ? void 0 : editData.question) == null ? void 0 : _f.answers.map((item) => {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === "\u5176\u5B83" ? true : false,
|
|
placeholder: item.answer_text === "\u5176\u5B83" ? "\u65E0\u6CD5\u7F16\u8F91\uFF0C\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u7F16\u8F91" : ""
|
|
};
|
|
}));
|
|
} else {
|
|
setQuestionChoiceList((_g = editData == null ? void 0 : editData.question) == null ? void 0 : _g.question_answers.map((item) => {
|
|
return {
|
|
value: item,
|
|
disabled: item === "\u5176\u5B83" ? true : false,
|
|
placeholder: item === "\u5176\u5B83" ? "\u65E0\u6CD5\u7F16\u8F91\uFF0C\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u7F16\u8F91" : ""
|
|
};
|
|
}));
|
|
}
|
|
setOther(!!((_i = (_h = editData == null ? void 0 : editData.question) == null ? void 0 : _h.answers) == null ? void 0 : _i.find((item) => item.answer_text === "\u5176\u5B83")));
|
|
}, [editData]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(ref, () => ({
|
|
onSave
|
|
}));
|
|
const onSave = (status) => __async(void 0, null, function* () {
|
|
var _a2;
|
|
if (maxChoices && !minChoices || !maxChoices && minChoices) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info('\u53EF\u9009\uFF1A\u6700\u5C0F\u548C\u6700\u5927\u9650\u5236\u987B\u540C\u65F6\u4E3A\u6570\u503C\u6216\u8005\u201C--"');
|
|
return;
|
|
}
|
|
if (minChoices > maxChoices) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info("\u53EF\u9009\u7684\u6700\u5927\u9650\u5236\u4E0D\u80FD\u5C0F\u4E8E\u6700\u5C0F\u9650\u5236");
|
|
return;
|
|
}
|
|
if (!title) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE");
|
|
return false;
|
|
}
|
|
if (other) {
|
|
questionChoiceList[questionChoiceList.length - 1].value = "\u5176\u5B83";
|
|
}
|
|
const findNotAnswerIndex = questionChoiceList.findIndex((item) => !item.value);
|
|
if (findNotAnswerIndex > -1) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info(`\u8BF7\u5148\u8F93\u5165 ${tagList[findNotAnswerIndex]} \u9009\u9879\u7684\u5185\u5BB9`);
|
|
return false;
|
|
}
|
|
let res;
|
|
const 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((item) => item.value)
|
|
};
|
|
if ((_a2 = editData.question) == null ? void 0 : _a2.id) {
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .editPollsQuestion */ .IU)(__spreadValues({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
} else {
|
|
if (isadd) {
|
|
if (status) {
|
|
callback("isadd", bodyData, 2);
|
|
} else {
|
|
callback("isadd", bodyData);
|
|
}
|
|
} else {
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .addExerciseQuestion */ .MK)(__spreadValues({
|
|
"pollsId": params.categoryId
|
|
}, bodyData));
|
|
}
|
|
}
|
|
if (!isadd) {
|
|
if (res.status === 0) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.success("\u4FDD\u5B58\u6210\u529F");
|
|
callback("edit", -1);
|
|
const res2 = yield dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map((item) => {
|
|
return { answer_text: item };
|
|
});
|
|
const d = [...res2.poll_questions];
|
|
d.splice(editData == null ? void 0 : editData.key, 0, { insert_id: editData == null ? void 0 : editData.insert_id, question: __spreadValues({}, bodyData) }).slice();
|
|
callback("addContinue", [...d]);
|
|
callback("edit", editData.key + 1);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const actionArr = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u4E0A\u79FB", icon: "iconfont c-green ml30 icon-xiangshangyi current font20", id: "up" },
|
|
{ name: "\u4E0B\u79FB", icon: "iconfont c-green ml30 icon-xiangxiayi current font20", id: "down" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionArradd = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionClick = (item) => __async(void 0, null, function* () {
|
|
var _b2, _c;
|
|
switch (item.id) {
|
|
case "del":
|
|
let _a2;
|
|
antd__WEBPACK_IMPORTED_MODULE_6__["default"].confirm({
|
|
centered: true,
|
|
okText: "\u786E\u5B9A",
|
|
cancelText: "\u53D6\u6D88",
|
|
title: "\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",
|
|
onOk() {
|
|
return __async(this, null, function* () {
|
|
var _a3;
|
|
if (isadd) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .deletePollsQuestion */ .jy)({
|
|
pollsId: (_a3 = editData == null ? void 0 : editData.question) == null ? void 0 : _a3.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
break;
|
|
case "up":
|
|
case "down":
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .pollsMoveUpDown */ .wh)({
|
|
pollsId: (_b2 = editData == null ? void 0 : editData.question) == null ? void 0 : _b2.id,
|
|
opr: item.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
break;
|
|
case "edit":
|
|
callback("edit", editData.key);
|
|
break;
|
|
case "add":
|
|
callback("add", { type: 2, key: editData.key, insert_id: (_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.id, question_type: 2 });
|
|
break;
|
|
}
|
|
});
|
|
const showList = () => {
|
|
var _a2, _b2, _c, _d, _e;
|
|
let hasChooseChoices = (_a2 = editData.question) == null ? void 0 : _a2.min_choices;
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, editData.question.is_necessary > 0 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { color: "red", fontSize: "14px" } }, "*"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#3061D0" } }, "\u3010\u591A\u9009\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.can_select_count }, !hasChooseChoices ? null : `\u53EF\u9009${(_b2 = editData == null ? void 0 : editData.question) == null ? void 0 : _b2.min_choices}-${(_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.max_choices}\u9879`), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.edit_title }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { marginRight: "10px" } }, "\u7B2C", editData.key, "\u9898"), editData.question.question_title)), !isadd && 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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
}), isadd && actionArradd.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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
})), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, !isadd && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, (_d = editData == null ? void 0 : editData.question.answers) == null ? void 0 : _d.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_10__["default"], { key: index, disabled: true })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "c-black font14 ml10" }, item.answer_text)));
|
|
})), isadd && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, (_e = editData == null ? void 0 : editData.question.question_answers) == null ? void 0 : _e.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_10__["default"], { key: index, disabled: true })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "c-black font14 ml10" }, item)));
|
|
}))));
|
|
};
|
|
const showEdit = () => {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16 c-blue" }, "\u3010\u591A\u9009\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#666666" } }, "\u5FC5\u7B54"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, { checked: isNecessary ? true : false, onChange: (e) => setIsNecessary(e), className: "ml10" }))), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.titleWrap }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "\u6807\u9898")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.editorWrap, flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_12__["default"], { style: { width: "1000px", height: "40px" }, value: title, placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE", onChange: (e) => setTitle(e.target.value) })))), questionChoiceList.map((item, index) => {
|
|
var _a2;
|
|
let lastIndex = questionChoiceList.length - 1;
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, key: index, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, other && index === lastIndex ? "\u5176\u5B83" : "\u9009\u9879")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.editorWrap, flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_12__["default"], { style: { width: "1000px", height: "40px" }, placeholder: (_a2 = item.placeholder) != null ? _a2 : "", value: other && index === lastIndex ? "" : questionChoiceList[index]["value"], disabled: item.disabled ? true : false, onChange: (e) => {
|
|
questionChoiceList[index]["value"] = e.target.value;
|
|
setQuestionChoiceList([...questionChoiceList]);
|
|
} })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, index > 1 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { title: "\u5220\u9664" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
"i",
|
|
{
|
|
className: `${_editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.deleteIcon} iconfont icon-yichu1`,
|
|
onClick: () => {
|
|
setQuestionChoiceList(questionChoiceList.filter((_, key) => key !== index));
|
|
if (item.disabled)
|
|
setOther(false);
|
|
}
|
|
}
|
|
))));
|
|
}), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.titleWrap }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "\u53EF\u9009")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"], { value: minChoices || "", style: { width: 183, height: "40px" }, onChange: (value) => setMinChoices(value) }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"].Option, { value: "" }, "--"), questionChoiceList.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"].Option, { value: String(index + 1) }, index + 1);
|
|
})), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "ml10 mr10" }, "-"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"], { style: { width: 183, height: "40px" }, value: maxChoices || "", onChange: (value) => setMaxChoices(value) }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"].Option, { value: "" }, "--"), questionChoiceList.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_13__["default"].Option, { value: String(index + 1) }, index + 1);
|
|
})), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { title: "\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" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("i", { className: "iconfont icon-xiaowenhao1 font14", style: { marginLeft: "10px", color: "#3061D0", cursor: "pointer" } }))))), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { style: { display: "flex", width: "1000px", margin: "20px 0 0 40px" } }, polls_status === 1 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
_components_ui_customization__WEBPACK_IMPORTED_MODULE_4__/* .CustomButton */ .op,
|
|
{
|
|
style: { height: "38px" },
|
|
onClick: () => {
|
|
let rs = [...questionChoiceList];
|
|
if (other) {
|
|
rs.splice(rs.length - 1, 0, { value: "" });
|
|
} else {
|
|
rs.push({ value: "" });
|
|
}
|
|
setQuestionChoiceList([...rs]);
|
|
}
|
|
},
|
|
"\u65B0\u589E\u9009\u9879"
|
|
), !other && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
_components_ui_customization__WEBPACK_IMPORTED_MODULE_4__/* .CustomButton */ .op,
|
|
{
|
|
style: { height: "38px", marginLeft: "20px" },
|
|
onClick: () => {
|
|
setQuestionChoiceList([...questionChoiceList, { disabled: true, value: "", placeholder: "\u65E0\u6CD5\u7F16\u8F91\uFF01\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u5F55\u5165" }]);
|
|
setOther(true);
|
|
}
|
|
},
|
|
"\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
)), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.close_style, onClick: () => {
|
|
var _a2;
|
|
if ((_a2 = editData.question) == null ? void 0 : _a2.id) {
|
|
const findNotAnswerIndex = questionChoiceList.findIndex((item) => !item.value);
|
|
if (isadd) {
|
|
if (findNotAnswerIndex > -1) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("del", editData.key);
|
|
}
|
|
} }, "\u53D6\u6D88"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.save_style, onClick: () => onSave() }, "\u4FDD\u5B58")));
|
|
};
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.wrap }, editKey !== editData.key && showList(), editKey === editData.key && showEdit());
|
|
};
|
|
/* harmony default export */ __webpack_exports__.Z = ((0,umi__WEBPACK_IMPORTED_MODULE_1__.connect)(
|
|
({
|
|
problemset,
|
|
loading,
|
|
globalSetting
|
|
}) => ({
|
|
problemset,
|
|
globalSetting,
|
|
loading: loading.effects
|
|
}),
|
|
null,
|
|
null,
|
|
{ forwardRef: true }
|
|
)((0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(SingleEditor)));
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 34885:
|
|
/*!*********************************************************************************!*\
|
|
!*** ./src/pages/Classrooms/Lists/Polls/Edit/components/SingleEditor/index.tsx ***!
|
|
\*********************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var umi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! umi */ 23852);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! antd */ 8591);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! antd */ 43418);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 6848);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 95237);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 43604);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! antd */ 5112);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! antd */ 78673);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! antd */ 20008);
|
|
/* harmony import */ var _service_polls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/service/polls */ 74051);
|
|
/* harmony import */ var _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../editor.less?modules */ 23960);
|
|
/* harmony import */ var _components_ui_customization__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/ui-customization */ 20473);
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __objRest = (source, exclude) => {
|
|
var target = {};
|
|
for (var prop in source)
|
|
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
target[prop] = source[prop];
|
|
if (source != null && __getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(source)) {
|
|
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
target[prop] = source[prop];
|
|
}
|
|
return target;
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const 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"
|
|
];
|
|
const SingleEditor = (_a, ref) => {
|
|
var _b = _a, {
|
|
problemset,
|
|
globalSetting,
|
|
loading,
|
|
dispatch,
|
|
onRef = () => {
|
|
},
|
|
editData,
|
|
editKey,
|
|
callback,
|
|
isadd,
|
|
polls_status
|
|
} = _b, props = __objRest(_b, [
|
|
"problemset",
|
|
"globalSetting",
|
|
"loading",
|
|
"dispatch",
|
|
"onRef",
|
|
"editData",
|
|
"editKey",
|
|
"callback",
|
|
"isadd",
|
|
"polls_status"
|
|
]);
|
|
const [questionChoiceList, setQuestionChoiceList] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)([]);
|
|
const [title, setTitle] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
const [isNecessary, setIsNecessary] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true);
|
|
const [other, setOther] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
|
|
const params = (0,umi__WEBPACK_IMPORTED_MODULE_1__.useParams)();
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
if (!((_a2 = editData == null ? void 0 : editData.question) == null ? void 0 : _a2.question_title)) {
|
|
setQuestionChoiceList([{ disabled: false, value: "" }, { disabled: false, value: "" }, { disabled: false, value: "" }, { disabled: false, value: "" }]);
|
|
setIsNecessary(true);
|
|
setTitle("");
|
|
setOther(false);
|
|
return;
|
|
}
|
|
setTitle((_b2 = editData == null ? void 0 : editData.question) == null ? void 0 : _b2.question_title);
|
|
setIsNecessary(!!((_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.is_necessary));
|
|
if (!isadd) {
|
|
setQuestionChoiceList((_d = editData == null ? void 0 : editData.question) == null ? void 0 : _d.answers.map((item) => {
|
|
return {
|
|
value: item.answer_text,
|
|
disabled: item.answer_text === "\u5176\u5B83" ? true : false,
|
|
placeholder: item.answer_text === "\u5176\u5B83" ? "\u65E0\u6CD5\u7F16\u8F91\uFF0C\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u7F16\u8F91" : ""
|
|
};
|
|
}));
|
|
} else {
|
|
setQuestionChoiceList((_e = editData == null ? void 0 : editData.question) == null ? void 0 : _e.question_answers.map((item) => {
|
|
return {
|
|
value: item,
|
|
disabled: item === "\u5176\u5B83" ? true : false,
|
|
placeholder: item === "\u5176\u5B83" ? "\u65E0\u6CD5\u7F16\u8F91\uFF0C\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u7F16\u8F91" : ""
|
|
};
|
|
}));
|
|
}
|
|
setOther(!!((_g = (_f = editData == null ? void 0 : editData.question) == null ? void 0 : _f.answers) == null ? void 0 : _g.find((item) => item.answer_text === "\u5176\u5B83")));
|
|
}, [editData]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(ref, () => ({
|
|
onSave
|
|
}));
|
|
const onSave = (status) => __async(void 0, null, function* () {
|
|
var _a2;
|
|
if (!title) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE");
|
|
return false;
|
|
}
|
|
if (other) {
|
|
questionChoiceList[questionChoiceList.length - 1].value = "\u5176\u5B83";
|
|
}
|
|
const findNotAnswerIndex = questionChoiceList.findIndex((item) => !item.value);
|
|
if (findNotAnswerIndex > -1) {
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.info(`\u8BF7\u5148\u8F93\u5165 ${tagList[findNotAnswerIndex]} \u9009\u9879\u7684\u5185\u5BB9`);
|
|
return false;
|
|
}
|
|
let res;
|
|
const bodyData = {
|
|
"question_title": title,
|
|
"question_type": 1,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary),
|
|
"question_answers": questionChoiceList.map((item) => item.value)
|
|
};
|
|
if ((_a2 = editData.question) == null ? void 0 : _a2.id) {
|
|
callback("edit", -1);
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .editPollsQuestion */ .IU)(__spreadValues({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
} else {
|
|
if (isadd) {
|
|
if (status) {
|
|
callback("isadd", bodyData, 1);
|
|
} else {
|
|
callback("isadd", bodyData);
|
|
}
|
|
} else {
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .addExerciseQuestion */ .MK)(__spreadValues({
|
|
"pollsId": params.categoryId
|
|
}, bodyData));
|
|
}
|
|
}
|
|
if (isadd) {
|
|
} else {
|
|
if (res.status === 0) {
|
|
callback("edit", -1);
|
|
antd__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .ZP.success("\u4FDD\u5B58\u6210\u529F");
|
|
const res2 = yield dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
if (status) {
|
|
bodyData.answers = bodyData.question_answers.map((item) => {
|
|
return { answer_text: item };
|
|
});
|
|
const d = [...res2.poll_questions];
|
|
d.splice(editData == null ? void 0 : editData.key, 0, { insert_id: editData == null ? void 0 : editData.insert_id, question: __spreadValues({}, bodyData) }).slice();
|
|
callback("addContinue", [...d]);
|
|
callback("edit", editData.key + 1);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const actionArr = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u4E0A\u79FB", icon: "iconfont c-green ml30 icon-xiangshangyi current font20", id: "up" },
|
|
{ name: "\u4E0B\u79FB", icon: "iconfont c-green ml30 icon-xiangxiayi current font20", id: "down" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionArradd = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionClick = (item) => __async(void 0, null, function* () {
|
|
var _b2, _c;
|
|
switch (item.id) {
|
|
case "del":
|
|
let _a2;
|
|
antd__WEBPACK_IMPORTED_MODULE_6__["default"].confirm({
|
|
centered: true,
|
|
okText: "\u786E\u5B9A",
|
|
cancelText: "\u53D6\u6D88",
|
|
title: "\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",
|
|
onOk() {
|
|
return __async(this, null, function* () {
|
|
var _a3;
|
|
if (isadd) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .deletePollsQuestion */ .jy)({
|
|
pollsId: (_a3 = editData == null ? void 0 : editData.question) == null ? void 0 : _a3.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
break;
|
|
case "up":
|
|
case "down":
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .pollsMoveUpDown */ .wh)({
|
|
pollsId: (_b2 = editData == null ? void 0 : editData.question) == null ? void 0 : _b2.id,
|
|
opr: item.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
break;
|
|
case "edit":
|
|
callback("edit", editData.key);
|
|
break;
|
|
case "add":
|
|
callback("add", { type: 1, key: editData.key, insert_id: (_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.id, question_type: 1 });
|
|
break;
|
|
}
|
|
});
|
|
const showList = () => {
|
|
var _a2, _b2;
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, editData.question.is_necessary > 0 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { color: "red", fontSize: "14px" } }, "*"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#3061D0" } }, "\u3010\u5355\u9009\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.edit_title }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { marginRight: "10px" } }, "\u7B2C", editData.key, "\u9898"), editData.question.question_title)), !isadd && 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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
}), isadd && actionArradd.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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
})), !isadd && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, (_a2 = editData == null ? void 0 : editData.question.answers) == null ? void 0 : _a2.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_10__/* ["default"] */ .ZP, { key: index, disabled: true })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "c-black font14" }, item.answer_text)));
|
|
})), isadd && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, (_b2 = editData == null ? void 0 : editData.question.question_answers) == null ? void 0 : _b2.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_10__/* ["default"] */ .ZP, { key: index, disabled: true })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "c-black font14" }, item)));
|
|
})));
|
|
};
|
|
const showEdit = () => {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16 c-blue" }, "\u3010\u5355\u9009\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#666666" } }, "\u5FC5\u7B54"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_11__/* ["default"] */ .Z, { checked: isNecessary ? true : false, onChange: (e) => setIsNecessary(e), className: "ml10" }))), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.titleWrap }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "\u6807\u9898")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.editorWrap }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_12__["default"], { style: { width: "1000px", height: "40px" }, value: title, placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE", onChange: (e) => setTitle(e.target.value) })))), questionChoiceList.map((item, index) => {
|
|
var _a2;
|
|
let lastIndex = questionChoiceList.length - 1;
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, key: index, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, other && index === lastIndex ? "\u5176\u5B83" : "\u9009\u9879")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.editorWrap, flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_12__["default"], { style: { width: "1000px", height: "40px" }, placeholder: (_a2 = item.placeholder) != null ? _a2 : "", value: other && index === lastIndex ? "" : questionChoiceList[index]["value"], disabled: item.disabled ? true : false, onChange: (e) => {
|
|
questionChoiceList[index]["value"] = e.target.value;
|
|
setQuestionChoiceList([...questionChoiceList]);
|
|
} })), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .Z, null, index > 1 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { title: "\u5220\u9664" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
"i",
|
|
{
|
|
className: `${_editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.deleteIcon} iconfont icon-yichu1`,
|
|
onClick: () => {
|
|
setQuestionChoiceList(questionChoiceList.filter((_, key) => key !== index));
|
|
if (item.disabled)
|
|
setOther(false);
|
|
}
|
|
}
|
|
))));
|
|
}), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { style: { display: "flex", width: "1000px", margin: "20px 0 0 40px" } }, polls_status === 1 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
_components_ui_customization__WEBPACK_IMPORTED_MODULE_4__/* .CustomButton */ .op,
|
|
{
|
|
style: { height: "38px" },
|
|
onClick: () => {
|
|
let rs = [...questionChoiceList];
|
|
if (other) {
|
|
rs.splice(rs.length - 1, 0, { value: "" });
|
|
} else {
|
|
rs.push({ value: "" });
|
|
}
|
|
setQuestionChoiceList([...rs]);
|
|
}
|
|
},
|
|
"\u65B0\u589E\u9009\u9879"
|
|
), !other && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(
|
|
_components_ui_customization__WEBPACK_IMPORTED_MODULE_4__/* .CustomButton */ .op,
|
|
{
|
|
style: { height: "38px", marginLeft: "20px" },
|
|
onClick: () => {
|
|
setQuestionChoiceList([...questionChoiceList, { disabled: true, value: "", placeholder: "\u65E0\u6CD5\u7F16\u8F91\uFF01\u5C06\u7531\u53C2\u4E0E\u7B54\u9898\u7684\u4EBA\u624B\u52A8\u5F55\u5165" }]);
|
|
setOther(true);
|
|
}
|
|
},
|
|
"\u65B0\u589E\u5176\u5B83\u9009\u9879"
|
|
)), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.close_style, onClick: () => {
|
|
var _a2;
|
|
if ((_a2 = editData.question) == null ? void 0 : _a2.id) {
|
|
const findNotAnswerIndex = questionChoiceList.findIndex((item) => !item.value);
|
|
if (isadd) {
|
|
if (findNotAnswerIndex > -1) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("del", editData.key);
|
|
}
|
|
} }, "\u53D6\u6D88"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.save_style, onClick: () => onSave() }, "\u4FDD\u5B58")));
|
|
};
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.wrap }, editKey !== editData.key && showList(), editKey === editData.key && showEdit());
|
|
};
|
|
/* harmony default export */ __webpack_exports__.Z = ((0,umi__WEBPACK_IMPORTED_MODULE_1__.connect)(
|
|
({
|
|
problemset,
|
|
loading,
|
|
globalSetting
|
|
}) => ({
|
|
problemset,
|
|
globalSetting,
|
|
loading: loading.effects
|
|
}),
|
|
null,
|
|
null,
|
|
{ forwardRef: true }
|
|
)((0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(SingleEditor)));
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 67494:
|
|
/*!*************************************************************************************!*\
|
|
!*** ./src/pages/Classrooms/Lists/Polls/Edit/components/SubjectiveEditor/index.tsx ***!
|
|
\*************************************************************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ 59301);
|
|
/* harmony import */ var umi__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! umi */ 23852);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! antd */ 8591);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! antd */ 43418);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! antd */ 6848);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! antd */ 95237);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! antd */ 43604);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! antd */ 24905);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! antd */ 78673);
|
|
/* harmony import */ var antd__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! antd */ 20008);
|
|
/* harmony import */ var _service_polls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @/service/polls */ 74051);
|
|
/* harmony import */ var _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../editor.less?modules */ 23960);
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a, b) => {
|
|
for (var prop in b || (b = {}))
|
|
if (__hasOwnProp.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b)) {
|
|
if (__propIsEnum.call(b, prop))
|
|
__defNormalProp(a, prop, b[prop]);
|
|
}
|
|
return a;
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const SingleEditor = ({
|
|
problemset,
|
|
globalSetting,
|
|
loading,
|
|
dispatch,
|
|
onRef = () => {
|
|
},
|
|
editData,
|
|
polls_status,
|
|
editKey,
|
|
isadd,
|
|
callback
|
|
}, ref) => {
|
|
const [title, setTitle] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)("");
|
|
const [isNecessary, setIsNecessary] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(true);
|
|
const params = (0,umi__WEBPACK_IMPORTED_MODULE_1__.useParams)();
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
|
var _a, _b, _c;
|
|
if (!((_a = editData == null ? void 0 : editData.question) == null ? void 0 : _a.question_title)) {
|
|
setIsNecessary(true);
|
|
setTitle("");
|
|
return;
|
|
}
|
|
setTitle((_b = editData == null ? void 0 : editData.question) == null ? void 0 : _b.question_title);
|
|
setIsNecessary(!!((_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.is_necessary));
|
|
}, [editData]);
|
|
(0,react__WEBPACK_IMPORTED_MODULE_0__.useImperativeHandle)(ref, () => ({
|
|
onSave
|
|
}));
|
|
const onSave = (status) => __async(void 0, null, function* () {
|
|
var _a;
|
|
if (!title) {
|
|
antd__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP.info("\u8BF7\u60A8\u8F93\u5165\u9898\u76EE");
|
|
return false;
|
|
}
|
|
let res;
|
|
const bodyData = {
|
|
"question_title": title,
|
|
"question_type": 3,
|
|
"insert_id": editData.insert_id,
|
|
"is_necessary": Math.ceil(isNecessary)
|
|
};
|
|
if ((_a = editData.question) == null ? void 0 : _a.id) {
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .editPollsQuestion */ .IU)(__spreadValues({
|
|
"pollsId": editData.question.id
|
|
}, bodyData));
|
|
} else {
|
|
if (isadd) {
|
|
if (status) {
|
|
callback("isadd", bodyData, 3);
|
|
} else {
|
|
callback("isadd", bodyData);
|
|
}
|
|
} else {
|
|
res = yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .addExerciseQuestion */ .MK)(__spreadValues({
|
|
"pollsId": params.categoryId
|
|
}, bodyData));
|
|
}
|
|
}
|
|
if (!isadd) {
|
|
if (res.status === 0) {
|
|
antd__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .ZP.success("\u4FDD\u5B58\u6210\u529F");
|
|
callback("edit", -1);
|
|
const res2 = yield dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
if (status) {
|
|
const d = [...res2.poll_questions];
|
|
d.splice(editData == null ? void 0 : editData.key, 0, { insert_id: editData == null ? void 0 : editData.insert_id, question: __spreadValues({}, bodyData) }).slice();
|
|
callback("addContinue", [...d]);
|
|
callback("edit", editData.key + 1);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const actionArr = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u4E0A\u79FB", icon: "iconfont c-green ml30 icon-xiangshangyi current font20", id: "up" },
|
|
{ name: "\u4E0B\u79FB", icon: "iconfont c-green ml30 icon-xiangxiayi current font20", id: "down" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionArradd = [
|
|
{ name: "\u5220\u9664", icon: "iconfont c-red ml30 icon-shanchutimu current font20", id: "del" },
|
|
{ name: "\u590D\u5236\u9898\u578B", icon: "iconfont c-green ml30 icon-tianjia2 current font20", id: "add" },
|
|
{ name: "\u7F16\u8F91", icon: "iconfont c-green ml30 icon-bianji-moren current font20", id: "edit" }
|
|
];
|
|
const actionClick = (item) => __async(void 0, null, function* () {
|
|
var _b, _c;
|
|
switch (item.id) {
|
|
case "del":
|
|
let _a;
|
|
antd__WEBPACK_IMPORTED_MODULE_5__["default"].confirm({
|
|
centered: true,
|
|
okText: "\u786E\u5B9A",
|
|
cancelText: "\u53D6\u6D88",
|
|
title: "\u786E\u8BA4\u8981\u5220\u9664\u8FD9\u4E2A\u95EE\u9898\u5417\uFF1F",
|
|
onOk() {
|
|
return __async(this, null, function* () {
|
|
var _a2;
|
|
if (isadd) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .deletePollsQuestion */ .jy)({
|
|
pollsId: (_a2 = editData == null ? void 0 : editData.question) == null ? void 0 : _a2.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
break;
|
|
case "up":
|
|
case "down":
|
|
yield (0,_service_polls__WEBPACK_IMPORTED_MODULE_2__/* .pollsMoveUpDown */ .wh)({
|
|
pollsId: (_b = editData == null ? void 0 : editData.question) == null ? void 0 : _b.id,
|
|
opr: item.id
|
|
});
|
|
dispatch({
|
|
type: "polls/editPolls",
|
|
payload: __spreadValues({}, params)
|
|
});
|
|
break;
|
|
case "edit":
|
|
callback("edit", editData.key);
|
|
break;
|
|
case "add":
|
|
callback("add", { type: 3, key: editData.key, insert_id: (_c = editData == null ? void 0 : editData.question) == null ? void 0 : _c.id, question_type: 3 });
|
|
break;
|
|
}
|
|
});
|
|
const showList = () => {
|
|
var _a;
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, editData.question.is_necessary > 0 && /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { color: "red", fontSize: "14px" } }, "*"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#3061D0" } }, "\u3010\u95EE\u7B54\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.edit_title }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { style: { marginRight: "10px" } }, "\u7B2C", editData.key, "\u9898"), editData.question.question_title)), !isadd && 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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
}), isadd && actionArradd.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__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Z, { key: index, placement: "bottom", title: item.name }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { onClick: () => actionClick(item), className: item.icon }));
|
|
})), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionChoices }, (_a = editData == null ? void 0 : editData.question.answers) == null ? void 0 : _a.map(function(item, index) {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_9__["default"], { key: index, disabled: true }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "c-black font14" }, item.answer_text))));
|
|
})));
|
|
};
|
|
const showEdit = () => {
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("aside", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.questionType }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16 c-blue" }, "\u3010\u95EE\u7B54\u3011"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", { className: "font16", style: { color: "#666666" } }, "\u5FC5\u7B54"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_10__/* ["default"] */ .Z, { checked: isNecessary ? true : false, onChange: (e) => setIsNecessary(e), className: "ml10" }))), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("p", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.titleWrap }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.choiceWrap, gutter: [12, 12] }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, null, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("span", null, "\u6807\u9898")), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Z, { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.editorWrap, flex: "1" }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement(antd__WEBPACK_IMPORTED_MODULE_11__["default"], { style: { width: "1000px", height: "40px" }, value: title, placeholder: "\u8BF7\u8F93\u5165\u9898\u76EE", onChange: (e) => setTitle(e.target.value) })))), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { style: { display: "flex", width: "1000px", margin: "20px 0 0 40px" } }, /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.close_style, onClick: () => {
|
|
var _a;
|
|
if ((_a = editData.question) == null ? void 0 : _a.id) {
|
|
if (isadd) {
|
|
if (!title) {
|
|
callback("del", editData.key);
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("edit", -1);
|
|
}
|
|
} else {
|
|
callback("del", editData.key);
|
|
}
|
|
} }, "\u53D6\u6D88"), /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("div", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.save_style, onClick: () => onSave() }, "\u4FDD\u5B58")));
|
|
};
|
|
return /* @__PURE__ */ react__WEBPACK_IMPORTED_MODULE_0__.createElement("section", { className: _editor_less_modules__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Z.wrap }, editKey !== editData.key && showList(), editKey === editData.key && showEdit());
|
|
};
|
|
/* harmony default export */ __webpack_exports__.Z = ((0,umi__WEBPACK_IMPORTED_MODULE_1__.connect)(
|
|
({
|
|
problemset,
|
|
loading,
|
|
globalSetting
|
|
}) => ({
|
|
problemset,
|
|
globalSetting,
|
|
loading: loading.effects
|
|
}),
|
|
null,
|
|
null,
|
|
{ forwardRef: true }
|
|
)((0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(SingleEditor)));
|
|
|
|
|
|
/***/ })
|
|
|
|
}]); |