zhengyiming
2025-11-28 336441bd3d811427f957654f12936c4cab9b4c1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
<template>
  <LoadingLayout :loading="state.loading">
    <AppContainer>
      <ProTableQueryFilterBar @on-reset="reset">
        <template #query>
          <!-- <QueryFilterItem tip-content="录用状态">
            <FieldRadio
              v-model="extraParamState.hireStatus"
              :value-enum="EnumTaskUserHireStatusText"
              buttonStyle
              showAllBtn
              @change="getList()"
            />
          </QueryFilterItem> -->
          <QueryFilterItem tip-content="实名状态">
            <FieldRadio
              v-model="extraParamState.isReal"
              :value-enum="[
                { label: '已实名', value: true },
                { label: '未实名', value: false },
              ]"
              buttonStyle
              showAllBtn
              :all-btn-value="null"
              @change="getList()"
            />
          </QueryFilterItem>
          <QueryFilterItem tip-content="灵工来源">
            <FieldRadio
              v-model="extraParamState.source"
              :value-enum="EnumEnterpriseEmployeeSourceText"
              buttonStyle
              showAllBtn
              @change="getList()"
            />
          </QueryFilterItem>
          <QueryFilterItem tip-content="灵工签约状态">
            <FieldSelect
              v-model="extraParamState.userSignContractStatus"
              :value-enum="EnumTaskUserSignContractStatusText"
              placeholder="请选择灵工签约状态"
              clearable
              @change="getList()"
            />
          </QueryFilterItem>
          <QueryFilterItem tip-content="企业签约状态">
            <FieldSelect
              v-model="extraParamState.enterpriseSignContractStatus"
              :value-enum="EnumTaskUserSignContractStatusText"
              placeholder="请选择企业签约状态"
              clearable
              @change="getList()"
            />
          </QueryFilterItem>
          <!-- <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.createdTime"
              type="daterange"
              range-separator="~"
              start-placeholder="起始日期"
              end-placeholder="截止日期"
              clearable
              @change="getList()"
              tooltipContent="登记时间"
            ></FieldDatePicker>
          </QueryFilterItem>
          <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.signContractTime"
              type="daterange"
              range-separator="~"
              start-placeholder="起始日期"
              end-placeholder="截止日期"
              clearable
              @change="getList()"
              tooltipContent="签约时间"
            ></FieldDatePicker>
          </QueryFilterItem> -->
          <QueryFilterItem>
            <FieldDatePicker
              v-model="extraParamState.userRealTime"
              type="daterange"
              range-separator="~"
              start-placeholder="起始日期"
              end-placeholder="截止日期"
              clearable
              @change="getList()"
              tooltipContent="实名时间"
            ></FieldDatePicker>
          </QueryFilterItem>
          <QueryFilterItem>
            <SearchInput
              v-model="extraParamState.searchWord"
              style="width: 300px"
              placeholder="姓名/手机/身份证号"
              @on-click-search="getList"
              @keyup.enter="getList()"
            >
            </SearchInput>
          </QueryFilterItem>
        </template>
        <template #btn>
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'importBtn')"
            @click="handleDownloadFlexJobTemplate()"
            type="primary"
            link
            >模板下载</el-button
          >
          <BlFileUpload
            v-if="checkSubModuleItemShow('pageButton', 'importBtn')"
            v-model:file-url="state.flexjobUrl"
            ref="uploadRef"
            :showTip="false"
            :show-file-list="false"
            class="pro-table-operation-btn upload-style-btn"
            :on-success="(event) => handleUploadSuccess(event)"
            :limitFileSize="null"
            :limit="1"
            accept="xlsx,xls"
          >
            <el-button type="primary" class="pro-table-operation-btn">批量导入</el-button>
          </BlFileUpload>
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'addBtn')"
            @click="handleInternalStaffAdd()"
            type="primary"
            >新建</el-button
          >
          <!-- <el-button
            v-if="checkSubModuleItemShow('pageButton', 'batchUnSignBtn')"
            @click="handleBatchUnSign()"
            type="primary"
            >批量解约</el-button
          >
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'sendShotBtn')"
            @click="handleSendShotMessage()"
            type="primary"
            >短信发送</el-button
          >
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'batchSignBtn')"
            @click="handleBatchSign()"
            type="primary"
            >批量签约</el-button
          >
          <el-button
            v-if="checkSubModuleItemShow('pageButton', 'enterpriseBatchSignBtn')"
            @click="handleEnterpriseBatchSign()"
            type="primary"
            >批量企业签约</el-button
          > -->
        </template>
      </ProTableQueryFilterBar>
      <ProTableV2
        v-bind="proTableProps"
        :columns="column"
        :operationBtns="operationBtns"
        show-column-check
        ref="proTable"
        :table-props="{
          rowKey: 'id',
        }"
      >
      </ProTableV2>
    </AppContainer>
    <StaffInfoDialog v-bind="dialogStaffInfoProps" />
    <StaffDetailInfoDialog v-bind="dialogStaffDetailProps" />
    <BatchImportDialog
      v-bind="dialogBatchImportProps"
      @onDownloadTemplate="handleDownloadTemplate"
    />
    <SendShotMessageDialog v-bind="dialogShotMessageProps" />
    <SignDialog v-bind="dialogSignProps" />
    <AddInternalStaffDialog v-bind="dialogAddInternalStaffProps" />
  </LoadingLayout>
