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

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 +17 -6
  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 +15 -4
  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
@@ -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,147 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __read = (this && this.__read) || function (o, n) {
50
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
51
+ if (!m) return o;
52
+ var i = m.call(o), r, ar = [], e;
53
+ try {
54
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
+ }
56
+ catch (error) { e = { error: error }; }
57
+ finally {
58
+ try {
59
+ if (r && !r.done && (m = i["return"])) m.call(i);
60
+ }
61
+ finally { if (e) throw e.error; }
62
+ }
63
+ return ar;
64
+ };
65
+ Object.defineProperty(exports, "__esModule", { value: true });
66
+ var jsx_runtime_1 = require("react/jsx-runtime");
67
+ var ai_ability_1 = require("../../../../services/ai-ability");
68
+ var ahooks_1 = require("ahooks");
69
+ var fbm_ui_1 = require("fbm-ui");
70
+ var mui_1 = require("fbm-ui/lib/mui");
71
+ var react_1 = require("react");
72
+ var AbilityFormItem = function (_a) {
73
+ 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;
74
+ var _f = __read((0, react_1.useState)(items.length ? items.join('\n') : ''), 2), content = _f[0], setContent = _f[1];
75
+ var _g = __read((0, react_1.useState)(mode), 2), internalMode = _g[0], setMode = _g[1];
76
+ var _h = (0, ahooks_1.useRequest)(ai_ability_1.GetAiDefine, {
77
+ manual: true,
78
+ onSuccess: function (_a) {
79
+ var data = _a.data;
80
+ var _b = data.list, list = _b === void 0 ? [] : _b;
81
+ var defineRes = list[0].items;
82
+ setContent(defineRes.length ? defineRes.join('\n') : '');
83
+ nameTextField.setError();
84
+ },
85
+ onError: function (err) {
86
+ console.log(err);
87
+ nameTextField.setError("".concat(title, "\u751F\u6210\u8D85\u65F6"));
88
+ },
89
+ }), PostAiDefine = _h.run, loading = _h.loading;
90
+ var handleChange = (0, react_1.useCallback)(function (e) {
91
+ var value = e.target.value;
92
+ setContent(value);
93
+ }, []);
94
+ var handleReplace = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
95
+ return __generator(this, function (_a) {
96
+ PostAiDefine({
97
+ queryType: type,
98
+ collectionName: name,
99
+ });
100
+ return [2 /*return*/];
101
+ });
102
+ }); }, [type, name, PostAiDefine]);
103
+ var nameTextField = (0, fbm_ui_1.useTextField)({
104
+ value: content,
105
+ name: type,
106
+ required: true,
107
+ disabled: loading,
108
+ rules: [
109
+ {
110
+ required: true,
111
+ message: "".concat(title, "\u4E0D\u80FD\u4E3A\u7A7A"),
112
+ },
113
+ ],
114
+ onChange: handleChange,
115
+ max: maxTextLength,
116
+ rows: 3,
117
+ multiline: true,
118
+ sx: {
119
+ marginBottom: '43px',
120
+ },
121
+ });
122
+ (0, react_1.useEffect)(function () {
123
+ setMode(mode);
124
+ }, [mode]);
125
+ (0, react_1.useEffect)(function () {
126
+ var resItems = [4, 5].includes(type) ? content.split('\n') : [content];
127
+ onChange === null || onChange === void 0 ? void 0 : onChange({
128
+ name: title,
129
+ type: type,
130
+ items: content ? resItems : [],
131
+ });
132
+ // nameTextField.handleValidate();
133
+ // eslint-disable-next-line react-hooks/exhaustive-deps
134
+ }, [content, title, type]);
135
+ (0, react_1.useEffect)(function () {
136
+ // don't excute when edit detail
137
+ if (token)
138
+ return;
139
+ PostAiDefine({
140
+ queryType: type,
141
+ collectionName: name,
142
+ });
143
+ // eslint-disable-next-line react-hooks/exhaustive-deps
144
+ }, [type, name, token]);
145
+ return ((0, jsx_runtime_1.jsxs)(mui_1.Stack, { children: [(0, jsx_runtime_1.jsxs)(mui_1.Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && ((0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: (0, jsx_runtime_1.jsx)(fbm_ui_1.RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ width: 1 }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.TextField, __assign({}, nameTextField)) }))), internalMode === 'show' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
146
+ };
147
+ exports.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;
@@ -68,10 +68,11 @@ var ai_ability_1 = require("../../../../services/ai-ability");
68
68
  var ahooks_1 = require("ahooks");
69
69
  var fbm_ui_1 = require("fbm-ui");
70
70
  var mui_1 = require("fbm-ui/lib/mui");
71
+ var formik_1 = require("formik");
71
72
  var react_1 = require("react");
72
73
  var AbilityFormItem = function (_a) {
73
- 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;
74
- var _f = __read((0, react_1.useState)(items.length ? items.join('\n') : ''), 2), content = _f[0], setContent = _f[1];
74
+ 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;
75
+ var _f = __read((0, react_1.useState)(''), 2), content = _f[0], setContent = _f[1];
75
76
  var _g = __read((0, react_1.useState)(mode), 2), internalMode = _g[0], setMode = _g[1];
76
77
  var _h = (0, ahooks_1.useRequest)(ai_ability_1.GetAiDefine, {
77
78
  manual: true,
@@ -127,7 +128,7 @@ var AbilityFormItem = function (_a) {
127
128
  onChange === null || onChange === void 0 ? void 0 : onChange({
128
129
  name: title,
129
130
  type: type,
130
- items: content ? resItems : [],
131
+ items: content ? resItems : [''],
131
132
  });
132
133
  // nameTextField.handleValidate();
133
134
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -142,6 +143,16 @@ var AbilityFormItem = function (_a) {
142
143
  });
143
144
  // eslint-disable-next-line react-hooks/exhaustive-deps
144
145
  }, [type, name, token]);
145
- return ((0, jsx_runtime_1.jsxs)(mui_1.Stack, { children: [(0, jsx_runtime_1.jsxs)(mui_1.Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && ((0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: (0, jsx_runtime_1.jsx)(fbm_ui_1.RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ width: 1 }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.TextField, __assign({}, nameTextField)) }))), internalMode === 'show' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
146
+ (0, react_1.useEffect)(function () {
147
+ var _a;
148
+ if ((_a = item === null || item === void 0 ? void 0 : item.items) === null || _a === void 0 ? void 0 : _a.length) {
149
+ setContent(item.items.join('\n'));
150
+ }
151
+ }, [item]);
152
+ return ((0, jsx_runtime_1.jsxs)(mui_1.Stack, { children: [(0, jsx_runtime_1.jsxs)(mui_1.Stack, __assign({ style: { marginBottom: '18px' }, direction: "row", alignItems: "center", justifyContent: "space-between" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", fontWeight: "medium" }, { children: title })), canReplace && ((0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: loading, onClick: handleReplace, variant: "outlined", color: "inherit", size: "small", icon: (0, jsx_runtime_1.jsx)(fbm_ui_1.RefreshIcon, {}) }, { children: loading ? '生成中' : '换一换' })))] })), internalMode === 'edit' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ width: 1 }, { children: (0, jsx_runtime_1.jsx)(formik_1.FieldArray, __assign({ name: "workPlaceItems[".concat(index, "].items") }, { children: function (_a) {
153
+ var _b, _c;
154
+ var pushItem = _a.push, removeItem = _a.remove;
155
+ return ((0, jsx_runtime_1.jsxs)(mui_1.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 ((0, jsx_runtime_1.jsx)(mui_1.Stack, __assign({ direction: "row", alignItems: "center", spacing: 1 }, { children: [4, 5].includes(item === null || item === void 0 ? void 0 : item.type) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.FormItem, { name: "workPlaceItems[".concat(index, "].items[").concat(itemIndex, "]"), sx: { width: 512 }, max: maxTextLength }), (0, jsx_runtime_1.jsx)(fbm_ui_1.IconButton, __assign({ onClick: function () { return removeItem(itemIndex); }, sx: { alignSelf: 'flex-start', mt: 0.5 } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.CloseIcon, {}) }))] })) : ((0, jsx_runtime_1.jsx)(fbm_ui_1.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) && ((0, jsx_runtime_1.jsx)(fbm_ui_1.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: (0, jsx_runtime_1.jsx)(fbm_ui_1.AddIcon, {}), type: "button", onClick: function () { return pushItem(''); }, variant: "outlined", color: "inherit" }, { children: { 5: '评分关键点', 4: '面试题目' }[item.type] })))] })));
156
+ } })) }))), internalMode === 'show' && ((0, jsx_runtime_1.jsx)(mui_1.Box, __assign({ style: { marginTop: '-8px', marginBottom: '32px' } }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body2", sx: { whiteSpace: 'pre-wrap', color: 'RGBA(0, 0, 0, 0.56)' } }, { children: content })) })))] }));
146
157
  };
147
158
  exports.default = AbilityFormItem;
@@ -10,6 +10,29 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
13
36
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
37
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
38
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -67,146 +90,176 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
67
90
  };
68
91
  Object.defineProperty(exports, "__esModule", { value: true });
69
92
  var jsx_runtime_1 = require("react/jsx-runtime");
93
+ var Yup = __importStar(require("yup"));
70
94
  var AbilityFormItem_1 = __importDefault(require("../AbilityFormItem"));
71
95
  var ai_ability_1 = require("../../../../services/ai-ability");
72
96
  var ahooks_1 = require("ahooks");
73
97
  var fbm_ui_1 = require("fbm-ui");
98
+ var mui_1 = require("fbm-ui/lib/mui");
99
+ var formik_1 = require("formik");
74
100
  var react_1 = require("react");
101
+ var validationSchema = Yup.object().shape({
102
+ name: Yup.string().required('能力名称不能为空'),
103
+ workPlaceItems: Yup.array().of(Yup.object().shape({
104
+ name: Yup.string().required(''),
105
+ items: Yup.array().of(Yup.string().required('')),
106
+ })),
107
+ });
108
+ var InitialValues = {
109
+ workPlaceItems: [
110
+ {
111
+ name: '能力定义',
112
+ type: 1,
113
+ items: [],
114
+ maxTextLength: 100,
115
+ },
116
+ {
117
+ name: '优次表现-优秀表现',
118
+ type: 2,
119
+ items: [],
120
+ maxTextLength: 100,
121
+ },
122
+ {
123
+ name: '优次表现-较差表现',
124
+ type: 3,
125
+ items: [],
126
+ maxTextLength: 100,
127
+ },
128
+ {
129
+ name: '考察建议-评分关键点',
130
+ type: 5,
131
+ items: [],
132
+ maxTextLength: 300,
133
+ },
134
+ {
135
+ name: '考察建议-面试题目',
136
+ type: 4,
137
+ items: [],
138
+ maxTextLength: 300,
139
+ },
140
+ ],
141
+ };
75
142
  var AddAbility = function (props) {
76
- 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;
77
- var _c = __read((0, react_1.useState)(''), 2), value = _c[0], setValue = _c[1];
78
- var _d = __read((0, react_1.useState)(1), 2), step = _d[0], setStep = _d[1];
79
- // const [stepLoading, setStepLoading] = useState<boolean>(false);
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: 4,
103
- items: [],
104
- maxTextLength: 300,
105
- },
106
- {
107
- name: '考察建议-评分关键点',
108
- type: 5,
109
- items: [],
110
- maxTextLength: 300,
111
- },
112
- ],
113
- };
114
- var _e = __read((0, react_1.useState)(InitialValues.workPlaceItems), 2), workPlaceItems = _e[0], setWorkPlaceItems = _e[1];
115
- var _f = (0, ahooks_1.useRequest)(ai_ability_1.PostQuestionCollectionUpsert, {
143
+ 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;
144
+ var _b = __read((0, react_1.useState)(1), 2), step = _b[0], setStep = _b[1];
145
+ var _c = (0, ahooks_1.useRequest)(ai_ability_1.PostQuestionCollectionUpsert, {
116
146
  manual: true,
117
147
  onSuccess: function () {
118
148
  fbm_ui_1.Message.success('新增能力成功');
119
149
  onClose();
120
150
  onSuccess();
121
151
  },
122
- }), run = _f.run, loading = _f.loading;
123
- var _g = (0, ahooks_1.useRequest)(ai_ability_1.CheckDuplicateCollection, {
152
+ }), run = _c.run, loading = _c.loading;
153
+ var formik = (0, fbm_ui_1.useForm)({
154
+ initialValues: { name: '', workPlaceItems: InitialValues.workPlaceItems },
155
+ validationSchema: validationSchema,
156
+ validateOnChange: true,
157
+ onSubmit: function (values) {
158
+ // 处理表单提交逻辑
159
+ console.log(values);
160
+ console.log(values);
161
+ var avocadoConfig = window['AvocadoVideoInterviewConfig'];
162
+ run({
163
+ name: values.name,
164
+ tag: values.name,
165
+ token: token,
166
+ type: type,
167
+ workPlaceItems: values.workPlaceItems,
168
+ mateData: {
169
+ account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
170
+ enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
171
+ },
172
+ });
173
+ },
174
+ });
175
+ var _d = (0, ahooks_1.useRequest)(ai_ability_1.CheckDuplicateCollection, {
124
176
  manual: true,
125
177
  onSuccess: function (_a) {
126
178
  var data = _a.data;
127
179
  if (data.isDuplicate) {
128
- nameTextField.setError('能力名称不能重复');
180
+ formik.setFieldError('name', '能力名称不能重复');
129
181
  }
130
182
  else {
183
+ formik.setFieldError('name', '');
131
184
  setStep(2);
132
185
  }
133
186
  },
134
- }), checkDuplicateCollection = _g.run, stepLoading = _g.loading;
135
- var nameTextField = (0, fbm_ui_1.useTextField)({
136
- value: value,
137
- label: '能力名称',
138
- required: true,
139
- rules: [
140
- {
141
- required: true,
142
- message: '能力名称不能为空',
143
- },
144
- ],
145
- onChange: function (e) { return setValue(e.target.value); },
146
- max: ablilityNameLength,
147
- sx: {
148
- height: '48px',
149
- width: '100%',
150
- marginTop: '16px',
151
- },
152
- });
187
+ }), checkDuplicateCollection = _d.run, stepLoading = _d.loading;
188
+ // const nameTextField = useTextField({
189
+ // value,
190
+ // label: '能力名称',
191
+ // required: true,
192
+ // rules: [
193
+ // {
194
+ // required: true,
195
+ // message: '能力名称不能为空',
196
+ // },
197
+ // ],
198
+ // onChange: (e: { target: { value: string } }) => setValue(e.target.value),
199
+ // max: ablilityNameLength,
200
+ // sx: {
201
+ // height: '48px',
202
+ // width: '100%',
203
+ // marginTop: '16px',
204
+ // },
205
+ // });
153
206
  var handleStep = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
