Compare commits
2 Commits
d9b096c8ed
...
8da35d2d4b
Author | SHA1 | Date | |
---|---|---|---|
8da35d2d4b | |||
13f79986f8 |
@ -207,8 +207,8 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
await getGroupList();
|
|
||||||
modalApi.modalLoading(true);
|
modalApi.modalLoading(true);
|
||||||
|
await getGroupList();
|
||||||
// await markInitialized();
|
// await markInitialized();
|
||||||
modalApi.modalLoading(false);
|
modalApi.modalLoading(false);
|
||||||
},
|
},
|
||||||
|
@ -120,12 +120,13 @@ export const columns: VxeGridProps['columns'] = [
|
|||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
slots: {
|
slots: {
|
||||||
default: ({ row }) => {
|
default: ({ row }) => {
|
||||||
|
if(!row.attendanceShift) return '/';
|
||||||
if (row.attendanceShift.startTime && row.attendanceShift.endTime) {
|
if (row.attendanceShift.startTime && row.attendanceShift.endTime) {
|
||||||
if (
|
if (
|
||||||
row.attendanceShift.restEndTime &&
|
row.attendanceShift.restEndTime &&
|
||||||
row.attendanceShift.restStartTime
|
row.attendanceShift.restStartTime
|
||||||
) {
|
) {
|
||||||
return `${row.attendanceShift.startTime}~${row.attendanceShift.endTime} ${row.shift.restStartTime}~${row.shift.restEndTime}`;
|
return `${row.attendanceShift.startTime}~${row.attendanceShift.endTime} ${row.attendanceShift.restStartTime}~${row.attendanceShift.restEndTime}`;
|
||||||
} else {
|
} else {
|
||||||
return `${row.attendanceShift.startTime}~${row.attendanceShift.endTime}`;
|
return `${row.attendanceShift.startTime}~${row.attendanceShift.endTime}`;
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,6 @@ async function handleConfirm() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(tableData);
|
|
||||||
resetInitialized();
|
resetInitialized();
|
||||||
emit('reload', tableData);
|
emit('reload', tableData);
|
||||||
tableData = [];
|
tableData = [];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, onMounted } from 'vue';
|
import { reactive, onMounted,computed } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
import {
|
import {
|
||||||
@ -102,7 +102,7 @@ const columns = [
|
|||||||
];
|
];
|
||||||
const editDate = ref<string | undefined>('');
|
const editDate = ref<string | undefined>('');
|
||||||
function handleRemoveUser(row: any, user: any) {
|
function handleRemoveUser(row: any, user: any) {
|
||||||
row.users = row.users.filter((u: any) => u.id !== user.id);
|
row.users = row.users.filter((u: any) => u.userId !== user.userId);
|
||||||
}
|
}
|
||||||
function handleRemoveRow(index: number) {
|
function handleRemoveRow(index: number) {
|
||||||
tableData.splice(index, 1);
|
tableData.splice(index, 1);
|
||||||
@ -133,7 +133,7 @@ function handleTableData(newTableData: any) {
|
|||||||
for (const newUser of newItem.users) {
|
for (const newUser of newItem.users) {
|
||||||
// 检查该用户是否已存在
|
// 检查该用户是否已存在
|
||||||
const userExists = existingDept?.users.some(
|
const userExists = existingDept?.users.some(
|
||||||
(existingUser) => existingUser.id === newUser.id,
|
(existingUser) => existingUser.userId === newUser.userId,
|
||||||
);
|
);
|
||||||
if (!userExists) {
|
if (!userExists) {
|
||||||
// 用户不存在,添加到现有部门
|
// 用户不存在,添加到现有部门
|
||||||
@ -159,8 +159,8 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
await getGroupList();
|
|
||||||
modalApi.modalLoading(true);
|
modalApi.modalLoading(true);
|
||||||
|
await getGroupList();
|
||||||
const { id, date } = modalApi.getData() as {
|
const { id, date } = modalApi.getData() as {
|
||||||
id?: number | string;
|
id?: number | string;
|
||||||
date?: string;
|
date?: string;
|
||||||
@ -178,8 +178,8 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
const deptMap = new Map();
|
const deptMap = new Map();
|
||||||
|
|
||||||
for (const item of record.userGroupList) {
|
for (const item of record.userGroupList) {
|
||||||
const deptId = item.deptId;
|
const deptId = item.sysUser.deptId;
|
||||||
const deptName = item.deptName;
|
const deptName = item.sysUser.deptName;
|
||||||
|
|
||||||
if (!deptMap.has(deptId)) {
|
if (!deptMap.has(deptId)) {
|
||||||
deptMap.set(deptId, {
|
deptMap.set(deptId, {
|
||||||
@ -188,19 +188,23 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
deptMap.get(deptId).users.push({
|
deptMap.get(deptId).users.push({
|
||||||
id: item.employeeId,
|
userId: item.sysUser.userId,
|
||||||
userName: item.employeeName,
|
userName: item.sysUser.userName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// 转换为 tableData 格式
|
// 转换为 tableData 格式
|
||||||
tableData.splice(0, 0, ...Array.from(deptMap.values()));
|
tableData.splice(0, 0, ...Array.from(deptMap.values()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(tableData);
|
||||||
|
|
||||||
// await markInitialized();
|
// await markInitialized();
|
||||||
modalApi.modalLoading(false);
|
modalApi.modalLoading(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const totalSelected: number = 0;
|
const totalSelected = computed(() =>
|
||||||
|
tableData.reduce((sum, row) => sum + (row.users?.length || 0), 0),
|
||||||
|
);
|
||||||
async function getGroupList() {
|
async function getGroupList() {
|
||||||
const res = await groupList({
|
const res = await groupList({
|
||||||
pageSize: 1000000000,
|
pageSize: 1000000000,
|
||||||
@ -233,11 +237,13 @@ async function handleConfirm() {
|
|||||||
modalApi.lock(true);
|
modalApi.lock(true);
|
||||||
await formRef.value.validate(); // 先校验
|
await formRef.value.validate(); // 先校验
|
||||||
const data = formModal;
|
const data = formModal;
|
||||||
|
console.log(tableData);
|
||||||
|
|
||||||
data.userGroupList = tableData.flatMap((item) =>
|
data.userGroupList = tableData.flatMap((item) =>
|
||||||
item.users.map((user) => ({
|
item.users.map((user) => ({
|
||||||
deptId: item.dept.unitId,
|
deptId: item.dept.unitId,
|
||||||
deptName: item.dept.unitName,
|
deptName: item.dept.unitName,
|
||||||
employeeId: user.id,
|
employeeId: user.userId,
|
||||||
employeeName: user.userName,
|
employeeName: user.userName,
|
||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user