eli-video-interview 1.2.41-alpha.11 → 1.2.41-alpha.13

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 (53) hide show
  1. package/esm/constants/ai-report.d.ts +5 -0
  2. package/esm/constants/ai-report.js +5 -0
  3. package/esm/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.d.ts +14 -0
  4. package/esm/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.js +145 -0
  5. package/esm/modules/ai-ability/components/AbilityFormItem/index.d.ts +2 -0
  6. package/esm/modules/ai-ability/components/AbilityFormItem/index.js +16 -5
  7. package/esm/modules/ai-ability/components/AddAbility/index.js +127 -101
  8. package/esm/modules/ai-ability/components/UpdateAbility/index.js +77 -106
  9. package/esm/modules/ai-report/Root.js +54 -10
  10. package/esm/modules/ai-report/components/AIEvaluate/index.js +1 -1
  11. package/esm/modules/ai-report/components/ScoreReport/Bar.d.ts +4 -1
  12. package/esm/modules/ai-report/components/ScoreReport/Bar.js +11 -9
  13. package/esm/modules/ai-report/components/ScoreReport/RecommendIcon.d.ts +3 -0
  14. package/esm/modules/ai-report/components/ScoreReport/RecommendIcon.js +17 -0
  15. package/esm/modules/ai-report/components/ScoreReport/Score.js +49 -9
  16. package/esm/modules/ai-report/components/ScoreReport/Tips.d.ts +3 -0
  17. package/esm/modules/ai-report/components/ScoreReport/Tips.js +18 -0
  18. package/esm/modules/ai-report/components/ScoreReport/index.js +8 -9
  19. package/esm/modules/ai-report/components/ScoreReport/interface.d.ts +3 -0
  20. package/esm/modules/ai-report/components/ScoreReport/styled.js +2 -4
  21. package/esm/modules/ai-report/components/Suggestion/index.js +2 -2
  22. package/esm/modules/ai-report/components/VideoQuestion/index.js +2 -2
  23. package/esm/modules/ai-report/components/WorkPlaces/index.js +3 -3
  24. package/esm/modules/ai-report/interface.d.ts +2 -0
  25. package/esm/services/ai-report.d.ts +5 -0
  26. package/esm/services/ai-report.js +1 -0
  27. package/lib/constants/ai-report.d.ts +5 -0
  28. package/lib/constants/ai-report.js +6 -1
  29. package/lib/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.d.ts +14 -0
  30. package/lib/modules/ai-ability/components/AbilityFormItem/AbilityFormItem.js +147 -0
  31. package/lib/modules/ai-ability/components/AbilityFormItem/index.d.ts +2 -0
  32. package/lib/modules/ai-ability/components/AbilityFormItem/index.js +14 -3
  33. package/lib/modules/ai-ability/components/AddAbility/index.js +149 -100
  34. package/lib/modules/ai-ability/components/UpdateAbility/index.js +97 -103
  35. package/lib/modules/ai-report/Root.js +51 -7
  36. package/lib/modules/ai-report/components/AIEvaluate/index.js +1 -1
  37. package/lib/modules/ai-report/components/ScoreReport/Bar.d.ts +4 -1
  38. package/lib/modules/ai-report/components/ScoreReport/Bar.js +10 -8
  39. package/lib/modules/ai-report/components/ScoreReport/RecommendIcon.d.ts +3 -0
  40. package/lib/modules/ai-report/components/ScoreReport/RecommendIcon.js +22 -0
  41. package/lib/modules/ai-report/components/ScoreReport/Score.js +47 -7
  42. package/lib/modules/ai-report/components/ScoreReport/Tips.d.ts +3 -0
  43. package/lib/modules/ai-report/components/ScoreReport/Tips.js +20 -0
  44. package/lib/modules/ai-report/components/ScoreReport/index.js +5 -6
  45. package/lib/modules/ai-report/components/ScoreReport/interface.d.ts +3 -0
  46. package/lib/modules/ai-report/components/ScoreReport/styled.js +2 -4
  47. package/lib/modules/ai-report/components/Suggestion/index.js +1 -1
  48. package/lib/modules/ai-report/components/VideoQuestion/index.js +1 -1
  49. package/lib/modules/ai-report/components/WorkPlaces/index.js +2 -2
  50. package/lib/modules/ai-report/interface.d.ts +2 -0
  51. package/lib/services/ai-report.d.ts +5 -0
  52. package/lib/services/ai-report.js +3 -1
  53. package/package.json +5 -3