154
- var error;
155
207
  return __generator(this, function (_a) {
156
208
  switch (_a.label) {
157
- case 0: return [4 /*yield*/, nameTextField.handleValidate()];
209
+ case 0: return [4 /*yield*/, formik.setFieldTouched('name', true, true)];
158
210
  case 1:
159
- error = _a.sent();
160
- if (!error) {
161
- checkDuplicateCollection({ collectionName: value });
211
+ _a.sent();
212
+ if (formik.values.name !== '') {
213
+ checkDuplicateCollection({ collectionName: formik.values.name });
162
214
  }
163
215
  return [2 /*return*/];
164
216
  }
165
217
  });
166
- }); }, [nameTextField, value, checkDuplicateCollection]);
218
+ }); }, [checkDuplicateCollection, formik]);
167
219
  var handleValue = (0, react_1.useCallback)(function (v) {
220
+ var workPlaceItems = formik.values.workPlaceItems;
168
221
  var index = workPlaceItems.findIndex(function (ele) { return ele.type === v.type; });
169
222
  workPlaceItems.splice(index, 1, v);
170
223
  var list = workPlaceItems;
171
- // console.log(v, list);
172
- setWorkPlaceItems(list);
173
- }, [workPlaceItems]);
174
- var handleOk = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
175
- var error, avocadoConfig;
176
- return __generator(this, function (_a) {
177
- error = workPlaceItems.some(function (v) { return v.items.length === 0; });
178
- if (!error) {
179
- avocadoConfig = window['AvocadoVideoInterviewConfig'];
180
- run({
181
- name: value,
182
- tag: value,
183
- token: token,
184
- type: type,
185
- workPlaceItems: workPlaceItems,
186
- mateData: {
187
- account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
188
- enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
189
- },
190
- });
191
- }
192
- return [2 /*return*/];
193
- });
194
- }); }, [run, type, token, value, workPlaceItems]);
224
+ formik.setFieldValue('workPlaceItems', list);
225
+ }, [formik]);
226
+ // const handleOk = useCallback(async () => {
227
+ // // console.log(workPlaceItems);
228
+ // const error = workPlaceItems.some(v => v.items.length === 0);
229
+ // if (!error) {
230
+ // const avocadoConfig = window['AvocadoVideoInterviewConfig'];
231
+ // run({
232
+ // name: value,
233
+ // tag: value,
234
+ // token,
235
+ // type,
236
+ // workPlaceItems,
237
+ // mateData: {
238
+ // account: avocadoConfig?.account,
239
+ // enterpriseId: avocadoConfig?.enterpriseId,
240
+ // },
241
+ // });
242
+ // }
243
+ // }, [run, type, token, value, workPlaceItems]);
195
244
  var footer = (0, react_1.useCallback)(function () {
196
- return step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "flex-end", padding: "12px 16px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: stepLoading, onClick: handleStep }, { children: "\u4E0B\u4E00\u6B65" }))] }))) : ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "space-between", padding: "12px 16px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(1); } }, { children: "\u4E0A\u4E00\u6B65" })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: loading, onClick: handleOk }, { children: "\u65B0\u589E" }))] }))] })));
197
- }, [step, loading, stepLoading, handleStep, setStep, handleOk, onClose]);
198
- (0, react_1.useEffect)(function () {
199
- setValue(name);
200
- }, [name]);
245
+ return step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "flex-end", padding: "12px 16px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: stepLoading, onClick: handleStep }, { children: "\u4E0B\u4E00\u6B65" }))] }))) : ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex", justifyContent: "space-between", padding: "12px 16px" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(1); } }, { children: "\u4E0A\u4E00\u6B65" })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ display: "flex" }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ sx: { mr: 1, fontWeight: 400 }, variant: "text", color: "inherit", onClick: onClose }, { children: "\u53D6\u6D88" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ loading: loading, onClick: formik.submitForm }, { children: "\u65B0\u589E" }))] }))] })));
246
+ }, [step, onClose, stepLoading, handleStep, loading, formik.submitForm]);
247
+ // useEffect(() => {
248
+ // setValue(name);
249
+ // }, [name]);
201
250
  (0, react_1.useEffect)(function () {
202
251
  console.log(InitialValues.workPlaceItems);
203
252
  if (!open) {
204
- setValue('');
253
+ // setValue('');
205
254
  setStep(1);
206
- nameTextField.setError();
255
+ // nameTextField.setError();
207
256
  }
208
257
  // eslint-disable-next-line react-hooks/exhaustive-deps
209
258
  }, [open]);