</template>
 
<script setup lang="ts">
import {
  ProTableQueryFilterBar,
  OperationBtnType,
  ProTableV2,
  SearchInput,
  LoadingLayout,
  AppContainer,
  QueryFilterItem,
  useTable,
  FieldDatePicker,
  FieldRadio,
  FieldSelect,
  useFormDialog,
  UploadUserFile,
  XLSXUtils,
  BlFileUpload,
} from '@bole-core/components';
import {
  EnumTaskUserHireStatusText,
  EnumTaskUserSignContractStatusText,
  EnumEnterpriseEmployeeSourceText,
} from '@/constants';
import { Message } from '@bole-core/core';
import {
  convertApi2FormUrlOnlyOne,
  downloadFileByUrl,
  format,
  hiddenIDNumberForEnd4,
} from '@/utils';
import StaffInfoDialog from './components/StaffInfoDialog.vue';
import BatchImportDialog from './components/BatchImportDialog.vue';
import SendShotMessageDialog from './components/SendShotMessageDialog.vue';
import StaffDetailInfoDialog from './components/StaffDetailInfoDialog.vue';
import AddInternalStaffDialog from './components/AddInternalStaffDialog.vue';
import SignDialog from './components/SignDialog.vue';
import * as enterpriseEmployeeServices from '@/services/api/enterpriseEmployee';
import { ModelValueType } from 'element-plus';
import _ from 'lodash';
import { getEnterpriseEmployeesHooks } from './hooks';
 
defineOptions({
  name: 'FlexJobManageList',
});
 
const operationBtnMap: Record<string, OperationBtnType> = {
  editBtn: {
    emits: {
      onClick: (role) => openInternalDialog(role),
    },
    extraProps: {
      hide: (row: API.GetEnterpriseEmployeesQueryResultItem) =>
        row.source === EnumEnterpriseEmployeeSource.External,
    },
  },
  detailBtn: {
    emits: {
      onClick: (role: API.GetEnterpriseEmployeesQueryResultItem) =>
        handleStaffDetailEdit({ id: role.id, tabType: 'info' }),
    },
  },
  // enterpriseSignBtn: {
  //   emits: {
  //     onClick: (role) => handleEnterpriseSign(role),
  //   },
  //   extraProps: {
  //     hide: (row: API.GetEnterpriseEmployeesQueryResultItem) =>
  //       !(
  //         row.userSignContractStatus === EnumTaskUserSignContractStatus.Pass &&
  //         row.enterpriseSignContractStatus === EnumTaskUserSignContractStatus.Wait
  //       ),
  //   },
  // },
  // inviteSignBtn: {
  //   emits: {
  //     onClick: (role) => handleInviteSign(role),
  //   },
  //   extraProps: {
  //     hide: (row: API.GetEnterpriseEmployeesQueryResultItem) =>
  //       !(
  //         row.userSignContractStatus !== EnumTaskUserSignContractStatus.Pass &&
  //         row.hireStatus === EnumTaskUserHireStatus.Pass
  //       ),
  //   },
  // },
  // unSignBtn: {
  //   emits: {
  //     onClick: (role) => handleUnSign(role),
  //   },
  //   extraProps: {
  //     hide: (row: API.GetEnterpriseEmployeesQueryResultItem) =>
  //       !(
  //         row.userSignContractStatus === EnumTaskUserSignContractStatus.Pass &&
  //         row.enterpriseSignContractStatus === EnumTaskUserSignContractStatus.Pass
  //       ),
  //   },
  // },
};
 