@@ -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,172 @@ 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: 4,
131
+ items: [],
132
+ maxTextLength: 300,
133
+ },
134
+ {
135
+ name: '考察建议-评分关键点',
136
+ type: 5,
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 })] }))) : ((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 : 50, canReplace: true, onChange: handleValue }, item.type) }, index)); }) })); } }))] }))) })) })));
211
260
  };
212
261
  exports.default = AddAbility;
@@ -10,41 +10,28 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
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 };
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]; } };
47
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;
48
35
  };
49
36
  var __read = (this && this.__read) || function (o, n) {
50
37
  var m = typeof Symbol === "function" && o[Symbol.iterator];
@@ -67,12 +54,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
67
54
  };
68
55
  Object.defineProperty(exports, "__esModule", { value: true });
69
56
  var jsx_runtime_1 = require("react/jsx-runtime");
57
+ /* eslint-disable react-hooks/exhaustive-deps */
58
+ var Yup = __importStar(require("yup"));
70
59
  var const_1 = require("../../const");
71
60
  var AbilityFormItem_1 = __importDefault(require("../AbilityFormItem"));
72
61
  var ai_ability_1 = require("../../../../services/ai-ability");
73
62
  var ahooks_1 = require("ahooks");
74
63
  var fbm_ui_1 = require("fbm-ui");
64
+ var mui_1 = require("fbm-ui/lib/mui");
65
+ var formik_1 = require("formik");
75
66
  var react_1 = require("react");
