eli-video-interview 1.2.41-alpha.2 → 1.2.41-alpha.20

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.
Files changed (85) hide show
  1. package/esm/constants/ai-question.d.ts +3 -0
  2. package/esm/constants/ai-question.js +10 -0
  3. package/esm/constants/ai-report.d.ts +5 -0
  4. package/esm/constants/ai-report.js +5 -0
  5. package/esm/enum/ai-report.d.ts +12 -0
  6. package/esm/enum/ai-report.js +12 -0
  7. package/esm/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.d.ts +14 -0
  8. package/esm/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.js +145 -0
  9. package/esm/modules/ai-ability/components/AbilityFormItem/index.d.ts +2 -0
  10. package/esm/modules/ai-ability/components/AbilityFormItem/index.js +16 -5
  11. package/esm/modules/ai-ability/components/AddAbility/index.js +131 -101
  12. package/esm/modules/ai-ability/components/UpdateAbility/index.js +81 -106
  13. package/esm/modules/ai-question/components/BootVideo/CustomVideos.js +1 -1
  14. package/esm/modules/ai-question/components/BootVideo/UploadPreview.js +9 -1
  15. package/esm/modules/ai-question/components/BootVideo/index.js +16 -7
  16. package/esm/modules/ai-question/components/QuestionModel/Item.js +4 -4
  17. package/esm/modules/ai-question/components/QuestionUpdate/RandomQuestion.js +2 -1
  18. package/esm/modules/ai-question/components/QuestionUpdate/index.js +3 -3
  19. package/esm/modules/ai-report/Root.js +54 -10
  20. package/esm/modules/ai-report/components/AIEvaluate/index.js +1 -1
  21. package/esm/modules/ai-report/components/ScoreReport/Bar.d.ts +4 -1
  22. package/esm/modules/ai-report/components/ScoreReport/Bar.js +12 -10
  23. package/esm/modules/ai-report/components/ScoreReport/Failed.d.ts +1 -1
  24. package/esm/modules/ai-report/components/ScoreReport/Failed.js +18 -5
  25. package/esm/modules/ai-report/components/ScoreReport/RecommendIcon.d.ts +3 -0
  26. package/esm/modules/ai-report/components/ScoreReport/RecommendIcon.js +17 -0
  27. package/esm/modules/ai-report/components/ScoreReport/Score.js +38 -9
  28. package/esm/modules/ai-report/components/ScoreReport/Tips.d.ts +3 -0
  29. package/esm/modules/ai-report/components/ScoreReport/Tips.js +18 -0
  30. package/esm/modules/ai-report/components/ScoreReport/index.js +8 -10
  31. package/esm/modules/ai-report/components/ScoreReport/interface.d.ts +5 -0
  32. package/esm/modules/ai-report/components/ScoreReport/styled.js +2 -4
  33. package/esm/modules/ai-report/components/Suggestion/index.js +2 -2
  34. package/esm/modules/ai-report/components/VideoQuestion/QuestionItem.js +1 -1
  35. package/esm/modules/ai-report/components/VideoQuestion/index.js +2 -2
  36. package/esm/modules/ai-report/components/WorkPlaces/WorkPlace.d.ts +1 -0
  37. package/esm/modules/ai-report/components/WorkPlaces/WorkPlace.js +2 -1
  38. package/esm/modules/ai-report/components/WorkPlaces/index.js +4 -3
  39. package/esm/modules/ai-report/interface.d.ts +2 -0
  40. package/esm/services/ai-report.d.ts +6 -0
  41. package/esm/services/ai-report.js +1 -0
  42. package/esm/store/enterprise/enterprise-store.js +2 -2
  43. package/lib/constants/ai-question.d.ts +3 -0
  44. package/lib/constants/ai-question.js +12 -1
  45. package/lib/constants/ai-report.d.ts +5 -0
  46. package/lib/constants/ai-report.js +6 -1
  47. package/lib/enum/ai-report.d.ts +12 -0
  48. package/lib/enum/ai-report.js +13 -1
  49. package/lib/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.d.ts +14 -0
  50. package/lib/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.js +147 -0
  51. package/lib/modules/ai-ability/components/AbilityFormItem/index.d.ts +2 -0
  52. package/lib/modules/ai-ability/components/AbilityFormItem/index.js +14 -3
  53. package/lib/modules/ai-ability/components/AddAbility/index.js +153 -100
  54. package/lib/modules/ai-ability/components/UpdateAbility/index.js +101 -103
  55. package/lib/modules/ai-question/components/BootVideo/CustomVideos.js +1 -1
  56. package/lib/modules/ai-question/components/BootVideo/UploadPreview.js +9 -1
  57. package/lib/modules/ai-question/components/BootVideo/index.js +16 -7
  58. package/lib/modules/ai-question/components/QuestionModel/Item.js +3 -3
  59. package/lib/modules/ai-question/components/QuestionUpdate/RandomQuestion.js +4 -3
  60. package/lib/modules/ai-question/components/QuestionUpdate/index.js +2 -2
  61. package/lib/modules/ai-report/Root.js +51 -7
  62. package/lib/modules/ai-report/components/AIEvaluate/index.js +1 -1
  63. package/lib/modules/ai-report/components/ScoreReport/Bar.d.ts +4 -1
  64. package/lib/modules/ai-report/components/ScoreReport/Bar.js +11 -9
  65. package/lib/modules/ai-report/components/ScoreReport/Failed.d.ts +1 -1
  66. package/lib/modules/ai-report/components/ScoreReport/Failed.js +19 -6
  67. package/lib/modules/ai-report/components/ScoreReport/RecommendIcon.d.ts +3 -0
  68. package/lib/modules/ai-report/components/ScoreReport/RecommendIcon.js +22 -0
  69. package/lib/modules/ai-report/components/ScoreReport/Score.js +36 -7
  70. package/lib/modules/ai-report/components/ScoreReport/Tips.d.ts +3 -0
  71. package/lib/modules/ai-report/components/ScoreReport/Tips.js +20 -0
  72. package/lib/modules/ai-report/components/ScoreReport/index.js +6 -8
  73. package/lib/modules/ai-report/components/ScoreReport/interface.d.ts +5 -0
  74. package/lib/modules/ai-report/components/ScoreReport/styled.js +2 -4
  75. package/lib/modules/ai-report/components/Suggestion/index.js +1 -1
  76. package/lib/modules/ai-report/components/VideoQuestion/QuestionItem.js +1 -1
  77. package/lib/modules/ai-report/components/VideoQuestion/index.js +1 -1
  78. package/lib/modules/ai-report/components/WorkPlaces/WorkPlace.d.ts +1 -0
  79. package/lib/modules/ai-report/components/WorkPlaces/WorkPlace.js +2 -1
  80. package/lib/modules/ai-report/components/WorkPlaces/index.js +3 -2
  81. package/lib/modules/ai-report/interface.d.ts +2 -0
  82. package/lib/services/ai-report.d.ts +6 -0
  83. package/lib/services/ai-report.js +3 -1
  84. package/lib/store/enterprise/enterprise-store.js +2 -2
  85. package/package.json +5 -3
