eli-video-interview 1.1.2 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/modules/ai-question/components/QuestionModel/Item.js +2 -4
- package/esm/modules/ai-question/components/QuestionModel/List.js +9 -1
- package/esm/modules/ai-question/components/QuestionModel/interface.d.ts +1 -0
- package/esm/store/ai-question/question-model-store.js +21 -17
- package/lib/modules/ai-question/components/QuestionModel/Item.js +2 -4
- package/lib/modules/ai-question/components/QuestionModel/List.js +9 -1
- package/lib/modules/ai-question/components/QuestionModel/interface.d.ts +1 -0
- package/lib/store/ai-question/question-model-store.js +20 -16
- package/package.json +1 -1
|
@@ -29,10 +29,8 @@ import { useUpdateQuestionStore } from "../../../../store/ai-question/question-u
|
|
|
29
29
|
import { getSecondToTime } from "../../../../utils/utils";
|
|
30
30
|
import { TEST_TYPE_READONLY, DISABLED_REPEAT_TYPE, IS_AI_ANALYSIS } from "../../../../constants/ai-question";
|
|
31
31
|
var QuestionModelListItem = function (props) {
|
|
32
|
-
var index = props.index, steps = props.steps, step = __rest(props, ["index", "steps"]);
|
|
32
|
+
var index = props.index, disabledWeight = props.disabledWeight, steps = props.steps, step = __rest(props, ["index", "disabledWeight", "steps"]);
|
|
33
33
|
var token = step.token, name = step.name, desc = step.desc, duration = step.duration, weight = step.weight, type = step.type, aiShowType = step.aiShowType, answerStatus = step.answerStatus, category = step.category;
|
|
34
|
-
var aiTypeList = steps.filter(function (step) { return IS_AI_ANALYSIS(step); });
|
|
35
|
-
var lastAiTestToken = aiTypeList.length ? aiTypeList[aiTypeList.length - 1].token : '';
|
|
36
34
|
var isAiAnalysis = IS_AI_ANALYSIS(step);
|
|
37
35
|
var _a = useQuestionModelStore(), editModel = _a.editModel, removeModel = _a.removeModel, updateModelWeight = _a.updateModelWeight;
|
|
38
36
|
var updateQuestionState = useUpdateQuestionStore().updateQuestionState;
|
|
@@ -69,6 +67,6 @@ var QuestionModelListItem = function (props) {
|
|
|
69
67
|
console.log(answerStatus);
|
|
70
68
|
editModel(__assign(__assign({}, step), { answerStatus: answerStatus === 2 ? 1 : 2 }), index);
|
|
71
69
|
}, [editModel, answerStatus, step, index]);
|
|
72
|
-
return (_jsxs(Paper, __assign({ variant: "outlined", sx: { display: 'block', mt: 2 } }, { children: [_jsxs(Box, __assign({ display: "flex", borderBottom: "1px solid rgba(0, 0, 0, 0.08)" }, { children: [_jsx(Box, __assign({ width: 40, display: "flex", alignItems: "center", justifyContent: "center", sx: { cursor: 'move' } }, { children: _jsx(DragIndicatorIcon, { className: "dragHandle" }) })), _jsxs(Box, __assign({ flex: "1 0", padding: "16px 0" }, { children: [_jsxs(Box, __assign({ display: "flex", justifyContent: "space-between" }, { children: [_jsxs(Box, __assign({ flex: "1 0", display: "flex", alignItems: "center" }, { children: [_jsx(Typography, __assign({ variant: "subtitle1" }, { children: name })), category === null || category === void 0 ? void 0 : category.map(function (label) { return label && _jsx(Chip, { color: "default", label: label, size: "medium", sx: { ml: 1 } }, label); }), _jsx(Typography, __assign({ sx: { ml: 2 }, variant: "body2", color: "secondary" }, { children: getSecondToTime(Number(duration)) }))] })), _jsxs(Box, __assign({ width: 62, mr: 1, textAlign: "right" }, { children: [!TEST_TYPE_READONLY.includes(type) && (_jsx(IconButton, __assign({ size: "small", onClick: handleEdit }, { children: _jsx(EditIcon, {}) }))), _jsx(IconButton, __assign({ size: "small", onClick: handleRemove }, { children: _jsx(DeleteIcon, {}) }))] }))] })), _jsxs(Box, __assign({ mt: 1, display: "flex", alignItems: "center", justifyContent: "space-between" }, { children: [_jsx(Typography, __assign({ variant: "body2", color: "secondary" }, { children: desc })), !DISABLED_REPEAT_TYPE.includes(type) && (_jsx(FormGroup, __assign({ sx: { flexShrink: 0, ml: 2 } }, { children: _jsx(FormControlLabel, { control: _jsx(Switch, { size: "small", checked: answerStatus === 1 }), label: _jsx(Typography, __assign({ fontSize: 12, lineHeight: 1.5, color: "rgba(0, 0, 0, 0.56)" }, { children: "\u5141\u8BB8\u91CD\u590D\u7B54\u9898" })), onChange: handleAnswerStatus }) })))] }))] }))] })), isAiAnalysis && (_jsxs(Box, __assign({ display: "flex", alignItems: "center", padding: "3px 0 3px 40px" }, { children: [_jsx(Typography, __assign({ variant: "body2" }, { children: "\u6743\u91CD\u5360\u6BD4\uFF1A" })), _jsx(Input, { sx: { width: 82 }, size: "small", value: weight, endAdornment: "%", disabled:
|
|
70
|
+
return (_jsxs(Paper, __assign({ variant: "outlined", sx: { display: 'block', mt: 2 } }, { children: [_jsxs(Box, __assign({ display: "flex", borderBottom: "1px solid rgba(0, 0, 0, 0.08)" }, { children: [_jsx(Box, __assign({ width: 40, display: "flex", alignItems: "center", justifyContent: "center", sx: { cursor: 'move' } }, { children: _jsx(DragIndicatorIcon, { className: "dragHandle" }) })), _jsxs(Box, __assign({ flex: "1 0", padding: "16px 0" }, { children: [_jsxs(Box, __assign({ display: "flex", justifyContent: "space-between" }, { children: [_jsxs(Box, __assign({ flex: "1 0", display: "flex", alignItems: "center" }, { children: [_jsx(Typography, __assign({ variant: "subtitle1" }, { children: name })), category === null || category === void 0 ? void 0 : category.map(function (label) { return label && _jsx(Chip, { color: "default", label: label, size: "medium", sx: { ml: 1 } }, label); }), _jsx(Typography, __assign({ sx: { ml: 2 }, variant: "body2", color: "secondary" }, { children: getSecondToTime(Number(duration)) }))] })), _jsxs(Box, __assign({ width: 62, mr: 1, textAlign: "right" }, { children: [!TEST_TYPE_READONLY.includes(type) && (_jsx(IconButton, __assign({ size: "small", onClick: handleEdit }, { children: _jsx(EditIcon, {}) }))), _jsx(IconButton, __assign({ size: "small", onClick: handleRemove }, { children: _jsx(DeleteIcon, {}) }))] }))] })), _jsxs(Box, __assign({ mt: 1, display: "flex", alignItems: "center", justifyContent: "space-between" }, { children: [_jsx(Typography, __assign({ variant: "body2", color: "secondary" }, { children: desc })), !DISABLED_REPEAT_TYPE.includes(type) && (_jsx(FormGroup, __assign({ sx: { flexShrink: 0, ml: 2 } }, { children: _jsx(FormControlLabel, { control: _jsx(Switch, { size: "small", checked: answerStatus === 1 }), label: _jsx(Typography, __assign({ fontSize: 12, lineHeight: 1.5, color: "rgba(0, 0, 0, 0.56)" }, { children: "\u5141\u8BB8\u91CD\u590D\u7B54\u9898" })), onChange: handleAnswerStatus }) })))] }))] }))] })), isAiAnalysis && (_jsxs(Box, __assign({ display: "flex", alignItems: "center", padding: "3px 0 3px 40px" }, { children: [_jsx(Typography, __assign({ variant: "body2" }, { children: "\u6743\u91CD\u5360\u6BD4\uFF1A" })), _jsx(Input, { sx: { width: 82 }, size: "small", value: weight, endAdornment: "%", disabled: disabledWeight, onChange: handleWeightChange, onBlur: handleWeightBlur })] })))] })));
|
|
73
71
|
};
|
|
74
72
|
export default memo(QuestionModelListItem);
|
|
@@ -15,12 +15,18 @@ import { Box, Empty } from 'fbm-ui';
|
|
|
15
15
|
import Sortable from 'sortablejs';
|
|
16
16
|
import { arrayMoveImmutable } from 'array-move';
|
|
17
17
|
import { useQuestionModelStore } from "../../../../store/ai-question/question-model-store";
|
|
18
|
+
import { IS_AI_ANALYSIS } from "../../../../constants/ai-question";
|
|
18
19
|
import QuestionModelListItem from './Item';
|
|
19
20
|
var QuestionModelList = function () {
|
|
20
21
|
var ref = useRef();
|
|
21
22
|
var sortable = useRef();
|
|
22
23
|
var _a = useQuestionModelStore(), questionModelData = _a.questionModelData, updateModel = _a.updateModel;
|
|
23
24
|
var _b = (questionModelData || {}).steps, steps = _b === void 0 ? [] : _b;
|
|
25
|
+
var lastAiTestIndex = 0;
|
|
26
|
+
steps.forEach(function (step, i) {
|
|
27
|
+
if (IS_AI_ANALYSIS(step))
|
|
28
|
+
lastAiTestIndex = i;
|
|
29
|
+
});
|
|
24
30
|
useEffect(function () {
|
|
25
31
|
if (steps) {
|
|
26
32
|
sortable.current && sortable.current.destroy();
|
|
@@ -34,6 +40,8 @@ var QuestionModelList = function () {
|
|
|
34
40
|
});
|
|
35
41
|
}
|
|
36
42
|
}, [questionModelData, updateModel, steps]);
|
|
37
|
-
return (_jsx(Box, __assign({ width: "100%", sx: steps.length > 0 ? {} : { height: 'calc(100% - 100px)', display: 'flex', alignItems: 'center', justifyContent: 'center' }, ref: ref }, { children: steps.length > 0 ? (steps.map(function (item, index) {
|
|
43
|
+
return (_jsx(Box, __assign({ width: "100%", sx: steps.length > 0 ? {} : { height: 'calc(100% - 100px)', display: 'flex', alignItems: 'center', justifyContent: 'center' }, ref: ref }, { children: steps.length > 0 ? (steps.map(function (item, index) {
|
|
44
|
+
return (_jsx(QuestionModelListItem, __assign({ steps: steps, index: index, disabledWeight: index === lastAiTestIndex }, item), item.uniqueId || item.token));
|
|
45
|
+
})) : (_jsx(Empty, { desc: "\u6682\u65E0\u6570\u636E" })) })));
|
|
38
46
|
};
|
|
39
47
|
export default QuestionModelList;
|
|
@@ -14,7 +14,7 @@ import { useState, useCallback } from 'react';
|
|
|
14
14
|
import { createGlobalStore } from 'hox';
|
|
15
15
|
import update from 'immutability-helper';
|
|
16
16
|
import { IS_AI_ANALYSIS } from "../../constants/ai-question";
|
|
17
|
-
import { formatNumberDecimal, computeDecimalValue, uniqueId
|
|
17
|
+
import { formatNumberDecimal, computeDecimalValue, uniqueId } from "../../utils/utils";
|
|
18
18
|
export var useQuestionModelStore = (_a = createGlobalStore(function () {
|
|
19
19
|
var _a = useState(), questionModelData = _a[0], updateModel = _a[1];
|
|
20
20
|
var _b = (questionModelData || {}).steps, steps = _b === void 0 ? [] : _b;
|
|
@@ -23,9 +23,16 @@ export var useQuestionModelStore = (_a = createGlobalStore(function () {
|
|
|
23
23
|
* @param steps 模型数据
|
|
24
24
|
*/
|
|
25
25
|
var computeWeight = useCallback(function (steps) {
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var
|
|
26
|
+
var lastAiTestIndex = 0;
|
|
27
|
+
// AI评分题
|
|
28
|
+
var aiTypeList = steps.filter(function (step, index) {
|
|
29
|
+
if (IS_AI_ANALYSIS(step)) {
|
|
30
|
+
lastAiTestIndex = index;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
});
|
|
35
|
+
var aiTypeListLength = aiTypeList.length;
|
|
29
36
|
var weightList = aiTypeList.filter(function (_a) {
|
|
30
37
|
var isNotCompute = _a.isNotCompute;
|
|
31
38
|
return !isNotCompute;
|
|
@@ -34,25 +41,22 @@ export var useQuestionModelStore = (_a = createGlobalStore(function () {
|
|
|
34
41
|
return Math.floor(Number(weight));
|
|
35
42
|
});
|
|
36
43
|
var weightsLen = Array.from(new Set(weightList)).length; // 权重值分组数量
|
|
37
|
-
var lastAiTestToken = aiTypeList.length ? aiTypeList[aiTypeList.length - 1].token : '';
|
|
38
44
|
var beforeTotalWeight = aiTypeList
|
|
39
|
-
.map(function (_a) {
|
|
40
|
-
var
|
|
41
|
-
return (
|
|
45
|
+
.map(function (_a, index) {
|
|
46
|
+
var weight = _a.weight;
|
|
47
|
+
return (index !== aiTypeListLength - 1 ? Number(weight) : 0);
|
|
42
48
|
})
|
|
43
49
|
.reduce(function (pv, i) { return pv + i; }, 0);
|
|
44
50
|
var totalDuration = 0;
|
|
45
|
-
var getWeight = function (_a) {
|
|
46
|
-
var
|
|
51
|
+
var getWeight = function (_a, i) {
|
|
52
|
+
var weight = _a.weight;
|
|
47
53
|
if (weightsLen <= 1) {
|
|
48
|
-
var averageWeight = 100 /
|
|
49
|
-
var disableWeight = 100 - Math.floor(averageWeight * (
|
|
50
|
-
return
|
|
51
|
-
? computeDecimalValue(disableWeight.toString())
|
|
52
|
-
: computeDecimalValue(averageWeight.toString());
|
|
54
|
+
var averageWeight = 100 / aiTypeListLength;
|
|
55
|
+
var disableWeight = 100 - Math.floor(averageWeight * (aiTypeListLength - 1) * 100) / 100;
|
|
56
|
+
return i === lastAiTestIndex ? computeDecimalValue(disableWeight.toString()) : computeDecimalValue(averageWeight.toString());
|
|
53
57
|
}
|
|
54
58
|
else {
|
|
55
|
-
return
|
|
59
|
+
return i !== lastAiTestIndex ? weight : computeDecimalValue((100 - beforeTotalWeight).toString());
|
|
56
60
|
}
|
|
57
61
|
};
|
|
58
62
|
var $splice = steps.map(function (step, i) {
|
|
@@ -61,7 +65,7 @@ export var useQuestionModelStore = (_a = createGlobalStore(function () {
|
|
|
61
65
|
return [
|
|
62
66
|
i,
|
|
63
67
|
1,
|
|
64
|
-
__assign(__assign({}, step), { weight: IS_AI_ANALYSIS(step) ? getWeight(step) : 0 }),
|
|
68
|
+
__assign(__assign({}, step), { weight: IS_AI_ANALYSIS(step) ? getWeight(step, i) : 0 }),
|
|
65
69
|
];
|
|
66
70
|
});
|
|
67
71
|
updateModel(__assign(__assign({}, questionModelData), { duration: totalDuration, steps: update(steps, { $splice: $splice }) }));
|
|
@@ -31,10 +31,8 @@ var question_update_store_1 = require("../../../../store/ai-question/question-up
|
|
|
31
31
|
var utils_1 = require("../../../../utils/utils");
|
|
32
32
|
var ai_question_1 = require("../../../../constants/ai-question");
|
|
33
33
|
var QuestionModelListItem = function (props) {
|
|
34
|
-
var index = props.index, steps = props.steps, step = __rest(props, ["index", "steps"]);
|
|
34
|
+
var index = props.index, disabledWeight = props.disabledWeight, steps = props.steps, step = __rest(props, ["index", "disabledWeight", "steps"]);
|
|
35
35
|
var token = step.token, name = step.name, desc = step.desc, duration = step.duration, weight = step.weight, type = step.type, aiShowType = step.aiShowType, answerStatus = step.answerStatus, category = step.category;
|
|
36
|
-
var aiTypeList = steps.filter(function (step) { return (0, ai_question_1.IS_AI_ANALYSIS)(step); });
|
|
37
|
-
var lastAiTestToken = aiTypeList.length ? aiTypeList[aiTypeList.length - 1].token : '';
|
|
38
36
|
var isAiAnalysis = (0, ai_question_1.IS_AI_ANALYSIS)(step);
|
|
39
37
|
var _a = (0, question_model_store_1.useQuestionModelStore)(), editModel = _a.editModel, removeModel = _a.removeModel, updateModelWeight = _a.updateModelWeight;
|
|
40
38
|
var updateQuestionState = (0, question_update_store_1.useUpdateQuestionStore)().updateQuestionState;
|
|
@@ -71,6 +69,6 @@ var QuestionModelListItem = function (props) {
|
|
|
71
69
|
console.log(answerStatus);
|
|
72
70
|
editModel(__assign(__assign({}, step), { answerStatus: answerStatus === 2 ? 1 : 2 }), index);
|
|
73
71
|
}, [editModel, answerStatus, step, index]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Paper, __assign({ variant: "outlined", sx: { display: 'block', mt: 2 } }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", borderBottom: "1px solid rgba(0, 0, 0, 0.08)" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ width: 40, display: "flex", alignItems: "center", justifyContent: "center", sx: { cursor: 'move' } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.DragIndicatorIcon, { className: "dragHandle" }) })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ flex: "1 0", padding: "16px 0" }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ flex: "1 0", display: "flex", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "subtitle1" }, { children: name })), category === null || category === void 0 ? void 0 : category.map(function (label) { return label && (0, jsx_runtime_1.jsx)(fbm_ui_1.Chip, { color: "default", label: label, size: "medium", sx: { ml: 1 } }, label); }), (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ sx: { ml: 2 }, variant: "body2", color: "secondary" }, { children: (0, utils_1.getSecondToTime)(Number(duration)) }))] })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ width: 62, mr: 1, textAlign: "right" }, { children: [!ai_question_1.TEST_TYPE_READONLY.includes(type) && ((0, jsx_runtime_1.jsx)(fbm_ui_1.IconButton, __assign({ size: "small", onClick: handleEdit }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.EditIcon, {}) }))), (0, jsx_runtime_1.jsx)(fbm_ui_1.IconButton, __assign({ size: "small", onClick: handleRemove }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.DeleteIcon, {}) }))] }))] })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ mt: 1, display: "flex", alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", color: "secondary" }, { children: desc })), !ai_question_1.DISABLED_REPEAT_TYPE.includes(type) && ((0, jsx_runtime_1.jsx)(material_1.FormGroup, __assign({ sx: { flexShrink: 0, ml: 2 } }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { size: "small", checked: answerStatus === 1 }), label: (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ fontSize: 12, lineHeight: 1.5, color: "rgba(0, 0, 0, 0.56)" }, { children: "\u5141\u8BB8\u91CD\u590D\u7B54\u9898" })), onChange: handleAnswerStatus }) })))] }))] }))] })), isAiAnalysis && ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", alignItems: "center", padding: "3px 0 3px 40px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2" }, { children: "\u6743\u91CD\u5360\u6BD4\uFF1A" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Input, { sx: { width: 82 }, size: "small", value: weight, endAdornment: "%", disabled:
|
|
72
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Paper, __assign({ variant: "outlined", sx: { display: 'block', mt: 2 } }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", borderBottom: "1px solid rgba(0, 0, 0, 0.08)" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ width: 40, display: "flex", alignItems: "center", justifyContent: "center", sx: { cursor: 'move' } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.DragIndicatorIcon, { className: "dragHandle" }) })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ flex: "1 0", padding: "16px 0" }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ flex: "1 0", display: "flex", alignItems: "center" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "subtitle1" }, { children: name })), category === null || category === void 0 ? void 0 : category.map(function (label) { return label && (0, jsx_runtime_1.jsx)(fbm_ui_1.Chip, { color: "default", label: label, size: "medium", sx: { ml: 1 } }, label); }), (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ sx: { ml: 2 }, variant: "body2", color: "secondary" }, { children: (0, utils_1.getSecondToTime)(Number(duration)) }))] })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ width: 62, mr: 1, textAlign: "right" }, { children: [!ai_question_1.TEST_TYPE_READONLY.includes(type) && ((0, jsx_runtime_1.jsx)(fbm_ui_1.IconButton, __assign({ size: "small", onClick: handleEdit }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.EditIcon, {}) }))), (0, jsx_runtime_1.jsx)(fbm_ui_1.IconButton, __assign({ size: "small", onClick: handleRemove }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.DeleteIcon, {}) }))] }))] })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ mt: 1, display: "flex", alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", color: "secondary" }, { children: desc })), !ai_question_1.DISABLED_REPEAT_TYPE.includes(type) && ((0, jsx_runtime_1.jsx)(material_1.FormGroup, __assign({ sx: { flexShrink: 0, ml: 2 } }, { children: (0, jsx_runtime_1.jsx)(material_1.FormControlLabel, { control: (0, jsx_runtime_1.jsx)(material_1.Switch, { size: "small", checked: answerStatus === 1 }), label: (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ fontSize: 12, lineHeight: 1.5, color: "rgba(0, 0, 0, 0.56)" }, { children: "\u5141\u8BB8\u91CD\u590D\u7B54\u9898" })), onChange: handleAnswerStatus }) })))] }))] }))] })), isAiAnalysis && ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", alignItems: "center", padding: "3px 0 3px 40px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2" }, { children: "\u6743\u91CD\u5360\u6BD4\uFF1A" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Input, { sx: { width: 82 }, size: "small", value: weight, endAdornment: "%", disabled: disabledWeight, onChange: handleWeightChange, onBlur: handleWeightBlur })] })))] })));
|
|
75
73
|
};
|
|
76
74
|
exports.default = (0, react_1.memo)(QuestionModelListItem);
|
|
@@ -20,12 +20,18 @@ var fbm_ui_1 = require("fbm-ui");
|
|
|
20
20
|
var sortablejs_1 = __importDefault(require("sortablejs"));
|
|
21
21
|
var array_move_1 = require("array-move");
|
|
22
22
|
var question_model_store_1 = require("../../../../store/ai-question/question-model-store");
|
|
23
|
+
var ai_question_1 = require("../../../../constants/ai-question");
|
|
23
24
|
var Item_1 = __importDefault(require("./Item"));
|
|
24
25
|
var QuestionModelList = function () {
|
|
25
26
|
var ref = (0, react_1.useRef)();
|
|
26
27
|
var sortable = (0, react_1.useRef)();
|
|
27
28
|
var _a = (0, question_model_store_1.useQuestionModelStore)(), questionModelData = _a.questionModelData, updateModel = _a.updateModel;
|
|
28
29
|
var _b = (questionModelData || {}).steps, steps = _b === void 0 ? [] : _b;
|
|
30
|
+
var lastAiTestIndex = 0;
|
|
31
|
+
steps.forEach(function (step, i) {
|
|
32
|
+
if ((0, ai_question_1.IS_AI_ANALYSIS)(step))
|
|
33
|
+
lastAiTestIndex = i;
|
|
34
|
+
});
|
|
29
35
|
(0, react_1.useEffect)(function () {
|
|
30
36
|
if (steps) {
|
|
31
37
|
sortable.current && sortable.current.destroy();
|
|
@@ -39,6 +45,8 @@ var QuestionModelList = function () {
|
|
|
39
45
|
});
|
|
40
46
|
}
|
|
41
47
|
}, [questionModelData, updateModel, steps]);
|
|
42
|
-
return ((0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ width: "100%", sx: steps.length > 0 ? {} : { height: 'calc(100% - 100px)', display: 'flex', alignItems: 'center', justifyContent: 'center' }, ref: ref }, { children: steps.length > 0 ? (steps.map(function (item, index) {
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ width: "100%", sx: steps.length > 0 ? {} : { height: 'calc(100% - 100px)', display: 'flex', alignItems: 'center', justifyContent: 'center' }, ref: ref }, { children: steps.length > 0 ? (steps.map(function (item, index) {
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(Item_1.default, __assign({ steps: steps, index: index, disabledWeight: index === lastAiTestIndex }, item), item.uniqueId || item.token));
|
|
50
|
+
})) : ((0, jsx_runtime_1.jsx)(fbm_ui_1.Empty, { desc: "\u6682\u65E0\u6570\u636E" })) })));
|
|
43
51
|
};
|
|
44
52
|
exports.default = QuestionModelList;
|
|
@@ -29,9 +29,16 @@ exports.useQuestionModelStore = (_a = (0, hox_1.createGlobalStore)(function () {
|
|
|
29
29
|
* @param steps 模型数据
|
|
30
30
|
*/
|
|
31
31
|
var computeWeight = (0, react_1.useCallback)(function (steps) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
var
|
|
32
|
+
var lastAiTestIndex = 0;
|
|
33
|
+
// AI评分题
|
|
34
|
+
var aiTypeList = steps.filter(function (step, index) {
|
|
35
|
+
if ((0, ai_question_1.IS_AI_ANALYSIS)(step)) {
|
|
36
|
+
lastAiTestIndex = index;
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
});
|
|
41
|
+
var aiTypeListLength = aiTypeList.length;
|
|
35
42
|
var weightList = aiTypeList.filter(function (_a) {
|
|
36
43
|
var isNotCompute = _a.isNotCompute;
|
|
37
44
|
return !isNotCompute;
|
|
@@ -40,25 +47,22 @@ exports.useQuestionModelStore = (_a = (0, hox_1.createGlobalStore)(function () {
|
|
|
40
47
|
return Math.floor(Number(weight));
|
|
41
48
|
});
|
|
42
49
|
var weightsLen = Array.from(new Set(weightList)).length; // 权重值分组数量
|
|
43
|
-
var lastAiTestToken = aiTypeList.length ? aiTypeList[aiTypeList.length - 1].token : '';
|
|
44
50
|
var beforeTotalWeight = aiTypeList
|
|
45
|
-
.map(function (_a) {
|
|
46
|
-
var
|
|
47
|
-
return (
|
|
51
|
+
.map(function (_a, index) {
|
|
52
|
+
var weight = _a.weight;
|
|
53
|
+
return (index !== aiTypeListLength - 1 ? Number(weight) : 0);
|
|
48
54
|
})
|
|
49
55
|
.reduce(function (pv, i) { return pv + i; }, 0);
|
|
50
56
|
var totalDuration = 0;
|
|
51
|
-
var getWeight = function (_a) {
|
|
52
|
-
var
|
|
57
|
+
var getWeight = function (_a, i) {
|
|
58
|
+
var weight = _a.weight;
|
|
53
59
|
if (weightsLen <= 1) {
|
|
54
|
-
var averageWeight = 100 /
|
|
55
|
-
var disableWeight = 100 - Math.floor(averageWeight * (
|
|
56
|
-
return
|
|
57
|
-
? (0, utils_1.computeDecimalValue)(disableWeight.toString())
|
|
58
|
-
: (0, utils_1.computeDecimalValue)(averageWeight.toString());
|
|
60
|
+
var averageWeight = 100 / aiTypeListLength;
|
|
61
|
+
var disableWeight = 100 - Math.floor(averageWeight * (aiTypeListLength - 1) * 100) / 100;
|
|
62
|
+
return i === lastAiTestIndex ? (0, utils_1.computeDecimalValue)(disableWeight.toString()) : (0, utils_1.computeDecimalValue)(averageWeight.toString());
|
|
59
63
|
}
|
|
60
64
|
else {
|
|
61
|
-
return
|
|
65
|
+
return i !== lastAiTestIndex ? weight : (0, utils_1.computeDecimalValue)((100 - beforeTotalWeight).toString());
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
68
|
var $splice = steps.map(function (step, i) {
|
|
@@ -67,7 +71,7 @@ exports.useQuestionModelStore = (_a = (0, hox_1.createGlobalStore)(function () {
|
|
|
67
71
|
return [
|
|
68
72
|
i,
|
|
69
73
|
1,
|
|
70
|
-
__assign(__assign({}, step), { weight: (0, ai_question_1.IS_AI_ANALYSIS)(step) ? getWeight(step) : 0 }),
|
|
74
|
+
__assign(__assign({}, step), { weight: (0, ai_question_1.IS_AI_ANALYSIS)(step) ? getWeight(step, i) : 0 }),
|
|
71
75
|
];
|
|
72
76
|
});
|
|
73
77
|
updateModel(__assign(__assign({}, questionModelData), { duration: totalDuration, steps: (0, immutability_helper_1.default)(steps, { $splice: $splice }) }));
|