wupengfei
2025-03-24 ee36747f2db9ac3a641e1cbaeb01f726ce9faa98
feat: 页面
12个文件已修改
1个文件已添加
1345 ■■■■ 已修改文件
src/constants/oss.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/constants/temp.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/BatchChange.vue 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/Home.vue 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/InsuranceOrderDetail.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/components/BatchDownsizingDialog.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/components/InsureOrderInfoView.vue 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/components/UploadInsurePersonDialog.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/components/UploadStampFileDialog.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/Home/constants/index.ts 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/InsuranceClaim/InsuranceClaim.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/InsuranceClaim/InsuranceClaimDetail.vue 582 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/InsuranceClaim/components/InsuranceClaimView.vue 602 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/constants/oss.ts
@@ -4,7 +4,7 @@
export const OSSBaseURL = VITE_OSS_URL;
const _basicPath = '12333/YeXing/';
const _basicPath = '12333/JiangYouBao/';
export const OssHRSIE = _basicPath + 'HRSIE/';
src/constants/temp.ts
@@ -1,6 +1,9 @@
export const TempFolderPath =
  'https://parkmanagement.oss-cn-hangzhou.aliyuncs.com/12333/YeXing/temp';
  'https://parkmanagement.oss-cn-hangzhou.aliyuncs.com/12333/JiangYouBao/temp';
export const InsuranceOrderTempPath = `${TempFolderPath}/%E4%B9%9F%E8%A1%8C%E5%95%86%E4%BF%9D%E4%BA%BA%E5%91%98%E6%B8%85%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx`;
export const JYBInsuranceOrderTempPath = `${TempFolderPath}/%E6%B1%9F%E4%BD%91%E4%BF%9D%E4%BA%BA%E5%91%98%E6%B8%85%E5%8D%95%E6%A8%A1%E6%9D%BF.xlsx`;
// 导入
export const InsuranceOrderTempPath = `${TempFolderPath}/%E9%9B%87%E4%B8%BB%E4%BA%BA%E5%91%98%E6%B8%85%E5%8D%95.xlsx`;
// 加减人
export const InsuranceAddOrReduceTempPath = `${TempFolderPath}/%E5%8A%A0%E5%87%8F%E4%BA%BA%E6%A8%A1%E6%9D%BF.xls`;
// 替换人
export const InsuranceChangeTempPath = `${TempFolderPath}/%E6%9B%BF%E6%8D%A2%E4%BA%BA%E6%A8%A1%E6%9D%BF.xls`;
src/views/Home/BatchChange.vue
@@ -35,7 +35,7 @@
                >
                  <template #default>
                    <el-button type="primary">加减人</el-button>
                    <el-button link type="primary" @click.stop="handleTemplateDownload"
                    <el-button link type="primary" @click.stop="DownloadAddOrReducePersonTemplate"
                      >下载模板</el-button
                    >
                  </template>
@@ -55,7 +55,7 @@
                >
                  <template #default>
                    <el-button type="primary">替换人</el-button>
                    <el-button link type="primary" @click.stop="handleTemplateDownload"
                    <el-button link type="primary" @click.stop="downloadReplacePersonTemplate"
                      >下载模板</el-button
                    >
                  </template>
@@ -81,7 +81,7 @@
        >
        </ProTableV2>
        <div class="chuck-add-or-edit-actions">
          <el-button class="chuck-add-or-edit-actions" type="primary" @click="handleSubmit"
          <el-button class="chuck-add-or-edit-actions btn" type="primary" @click="handleSubmit"
            >提交</el-button
          >
        </div>
