From d01af540b961aaaa17f68e70374f78a6695219cc Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期一, 17 十一月 2025 10:25:32 +0800
Subject: [PATCH] fix: bug

---
 src/views/FlexJobManage/FlexJobContractManage.vue |  552 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 552 insertions(+), 0 deletions(-)

diff --git a/src/views/FlexJobManage/FlexJobContractManage.vue b/src/views/FlexJobManage/FlexJobContractManage.vue
new file mode 100644
index 0000000..0aea8c5
--- /dev/null
+++ b/src/views/FlexJobManage/FlexJobContractManage.vue
@@ -0,0 +1,552 @@
+<template>
+  <LoadingLayout :loading="state.loading">
+    <AppContainer>
+      <ProTableQueryFilterBar @on-reset="reset">
+        <template #query>
+          <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.userSignContractTime"
+              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>
+            <SearchInput
+              v-model="extraParamState.searchWord"
+              style="width: 300px"
+              placeholder="濮撳悕/鎵嬫満/韬唤璇佸彿"
+              @on-click-search="getList"
+              @keyup.enter="getList()"
+            >
+            </SearchInput>
+          </QueryFilterItem>
+        </template>
+        <template #btn>
+          <!-- <el-button @click="handleDownloadTemplate()" type="primary" link>妯℃澘涓嬭浇</el-button> -->
+          <!-- <el-button @click="handleBatchImportAdd()" type="primary">鎵归噺瀵煎叆</el-button> -->
+          <!-- <el-button @click="handleStaffInfoAdd()" type="primary">鏂板缓</el-button> -->
+          <el-button
+            v-if="checkSubModuleItemShow('pageButton', 'batchUnSignBtn')"
+            @click="handleBatchUnSign()"
+            type="primary"
+            >鎵归噺瑙g害</el-button
+          >
+          <el-button
+            v-if="checkSubModuleItemShow('pageButton', 'sendShotMessageBtn')"
+            @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', 'batchEnterpriseSignBtn')"
+            @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" />
+  </LoadingLayout>
+</template>
+
+<script setup lang="ts">
+import {
+  ProTableQueryFilterBar,
+  OperationBtnType,
+  ProTableV2,
+  SearchInput,
+  LoadingLayout,
+  AppContainer,
+  QueryFilterItem,
+  useTable,
+  FieldDatePicker,
+  FieldSelect,
+  useFormDialog,
+  UploadUserFile,
+  XLSXUtils,
+} from '@bole-core/components';
+import { EnumTaskUserHireStatusText, EnumTaskUserSignContractStatusText } from '@/constants';
+import { Message } from '@bole-core/core';
+import { convertApi2FormUrlOnlyOne, downloadFileByUrl, format } 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 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: 'FlexJobContractManage',
+});
+
+const operationBtnMap: Record<string, OperationBtnType> = {
+  // editBtn: {
+  //   emits: {
+  //     onClick: (role) => openDialog(role),
+  //   },
+  // },
+  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.source === EnumEnterpriseEmployeeSource.Internal &&
+          row.userSignContractStatus !== EnumTaskUserSignContractStatus.Pass
+        ),
+    },
+  },
+  unSignBtn: {
+    emits: {
+      onClick: (role) => handleUnSign(role),
+    },
+    extraProps: {
+      hide: (row: API.GetEnterpriseEmployeesQueryResultItem) =>
+        !(
+          row.userSignContractStatus === EnumTaskUserSignContractStatus.Pass &&
+          row.enterpriseSignContractStatus === EnumTaskUserSignContractStatus.Pass
+        ),
+    },
+  },
+  delBtn: {
+    props: { type: 'danger' },
+    emits: {
+      onClick: (role) => handleDelete(role),
+    },
+  },
+};
+
+const { checkSubModuleItemShow, column, operationBtns } = useAccess({
+  operationBtnMap,
+});
+
+const router = useRouter();
+
+const BaseState = {
+  loading: true,
+};
+
+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: handleAddOrEdit,
+  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 handleAddOrEdit() {
+  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.source === EnumEnterpriseEmployeeSource.External)) {
+        Message.warnMessage('鍕鹃�変汉鍛樹腑鍖呭惈澶栭儴浜哄憳');
+        return;
+      } else 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, '鎵归噺瀵煎叆妯℃澘');
+}
+
+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.source === EnumEnterpriseEmployeeSource.External
+    );
+    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('纭畾瑙g害鐢ㄦ埛锛�');
+    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) {}
+}
+</script>

--
Gitblit v1.9.1