const { checkSubModuleItemShow, column, operationBtns } = useAccess({
  operationBtnMap,
});
 
const router = useRouter();
 
const BaseState = {
  loading: true,
  flexjobUrl: [] as UploadUserFile[],
};
 
const state = reactive({ ...BaseState });
 
onMounted(async () => {
  await getList();
  state.loading = false;
});
 
const { getList, proTableProps, paginationState, extraParamState, reset } =
  getEnterpriseEmployeesHooks();
 
const proTable = ref<InstanceType<typeof ProTableV2>>();
 
function getSelectionRows() {
  if (proTableProps.value.tableData.length) {
    const res = proTable.value.innerTableRef.getSelectionRows();
    if (res.length > 0) {
      return res;
    } else {
      Message.errorMessage('未选择数据');
    }
  } else {
    Message.errorMessage('暂无数据');
  }
}
 
const {
  dialogProps: dialogStaffInfoProps,
  handleEdit: handleStaffInfoEdit,
  handleAdd: handleStaffInfoAdd,
  editForm: staffInfoEditForm,
} = useFormDialog({
  onConfirm: editEnterpriseEmployee,
  defaultFormParams: {
    id: '',
    name: '',
    identity: '',
    contactPhoneNumber: '',
    gender: EnumUserGender.Male,
    age: null as any as number,
    identityImg: [] as UploadUserFile[],
    identityBackImg: [] as UploadUserFile[],
    contractUrl: [] as UploadUserFile[],
    regiterTime: '',
    userRealTime: '',
    userSignContractTime: '',
    isDetail: false,
  },
});
 
async function openDialog(row: API.GetEnterpriseEmployeesQueryResultItem, isDetail = false) {
  try {
    let detail = await enterpriseEmployeeServices.getEnterpriseEmployee({ id: row.id });
    handleStaffInfoEdit({
      id: row.id,
      name: row.name,
      identity: row.identity,
      contactPhoneNumber: row.contactPhoneNumber,
      gender: detail.gender,
      age: detail.age ?? null,
      identityImg: convertApi2FormUrlOnlyOne(detail.identityImg),
      identityBackImg: convertApi2FormUrlOnlyOne(detail.identityBackImg),
      contractUrl: convertApi2FormUrlOnlyOne(detail.contractUrl, {
        fileName: detail.contractUrl ? detail.contractUrl.split('/').pop() : '合同',
      }),
      regiterTime: detail.applyTime ?? '',
      userRealTime: row.userRealTime ?? '',
      userSignContractTime: row.userSignContractTime ?? '',
      isDetail: isDetail,
    });
  } catch (error) {}
}
 
async function editEnterpriseEmployee() {
  try {
    let params: API.EditEnterpriseEmployeeCommand = {
      name: staffInfoEditForm.name,
      identity: staffInfoEditForm.identity,
      contactPhoneNumber: staffInfoEditForm.contactPhoneNumber,
      gender: staffInfoEditForm.gender,
      age: staffInfoEditForm.age,
      identityImg: staffInfoEditForm.identityImg[0]?.path ?? '',
      identityBackImg: staffInfoEditForm.identityBackImg[0]?.path ?? '',
      id: staffInfoEditForm.id,
    };
    let res = await enterpriseEmployeeServices.editEnterpriseEmployee(params);
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
    }
  } catch (error) {}
}
 