@@ -97,25 +97,17 @@
  ProForm,
  ProFormItemV2,
  ChunkCell,
  ProFormText,
  ProTableQueryFilterBar,
  QueryFilterItem,
  SearchInput,
  ProFormCol,
  ProFormColItem,
  ProFormDatePicker,
  ProFormInputNumber,
  useTable,
  ProTableV2,
  ProFormRadio,
  FieldSelect,
  defineOperationBtns,
  useFormDialog,
  ProFormUpload,
  UploadUserFile,
} from '@bole-core/components';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import { OrderInputType } from '@bole-core/core';
import { downloadFileByUrl, OrderInputType } from '@bole-core/core';
import { InsuranceAddOrReduceTempPath, InsuranceChangeTempPath } from '@/constants';
defineOptions({
  name: 'BatchChange',
@@ -211,7 +203,12 @@
function handleClear() {}
function handleSubmit() {}
function handleTemplateDownload() {}
function DownloadAddOrReducePersonTemplate() {
  downloadFileByUrl(InsuranceAddOrReduceTempPath, '加减人模板');
}
function downloadReplacePersonTemplate() {
  downloadFileByUrl(InsuranceChangeTempPath, '替换人模板');
}
onMounted(async () => {
  await getBatchRefundInfoDetail();
@@ -223,6 +220,8 @@
@use '@/style/common.scss' as *;
.chuck-add-or-edit-actions {
  //   margin-bottom: 20px;
  &.btn {
    margin-bottom: 20px;
  }
}
</style>
src/views/Home/Home.vue
@@ -44,25 +44,16 @@
          </QueryFilterItem>
        </template>
        <template #btn>
          <el-button
            @click="handleDownload()"
            icon="Download"
            type="primary"
            style="margin-right: 10px"
            link
          <el-button @click="handleDownload()" type="primary" style="margin-right: 10px" link
            >模板下载</el-button
          >
          <el-button @click="handleUpload()" icon="Upload" type="primary" style="margin-right: 10px"
          <el-button @click="handleUpload()" type="primary" style="margin-right: 10px"
            >导入</el-button
          >
          <el-button @click="downloadInsureOrder()" type="primary" icon="Download" link
            >导出保单列表</el-button
          >
          <el-button @click="downloadInsurePerson()" icon="Download" type="primary" link
            >导出在保人员</el-button
          >
          <el-button @click="downloadInsureOrder()" type="primary" link>导出保单列表</el-button>
          <el-button @click="downloadInsurePerson()" type="primary" link>导出在保人员</el-button>
        </template>
      </ProTableQueryFilterBar>
      <ProTableV2
@@ -92,10 +83,8 @@
  useTable,
  useFormDialog,
  FieldDatePicker,
  BlFileUpload,
  defineOperationBtns,
  UploadUserFile,
  XLSXUtils,
  SearchInput,
  FieldRadio,
} from '@bole-core/components';
@@ -104,16 +93,9 @@
import { columns } from './constants';
import UploadInsurePersonDialog from './components/UploadInsurePersonDialog.vue';
import UploadStampFileDialog from './components/UploadStampFileDialog.vue';
import { toThousand, format, downloadFile, setOSSLink } from '@/utils';
import { omit } from 'lodash';
import { format, downloadFile, setOSSLink } from '@/utils';
import { ModelValueType } from 'element-plus';
import { useQueryClient } from '@tanstack/vue-query';
import {
  InsuranceOrderTempPath,
  JYBInsuranceOrderTempPath,
  OnJobFlagEnumText,
  insuranceTypeText,
} from '@/constants';
import { InsuranceOrderTempPath, OnJobFlagEnumText, insuranceTypeText } from '@/constants';
import dayjs from 'dayjs';
import _ from 'lodash';
@@ -139,9 +121,9 @@
    emits: {
      onClick: (role) => handleBatch(role),
    },
    extraProps: {
      hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    },
    // extraProps: {
    //   hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    // },
  },
  {
    data: {
@@ -286,10 +268,10 @@
}
function handleDownload() {
  downloadFileByUrl(JYBInsuranceOrderTempPath, '保单导入模板');
  downloadFileByUrl(InsuranceOrderTempPath, '保单导入模板');
}
function handleRowStyle(data: { row: API.InsuranceOrderListOutput; rowIndex: number }) {
function handleRowStyle(data: { row: API.InsuranceOrderListOutput }) {
  if (
    dayjs(dayjs(data.row?.insuranceEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') >= 0 &&
    dayjs(dayjs(data.row?.insuranceEndTime).format('YYYY-MM-DD')).diff(dayjs(), 'day') < 6
src/views/Home/InsuranceOrderDetail.vue
@@ -28,7 +28,6 @@
}
const state = reactive({
  activeIndex: 1,
  tabType: InsureOrderTabType.InsureOrderInfo,
});
</script>
src/views/Home/components/BatchDownsizingDialog.vue
@@ -43,7 +43,7 @@
</template>
<script setup lang="ts">
import { JYBInsuranceOrderTempPath } from '@/constants';
import { InsuranceOrderTempPath } from '@/constants';
import {
  ProDialog,
  UploadUserFile,
@@ -121,6 +121,6 @@
}
function downloadImportEntryStaff() {
  downloadFileByUrl(JYBInsuranceOrderTempPath, '保单导入模板');
  downloadFileByUrl(InsuranceOrderTempPath, '保单导入模板');
}
</script>
src/views/Home/components/InsureOrderInfoView.vue
@@ -80,17 +80,11 @@
            </QueryFilterItem>
          </template>
          <template #btn>
            <el-button @click="handleTemplateDownload()" icon="Download" type="primary"
              >模板下载</el-button
            >
            <el-button @click="handleImport()" icon="Download" type="primary">导入</el-button>
            <el-button @click="handleClear()" icon="Download" type="primary">清空数据</el-button>
            <el-button @click="handleDownloadPerson()" icon="Download" type="primary"
              >人员清单下载</el-button
            >
            <el-button @click="handleDownloadOrder()" icon="Download" type="primary"
              >保单下载</el-button
            >
            <el-button @click="handleTemplateDownload()" link type="primary">模板下载</el-button>
            <el-button @click="handleImport()" type="primary">导入</el-button>
            <el-button @click="handleClear()" type="primary">清空数据</el-button>
            <el-button @click="handleDownloadPerson()" type="primary">人员清单下载</el-button>
            <el-button @click="handleDownloadOrder()" type="primary">保单下载</el-button>
          </template>
        </ProTableQueryFilterBar>
        <ProTableV2
@@ -131,11 +125,11 @@
  defineOperationBtns,
  useFormDialog,
} from '@bole-core/components';
import { insuranceTypeText } from '@/constants';
import { InsuranceOrderTempPath, insuranceTypeText } from '@/constants';
import ChangePersonInfoDialog from './ChangePersonInfoDialog.vue';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { OrderInputType } from '@bole-core/core';
import { downloadFileByUrl, OrderInputType } from '@bole-core/core';
defineOptions({
  name: 'InsureOrderInfoView',
@@ -208,9 +202,9 @@
    emits: {
      onClick: (role) => handleChangeInfo(role),
    },
    extraProps: {
      hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    },
    // extraProps: {
    //   hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    // },
  },
  {
    data: {
@@ -218,11 +212,11 @@
      name: '理赔详情',
    },
    emits: {
      onClick: (role) => handleInsureClaimDetail(),
      onClick: (role) => handleInsureClaimDetail(role),
    },
    extraProps: {
      hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    },
    // extraProps: {
    //   hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    // },
  },
]);
@@ -292,19 +286,21 @@
  }
);
function handleTemplateDownload() {}
function handleTemplateDownload() {
  downloadFileByUrl(InsuranceOrderTempPath, '人员信息模板');
}
function handleClear() {}
function handleImport() {}
function handleDownloadPerson() {}
function handleDownloadOrder() {}
function handleBatchChange() {
  // router.push({
  //   name: 'BatchChange',
  //   params: {
  //     id: id,
  //   },
  // });
  router.push({
    name: 'BatchChange',
    params: {
      id: id,
    },
  });
}
const { dialogProps, handleEdit, editForm } = useFormDialog({
@@ -322,7 +318,17 @@
async function changeInfo() {}
function handleInsureClaimDetail() {}
function handleInsureClaimDetail(row: API.InsuranceOrderListOutput) {
  router.push({
    name: 'InsuranceClaimDetail',
    params: {
      id: row.id,
    },
    query: {
      fromRoute: 'InsuranceOrderDetail',
    },
  });
}
</script>
<style lang="scss" scoped>
src/views/Home/components/UploadInsurePersonDialog.vue
@@ -6,6 +6,7 @@
    draggable
    bodyNoPaddingBottom
    @close="onDialogClose"
    width="600px"
  >
    <ProForm :model="innerForm" ref="dialogForm" label-width="120px">
      <ProFormItemV2
src/views/Home/components/UploadStampFileDialog.vue
@@ -6,6 +6,7 @@
    draggable
    bodyNoPaddingBottom
    @close="onDialogClose"
    width="600px"
  >
    <ProForm :model="innerForm" ref="dialogForm" label-width="120px">
      <ProFormItemV2
src/views/Home/constants/index.ts
@@ -2,12 +2,6 @@
export const columns = defineColumns([
  {
    id: '1',
    enCode: 'channel',
    name: '渠道',
    width: 160,
  },
  {
    id: '2',
    enCode: 'channel',
    name: '批次号',
src/views/InsuranceClaim/InsuranceClaim.vue
@@ -1,9 +1,9 @@
<template>
  <InsuranceClaimDetailView></InsuranceClaimDetailView>
  <InsuranceClaimView></InsuranceClaimView>
</template>
<script setup lang="ts">
import InsuranceClaimDetailView from './InsuranceClaimDetail.vue';
import InsuranceClaimView from './components/InsuranceClaimView.vue';
defineOptions({
  name: 'InsuranceClaim',
src/views/InsuranceClaim/InsuranceClaimDetail.vue
@@ -1,587 +1,11 @@
<template>
  <LoadingLayout :loading="isLoading">
    <AppScrollContainer>
      <ChunkCell title="报案信息">
        <ProForm :model="form" ref="formRef" label-width="120px">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="身份证号码:"
                prop="idNumber"
                :check-rules="[{ message: '请输入身份证号码', type: 'idCard' }]"
              >
                <ProFormText
                  v-model.trim="form.idNumber"
                  placeholder="请输入身份证号码"
                  @change="handleIdNumberChange"
                />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="报案时间:"
                prop="reportedTime"
                :check-rules="[{ message: '请选择报案时间' }]"
              >
                <ProFormDatePicker
                  v-model="form.reportedTime"
                  type="datetime"
                  format="YYYY-MM-DD HH:mm:ss"
                  value-format="YYYY-MM-DD HH:mm:ss"
                  placeholder="请选择报案时间"
                  :disabled-date="disabledReportedDate"
                  @change="handleReportedTimeChange"
                  :key="datePickerKey"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="联系电话:"
                prop="contactNumber"
                :check-rules="[{ message: '请输入联系电话', type: 'phone' }]"
              >
                <ProFormText v-model.trim="form.contactNumber" placeholder="请输入联系电话" />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="备用联系电话:"
                prop="bakContactNumber"
                :check-rules="[{ message: '请输入备用联系电话', type: 'phone', required: false }]"
              >
                <ProFormText
                  v-model.trim="form.bakContactNumber"
                  placeholder="请输入备用联系电话"
                />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入姓名' }]">
                <ProFormText v-model.trim="form.name" placeholder="请输入姓名" :maxlength="30" />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
        </ProForm>
      </ChunkCell>
      <ChunkCell title="保单信息">
        <ProForm :model="form" ref="insuranceBaseFormRef" label-width="120px">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="参保机构:"
                prop="insuredInstitution"
                :check-rules="[{ message: '请选择参保机构' }]"
              >
                <ProFormSelect
                  placeholder="请选择参保机构"
                  :value-enum="InsuredInstitutionEnum"
                  clearable
                  v-model="form.insuredInstitution"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="投保方案:"
                prop="insuranceScheme"
                :check-rules="[{ message: '请选择投保方案' }]"
              >
                <ProFormSelect
                  placeholder="请选择投保方案"
                  :value-enum="InsuranceSchemeEnum"
                  clearable
                  v-model="form.insuranceScheme"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormMixinsItemContainer>
            <ProFormCol>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="起保日期:" prop="insuranceBeginTime" mode="read">
                  <ProFormDatePicker
                    v-model="form.insuranceBeginTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder="请选择起保日期"
                  ></ProFormDatePicker>
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="劳动合同单位:" prop="laborContractEnterprise" mode="read">
                  <ProFormText
                    v-model.trim="form.laborContractEnterprise"
                    placeholder="请输入劳动合同单位"
                  />
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="工种:" prop="workType" mode="read">
                  <ProFormText v-model.trim="form.workType" placeholder="请输入工种" />
                </ProFormItemV2>
              </ProFormColItem>
            </ProFormCol>
          </ProFormMixinsItemContainer>
          <ProFormMixinsItemContainer>
            <ProFormCol>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="终保日期:" prop="insuranceEndTime" mode="read">
                  <ProFormDatePicker
                    v-model="form.insuranceEndTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder="请选择终保日期"
                  ></ProFormDatePicker>
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="实际工作单位:" prop="workEnterprise" mode="read">
                  <ProFormText
                    v-model.trim="form.workEnterprise"
                    placeholder="请输入实际工作单位"
                  />
                </ProFormItemV2>
              </ProFormColItem>
            </ProFormCol>
          </ProFormMixinsItemContainer>
        </ProForm>
      </ChunkCell>
      <ChunkCell title="保单信息">
        <ProForm :model="form" ref="insuranceFormRef" label-width="120px">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="事故类型:"
                prop="accidentType"
                :check-rules="[{ message: '请选择事故类型' }]"
              >
                <ProFormSelect
                  placeholder="请选择事故类型"
                  :value-enum="AccidentTypeEnum"
                  clearable
                  v-model="form.accidentType"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="事故发生时间:"
                prop="accidentTime"
                :check-rules="[{ message: '请选择事故发生时间' }]"
              >
                <ProFormDatePicker
                  v-model="form.accidentTime"
                  type="datetime"
                  format="YYYY-MM-DD HH:mm:ss"
                  placeholder="请选择事故发生时间"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="伤残比例:" prop="disabilityRatio">
                <ProFormInputNumber
                  v-model="form.disabilityRatio"
                  :controls="false"
                  :min="0"
                  :max="100"
                  unit="%"
                ></ProFormInputNumber>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="18">
              <ProFormItemV2
                label="事发地点:"
                prop="accidentAddress"
                :check-rules="[{ message: '请输入事发地点' }]"
              >
                <ProFormText
                  v-model.trim="form.accidentAddress"
                  placeholder="请输入事发地点"
                  :maxlength="100"
                />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="24">
              <ProFormItemV2
                label="事故经过:"
                prop="accidentProcess"
                :check-rules="[{ message: '请输入事故经过' }]"
              >
                <ProFormTextArea
                  v-model="form.accidentProcess"
                  :rows="10"
                  placeholder="请输入事故经过"
                  :maxlength="500"
                  show-word-limit
                ></ProFormTextArea>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <div class="attachments-wrapper">
            <div class="attachments">
              <ProFormItemV2 label="伤者身份证照片(正反):">
                <div class="id-imgUrl-wrapper">
                  <ProFormItemV2 prop="attachmentFrontIdCards" class="pro-form-item-label-hidden">
                    <ProFormImageUpload
                      v-model:file-url="form.attachmentFrontIdCards"
                      :limitFileSize="10"
                      btnText="身份证人像面"
                      :showTip="false"
                    >
                    </ProFormImageUpload>
                  </ProFormItemV2>
                  <ProFormItemV2 prop="attachmentBackIdCards" class="pro-form-item-label-hidden">
                    <ProFormImageUpload
                      v-model:file-url="form.attachmentBackIdCards"
                      :limitFileSize="10"
                      btnText="身份证国徽面"
                      :showTip="false"
                    >
                    </ProFormImageUpload>
                  </ProFormItemV2>
                </div>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentSites" label="受伤场地:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentSites"
                  :limitFileSize="10"
                  :showTip="false"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentHandheldIdCards" label="伤者手持身份证照:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentHandheldIdCards"
                  :limitFileSize="10"
                  :showTip="false"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentAreas" label="受伤部位:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentAreas"
                  :limitFileSize="10"
                  :showTip="false"
                  :limitFileCount="0"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentCases" label="病例照片:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentCases"
                  :limitFileSize="10"
                  :showTip="false"
                  :limitFileCount="0"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
            </div>
            <ClaimPicDemoView />
          </div>
          <div class="chuck-add-or-edit-actions">
            <el-button @click="handleBack">关闭</el-button>
            <el-button type="primary" @click="handleSubmit">提交</el-button>
          </div>
        </ProForm>
      </ChunkCell>
      <!-- <ChunkCell title="理赔结果">
        <ProForm :model="form" ref="claimFormRef" label-width="120px">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="理赔结果:" prop="claimResult">
                <ProFormSelect
                  placeholder="请选择理赔结果"
                  :value-enum="InsuranceClaimResultEnumText"
                  clearable
                  v-model="form.claimResult"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="结/撤案时间:" prop="claimResultTime">
                <ProFormDatePicker
                  v-model="form.claimResultTime"
                  type="datetime"
                  format="YYYY-MM-DD"
                  value-format="YYYY-MM-DD"
                  placeholder="请选择结/撤案时间"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormItemV2 label="下款金额:" prop="downPaymentAmount">
            <ProFormInputNumber
              v-model="form.downPaymentAmount"
              :controls="false"
              :min="0"
              :precision="2"
            ></ProFormInputNumber>
          </ProFormItemV2>
          <div class="chuck-add-or-edit-actions">
            <el-button @click="handleBack">关闭</el-button>
            <el-button type="primary" @click="handleSubmit">提交</el-button>
          </div>
        </ProForm>
      </ChunkCell> -->
    </AppScrollContainer>
    <SelectOrderDialog v-bind="dialogProps" />
  </LoadingLayout>
  <InsuranceClaimView :isDetail="true"></InsuranceClaimView>
</template>
<script setup lang="ts">
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import * as insuranceClaimServices from '@/services/api/InsuranceClaim';
import {
  ChunkCell,
  AppScrollContainer,
  LoadingLayout,
  ProForm,
  ProFormCol,
  ProFormColItem,
  ProFormText,
  ProFormDatePicker,
  ProFormSelect,
  ProFormImageUpload,
  ProFormTextArea,
  ProFormItemV2,
  ProFormMixinsItemContainer,
  ProFormInputNumber,
  useFormDialog,
} from '@bole-core/components';
import { FormInstance, DatePickerInstance } from 'element-plus';
import { validateFormList, format } from '@/utils';
import { convertFormToattAchments } from './utils';
import {
  InsuredInstitutionEnum,
  InsuranceSchemeEnum,
  AccidentTypeEnum,
  InsuranceClaimAttachmentBusinessTypeEnum,
  InsuranceClaimResultEnumText,
} from '@/constants';
import { useRouteView } from '@/hooks';
import { Message, BoleRegExp } from '@bole-core/core';
import { useInsuranceClaimDetail, useInsuranceOrderListByOrderRelevance } from './hooks';
import ClaimPicDemoView from './components/ClaimPicDemoView.vue';
import SelectOrderDialog from './components/SelectOrderDialog.vue';
import { useQueryClient } from '@tanstack/vue-query';
import InsuranceClaimView from './components/InsuranceClaimView.vue';
defineOptions({
  name: 'InsuranceClaimDetail',
  name: 'InsuranceClaim',
});
const route = useRoute();
const insuranceOrderId = (route.params.id as string) ?? '';
const { closeViewPush } = useRouteView();
const datePickerKey = ref(1);
const { form, isLoading, claimDetail, disabledReportedDate, queryClaimDetailByOrderId, resetForm } =
  useInsuranceClaimDetail({
    insuranceOrderId,
  });
// const { existedInsuranceOrderList } = useInsuranceOrderListByOrderRelevance({
//   params: computed(() => ({
//     idIdNumber: form.idNumber,
//     reportedTime: form.reportedTime,
//   })),
//   onSuccess(data) {
//     if (data.length == 1) {
//       // importInsuranceOrderData(data[0]);
//       form.insuranceOrderId = data[0].id;
//     } else if (data.length > 1) {
//       handleAdd({
//         insuranceOrderList: data,
//       });
//     }
//   },
// });
const { dialogProps, handleAdd, editForm } = useFormDialog({
  onConfirm: handleSelectedOrder,
  defaultFormParams: {
    insuranceOrderId: '',
    insuranceOrderList: [] as API.InsuranceOrderListOutput[],
  },
});
async function handleSelectedOrder() {
  try {
    datePickerKey.value += 1;
    resetForm();
    await nextTick();
    form.insuranceOrderId = editForm.insuranceOrderId;
    // let claimDetail = await queryClaimDetailByOrderId();
    // if (claimDetail) {
    //   Message.errorMessage('该保单已理赔');
    // }
  } catch (error) {}
}
const queryClient = useQueryClient();
async function ensureInsuranceOrderList() {
  try {
    if (BoleRegExp.RegIDCard.test(form.idNumber) && !!form.reportedTime) {
      let params: API.QueryInsuranceOrderListByOrderRelevanceInput = {
        idIdNumber: form.idNumber,
        reportedTime: form.reportedTime,
      };
      let existedInsuranceOrderList = await queryClient.ensureQueryData({
        queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance', params],
        queryFn: async () => {
          return await insuranceOrderServices.getInsuranceOrderListByOrderRelevance(params, {
            showLoading: false,
          });
        },
      });
      if (existedInsuranceOrderList.length == 1) {
        form.insuranceOrderId = existedInsuranceOrderList[0].id;
      } else if (existedInsuranceOrderList.length > 1) {
        handleAdd({
          insuranceOrderList: existedInsuranceOrderList,
        });
      } else {
        Message.errorMessage('未找到匹配的保单信息');
      }
    }
    // return existedInsuranceOrderList;
  } catch (error) {}
}
function handleIdNumberChange() {
  ensureInsuranceOrderList();
}
function handleReportedTimeChange() {
  if (form.accidentTime === '') {
    form.accidentTime = form.reportedTime;
  }
  ensureInsuranceOrderList();
}
const formRef = ref<FormInstance>();
const insuranceBaseFormRef = ref<FormInstance>();
const insuranceFormRef = ref<FormInstance>();
const claimFormRef = ref<FormInstance>();
async function handleSubmit() {
  try {
    const valid = await validateFormList([
      formRef.value,
      insuranceBaseFormRef.value,
      insuranceFormRef.value,
    ]);
    if (valid) {
      addInsuranceClaim();
    }
  } catch (error) {}
}
async function addInsuranceClaim() {
  try {
    if (claimDetail.value === undefined) {
      Message.errorMessage('未找到匹配的保单信息');
      return;
    }
    let params: API.AddInsuranceClaimInput = {
      channel: form.channel,
      name: form.name,
      idNumber: form.idNumber,
      workType: form.workType,
      laborContractEnterprise: form.laborContractEnterprise,
      workEnterprise: form.workEnterprise,
      insuranceBeginTime: format(form.insuranceBeginTime),
      insuranceEndTime: format(form.insuranceEndTime),
      insuredInstitution: form.insuredInstitution,
      insuranceScheme: form.insuranceScheme,
      onJobFlag: form.onJobFlag,
      gender: form.gender,
      age: form.age,
      premiumAmount: form.premiumAmount,
      incDecAmount: form.incDecAmount,
      insuranceOrderId: form.insuranceOrderId,
      reportedTime: format(form.reportedTime, 'YYYY-MM-DD HH:mm:ss'),
      contactNumber: form.contactNumber,
      bakContactNumber: form.bakContactNumber,
      accidentType: form.accidentType,
      accidentTime: format(form.accidentTime, 'YYYY-MM-DD HH:mm:ss'),
      // disabilityRatio: form.disabilityRatio,
      accidentAddress: form.accidentAddress,
      accidentProcess: form.accidentProcess,
      // claimResult: form.claimResult,
      // claimResultTime: form.claimResultTime,
      attachments: [
        ...convertFormToattAchments(
          form.attachmentFrontIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentBackIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentSites,
          InsuranceClaimAttachmentBusinessTypeEnum.InjurySiteImg
        ),
        ...convertFormToattAchments(
          form.attachmentHandheldIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredHandheldIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentAreas,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredAreaImg
        ),
        ...convertFormToattAchments(
          form.attachmentCases,
          InsuranceClaimAttachmentBusinessTypeEnum.CasesImg
        ),
      ],
    };
    // if (form.downPaymentAmount) params.downPaymentAmount = form.downPaymentAmount;
    if (form.disabilityRatio) params.disabilityRatio = form.disabilityRatio;
    let res: number;
    // if (!!claimDetail.value) {
    //   Message.errorMessage('该保单已理赔');
    // } else {
    res = await insuranceClaimServices.addInsuranceClaim(params);
    // }
    if (res) {
      Message.successMessage('操作成功');
      handleBack();
    }
  } catch (error) {}
}
function handleBack() {
  closeViewPush(route, {
    name: 'Home',
  });
}
</script>
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
.attachments-wrapper {
  position: relative;
  display: flex;
  .attachments {
    flex: 1;
    min-width: 0;
  }
}
.id-imgUrl-wrapper {
  display: flex;
  gap: 40px;
}
</style>
src/views/InsuranceClaim/components/InsuranceClaimView.vue
New file
@@ -0,0 +1,602 @@
<template>
  <LoadingLayout :loading="isLoading">
    <AppScrollContainer>
      <ChunkCell title="报案信息">
        <ProForm :model="form" ref="formRef" label-width="120px" :is-read="isDetail">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="身份证号码:"
                prop="idNumber"
                :check-rules="[{ message: '请输入身份证号码', type: 'idCard' }]"
              >
                <ProFormText
                  v-model.trim="form.idNumber"
                  placeholder="请输入身份证号码"
                  @change="handleIdNumberChange"
                />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="报案时间:"
                prop="reportedTime"
                :check-rules="[{ message: '请选择报案时间' }]"
              >
                <ProFormDatePicker
                  v-model="form.reportedTime"
                  type="datetime"
                  format="YYYY-MM-DD HH:mm:ss"
                  value-format="YYYY-MM-DD HH:mm:ss"
                  placeholder="请选择报案时间"
                  :disabled-date="disabledReportedDate"
                  @change="handleReportedTimeChange"
                  :key="datePickerKey"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="联系电话:"
                prop="contactNumber"
                :check-rules="[{ message: '请输入联系电话', type: 'phone' }]"
              >
                <ProFormText v-model.trim="form.contactNumber" placeholder="请输入联系电话" />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="备用联系电话:"
                prop="bakContactNumber"
                :check-rules="[{ message: '请输入备用联系电话', type: 'phone', required: false }]"
              >
                <ProFormText
                  v-model.trim="form.bakContactNumber"
                  placeholder="请输入备用联系电话"
                />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="姓名:" prop="name" :check-rules="[{ message: '请输入姓名' }]">
                <ProFormText v-model.trim="form.name" placeholder="请输入姓名" :maxlength="30" />
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="保单号:"
                prop="name"
                :check-rules="[{ message: '请输入保单号' }]"
              >
                <ProFormText v-model.trim="form.name" placeholder="请输入保单号" :maxlength="30" />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
        </ProForm>
      </ChunkCell>
      <ChunkCell title="保单信息">
        <ProForm :model="form" ref="insuranceBaseFormRef" label-width="120px" :is-read="isDetail">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="参保机构:"
                prop="insuredInstitution"
                :check-rules="[{ message: '请选择参保机构' }]"
              >
                <ProFormSelect
                  placeholder="请选择参保机构"
                  :value-enum="InsuredInstitutionEnum"
                  clearable
                  v-model="form.insuredInstitution"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="投保方案:"
                prop="insuranceScheme"
                :check-rules="[{ message: '请选择投保方案' }]"
              >
                <ProFormSelect
                  placeholder="请选择投保方案"
                  :value-enum="InsuranceSchemeEnum"
                  clearable
                  v-model="form.insuranceScheme"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormMixinsItemContainer>
            <ProFormCol>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="起保日期:" prop="insuranceBeginTime" mode="read">
                  <ProFormDatePicker
                    v-model="form.insuranceBeginTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder="请选择起保日期"
                  ></ProFormDatePicker>
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="投保人:" prop="laborContractEnterprise" mode="read">
                  <ProFormText
                    v-model.trim="form.laborContractEnterprise"
                    placeholder="请输入投保人"
                  />
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="工种:" prop="workType" mode="read">
                  <ProFormText v-model.trim="form.workType" placeholder="请输入工种" />
                </ProFormItemV2>
              </ProFormColItem>
            </ProFormCol>
          </ProFormMixinsItemContainer>
          <ProFormMixinsItemContainer>
            <ProFormCol>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="终保日期:" prop="insuranceEndTime" mode="read">
                  <ProFormDatePicker
                    v-model="form.insuranceEndTime"
                    type="date"
                    value-format="YYYY-MM-DD"
                    placeholder="请选择终保日期"
                  ></ProFormDatePicker>
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="被保人:" prop="workEnterprise" mode="read">
                  <ProFormText v-model.trim="form.workEnterprise" placeholder="请输入被保人" />
                </ProFormItemV2>
              </ProFormColItem>
            </ProFormCol>
          </ProFormMixinsItemContainer>
        </ProForm>
      </ChunkCell>
      <ChunkCell title="保单信息">
        <ProForm :model="form" ref="insuranceFormRef" label-width="160px" :is-read="isDetail">
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="事故类型:"
                prop="accidentType"
                :check-rules="[{ message: '请选择事故类型' }]"
              >
                <ProFormSelect
                  placeholder="请选择事故类型"
                  :value-enum="AccidentTypeEnum"
                  clearable
                  v-model="form.accidentType"
                ></ProFormSelect>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="6">
              <ProFormItemV2
                label="事故发生时间:"
                prop="accidentTime"
                :check-rules="[{ message: '请选择事故发生时间' }]"
              >
                <ProFormDatePicker
                  v-model="form.accidentTime"
                  type="datetime"
                  format="YYYY-MM-DD HH:mm:ss"
                  placeholder="请选择事故发生时间"
                ></ProFormDatePicker>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="6">
              <ProFormItemV2 label="伤残比例:" prop="disabilityRatio">
                <ProFormInputNumber
                  v-model="form.disabilityRatio"
                  :controls="false"
                  :min="0"
                  :max="100"
                  unit="%"
                ></ProFormInputNumber>
              </ProFormItemV2>
            </ProFormColItem>
            <ProFormColItem :span="18">
              <ProFormItemV2
                label="事发地点:"
                prop="accidentAddress"
                :check-rules="[{ message: '请输入事发地点' }]"
              >
                <ProFormText
                  v-model.trim="form.accidentAddress"
                  placeholder="请输入事发地点"
                  :maxlength="100"
                />
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <ProFormCol>
            <ProFormColItem :span="24">
              <ProFormItemV2
                label="事故经过:"
                prop="accidentProcess"
                :check-rules="[{ message: '请输入事故经过' }]"
              >
                <ProFormTextArea
                  v-model="form.accidentProcess"
                  :rows="10"
                  placeholder="请输入事故经过"
                  :maxlength="500"
                  show-word-limit
                ></ProFormTextArea>
              </ProFormItemV2>
            </ProFormColItem>
          </ProFormCol>
          <div class="attachments-wrapper">
            <div class="attachments">
              <ProFormItemV2 label="伤者身份证照片(正反):">
                <div class="id-imgUrl-wrapper">
                  <ProFormItemV2 prop="attachmentFrontIdCards" class="pro-form-item-label-hidden">
                    <ProFormImageUpload
                      v-model:file-url="form.attachmentFrontIdCards"
                      :limitFileSize="10"
                      btnText="身份证人像面"
                      :showTip="false"
                    >
                    </ProFormImageUpload>
                  </ProFormItemV2>
                  <ProFormItemV2 prop="attachmentBackIdCards" class="pro-form-item-label-hidden">
                    <ProFormImageUpload
                      v-model:file-url="form.attachmentBackIdCards"
                      :limitFileSize="10"
                      btnText="身份证国徽面"
                      :showTip="false"
                    >
                    </ProFormImageUpload>
                  </ProFormItemV2>
                </div>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentSites" label="受伤场地:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentSites"
                  :limitFileSize="10"
                  :showTip="false"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentHandheldIdCards" label="伤者手持身份证照:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentHandheldIdCards"
                  :limitFileSize="10"
                  :showTip="false"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentAreas" label="受伤部位:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentAreas"
                  :limitFileSize="10"
                  :showTip="false"
                  :limitFileCount="0"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
              <ProFormItemV2 prop="attachmentCases" label="病例照片:">
                <ProFormImageUpload
                  v-model:file-url="form.attachmentCases"
                  :limitFileSize="10"
                  :showTip="false"
                  :limitFileCount="0"
                >
                </ProFormImageUpload>
              </ProFormItemV2>
            </div>
            <ClaimPicDemoView />
          </div>
          <div class="chuck-add-or-edit-actions">
            <el-button @click="handleBack">关闭</el-button>
            <el-button v-if="!isDetail" type="primary" @click="handleSubmit">提交</el-button>
          </div>
        </ProForm>
      </ChunkCell>
      <!-- <ChunkCell title="理赔结果">
          <ProForm :model="form" ref="claimFormRef" label-width="120px">
            <ProFormCol>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="理赔结果:" prop="claimResult">
                  <ProFormSelect
                    placeholder="请选择理赔结果"
                    :value-enum="InsuranceClaimResultEnumText"
                    clearable
                    v-model="form.claimResult"
                  ></ProFormSelect>
                </ProFormItemV2>
              </ProFormColItem>
              <ProFormColItem :span="6">
                <ProFormItemV2 label="结/撤案时间:" prop="claimResultTime">
                  <ProFormDatePicker
                    v-model="form.claimResultTime"
                    type="datetime"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD"
                    placeholder="请选择结/撤案时间"
                  ></ProFormDatePicker>
                </ProFormItemV2>
              </ProFormColItem>
            </ProFormCol>
            <ProFormItemV2 label="下款金额:" prop="downPaymentAmount">
              <ProFormInputNumber
                v-model="form.downPaymentAmount"
                :controls="false"
                :min="0"
                :precision="2"
              ></ProFormInputNumber>
            </ProFormItemV2>
            <div class="chuck-add-or-edit-actions">
              <el-button @click="handleBack">关闭</el-button>
              <el-button type="primary" @click="handleSubmit">提交</el-button>
            </div>
          </ProForm>
        </ChunkCell> -->
    </AppScrollContainer>
    <SelectOrderDialog v-bind="dialogProps" />
  </LoadingLayout>
</template>
<script setup lang="ts">
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import * as insuranceClaimServices from '@/services/api/InsuranceClaim';
import {
  ChunkCell,
  AppScrollContainer,
  LoadingLayout,
  ProForm,
  ProFormCol,
  ProFormColItem,
  ProFormText,
  ProFormDatePicker,
  ProFormSelect,
  ProFormImageUpload,
  ProFormTextArea,
  ProFormItemV2,
  ProFormMixinsItemContainer,
  ProFormInputNumber,
  useFormDialog,
} from '@bole-core/components';
import { FormInstance, DatePickerInstance } from 'element-plus';
import { validateFormList, format } from '@/utils';
import {
  InsuredInstitutionEnum,
  InsuranceSchemeEnum,
  AccidentTypeEnum,
  InsuranceClaimAttachmentBusinessTypeEnum,
  InsuranceClaimResultEnumText,
} from '@/constants';
import { useRouteView } from '@/hooks';
import { Message, BoleRegExp } from '@bole-core/core';
import ClaimPicDemoView from './ClaimPicDemoView.vue';
import SelectOrderDialog from './SelectOrderDialog.vue';
import { useQueryClient } from '@tanstack/vue-query';
import { convertFormToattAchments } from '../utils';
import { useInsuranceClaimDetail } from '../hooks';
defineOptions({
  name: 'InsuranceClaimDetail',
});
type Props = {
  isDetail?: boolean;
};
const props = withDefaults(defineProps<Props>(), {
  isDetail: false,
});
const route = useRoute();
const insuranceOrderId = (route.params.id as string) ?? '';
const fromRoute = route.query.fromRoute as string;
const { closeViewPush } = useRouteView();
const datePickerKey = ref(1);
const { form, isLoading, claimDetail, disabledReportedDate, queryClaimDetailByOrderId, resetForm } =
  useInsuranceClaimDetail({
    insuranceOrderId,
  });
// const { existedInsuranceOrderList } = useInsuranceOrderListByOrderRelevance({
//   params: computed(() => ({
//     idIdNumber: form.idNumber,
//     reportedTime: form.reportedTime,
//   })),
//   onSuccess(data) {
//     if (data.length == 1) {
//       // importInsuranceOrderData(data[0]);
//       form.insuranceOrderId = data[0].id;
//     } else if (data.length > 1) {
//       handleAdd({
//         insuranceOrderList: data,
//       });
//     }
//   },
// });
const { dialogProps, handleAdd, editForm } = useFormDialog({
  onConfirm: handleSelectedOrder,
  defaultFormParams: {
    insuranceOrderId: '',
    insuranceOrderList: [] as API.InsuranceOrderListOutput[],
  },
});
async function handleSelectedOrder() {
  try {
    datePickerKey.value += 1;
    resetForm();
    await nextTick();
    form.insuranceOrderId = editForm.insuranceOrderId;
    // let claimDetail = await queryClaimDetailByOrderId();
    // if (claimDetail) {
    //   Message.errorMessage('该保单已理赔');
    // }
  } catch (error) {}
}
const queryClient = useQueryClient();
async function ensureInsuranceOrderList() {
  try {
    if (BoleRegExp.RegIDCard.test(form.idNumber) && !!form.reportedTime) {
      let params: API.QueryInsuranceOrderListByOrderRelevanceInput = {
        idIdNumber: form.idNumber,
        reportedTime: form.reportedTime,
      };
      let existedInsuranceOrderList = await queryClient.ensureQueryData({
        queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance', params],
        queryFn: async () => {
          return await insuranceOrderServices.getInsuranceOrderListByOrderRelevance(params, {
            showLoading: false,
          });
        },
      });
      if (existedInsuranceOrderList.length == 1) {
        form.insuranceOrderId = existedInsuranceOrderList[0].id;
      } else if (existedInsuranceOrderList.length > 1) {
        handleAdd({
          insuranceOrderList: existedInsuranceOrderList,
        });
      } else {
        Message.errorMessage('未找到匹配的保单信息');
      }
    }
    // return existedInsuranceOrderList;
  } catch (error) {}
}
function handleIdNumberChange() {
  ensureInsuranceOrderList();
}
function handleReportedTimeChange() {
  if (form.accidentTime === '') {
    form.accidentTime = form.reportedTime;
  }
  ensureInsuranceOrderList();
}
const formRef = ref<FormInstance>();
const insuranceBaseFormRef = ref<FormInstance>();
const insuranceFormRef = ref<FormInstance>();
const claimFormRef = ref<FormInstance>();
async function handleSubmit() {
  try {
    const valid = await validateFormList([
      formRef.value,
      insuranceBaseFormRef.value,
      insuranceFormRef.value,
    ]);
    if (valid) {
      addInsuranceClaim();
    }
  } catch (error) {}
}
async function addInsuranceClaim() {
  try {
    if (claimDetail.value === undefined) {
      Message.errorMessage('未找到匹配的保单信息');
      return;
    }
    let params: API.AddInsuranceClaimInput = {
      channel: form.channel,
      name: form.name,
      idNumber: form.idNumber,
      workType: form.workType,
      laborContractEnterprise: form.laborContractEnterprise,
      workEnterprise: form.workEnterprise,
      insuranceBeginTime: format(form.insuranceBeginTime),
      insuranceEndTime: format(form.insuranceEndTime),
      insuredInstitution: form.insuredInstitution,
      insuranceScheme: form.insuranceScheme,
      onJobFlag: form.onJobFlag,
      gender: form.gender,
      age: form.age,
      premiumAmount: form.premiumAmount,
      incDecAmount: form.incDecAmount,
      insuranceOrderId: form.insuranceOrderId,
      reportedTime: format(form.reportedTime, 'YYYY-MM-DD HH:mm:ss'),
      contactNumber: form.contactNumber,
      bakContactNumber: form.bakContactNumber,
      accidentType: form.accidentType,
      accidentTime: format(form.accidentTime, 'YYYY-MM-DD HH:mm:ss'),
      // disabilityRatio: form.disabilityRatio,
      accidentAddress: form.accidentAddress,
      accidentProcess: form.accidentProcess,
      // claimResult: form.claimResult,
      // claimResultTime: form.claimResultTime,
      attachments: [
        ...convertFormToattAchments(
          form.attachmentFrontIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentBackIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentSites,
          InsuranceClaimAttachmentBusinessTypeEnum.InjurySiteImg
        ),
        ...convertFormToattAchments(
          form.attachmentHandheldIdCards,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredHandheldIdCardImg
        ),
        ...convertFormToattAchments(
          form.attachmentAreas,
          InsuranceClaimAttachmentBusinessTypeEnum.InjuredAreaImg
        ),
        ...convertFormToattAchments(
          form.attachmentCases,
          InsuranceClaimAttachmentBusinessTypeEnum.CasesImg
        ),
      ],
    };
    // if (form.downPaymentAmount) params.downPaymentAmount = form.downPaymentAmount;
    if (form.disabilityRatio) params.disabilityRatio = form.disabilityRatio;
    let res: number;
    // if (!!claimDetail.value) {
    //   Message.errorMessage('该保单已理赔');
    // } else {
    res = await insuranceClaimServices.addInsuranceClaim(params);
    // }
    if (res) {
      Message.successMessage('操作成功');
      handleBack();
    }
  } catch (error) {}
}
function handleBack() {
  closeViewPush(route, {
    name: fromRoute ?? 'Home',
  });
}
</script>
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
.attachments-wrapper {
  position: relative;
  display: flex;
  .attachments {
    flex: 1;
    min-width: 0;
  }
}
.id-imgUrl-wrapper {
  display: flex;
  gap: 40px;
}
</style>