210
- return ((0, jsx_runtime_1.jsx)(fbm_ui_1.Drawer, __assign({ className: "abilityDrawer", title: '新增能力', open: open, footer: footer, onClose: onClose }, { children: step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.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" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.TextField, __assign({}, nameTextField))] }))) : ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Typography, __assign({ variant: "body2", color: "secondary", mb: 2 }, { children: ["\u6839\u636E\u60A8\u8F93\u5165\u7684\u80FD\u529B\u540D\u79F0\u300C", (0, jsx_runtime_1.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 ((0, jsx_runtime_1.jsx)(AbilityFormItem_1.default, { 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)); })] }))) })));
259
+ return ((0, jsx_runtime_1.jsx)(fbm_ui_1.Drawer, __assign({ className: "abilityDrawer", title: '新增能力', open: open, footer: footer, onClose: onClose }, { children: (0, jsx_runtime_1.jsx)(fbm_ui_1.Form, __assign({}, formik, { children: step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.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" })), (0, jsx_runtime_1.jsx)(fbm_ui_1.FormItem, { name: "name", label: "\u80FD\u529B\u540D\u79F0", sx: { height: '48px', width: '100%', marginTop: '16px' }, max: ablilityNameLength, onKeyDown: function (event) {
260
+ if (event.key === 'Enter') {
261
+ event.preventDefault();
262
+ }
263
+ } })] }))) : ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), (0, jsx_runtime_1.jsxs)(fbm_ui_1.Typography, __assign({ variant: "body2", color: "secondary", mb: 2 }, { children: ["\u6839\u636E\u60A8\u8F93\u5165\u7684\u80FD\u529B\u540D\u79F0\u300C", (0, jsx_runtime_1.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"] })), (0, jsx_runtime_1.jsx)(formik_1.FieldArray, __assign({ name: "workPlaceItems" }, { children: function () { return ((0, jsx_runtime_1.jsx)(mui_1.Stack, { children: formik.values.workPlaceItems.map(function (item, index) { return ((0, jsx_runtime_1.jsx)(mui_1.Stack, { children: (0, jsx_runtime_1.jsx)(AbilityFormItem_1.default, { 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)); }) })); } }))] }))) })) })));
211
264
  };
212
265
  exports.default = AddAbility;