wupengfei
2025-03-21 cd4a07141ec97ff6c51dd7137462e506d8d0881f
src/views/Home/Home.vue
@@ -37,7 +37,7 @@
            <SearchInput
              v-model="extraParamState.keyword"
              style="width: 260px"
              placeholder="姓名/身份证/单位/保单号等"
              placeholder="单位/保单号/参保机构"
              @on-click-search="getList"
            >
            </SearchInput>
@@ -53,39 +53,22 @@
            >模板下载</el-button
          >
          <BlFileUpload
            :limitFileSize="10"
            accept="xls,xlsx"
            :showTip="false"
            :show-file-list="false"
            :on-success="handleUploadSuccess"
          <el-button @click="handleUpload()" icon="Upload" type="primary" style="margin-right: 10px"
            >导入</el-button
          >
            <template #default>
              <el-button icon="Plus" type="primary">导入</el-button>
            </template>
          </BlFileUpload>
          <el-button
            @click="handleEnterpriseBatchRefund()"
            type="primary"
            style="margin-right: 10px"
            >批量减员</el-button
          <el-button @click="downloadInsureOrder()" type="primary" icon="Download" link
            >导出保单列表</el-button
          >
          <el-button
            @click="handleExport()"
            icon="Download"
            type="primary"
            style="margin-left: 10px"
            >导出</el-button
          <el-button @click="downloadInsurePerson()" icon="Download" type="primary" link
            >导出在保人员</el-button
          >
        </template>
      </ProTableQueryFilterBar>
      <ProTableV2
        v-bind="proTableProps"
        :columns="HomeColumns"
        :columns="columns"
        :operationBtns="operationBtns"
        :show-column-check="true"
        :column-selectable="columnSelectable"
        ref="proTable"
        :table-props="{
          rowStyle: handleRowStyle,
@@ -94,11 +77,8 @@
      >
      </ProTableV2>
    </AppContainer>
    <UploadMaterialDialog
      v-bind="dialogProps"
      @onAddUpdateMaterial="getList(paginationState.pageIndex)"
    />
    <BatchDownsizingDialog v-bind="dialogBatchDownsizingProps" />
    <UploadInsurePersonDialog v-bind="dialogProps" />
    <UploadStampFileDialog v-bind="dialogStampFileProps" />
  </LoadingLayout>
