|
154 | 154 | import { ref, PropType, watch, computed } from 'vue'; |
155 | 155 | import { Group, recruitSteps, Step, SMSTemplate } from '@/constants/team'; |
156 | 156 | import { sendSms } from '@/api'; |
| 157 | +import { groupBy } from 'lodash'; |
157 | 158 | import { Message } from '@arco-design/web-vue'; |
158 | 159 | import { useI18n } from 'vue-i18n'; |
159 | 160 | import dayjs from 'dayjs'; |
@@ -334,20 +335,30 @@ const handleNotify = async () => { |
334 | 335 | Message.error(t('candidate.requireAllocateTime')); |
335 | 336 | return false; |
336 | 337 | } |
337 | | - } |
338 | 338 |
|
339 | | - const reqs = props.candidates.map((candidate) => { |
340 | | - const content = isCustom.value |
341 | | - ? customContents.value[candidate.aid] |
342 | | - : generateSMSContent(candidate); |
343 | | - return sendSms({ |
344 | | - aid: candidate.aid, |
345 | | - content, |
| 339 | + const res = groupBy(props.candidates, ({ step }) => step); |
| 340 | + const reqs = Object.entries(res).map(([current, arr]) => { |
| 341 | + const aids = arr.map(({ aid }) => aid); |
| 342 | + return sendSms({ |
| 343 | + type: props.type, |
| 344 | + current: current as Step, |
| 345 | + ...formData.value, |
| 346 | + aids, |
| 347 | + }); |
346 | 348 | }); |
347 | | - }); |
| 349 | + const resp = await Promise.all(reqs); |
| 350 | + if (!resp.every((x) => x)) return false; |
| 351 | + } else { |
| 352 | + const reqs = props.candidates.map((candidate) => { |
| 353 | + return sendSms({ |
| 354 | + aid: candidate.aid, |
| 355 | + content: customContents.value[candidate.aid], |
| 356 | + }); |
| 357 | + }); |
| 358 | + const resp = await Promise.all(reqs); |
| 359 | + if (!resp.every((x) => x)) return false; |
| 360 | + } |
348 | 361 |
|
349 | | - const resp = await Promise.all(reqs); |
350 | | - if (!resp.every((x) => x)) return false; |
351 | 362 | Message.success(t('common.result.sendSuccess')); |
352 | 363 | notifyFormRef.value?.resetFields(); |
353 | 364 | [formData.value.next] = nextValidSteps.value; |
|
0 commit comments