67
+ var validationSchema = Yup.object().shape({
68
+ name: Yup.string().required('能力名称不能为空'),
69
+ workPlaceItems: Yup.array().of(Yup.object().shape({
70
+ name: Yup.string().required(''),
71
+ items: Yup.array().of(Yup.string().required('')),
72
+ })),
73
+ });
76
74
  var UpdateAbility = function (props) {
77
75
  var open = props.open, _a = props.type, type = _a === void 0 ? 1 : _a, isWorkplace = props.isWorkplace, _b = props.name, name = _b === void 0 ? '' : _b, ablilityNameLength = props.ablilityNameLength, token = props.token, onClose = props.onClose, onSuccess = props.onSuccess;
78
76
  var _c = __read((0, react_1.useState)(''), 2), value = _c[0], setValue = _c[1];
@@ -80,8 +78,27 @@ var UpdateAbility = function (props) {
80
78
  var _e = __read((0, react_1.useState)('show'), 2), mode = _e[0], setMode = _e[1];
81
79
  var firstLoad = (0, react_1.useRef)(true);
82
80
  var _f = __read((0, react_1.useState)(false), 2), showAiDefineDetail = _f[0], setShowAiDefineDetail = _f[1];
83
- // const [submitDisabled, setSubmitDisabled] = useState<boolean>(true);
84
81
  var _g = __read((0, react_1.useState)(const_1.InitialValues.workPlaceItems), 2), workPlaceItems = _g[0], setWorkPlaceItems = _g[1];
82
+ var formik = (0, fbm_ui_1.useForm)({
83
+ initialValues: { name: '', workPlaceItems: [] },
84
+ validationSchema: validationSchema,
85
+ validateOnChange: true,
86
+ onSubmit: function (values) {
87
+ // 处理表单提交逻辑
88
+ console.log(values);
89
+ var avocadoConfig = window['AvocadoVideoInterviewConfig'];
90
+ run({
91
+ name: values.name,
92
+ tag: values.name,
93
+ token: token,
94
+ workPlaceItems: values.workPlaceItems,
95
+ mateData: {
96
+ account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
97
+ enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
98
+ },
99
+ });
100
+ },
101
+ });
85
102
  var _h = (0, ahooks_1.useRequest)(ai_ability_1.PostQuestionCollectionUpsert, {
86
103
  manual: true,
87
104
  onSuccess: function () {
@@ -92,7 +109,7 @@ var UpdateAbility = function (props) {
92
109
  onError: function (err) {
93
110
  console.log(err);
94
111
  if ((err === null || err === void 0 ? void 0 : err.code) === -1211) {
95
- nameTextField.setError('能力名称不能重复');
112
+ formik.errors.name = '能力名称不能重复';
96
113
  }
97
114
  },
98
115
  }), run = _h.run, loading = _h.loading;
@@ -111,82 +128,60 @@ var UpdateAbility = function (props) {
111
128
  }
112
129
  },
113
130
  }).run;
114
- var nameTextField = (0, fbm_ui_1.useTextField)({
115
- value: value,
116
- label: '能力名称',
117
- required: true,
118
- rules: [
119
- {
120
- required: true,
121
- message: '能力名称不能为空',
122
- },
123
- ],
124
- onChange: function (e) { return setValue(e.target.value); },
125
- max: ablilityNameLength,
126
- sx: {
127
- height: '48px',
128
- width: '100%',
129
- marginTop: '16px',
130
- },
131
- });
132
131
  var handleValue = (0, react_1.useCallback)(function (v) {
133
- var index = workPlaceItems.findIndex(function (ele) { return ele.type === v.type; });
134
- workPlaceItems.splice(index, 1, v);
135
- var list = workPlaceItems;
136
- setWorkPlaceItems(list);
132
+ // const index = workPlaceItems.findIndex(ele => ele.type === v.type);
133
+ // workPlaceItems.splice(index, 1, v);
134
+ // const list = workPlaceItems;
135
+ // setWorkPlaceItems(list);
137
136
  }, [workPlaceItems]);
138
- var handleOk = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
139
- var error, workPlaceItemsError, avocadoConfig;
140
- return __generator(this, function (_a) {
141
- switch (_a.label) {
142
- case 0: return [4 /*yield*/, nameTextField.handleValidate()];
143
- case 1:
144
- error = _a.sent();
145
- workPlaceItemsError = workPlaceItems.some(function (v) { return v.items.length === 0; });
146
- if (!error) {
147
- avocadoConfig = window['AvocadoVideoInterviewConfig'];
148
- // 旧自定义能力
149
- if (type === 3 && !isWorkplace) {
150
- run({
151
- name: value,
152
- tag: value,
153
- token: token,
154
- mateData: {
155
- account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
156
- enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
157
- },
158
- });
159
- }
160
- else if (!workPlaceItemsError) {
161
- // 职场能力
162
- run({
163
- name: value,
164
- tag: value,
165
- token: token,
166
- workPlaceItems: workPlaceItems,
167
- mateData: {
168
- account: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.account,
169
- enterpriseId: avocadoConfig === null || avocadoConfig === void 0 ? void 0 : avocadoConfig.enterpriseId,
170
- },
171
- });
172
- }
173
- }
174
- return [2 /*return*/];
175
- }
176
- });
177
- }); }, [nameTextField, run, token, value, isWorkplace, type, workPlaceItems]);
137
+ // const handleOk = useCallback(async () => {
138
+ // // const error = await nameTextField.handleValidate();
139
+ // const error = false;
140
+ // const workPlaceItemsError = workPlaceItems.some(v => v.items.length === 0);
141
+ // if (!error) {
142
+ // const avocadoConfig = window['AvocadoVideoInterviewConfig'];
143
+ // // 旧自定义能力
144
+ // if (type === 3 && !isWorkplace) {
145
+ // run({
146
+ // name: value,
147
+ // tag: value,
148
+ // token,
149
+ // mateData: {
150
+ // account: avocadoConfig?.account,
151
+ // enterpriseId: avocadoConfig?.enterpriseId,
152
+ // },
153
+ // });
154
+ // } else if (!workPlaceItemsError) {
155
+ // // 职场能力
156
+ // run({
157
+ // name: value,
158
+ // tag: value,
159
+ // token,
160
+ // workPlaceItems,
161
+ // mateData: {
162
+ // account: avocadoConfig?.account,
163
+ // enterpriseId: avocadoConfig?.enterpriseId,
164
+ // },
165
+ // });
166
+ // }
167
+ // }
168
+ // }, [run, token, value, isWorkplace, type, workPlaceItems]);
178
169
  var footer = (0, react_1.useCallback)(function () {
179
- return step === 1 ? ((0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ display: "flex", padding: "12px 16px" }, { children: type === 1 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {})) : ((0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(2); } }, { children: "\u7F16\u8F91" }))) }))) : ((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: loading, onClick: handleOk }, { children: "\u4FDD\u5B58" }))] })));
180
- }, [type, step, loading, setStep, handleOk, onClose]);
170
+ return step === 1 ? ((0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ display: "flex", padding: "12px 16px" }, { children: type === 1 ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {})) : ((0, jsx_runtime_1.jsx)(fbm_ui_1.Button, __assign({ variant: "outlined", color: "inherit", onClick: function () { return setStep(2); } }, { children: "\u7F16\u8F91" }))) }))) : ((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: loading, onClick: formik.submitForm }, { children: "\u4FDD\u5B58" }))] })));
171
+ }, [step, type, onClose, loading, formik]);
172
+ (0, react_1.useEffect)(function () {
173
+ formik.setFieldValue('workPlaceItems', workPlaceItems);
174
+ }, [workPlaceItems]);
181
175
  (0, react_1.useEffect)(function () {
182
176
  setValue(name);
177
+ formik.setFieldValue('name', name);
183
178
  }, [name]);