</template>
@@ -121,9 +101,9 @@
} from '@bole-core/components';
import * as insuranceOrderServices from '@/services/api/InsuranceOrder';
import { Message, OrderInputType, downloadFileByUrl } from '@bole-core/core';
import { HomeColumns } from './constants';
import UploadMaterialDialog from './components/UploadMaterialDialog.vue';
import BatchDownsizingDialog from './components/BatchDownsizingDialog.vue';
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 { ModelValueType } from 'element-plus';
@@ -144,6 +124,39 @@
const operationBtns = defineOperationBtns([
  {
    data: {
      enCode: 'detailBtn',
      name: '详情',
    },
    emits: {
      onClick: (role) => handleDetail(role),
    },
  },
  {
    data: {
      enCode: 'batchBtn',
      name: '批改',
    },
    emits: {
      onClick: (role) => handleBatch(role),
    },
    extraProps: {
      hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    },
  },
  {
    data: {
      enCode: 'uploadStampFileBtn',
      name: '上传盖章文件',
    },
    emits: {
      onClick: (role) => handleUploadStampFile(role),
    },
    // extraProps: {
    //   hide: (row: API.InsuranceOrderListOutput) => !row.orderBillFile,
    // },
  },
  {
    data: {
      enCode: 'downloadBtn',
      name: '保单下载',
    },
@@ -155,10 +168,6 @@
    },
  },
]).filter(Boolean);
const columnSelectable = (row: API.InsuranceOrderListOutput) => {
  return row.onJobFlag === '增员';
};
const BaseState = {
  loading: true,
@@ -209,14 +218,6 @@
        format: 'YYYY/MM/DD',
      },
    },
    showSummary: true,
    summaryPropertys: [
      {
        property: 'table-operation',
        valueKey: 'totalAmount',
        formatter: (v) => `¥${toThousand(v)}`,
      },
    ],
  }
);
@@ -236,60 +237,36 @@
  return params;
}
const queryClient = useQueryClient();
async function handleUploadSuccess(response: UploadUserFile) {
  try {
    let res = await insuranceOrderServices.importInsuranceOrderData(response.url, {
      getResponse: true,
      responseType: 'blob',
    });
    if (res?.data?.size) {
      await Message.tipMessage('存在错误数据,是否导出?');
      downloadFile(res.data, `错误人员名单`, 'xlsx');
      // XLSXUtils.exportToXLSX({
      //   workbookDataList: res,
      //   fileName: '错误人员名单',
      //   workbookHeaderMap: {
      //     ...omit(Object.fromEntries(HomeColumns.map((x) => [x.enCode, x.name])), [
      //       'channel',
      //       'salesmanName',
      //       'createTime',
      //     ]),
      //     erroMsg: '备注',
      //   },
      // });
    }
    queryClient.invalidateQueries({
      queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance'],
    });
    getList();
  } catch (error) {}
}
const { dialogProps, handleAdd } = useFormDialog({
const { dialogProps, handleAdd, editForm } = useFormDialog({
  onConfirm: uploadInsurePerson,
  defaultFormParams: {
    id: '',
    materialName: '',
    orderNo: '',
    url: [] as UploadUserFile[],
  },
});
function openDialog(row: API.InsuranceOrderListOutput) {
function handleUpload() {
  handleAdd({
    id: row.id,
    orderNo: '',
    url: [] as UploadUserFile[],
  });
}
const router = useRouter();
function goDetail(row: API.InsuranceOrderListOutput) {
  router.push({
    name: 'InsuranceClaimDetail',
    params: {
      id: row.id,
    },
  });
async function uploadInsurePerson() {
  try {
    let params = {
      orderNo: editForm.orderNo,
      url: editForm.url?.[0]?.path,
    };
    // let res = await insuranceOrderServices.uploadStampFile(params);
    // if (res) {
    //   Message.successMessage('上传成功');
    //   getList(paginationState.pageIndex);
    // }
  } catch (error) {}
}
const router = useRouter();
async function handleExport() {
  try {
@@ -323,72 +300,59 @@
  }
}
const proTable = ref<InstanceType<typeof ProTableV2>>();
function handleEnterpriseBatchRefund() {
  if (proTableProps.value.tableData.length) {
    const res: API.InsuranceOrderListOutput[] = proTable.value.innerTableRef.getSelectionRows();
    if (res.length > 0) {
      const orderNos = _.uniq(res.map((x) => x.orderNo));
      if (orderNos.length > 1) {
        Message.errorMessage('存在不同的保单号,无法批量减员');
        return;
      }
      handleBatchDownsizing(res);
    } else {
      Message.errorMessage('请先勾选减员人员');
    }
  } else {
    Message.errorMessage('暂无数据');
  }
}
const {
  dialogProps: dialogBatchDownsizingProps,
  handleAdd: handleBatchDownsizingAdd,
  editForm: batchDownsizingForm,
  dialogProps: dialogStampFileProps,
  handleEdit: handleStampFileEdit,
  editForm: stampFileForm,
} = useFormDialog({
  onConfirm: downsizingInsuranceOrderData,
  onConfirm: uploadStampFile,
  defaultFormParams: {
    orderNo: '',
    checkOrderNo: '',
    id: '',
    url: [] as UploadUserFile[],
    downsizingInsuranceList: [] as string[],
  },
});
function handleBatchDownsizing(res: API.InsuranceOrderListOutput[]) {
  handleBatchDownsizingAdd({
    checkOrderNo: res[0]?.orderNo,
    downsizingInsuranceList: res.map((x) => x.id),
function handleUploadStampFile(row: API.InsuranceOrderListOutput) {
  handleStampFileEdit({
    id: row.id,
    url: [] as UploadUserFile[],
  });
}
async function downsizingInsuranceOrderData() {
async function uploadStampFile() {
  try {
    let params: API.DownsizingInsuranceOrderData = {
      orderNo: batchDownsizingForm.checkOrderNo,
      downsizingInsuranceList: batchDownsizingForm.downsizingInsuranceList,
      url: batchDownsizingForm.url?.[0]?.path ?? '',
    let params = {
      id: stampFileForm.id,
      url: stampFileForm.url?.[0]?.path,
    };
    let res = await insuranceOrderServices.downsizingInsuranceOrderDataCheck(params);
    if (res) {
      let downRes = await insuranceOrderServices.downsizingInsuranceOrderData(params, {
        getResponse: true,
        responseType: 'blob',
      });
      if (downRes?.data?.size) {
        await Message.tipMessage('存在错误数据,是否导出?');
        downloadFile(downRes.data, `错误人员名单`, 'xlsx');
      }
      queryClient.invalidateQueries({
        queryKey: ['insuranceOrderServices/getInsuranceOrderListByOrderRelevance'],
      });
      getList(paginationState.pageIndex);
    }
    // let res = await insuranceOrderServices.uploadStampFile(params);
    // if (res) {
    //   Message.successMessage('上传成功');
    //   getList(paginationState.pageIndex);
    // }
  } catch (error) {}
}
function handleDownloadOrderNo(row: API.InsuranceOrderListOutput) {
  downloadFileByUrl(setOSSLink(row.orderBillFile));
}
function handleDetail(row: API.InsuranceOrderListOutput) {
  router.push({
    name: 'InsuranceOrderDetail',
    params: {
      id: row.id,
    },
  });
}
function handleBatch(row: API.InsuranceOrderListOutput) {
  router.push({
    name: 'BatchChange',
    params: {
      id: row.id,
    },
  });
}
function downloadInsureOrder() {}
function downloadInsurePerson() {}
</script>