const {
  dialogProps: dialogBatchImportProps,
  handleAdd: handleBatchImportAdd,
  editForm: batchImportForm,
} = useFormDialog({
  onConfirm: handleBatchImport,
  defaultFormParams: {
    url: [] as UploadUserFile[],
  },
});
 
async function handleBatchImport() {
  try {
    let params: API.ImportEnterpriseEmployeesCommand = {
      excelUrl: batchImportForm.url[0]?.path ?? '',
    };
    let res = await enterpriseEmployeeServices.importEnterpriseEmployees(params);
    if (res.failCount > 0) {
      await Message.tipMessage('存在错误数据,是否导出?');
      XLSXUtils.exportToXLSX({
        workbookDataList: res.errors,
        fileName: '灵工批量导入-错误数据',
        workbookHeaderMap: {
          name: '姓名',
          identity: '身份证号',
          contactPhoneNumber: '手机号',
          errorMessage: '备注',
        },
      });
    } else {
      Message.successMessage('导入成功');
      getList();
    }
  } catch (error) {}
}
 
const {
  dialogProps: dialogShotMessageProps,
  handleAdd: handleShotMessageAdd,
  editForm: editShotMessageForm,
} = useFormDialog({
  onConfirm: sendMessageForSign,
  defaultFormParams: {
    ids: [] as string[],
    customerId: '',
    name: '',
    contractTemplateId: '',
  },
});
 
async function handleSendShotMessage() {
  try {
    const selectionRows = getSelectionRows();
    if (selectionRows) {
      if (
        selectionRows.some((x) => x.userSignContractStatus === EnumTaskUserSignContractStatus.Pass)
      ) {
        await Message.tipMessage('勾选人员中包含已签约完成人员,确认要继续发送短信通知吗?');
      }
      handleShotMessageAdd({
        ids: selectionRows.map((x) => x.id),
        name: '人员签约通道短信',
      });
    }
  } catch (error) {}
}
 
async function sendMessageForSign() {
  try {
    let params: API.SendInviteElectronSignSmsCommand = {
      ids: editShotMessageForm.ids,
      contractTemplateId: editShotMessageForm.contractTemplateId,
    };
    let res = await enterpriseEmployeeServices.sendInviteElectronSignSms(params);
    if (res) {
      Message.successMessage('短信已发送');
    }
  } catch (error) {}
}
 
function handleDownloadTemplate() {
  downloadFileByUrl(ImportEnterpriseEmployeesTempPath, '批量导入模板');
}
 
function handleDownloadFlexJobTemplate() {
  downloadFileByUrl(ImportFlexJobTempPath, '批量导入模板');
}
 
const {
  dialogProps: dialogSignProps,
  handleAdd: handleSignAdd,
  handleEdit: handleSignEdit,
  editForm: signEditForm,
} = useFormDialog({
  onConfirm: signContract,
  defaultFormParams: {
    ids: [] as string[],
    contractTemplateId: '',
  },
});
 
function handleInviteSign(row: API.GetEnterpriseEmployeesQueryResultItem) {
  if (row) {
    handleSignEdit({
      ids: [row.id],
      contractTemplateId: '',
    });
  }
}
function handleBatchSign() {
  const selectionRows = getSelectionRows();
  if (selectionRows) {
    const hasSigned = selectionRows?.some(
      (x) =>
        x.userSignContractStatus === EnumTaskUserSignContractStatus.Pass ||
        x.enterpriseSignContractStatus === EnumTaskUserSignContractStatus.Pass ||
        x.hireStatus === EnumTaskUserHireStatus.Wait
    );
    if (hasSigned) {
      Message.warnMessage('勾选人员中包含已签约完成或未录用人员');
      return;
    }
    handleSignAdd({
      ids: selectionRows.map((x) => x.id),
      contractTemplateId: '',
    });
  }
}
 