184
179
  (0, react_1.useEffect)(function () {
185
180
  if (!open) {
186
181
  setValue('');
187
182
  setWorkPlaceItems([]);
188
183
  setStep(1);
189
- nameTextField.setError();
184
+ // nameTextField.setError();
190
185
  }
191
186
  // eslint-disable-next-line react-hooks/exhaustive-deps
192
187
  }, [open]);
@@ -205,7 +200,6 @@ var UpdateAbility = function (props) {
205
200
  (0, react_1.useEffect)(function () {
206
201
  setWorkPlaceItems(workPlaceItems);
207
202
  }, [workPlaceItems, setWorkPlaceItems]);
208
- return ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Drawer, __assign({ className: "abilityDrawer", title: '能力详情', open: open, footer: footer, onClose: onClose }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium" }, { children: ["\u80FD\u529B\u540D\u79F0\uFF1A", value] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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))] })) })), !(type === 3 && !isWorkplace) && ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Divider, { style: { margin: '24px 0' } }), (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), showAiDefineDetail &&
209
- workPlaceItems.map(function (v) { return ((0, jsx_runtime_1.jsx)(AbilityFormItem_1.default, { token: token, name: value, title: v.name, type: v.type, items: v.items, mode: mode, maxTextLength: v.type === 4 || v.type === 5 ? 300 : 100, canReplace: mode === 'edit' ? true : false, onChange: handleValue }, v.type)); })] })))] })));
203
+ 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.jsxs)(fbm_ui_1.Form, __assign({}, formik, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: step === 1 ? ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium" }, { children: ["\u80FD\u529B\u540D\u79F0\uFF1A", value] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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 })] })) })), !(type === 3 && !isWorkplace) && ((0, jsx_runtime_1.jsxs)(fbm_ui_1.Box, __assign({ style: { width: '556px' } }, { children: [(0, jsx_runtime_1.jsx)(fbm_ui_1.Divider, { style: { margin: '24px 0' } }), (0, jsx_runtime_1.jsx)(fbm_ui_1.Typography, __assign({ variant: "body1", fontWeight: "medium", mb: 2 }, { children: "\u80FD\u529B\u6807\u51C6" })), showAiDefineDetail && ((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: value, title: item.name, type: item.type, items: item.items, mode: mode, index: index, item: item, maxTextLength: item.type === 4 || item.type === 5 ? 300 : 100, canReplace: mode === 'edit' ? true : false, onChange: handleValue }, item.type) }, index)); }) })); } })))] })))] })) })));
210
204
  };
211
205
  exports.default = UpdateAbility;