|
|
@@ -14,6 +14,8 @@ import { useTable } from '@/components/zt/Table/hooks/useTable';
|
|
|
import { useModalFrom } from '@/components/zt/ModalForm/hooks/useModalForm';
|
|
|
import type { ModalMethods } from '@/components/zt/Modal/types';
|
|
|
import { useModal } from '@/components/zt/Modal/hooks/useModal';
|
|
|
+import SVGIcon from '@/components/custom/svg-icon.vue';
|
|
|
+
|
|
|
const importTemplateRef = ref<ModalMethods>();
|
|
|
const columns: NaiveUI.TableColumn<Api.government.userList>[] = [
|
|
|
{
|
|
|
@@ -75,9 +77,14 @@ const [registerTable, { refresh, setTableLoading }] = useTable({
|
|
|
searchFormConfig: {
|
|
|
schemas: [
|
|
|
{
|
|
|
- field: 'channelName',
|
|
|
+ field: 'channelId',
|
|
|
label: '所属企业',
|
|
|
- component: 'NInput'
|
|
|
+ component: 'ApiSelect',
|
|
|
+ componentProps: {
|
|
|
+ api: fetchGetAllChannelList,
|
|
|
+ labelFeild: 'channelName',
|
|
|
+ valueFeild: 'id'
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
field: 'realName',
|
|
|
@@ -141,27 +148,33 @@ const failColumns: NaiveUI.TableColumn<Api.government.importRecordList>[] = [
|
|
|
align: 'center',
|
|
|
width: 240,
|
|
|
render(row) {
|
|
|
- const resultText = row.result;
|
|
|
- // 使用正则表达式匹配"失败X条"部分
|
|
|
- const failedMatch = resultText.match(/(失败\d+条)/);
|
|
|
-
|
|
|
- if (failedMatch) {
|
|
|
- const failedText = failedMatch[1];
|
|
|
- const parts = resultText.split(failedText);
|
|
|
-
|
|
|
- return (
|
|
|
- <div>
|
|
|
- {parts[0]}
|
|
|
- <span class={'text-red-500'}>{failedText}</span>
|
|
|
- {parts[1]}
|
|
|
- </div>
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- return <div>{resultText}</div>;
|
|
|
+ return (
|
|
|
+ <div class={'flex items-center'}>
|
|
|
+ 共{Number(row.success) + Number(row.error)}条,成功:{row.success},
|
|
|
+ <span class={'flex items-center text-red-500'}>
|
|
|
+ 失败:
|
|
|
+ {row.error}
|
|
|
+ {row.error != 0 && (
|
|
|
+ <div onClick={() => hanleExportFailure(row.batchNo)}>
|
|
|
+ <SVGIcon
|
|
|
+ icon={'tdesign:download'}
|
|
|
+ class={'ml-1 cursor-pointer text-20px'}
|
|
|
+ style={'color:var(--n-loading-color)'}
|
|
|
+ ></SVGIcon>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
];
|
|
|
+function hanleExportFailure(batchNo: string) {
|
|
|
+ window.open(
|
|
|
+ `${import.meta.env.VITE_SERVICE_BASE_URL}/admin/enterprise/downloadErrorExcel?batchNo=${batchNo}`,
|
|
|
+ '_blank'
|
|
|
+ );
|
|
|
+}
|
|
|
async function handleDelete(row: Api.government.userList) {
|
|
|
setTableLoading(true);
|
|
|
await fetchDeleteUser(row.userId);
|
|
|
@@ -187,13 +200,24 @@ const [registerModalForm, { openModal, closeModal, getFieldsValue, setFieldsValu
|
|
|
{
|
|
|
field: 'realName',
|
|
|
label: '员工姓名',
|
|
|
- component: 'NInput'
|
|
|
+ component: 'NInput',
|
|
|
+ required: true
|
|
|
},
|
|
|
{
|
|
|
field: 'userMobile',
|
|
|
label: '手机号码',
|
|
|
component: 'NInput',
|
|
|
- required: true
|
|
|
+ required: true,
|
|
|
+ componentProps: {
|
|
|
+ maxlength: 11
|
|
|
+ },
|
|
|
+ rules: [
|
|
|
+ {
|
|
|
+ pattern: /^1[3456789]\d{9}$/,
|
|
|
+ message: '请输入正确的手机号',
|
|
|
+ trigger: ['blur', 'input']
|
|
|
+ }
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
field: 'channelId',
|
|
|
@@ -252,10 +276,10 @@ async function handleSubmitImport(file: File) {
|
|
|
<LayoutTable>
|
|
|
<ZTable :columns="columns" :api="fetchGetUserList" @register="registerTable" @add="openModal">
|
|
|
<template #op="{ row }">
|
|
|
- <NButton size="small" ghost type="primary" :disabled="Boolean(row.used)" @click="edit(row)">编辑</NButton>
|
|
|
+ <NButton size="small" ghost type="primary" :disabled="Boolean(row.available)" @click="edit(row)">编辑</NButton>
|
|
|
<NPopconfirm @positive-click="handleDelete(row)">
|
|
|
<template #trigger>
|
|
|
- <NButton size="small" type="error" ghost>删除</NButton>
|
|
|
+ <NButton size="small" type="error" ghost :disabled="Boolean(row.available)">删除</NButton>
|
|
|
</template>
|
|
|
确定删除吗?
|
|
|
</NPopconfirm>
|