const handleEnterpriseBatchSign = _.debounce(
  () => {
    const selectionRows = getSelectionRows();
    if (selectionRows) {
      const hasSigned = selectionRows?.some(
        (x) =>
          !(
            x.userSignContractStatus === EnumTaskUserSignContractStatus.Pass &&
            x.enterpriseSignContractStatus === EnumTaskUserSignContractStatus.Wait
          )
      );
      if (hasSigned) {
        Message.warnMessage('勾选人员中包含已企业签约、未录用人员或未签约完成人员');
        return;
      }
      const ids = selectionRows.map((x) => x.id);
      handleBatchEnterpriseSign(ids);
    }
  },
  1000,
  { leading: true, trailing: false }
);
 
async function handleBatchEnterpriseSign(ids: string[]) {
  try {
    state.loading = true;
    let res = await enterpriseEmployeeServices.batchEnterpriseSignContract({ ids: ids });
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
      if (res?.errors?.length > 0) {
        Message.tipMessage('存在签约失败的灵工信息数据,是否导出?').then(() => {
          XLSXUtils.exportToXLSX({
            workbookDataList: res.errors,
            fileName: '签约失败灵工信息',
            workbookHeaderMap: {
              name: '姓名',
              contactPhoneNumber: '手机号',
              identity: '身份证号',
              errorMessages: '错误信息',
            },
          });
        });
      }
    }
  } catch (error) {
  } finally {
    state.loading = false;
  }
}
 
async function signContract() {
  try {
    let params: API.InviteElectronSignCommand = {
      ids: signEditForm.ids,
      contractTemplateId: signEditForm.contractTemplateId,
    };
    let res = await enterpriseEmployeeServices.inviteElectronSign(params);
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
    }
  } catch (error) {}
}
 
async function handleEnterpriseSign(row: API.GetEnterpriseEmployeesQueryResultItem) {
  try {
    let res = await enterpriseEmployeeServices.enterpriseUserElectronSign({ id: row.id });
    if (res) {
      window.open(res?.signContractLongUrl, '_blank');
    }
  } catch (error) {}
}
 
function handleUnSign(row: API.GetEnterpriseEmployeesQueryResultItem) {
  stopElectronSign([row.id]);
}
 
function handleBatchUnSign() {
  try {
    const selectionRows = getSelectionRows();
    if (selectionRows) {
      const hasUnSigned = selectionRows?.some(
        (x) => x.enterpriseSignContractStatus !== EnumTaskUserSignContractStatus.Pass
      );
      if (hasUnSigned) {
        Message.warnMessage('勾选数据中包含企业未签约或已解约数据');
        return;
      }
      stopElectronSign(selectionRows.map((x) => x.id));
    }
  } catch (error) {}
}
 
async function stopElectronSign(ids: string[]) {
  try {
    await Message.tipMessage('确定解约用户?');
    let res = await enterpriseEmployeeServices.stopElectronSign({ ids: ids });
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
    }
  } catch (error) {}
}
 
const {
  dialogProps: dialogStaffDetailProps,
  handleEdit: handleStaffDetailEdit,
  editForm: staffDetailEditForm,
} = useFormDialog({
  defaultFormParams: {
    id: '',
    tabType: 'info',
  },
});
 
async function handleDelete(row: API.GetEnterpriseEmployeesQueryResultItem) {
  try {
    await Message.deleteMessage();
  } catch (error) {}
}
 
function handleUploadSuccess(response: UploadUserFile & { file: File & { uid: number } }) {
  if (response.path) {
    importEnterpriseEmployees(response.path);
  }
}
 