@@ -1,3 +1,4 @@
1
+ import { InteractionMethod } from '../modules/ai-question/interface';
1
2
  import { QuestionParams } from '@/modules/ai-question/components/QuestionUpdate/interface';
2
3
  import { ADD_QUESTION_TYPE } from '@enum/ai-question';
3
4
  export declare const ADD_QUESTION_TYPE_LIST: {
@@ -45,3 +46,5 @@ export declare const TEST_TYPE_READONLY: number[];
45
46
  export declare const DISABLED_REPEAT_TYPE: number[];
46
47
  export declare const DISABLED_COST_TYPE: number[];
47
48
  export declare const IS_AI_ANALYSIS: (step: Pick<QuestionParams, 'aiType'>) => boolean;
49
+ export declare const IS_AI_FOLLOW_UP: (step: QuestionParams, interaction: InteractionMethod[]) => boolean;
50
+ export declare const MAX_RANDOM_QUESTION_NUM = 50;
@@ -85,3 +85,13 @@ export var DISABLED_REPEAT_TYPE = [2, 4, 7, 8, 9, 11, 12, 16, 17];
85
85
  export var DISABLED_COST_TYPE = [7, 9, 8, 4, 11, 2, 16];
86
86
  // 是否开启AI分析
87
87
  export var IS_AI_ANALYSIS = function (step) { return step.aiType === 2; };
88
+ // 是否可以追问
89
+ export var IS_AI_FOLLOW_UP = function (step, interaction) {
90
+ return step.aiShowType === 1 && (step.broadcastType === 2 || !IS_VIRTUAL_HUMAN(interaction));
91
+ };
92
+ var IS_VIRTUAL_HUMAN = function (interaction) {
93
+ if (interaction.length === 0)
94
+ return false;
95
+ return interaction.some(function (v) { var _a; return v.selected && (v.type === 2 || (v.type === 3 && ((_a = v.detail.interviewerShows) === null || _a === void 0 ? void 0 : _a.some(function (v) { return v.selected && v.humanType === 2; }))) || false); });
96
+ };
97
+ export var MAX_RANDOM_QUESTION_NUM = 50;
@@ -1,5 +1,10 @@
1
1
  export declare const RosePieColors: string[][];
2
2
  export declare const scoreRankIntervalColors: string[];
3
+ export declare const scoreRankIntervalProColors: string[];
4
+ export declare const scoreRankIntervalModeColors: {
5
+ pro: string[];
6
+ standard: string[];
7
+ };
3
8
  export declare const REPORT_MODULE_MAP: {
4
9
  score: {
5
10
  id: string;
@@ -10,6 +10,11 @@ export var RosePieColors = [
10
10
  ['rgba(160, 115, 255, 0.2)', 'rgba(160, 115, 255, 0.4)', 'rgba(160, 115, 255, 0.6)', 'rgba(160, 115, 255, 1)'],
11
11
  ];
12
12
  export var scoreRankIntervalColors = ['#C8E6C9', '#A5D6A7', '#81C784', '#66BB6A', '#4CAF50'];
13
+ export var scoreRankIntervalProColors = ['#F2E8D1', '#e1c492', '#cd9f55', '#AF6805', '#4CAF50'];
14
+ export var scoreRankIntervalModeColors = {
15
+ pro: scoreRankIntervalProColors,
16
+ standard: scoreRankIntervalColors,
17
+ };
13
18
  export var REPORT_MODULE_MAP = {
14
19
  score: {
15
20
  id: 'report-score',
@@ -25,3 +25,15 @@ export declare enum COMPLETED_STATUS {
25
25
  NOT_COMPLETED = 2,
26
26
  COMPLETED = 3
27
27
  }
28
+ export declare const BackgroundImage: {
29
+ pro: string;
30
+ standard: string;
31
+ };
32
+ export declare const Colors: {
33
+ pro: string;
34
+ standard: string;
35
+ };
36
+ export declare const SwitchTitle: {
37
+ standard: string;
38
+ pro: string;
39
+ };
@@ -28,3 +28,15 @@ export var COMPLETED_STATUS;
28
28
  COMPLETED_STATUS[COMPLETED_STATUS["NOT_COMPLETED"] = 2] = "NOT_COMPLETED";
29
29
  COMPLETED_STATUS[COMPLETED_STATUS["COMPLETED"] = 3] = "COMPLETED";
30
30
  })(COMPLETED_STATUS || (COMPLETED_STATUS = {}));
31
+ export var BackgroundImage = {
32
+ pro: 'https://webcdn.fbmms.cn/assets/DPXE/Oj-k12zdt9HuOrcEECDsm',
33
+ standard: 'https://webcdn.fbmms.cn/assets/S3uM/nAU25qJa6bVmZVHpcb11G',
34
+ };
35
+ export var Colors = {
36
+ pro: '#86350F',
37
+ standard: '#4caf50',
38
+ };
39
+ export var SwitchTitle = {
40
+ standard: '升级为专业版',
41
+ pro: '切换为标准版',
42
+ };
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ interface AbilityFormItemProps {
3
+ token?: string;
4
+ title: string;
5
+ name: string;
6
+ type: number;
7
+ items?: string[];
8
+ mode: string;
9
+ canReplace?: boolean;
10
+ maxTextLength?: number;
11
+ onChange?: (v: any) => void;
12
+ }
13
+ declare const AbilityFormItem: React.FC<AbilityFormItemProps>;
14
+ export default AbilityFormItem;
@@ -0,0 +1,145 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __read = (this && this.__read) || function (o, n) {
49
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
50
+ if (!m) return o;
51
+ var i = m.call(o), r, ar = [], e;
52
+ try {
53
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
54
+ }
55
+ catch (error) { e = { error: error }; }
56
+ finally {
57
+ try {
58
+ if (r && !r.done && (m = i["return"])) m.call(i);
59
+ }
60
+ finally { if (e) throw e.error; }
61
+ }
62
+ return ar;
63
+ };
64
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
65
+ import { GetAiDefine } from "../../../../services/ai-ability";
66
+ import { useRequest } from 'ahooks';
67
+ import { Button, RefreshIcon, TextField, Typography, useTextField } from 'fbm-ui';
68
+ import { Box, Stack } from 'fbm-ui/lib/mui';
69
+ import { useCallback, useEffect, useState } from 'react';
70
+ var AbilityFormItem = function (_a) {
71
+ var token = _a.token, title = _a.title, name = _a.name, type = _a.type, _b = _a.items, items = _b === void 0 ? [] : _b, _c = _a.mode, mode = _c === void 0 ? 'show' : _c, _d = _a.canReplace, canReplace = _d === void 0 ? false : _d, _e = _a.maxTextLength, maxTextLength = _e === void 0 ? 100 : _e, onChange = _a.onChange;
72
+ var _f = __read(useState(items.length ? items.join('\n') : ''), 2), content = _f[0], setContent = _f[1];
73
+ var _g = __read(useState(mode), 2), internalMode = _g[0], setMode = _g[1];
74
+ var _h = useRequest(GetAiDefine, {
75
+ manual: true,
76
+ onSuccess: function (_a) {
77
+ var data = _a.data;
78
+ var _b = data.list, list = _b === void 0 ? [] : _b;
79
+ var defineRes = list[0].items;
80
+ setContent(defineRes.length ? defineRes.join('\n') : '');
81
+ nameTextField.setError();
82
+ },
83
+ onError: function (err) {
84
+ console.log(err);
85
+ nameTextField.setError("".concat(title, "\u751F\u6210\u8D85\u65F6"));
86
+ },
87
+ }), PostAiDefine = _h.run, loading = _h.loading;
88
+ var handleChange = useCallback(function (e) {
89
+ var value = e.target.value;
90
+ setContent(value);
91
+ }, []);
92
+ var handleReplace = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
93
+ return __generator(this, function (_a) {
94
+ PostAiDefine({
95
+ queryType: type,
96
+ collectionName: name,
97
+ });
98
+ return [2 /*return*/];
99
+ });
100
+ }); }, [type, name, PostAiDefine]);
101
+ var nameTextField = useTextField({
102
+ value: content,
103
+ name: type,
104
+ required: true,
105
+ disabled: loading,
106
+ rules: [
107
+ {
108
+ required: true,
109
+ message: "".concat(title, "\u4E0D\u80FD\u4E3A\u7A7A"),
110
+ },
111
+ ],
112
+ onChange: handleChange,
113
+ max: maxTextLength,
114
+ rows: 3,
115
+ multiline: true,
116
+ sx: {
117
+ marginBottom: '43px',
118
+ },
119
+ });
120
+ useEffect(function () {
121
+ setMode(mode);
122
+ }, [mode]);
123
+ useEffect(function () {
124
+ var resItems = [4, 5].includes(type) ? content.split('\n') : [content];
125
+ onChange === null || onChange === void 0 ? void 0 : onChange({
126
+ name: title,
127
+ type: type,
128
+ items: content ? resItems : [],
129
+ });
130
+ // nameTextField.handleValidate();
131
+ // eslint-disable-next-line react-hooks/exhaustive-deps
132
+ }, [content, title, type]);
133
+ useEffect(function () {
134
+ // don't excute when edit detail
135
+ if (token)
136
+ return;
137
+ PostAiDefine({
138
+ queryType: type,
139
+ collectionName: name,
140
+ });
141
+ // eslint-disable-next-line react-hooks/exhaustive-deps
142
+ }, [type, name, token]);
143
+ return (_jsxs(Stack, { children: [_jsxs(Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [_jsx(Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && (_jsx(Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: _jsx(RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && (_jsx(Box, __assign({ width: 1 }, { children: _jsx(TextField, __assign({}, nameTextField)) }))), internalMode === 'show' && (_jsx(Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: _jsx(Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
144
+ };
145
+ export default AbilityFormItem;
@@ -8,7 +8,9 @@ interface AbilityFormItemProps {
8
8
  mode: string;
9
9
  canReplace?: boolean;
10
10
  maxTextLength?: number;
11
+ index: number;
11
12
  onChange?: (v: any) => void;
13
+ item: any;
12
14
  }
13
15
  declare const AbilityFormItem: React.FC<AbilityFormItemProps>;
14
16
  export default AbilityFormItem;
@@ -61,15 +61,16 @@ var __read = (this && this.__read) || function (o, n) {
61
61
  }
62
62
  return ar;
63
63
  };
64
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
64
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
65
65
  import { GetAiDefine } from "../../../../services/ai-ability";
66
66
  import { useRequest } from 'ahooks';
67
- import { Button, RefreshIcon, TextField, Typography, useTextField } from 'fbm-ui';
67
+ import { AddIcon, Button, CloseIcon, FormItem, IconButton, RefreshIcon, Typography, useTextField } from 'fbm-ui';
68
68
  import { Box, Stack } from 'fbm-ui/lib/mui';
69
+ import { FieldArray } from 'formik';
69
70
  import { useCallback, useEffect, useState } from 'react';
70
71
  var AbilityFormItem = function (_a) {
71
- var token = _a.token, title = _a.title, name = _a.name, type = _a.type, _b = _a.items, items = _b === void 0 ? [] : _b, _c = _a.mode, mode = _c === void 0 ? 'show' : _c, _d = _a.canReplace, canReplace = _d === void 0 ? false : _d, _e = _a.maxTextLength, maxTextLength = _e === void 0 ? 100 : _e, onChange = _a.onChange;
72
- var _f = __read(useState(items.length ? items.join('\n') : ''), 2), content = _f[0], setContent = _f[1];
72
+ var token = _a.token, title = _a.title, name = _a.name, type = _a.type, index = _a.index, _b = _a.items, items = _b === void 0 ? [] : _b, _c = _a.mode, mode = _c === void 0 ? 'show' : _c, _d = _a.canReplace, canReplace = _d === void 0 ? false : _d, _e = _a.maxTextLength, maxTextLength = _e === void 0 ? 100 : _e, item = _a.item, onChange = _a.onChange;
73
+ var _f = __read(useState(''), 2), content = _f[0], setContent = _f[1];
73
74
  var _g = __read(useState(mode), 2), internalMode = _g[0], setMode = _g[1];
74
75
  var _h = useRequest(GetAiDefine, {
75
76
  manual: true,
@@ -140,6 +141,16 @@ var AbilityFormItem = function (_a) {
140
141
  });
141
142
  // eslint-disable-next-line react-hooks/exhaustive-deps
142
143
  }, [type, name, token]);
143
- return (_jsxs(Stack, { children: [_jsxs(Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [_jsx(Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && (_jsx(Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: _jsx(RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && (_jsx(Box, __assign({ width: 1 }, { children: _jsx(TextField, __assign({}, nameTextField)) }))), internalMode === 'show' && (_jsx(Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: _jsx(Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
144
+ useEffect(function () {
145
+ var _a;
146
+ if ((_a = item === null || item === void 0 ? void 0 : item.items) === null || _a === void 0 ? void 0 : _a.length) {
147
+ setContent(item.items.join('\n'));
148
+ }
149
+ }, [item]);
150
+ return (_jsxs(Stack, { children: [_jsxs(Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [_jsx(Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && (_jsx(Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: _jsx(RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && (_jsx(Box, __assign({ width: 1 }, { children: _jsx(FieldArray, __assign({ name: "workPlaceItems[".concat(index, "].items") }, { children: function (_a) {
151
+ var _b, _c;
152
+ var pushItem = _a.push, removeItem = _a.remove;
153
+ return (_jsxs(Stack, __assign({ mb: 5 }, { children: [(_b = item === null || item === void 0 ? void 0 : item.items) === null || _b === void 0 ? void 0 : _b.map(function (_, itemIndex) { return (_jsx(Stack, __assign({ direction: "row", alignItems: "center", spacing: 1 }, { children: [4, 5].includes(item === null || item === void 0 ? void 0 : item.type) ? (_jsxs(_Fragment, { children: [_jsx(FormItem, { name: "workPlaceItems[".concat(index, "].items[").concat(itemIndex, "]"), sx: { width: 512 }, max: maxTextLength }), _jsx(IconButton, __assign({ onClick: function () { return removeItem(itemIndex); }, sx: { alignSelf: 'flex-start', mt: 0.5 } }, { children: _jsx(CloseIcon, {}) }))] })) : (_jsx(FormItem, { multiline: true, rows: 3, max: maxTextLength, name: "workPlaceItems[".concat(index, "].items[").concat(itemIndex, "]"), sx: { width: '100%' } })) }), itemIndex)); }), [4, 5].includes(item === null || item === void 0 ? void 0 : item.type) && (_jsx(Button, __assign({ sx: { alignSelf: 'flex-start', display: "".concat(item.type === 5 && ((_c = item === null || item === void 0 ? void 0 : item.items) === null || _c === void 0 ? void 0 : _c.length) >= 3 ? 'none' : 'flex') }, startIcon: _jsx(AddIcon, {}), type: "button", onClick: function () { return pushItem(''); }, variant: "outlined", color: "inherit" }, { children: { 5: '评分关键点', 4: '面试题目' }[item.type] })))] })));
154
+ } })) }))), internalMode === 'show' && (_jsx(Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: _jsx(Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
144
155
  };
145
156
  export default AbilityFormItem;
@@ -62,146 +62,176 @@ var __read = (this && this.__read) || function (o, n) {
62
62
  return ar;
63
63
  };
64
64
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
65
+ import * as Yup from 'yup';
65
66
  import AbilityFormItem from '../AbilityFormItem';
66
67
  import { CheckDuplicateCollection, PostQuestionCollectionUpsert } from "../../../../services/ai-ability";
67
68
  import { useRequest } from 'ahooks';
68
- import { Box, Button, Drawer, Message, TextField, Typography, useTextField } from 'fbm-ui';
69
+ import { Box, Button, Drawer, Form, FormItem, Message, Typography, useForm } from 'fbm-ui';
70
+ import { Stack } from 'fbm-ui/lib/mui';
71
+ import { FieldArray } from 'formik';
69
72
  import { useCallback, useEffect, useState } from 'react';
73
+ var validationSchema = Yup.object().shape({
74
+ name: Yup.string().required('能力名称不能为空'),
75
+ workPlaceItems: Yup.array().of(Yup.object().shape({
76
+ name: Yup.string().required(''),
77
+ items: Yup.array().of(Yup.string().required('')),
78
+ })),
79
+ });
80
+ var InitialValues = {
81
+ workPlaceItems: [
82
+ {
83
+ name: '能力定义',
84
+ type: 1,
85
+ items: [],
86
+ maxTextLength: 100,
87
+ },
88
+ {
89
+ name: '优次表现-优秀表现',
90
+ type: 2,
91
+ items: [],
92
+ maxTextLength: 100,
93
+ },
94
+ {
95
+ name: '优次表现-较差表现',
96
+ type: 3,
97
+ items: [],
98
+ maxTextLength: 100,
99
+ },
100
+ {
101
+ name: '考察建议-评分关键点',
102
+ type: 5,
103
+ items: [],
104
+ maxTextLength: 300,
105
+ },
106
+ {
107
+ name: '考察建议-面试题目',
108
+ type: 4,
109
+ items: [],
110
+ maxTextLength: 300,
111
+ },
112
+ ],
113
+ };
70
114
  var AddAbility = function (props) {
71
- var open = props.open, _a = props.name, name = _a === void 0 ? '' : _a, _b = props.type, type = _b === void 0 ? 3 : _b, ablilityNameLength = props.ablilityNameLength, token = props.token, onClose = props.onClose, onSuccess = props.onSuccess;
72
- var _c = __read(useState(''), 2), value = _c[0], setValue = _c[1];
73
- var _d = __read(useState(1), 2), step = _d[0], setStep = _d[1];
74
- // const [stepLoading, setStepLoading] = useState<boolean>(false);
75
- var InitialValues = {
76
- workPlaceItems: [
77
- {
78
- name: '能力定义',
79
- type: 1,
80
- items: [],
81
- maxTextLength: 100,
82
- },
83
- {
84
- name: '优次表现-优秀表现',
85
- type: 2,
86
- items: [],
87
- maxTextLength: 100,
88
- },
89
- {
90
- name: '优次表现-较差表现',
91
- type: 3,
92
- items: [],
93
- maxTextLength: 100,
94
- },
95
- {
96
- name: '考察建议-面试题目',
97
- type: 4,
98
- items: [],
99
- maxTextLength: 300,
100
- },
101
- {
102
- name: '考察建议-评分关键点',
103
- type: 5,
104
- items: [],
105
- maxTextLength: 300,
106
- },
107
- ],
108
- };
109
- var _e = __read(useState(InitialValues.workPlaceItems), 2), workPlaceItems = _e[0], setWorkPlaceItems = _e[1];
110
- var _f = useRequest(PostQuestionCollectionUpsert, {
115
+ var open = props.open, _a = props.type, type = _a === void 0 ? 3 : _a, ablilityNameLength = props.ablilityNameLength, token = props.token, onClose = props.onClose, onSuccess = props.onSuccess;
116
+ var _b = __read(useState(1), 2), step = _b[0], setStep = _b[1];
117
+ var _c = useRequest(PostQuestionCollectionUpsert, {
111
118
  manual: true,
112
119
  onSuccess: function () {
113
120
  Message.success('新增能力成功');
114
121
  onClose();
115
122
  onSuccess();
116
123
  },
117
- }), run = _f.run, loading = _f.loading;
118
- var _g = useRequest(CheckDuplicateCollection, {
124
+ }), run = _c.run, loading = _c.loading;
125
+ var formik = useForm({
126
+ initialValues: { name: '', workPlaceItems: InitialValues.workPlaceItems },
127
+ validationSchema: validationSchema,
128
+ validateOnChange: true,
129
+ onSubmit: function (values) {
130
+ // 处理表单提交逻辑
131
+ console.log(values);
132
+ console.log(values);
133
+ var avocadoConfig = window['AvocadoVideoInterviewConfig'];
134
+ run({
135
+ name: values.name,
136
+ tag: values.name,
137
+ token: token,
138
+ type: type,
139
+ workPlaceItems: values.workPlaceItems,
140
+ mateData: {
141
+ account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
142
+ enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
143
+ },
144
+ });
145
+ },
146
+ });
147
+ var _d = useRequest(CheckDuplicateCollection, {
119
148
  manual: true,
120
149
  onSuccess: function (_a) {
121
150
  var data = _a.data;
122
151
  if (data.isDuplicate) {
123
- nameTextField.setError('能力名称不能重复');
152
+ formik.setFieldError('name', '能力名称不能重复');
124
153
  }
125
154
  else {
155
+ formik.setFieldError('name', '');
126
156
  setStep(2);
127
157
  }
128
158
  },
129
- }), checkDuplicateCollection = _g.run, stepLoading = _g.loading;
130
- var nameTextField = useTextField({
131
- value: value,
132
- label: '能力名称',
133
- required: true,
134
- rules: [
135
- {
136
- required: true,
137
- message: '能力名称不能为空',
138
- },
139
- ],
140
- onChange: function (e) { return setValue(e.target.value); },
141
- max: ablilityNameLength,
142
- sx: {
143
- height: '48px',
144
- width: '100%',
145
- marginTop: '16px',
146
- },
147
- });
159
+ }), checkDuplicateCollection = _d.run, stepLoading = _d.loading;
160
+ // const nameTextField = useTextField({
161
+ // value,
162
+ // label: '能力名称',
163
+ // required: true,
164
+ // rules: [
165
+ // {
166
+ // required: true,
167
+ // message: '能力名称不能为空',
168
+ // },
169
+ // ],
170
+ // onChange: (e: { target: { value: string } }) => setValue(e.target.value),
171
+ // max: ablilityNameLength,
172
+ // sx: {
173
+ // height: '48px',
174
+ // width: '100%',
175
+ // marginTop: '16px',
176
+ // },
177
+ // });
148
178
  var handleStep = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
149
- var error;
150
179
  return __generator(this, function (_a) {
151
180
  switch (_a.label) {
152
- case 0: return [4 /*yield*/, nameTextField.handleValidate()];
181
+ case 0: return [4 /*yield*/, formik.setFieldTouched('name', true, true)];
153
182
  case 1:
154
- error = _a.sent();
155
- if (!error) {
156
- checkDuplicateCollection({ collectionName: value });
183
+ _a.sent();
184
+ if (formik.values.name !== '') {
185
+ checkDuplicateCollection({ collectionName: formik.values.name });
157
186
  }
158
187
  return [2 /*return*/];
159
188
  }
160
189
  });
161
- }); }, [nameTextField, value, checkDuplicateCollection]);
190
+ }); }, [checkDuplicateCollection, formik]);
162
191
  var handleValue = useCallback(function (v) {
192
+ var workPlaceItems = formik.values.workPlaceItems;
163
193
  var index = workPlaceItems.findIndex(function (ele) { return ele.type === v.type; });
164
194
  workPlaceItems.splice(index, 1, v);
165
195
  var list = workPlaceItems;
166
- // console.log(v, list);
167
- setWorkPlaceItems(list);
168
- }, [workPlaceItems]);
169
- var handleOk = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
170
- var error, avocadoConfig;
171
- return __generator(this, function (_a) {
172
- error = workPlaceItems.some(function (v) { return v.items.length === 0; });
173
- if (!error) {
174
- avocadoConfig = window['AvocadoVideoInterviewConfig'];
175
- run({
176
- name: value,
177
- tag: value,
178
- token: token,
179
- type: type,
180
- workPlaceItems: workPlaceItems,
181
- mateData: {
182
- account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
183
- enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
184
- },
185
- });
186
- }
187
- return [2 /*return*/];
188
- });
189
- }); }, [run, type, token, value, workPlaceItems]);
196
+ formik.setFieldValue('workPlaceItems', list);
197
+ }, [formik]);
198
+ // const handleOk = useCallback(async () => {
199
+ // // console.log(workPlaceItems);
200
+ // const error = workPlaceItems.some(v => v.items.length === 0);
201
+ // if (!error) {
202
+ // const avocadoConfig = window['AvocadoVideoInterviewConfig'];
203
+ // run({
204
+ // name: value,
205
+ // tag: value,
206
+ // token,
207
+ // type,
208
+ // workPlaceItems,
209
+ // mateData: {
210
+ // account: avocadoConfig?.account,
211
+ // enterpriseId: avocadoConfig?.enterpriseId,
212
+ // },
213
+ // });
214
+ // }
215
+ // }, [run, type, token, value, workPlaceItems]);
190
216
  var footer = useCallback(function () {
191
- return step === 1 ? (_jsxs(Box, __assign({ display: "flex", justifyContent: "flex-end", padding: "12px 16px" }, { children: [_jsx(Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ loading: stepLoading, onClick: handleStep }, { children: "\u4E0B\u4E00\u6B65" }))] }))) : (_jsxs(Box, __assign({ display: "flex", justifyContent: "space-between", padding: "12px 16px" }, { children: [_jsx(Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(1); } }, { children: "\u4E0A\u4E00\u6B65" })), _jsxs(Box, __assign({ display: "flex" }, { children: [_jsx(Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ loading: loading, onClick: handleOk }, { children: "\u65B0\u589E" }))] }))] })));
192
- }, [step, loading, stepLoading, handleStep, setStep, handleOk, onClose]);
193
- useEffect(function () {
194
- setValue(name);
195
- }, [name]);
217
+ return step === 1 ? (_jsxs(Box, __assign({ display: "flex", justifyContent: "flex-end", padding: "12px 16px" }, { children: [_jsx(Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ loading: stepLoading, onClick: handleStep }, { children: "\u4E0B\u4E00\u6B65" }))] }))) : (_jsxs(Box, __assign({ display: "flex", justifyContent: "space-between", padding: "12px 16px" }, { children: [_jsx(Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(1); } }, { children: "\u4E0A\u4E00\u6B65" })), _jsxs(Box, __assign({ display: "flex" }, { children: [_jsx(Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), _jsx(Button, __assign({ loading: loading, onClick: formik.submitForm }, { children: "\u65B0\u589E" }))] }))] })));
218
+ }, [step, onClose, stepLoading, handleStep, loading, formik.submitForm]);
219
+ // useEffect(() => {
220
+ // setValue(name);
221
+ // }, [name]);
196
222
  useEffect(function () {
197
223
  console.log(InitialValues.workPlaceItems);
198
224
  if (!open) {
199
- setValue('');
225
+ // setValue('');
200
226
  setStep(1);
201
- nameTextField.setError();
227
+ // nameTextField.setError();
202
228
  }
203
229
  // eslint-disable-next-line react-hooks/exhaustive-deps
204
230
  }, [open]);
205
- return (_jsx(Drawer, __assign({ className: "abilityDrawer", title: '新增能力', open: open, footer: footer, onClose: onClose }, { children: step === 1 ? (_jsxs(Box, __assign({ style: { width: '556px' } }, { children: [_jsx(Typography, __assign({ variant: "body2", color: "secondary" }, { children: "\u4F7F\u7528\u901A\u7528\u7684\u80FD\u529B\u540D\u79F0\uFF08\u4F8B\u5982\uFF1A\u9886\u5BFC\u529B\u3001\u5E94\u53D8\u80FD\u529B\u7B49\u5E38\u89C1\u8003\u6838\u9879\uFF09\u547D\u540D\u6709\u52A9\u4E8E\u63D0\u9AD8 AI \u8BC4\u4EF7\u53CA\u8BC4\u5206\u51C6\u786E\u6027\u3002" })), _jsx(TextField, __assign({}, nameTextField))] }))) : (_jsxs(Box, __assign({ style: { width: '556px' } }, { children: [_jsx(Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), _jsxs(Typography, __assign({ variant: "body2", color: "secondary", mb: 2 }, { children: ["\u6839\u636E\u60A8\u8F93\u5165\u7684\u80FD\u529B\u540D\u79F0\u300C", _jsx("span", __assign({ style: { color: '#4CAF50', fontWeight: '500' } }, { children: value })), "\u300D\uFF0C\u5E2E\u60A8\u81EA\u52A8\u751F\u6210\u5173\u4E8E\u8BE5\u80FD\u529B\u7684\u5B9A\u4E49\u5185\u5BB9\u3001\u4F18\u6B21\u8868\u73B0\u4EE5\u53CA\u8003\u5BDF\u5EFA\u8BAE\u5185\u5BB9\uFF0C\u786E\u5B9A\u540E\u5C06\u4F1A\u6309\u7167\u8BE5\u6807\u51C6\u751F\u6210AI\u62A5\u544A\u3002"] })), InitialValues.workPlaceItems.map(function (v) { return (_jsx(AbilityFormItem, { name: value, title: v.name, type: v.type, items: v.items, mode: "edit", maxTextLength: v.type === 4 || v.type === 5 ? 300 : 100, canReplace: true, onChange: handleValue }, v.type)); })] }))) })));
231
+ return (_jsx(Drawer, __assign({ className: "abilityDrawer", title: '新增能力', open: open, footer: footer, onClose: onClose }, { children: _jsx(Form, __assign({}, formik, { children: step === 1 ? (_jsxs(Box, __assign({ style: { width: '556px' } }, { children: [_jsx(Typography, __assign({ variant: "body2", color: "secondary" }, { children: "\u4F7F\u7528\u901A\u7528\u7684\u80FD\u529B\u540D\u79F0\uFF08\u4F8B\u5982\uFF1A\u9886\u5BFC\u529B\u3001\u5E94\u53D8\u80FD\u529B\u7B49\u5E38\u89C1\u8003\u6838\u9879\uFF09\u547D\u540D\u6709\u52A9\u4E8E\u63D0\u9AD8 AI \u8BC4\u4EF7\u53CA\u8BC4\u5206\u51C6\u786E\u6027\u3002" })), _jsx(FormItem, { name: "name", label: "\u80FD\u529B\u540D\u79F0", sx: { height: '48px', width: '100%', marginTop: '16px' }, max: ablilityNameLength, onKeyDown: function (event) {
232
+ if (event.key === 'Enter') {
233
+ event.preventDefault();
234
+ }
235
+ } })] }))) : (_jsxs(Box, __assign({ style: { width: '556px' } }, { children: [_jsx(Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), _jsxs(Typography, __assign({ variant: "body2", color: "secondary", mb: 2 }, { children: ["\u6839\u636E\u60A8\u8F93\u5165\u7684\u80FD\u529B\u540D\u79F0\u300C", _jsx("span", __assign({ style: { color: '#4CAF50', fontWeight: '500' } }, { children: formik.values.name })), "\u300D\uFF0C\u5E2E\u60A8\u81EA\u52A8\u751F\u6210\u5173\u4E8E\u8BE5\u80FD\u529B\u7684\u5B9A\u4E49\u5185\u5BB9\u3001\u4F18\u6B21\u8868\u73B0\u4EE5\u53CA\u8003\u5BDF\u5EFA\u8BAE\u5185\u5BB9\uFF0C\u786E\u5B9A\u540E\u5C06\u4F1A\u6309\u7167\u8BE5\u6807\u51C6\u751F\u6210AI\u62A5\u544A\u3002"] })), _jsx(FieldArray, __assign({ name: "workPlaceItems" }, { children: function () { return (_jsx(Stack, { children: formik.values.workPlaceItems.map(function (item, index) { return (_jsx(Stack, { children: _jsx(AbilityFormItem, { token: token, name: formik.values.name, title: item.name, type: item.type, items: item.items, mode: "edit", index: index, item: item, maxTextLength: item.type === 4 || item.type === 5 ? 300 : 100, canReplace: true, onChange: handleValue }, item.type) }, index)); }) })); } }))] }))) })) })));
206
236
  };
207
237
  export default AddAbility;