1、考勤组管理
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
2025-07-19 17:25:17 +08:00
parent 9135ee31b9
commit 97f298d8c7
9 changed files with 636 additions and 16 deletions

View File

@@ -0,0 +1,169 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import {getDictOptions} from "#/utils/dict";
import {renderDict} from "#/utils/render";
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'groupName',
label: '考勤组名称',
},
{
component: 'Select',
componentProps: {
options:getDictOptions('wy_kqlx')
},
fieldName: 'attendanceType',
label: '考勤类型',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '考勤组名称',
field: 'groupName',
minWidth:180,
},
{
title: '考勤类型',
field: 'attendanceType',
slots:{
default: ({row})=>{
return renderDict(row.attendanceType,'wy_kqlx')
}
},
width:150
},
{
title: '状态',
field: 'status',
slots:{
default: 'status'
},
width:180
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '考勤组名称',
fieldName: 'groupName',
component: 'Input',
rules: 'required',
},
{
label: '考勤类型',//(0:固定班制,1:排班制)
fieldName: 'attendanceType',
component: 'RadioGroup',
componentProps: {
buttonStyle: 'solid',
options: getDictOptions('wy_kqlx'),
},
rules: 'selectRequired',
defaultValue:'0'
},
{
label: '工作日设置',
fieldName: 'weekdaySetting',
component: 'Input',
dependencies: {
show: (formValue) => formValue.attendanceType=='0',
triggerFields: ['attendanceType'],
},
slots:{
default:'weekdaySetting'
},
rules:'required',
defaultValue:'1',
},
{
label: '',
fieldName: 'settingItem',
component: 'Input',
dependencies: {
show: (formValue) => formValue.attendanceType=='0',
triggerFields: ['attendanceType'],
},
slots:{
default:'settingItem'
},
},
{
label: '考勤班次',
fieldName: 'attendanceShift',
component: 'Input',
dependencies: {
show: (formValue) => formValue.attendanceType=='1',
triggerFields: ['attendanceType'],
},
slots:{
default:'attendanceShift'
},
rules:'required',
defaultValue:'1',
},
{
label: '排班周期',
fieldName: 'schedulingCycle',
component: 'Input',
dependencies: {
show: (formValue) => formValue.attendanceType=='1',
triggerFields: ['attendanceType'],
},
slots:{
default:'schedulingCycle'
},
defaultValue:'1',
rules:'required'
},
];
export const weekdayColumns: VxeGridProps['columns'] = [
{
title: '工作日',
name: 'label',
width:180,
align:'center',
dataIndex:'label'
},
{
title: '班次',
name: 'shift',
minWidth:180,
align:'center',
dataIndex:'shift'
},
{
title: '操作',
name: 'action',
dataIndex:'action',
width:180,
align:'center',
slots:{
default:'action'
},
},
]

View File

@@ -0,0 +1,146 @@
<script setup lang="ts">
import {computed, ref} from 'vue';
import {useVbenModal} from '@vben/common-ui';
import {$t} from '@vben/locales';
import {cloneDeep} from '@vben/utils';
import {useVbenForm} from '#/adapter/form';
import {
groupAdd,
groupInfo,
groupUpdate
} from '#/api/property/attendanceManagement/attendanceGroupSettings';
import {defaultFormValueGetter, useBeforeCloseDiff} from '#/utils/popup';
import {modalSchema, weekdayColumns} from './data';
import {Tag, Button, Table} from 'ant-design-vue'
import {getDictOptions} from "#/utils/dict";
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const weekdayData = ref<any[]>([])
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
// 默认占满两列
formItemClass: 'col-span-2',
// 默认label宽度 px
labelWidth: 80,
// 通用配置项 会影响到所有表单项
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const {onBeforeClose, markInitialized, resetInitialized} = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
// 在这里更改宽度
class: 'w-[70%]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const {id} = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await groupInfo(id);
await formApi.setValues(record);
}else {
weekdayData.value=[]
getDictOptions('wy_kqgzr').forEach(item=>{
weekdayData.value.push({
dayOfWeek:item.value,
label:item.label,
shift:item.value=='6'||item.value=='7'?'休息':'常规班次08:00:00~12:00:00 14:00:00~17:00:00'
})
})
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const {valid} = await formApi.validate();
if (!valid) {
return;
}
// getValues获取为一个readonly的对象 需要修改必须先深拷贝一次
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? groupUpdate(data) : groupAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm>
<template #weekdaySetting>
<div style="font-size: 0.875rem;">
<span>快捷设置班次</span>
<Tag color="processing">常规班次08:00:00~12:00:00 14:00:00~17:00:00</Tag>
<Button type="link">更改班次</Button>
</div>
</template>
<template #settingItem>
<Table style="width: 100%" bordered :columns="weekdayColumns" :data-source="weekdayData"
size="small" :pagination="false">
<!-- <template #headerCell="{ column }">-->
<!-- </template>-->
<!-- <template #bodyCell="{ column, record }">-->
<!-- <template>-->
<!-- {{ record[column.field] }}-->
<!-- </template>-->
<!-- </template>-->
<!-- <template #action="{row}">-->
<!-- <Button type="link">更改班次</Button>-->
<!-- <Button type="link">休息</Button>-->
<!-- </template>-->
</Table>
</template>
<template #attendanceShift>
班次
</template>
<template #schedulingCycle>
周期
</template>
</BasicForm>
</BasicModal>
</template>

View File

@@ -1,11 +1,181 @@
<script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
groupExport,
groupList,
groupRemove, groupUpdate,
} from '#/api/property/attendanceManagement/attendanceGroupSettings';
import type { GroupForm } from '#/api/property/attendanceManagement/attendanceGroupSettings/model';
import { commonDownloadExcel } from '#/utils/file/download';
import groupModal from './group-modal.vue';
import { columns, querySchema } from './data';
import {TableSwitch} from "#/components/table";
import {useAccess} from "@vben/access";
const { hasAccessByCodes } = useAccess();
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
// 高亮
highlight: true,
// 翻页时保留选中状态
reserve: true,
// 点击行选中
// trigger: 'row',
},
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await groupList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
// 表格全局唯一表示 保存列配置需要用到
id: 'Property-group-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [GroupModal, modalApi] = useVbenModal({
connectedComponent: groupModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<GroupForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<GroupForm>) {
await groupRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<GroupForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await groupRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(groupExport, '考勤组基本信息数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
}
</script>
<template>
考勤组设置
<Page :auto-content-height="true">
<BasicTable table-title="考勤组列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['Property:group:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['Property:group:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['Property:group:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['Property:group:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['Property:group:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
<template #status="{row}">
<TableSwitch
:checkedValue="1"
:unCheckedValue="0"
v-model:value="row.status"
:api="() => groupUpdate(row)"
:disabled="!hasAccessByCodes(['property:depot:edit'])"
@reload="() => tableApi.query()"
/>
</template>
</BasicTable>
<GroupModal @reload="tableApi.query()" />
</Page>
</template>
<style scoped lang="scss">
</style>