async function importEnterpriseEmployees(excelUrl: string) {
  try {
    let params: API.ImportEnterpriseEmployeesCommand = {
      excelUrl: excelUrl,
    };
    let res = await enterpriseEmployeeServices.importEnterpriseEmployees(params);
    if (res.failCount > 0) {
      await Message.tipMessage('存在错误数据,是否导出?');
      XLSXUtils.exportToXLSX({
        workbookDataList: res.errors,
        fileName: '灵工批量导入-错误数据',
        workbookHeaderMap: {
          name: '姓名',
          contactPhoneNumber: '手机号',
          identity: '身份证号',
          contractBegin: '协议起始时间',
          contractEnd: '协议终止时间',
          errorMessage: '错误信息',
        },
      });
    } else {
      Message.successMessage('导入成功');
      getList();
    }
  } catch (error) {
  } finally {
    state.flexjobUrl = [] as UploadUserFile[];
  }
}
 
const {
  dialogProps: dialogAddInternalStaffProps,
  handleAdd: handleInternalStaffAdd,
  handleEdit: handleInternalStaffEdit,
  editForm: internalStaffEditForm,
  dialogState: internalDialogState,
} = useFormDialog({
  onConfirm: addEnterpriseEmployee,
  defaultFormParams: {
    id: '',
    name: '',
    identity: '',
    contactPhoneNumber: '',
    gender: EnumUserGender.Male,
    age: null as any as number,
    identityImg: [] as UploadUserFile[],
    identityBackImg: [] as UploadUserFile[],
    contractUrl: [] as UploadUserFile[],
    regiterTime: '',
    userRealTime: '',
    userSignContractTime: '',
    contractTime: [] as unknown as ModelValueType,
  },
  closeAfterConfirm: false,
});
 
async function openInternalDialog(row: API.GetEnterpriseEmployeesQueryResultItem) {
  try {
    let detail = await enterpriseEmployeeServices.getEnterpriseEmployee({ id: row.id });
    handleInternalStaffEdit({
      id: row.id,
      name: row.name,
      identity: row.identity,
      contactPhoneNumber: row.contactPhoneNumber,
      gender: detail.gender,
      age: detail.age ?? null,
      identityImg: convertApi2FormUrlOnlyOne(detail.identityImg),
      identityBackImg: convertApi2FormUrlOnlyOne(detail.identityBackImg),
      contractUrl: convertApi2FormUrlOnlyOne(detail.contractUrl, {
        fileName: detail.contractUrl ? detail.contractUrl.split('/').pop() : '合同',
      }),
      regiterTime: detail.applyTime ?? '',
      userRealTime: row.userRealTime ?? '',
      userSignContractTime: row.userSignContractTime ?? '',
      contractTime: [row.contractBegin, row.contractEnd],
    });
  } catch (error) {}
}
 
async function addEnterpriseEmployee() {
  try {
    const isEdit = !!internalStaffEditForm.id;
    let params: API.AddEnterpriseEmployeeCommand = {
      name: internalStaffEditForm.name,
      identity: internalStaffEditForm.identity,
      contactPhoneNumber: internalStaffEditForm.contactPhoneNumber,
      gender: internalStaffEditForm.gender,
      age: internalStaffEditForm.age,
      identityImg: internalStaffEditForm.identityImg[0]?.path ?? '',
      identityBackImg: internalStaffEditForm.identityBackImg[0]?.path ?? '',
      contractUrl: internalStaffEditForm.contractUrl[0]?.path ?? '',
      contractBegin: format(internalStaffEditForm.contractTime[0], 'YYYY-MM-DD 00:00:00'),
      contractEnd: format(internalStaffEditForm.contractTime[1], 'YYYY-MM-DD 23:59:59'),
    };
    let res;
    if (isEdit) {
      (params as API.EditEnterpriseEmployeeCommand).id = internalStaffEditForm.id;
      res = await enterpriseEmployeeServices.editEnterpriseEmployee(params);
    } else {
      res = await enterpriseEmployeeServices.addEnterpriseEmployee(params);
    }
    if (res) {
      Message.successMessage('操作成功');
      getList(paginationState.pageIndex);
      internalDialogState.dialogVisible = false;
    }
  } catch (error) {
    internalDialogState.dialogVisible = true;
  }
}
</script>