Commit 2f5b8f853fac6aeee860362c4a8deb3404877ad9

Authored by 张志伟
2 parents 02045120 f007db38

Merge branch 'attendence' into 'master'

fix(attendence): 优化 排班设置 添加 (特殊)排班确认功能 并对接接口



See merge request !701
src/pages/attendance/Attend/subpages/Roster/api.ts
... ... @@ -18,6 +18,21 @@ export interface SettingItem {
18 18 posts: Post[];
19 19 month: string[];
20 20 effectMonth: string;
  21 + confirmType?: number; // 确认类型(-1:待办未推送, 0:未确认, 1:主动确认, 2:到期系统自动确认)
  22 +}
  23 +
  24 +export enum ConfirmType {
  25 + 待办未推送 = -1,
  26 + 未确认 = 0,
  27 + 主动确认 = 1,
  28 + 到期系统自动确认 = 2,
  29 +}
  30 +
  31 +export enum ConfirmTypeColor {
  32 + '#999' = -1,
  33 + '#FF921C' = 0,
  34 + '#4189FD' = 1,
  35 + '#F4333C' = 2,
21 36 }
22 37  
23 38 export interface Shop {
... ... @@ -61,6 +76,7 @@ export interface SepcialSettingsItem {
61 76 shops?: Shop[];
62 77 posts?: Post[];
63 78 restMode?: number[];
  79 + confirmType?: number; // 确认类型(-1:待办未推送, 0:未确认, 1:主动确认, 2:到期系统自动确认)
64 80 }
65 81  
66 82 export enum RestMode {
... ... @@ -102,3 +118,21 @@ export function deleteSpecialItemApi(id: number): http.PromiseResp<string> {
102 118 export function deleteSettingItemApi(id: number): http.PromiseResp<string> {
103 119 return request.get(`${ATTENDANCE_HOST}/erp/schedule/setting/del`, { params: { id } });
104 120 }
  121 +
  122 +/**
  123 + * @description: 确认排班配置
  124 + * @param {number} id
  125 + * @return {http.PromiseResp<string>}
  126 + */
  127 +export function confirmSettingItemApi(id: number): http.PromiseResp<string> {
  128 + return request.get(`${ATTENDANCE_HOST}/erp/schedule/setting/confirmConfig`, { params: { id } });
  129 +}
  130 +
  131 +/**
  132 + * @description: 确认特殊排班配置
  133 + * @param {number} id
  134 + * @return {http.PromiseResp<string>}
  135 + */
  136 +export function confirmSpecialSettingItemApi(id: number): http.PromiseResp<string> {
  137 + return request.get(`${ATTENDANCE_HOST}/erp/schedule/special/setting/confirmConfig`, { params: { id } });
  138 +}
... ...
src/pages/attendance/Attend/subpages/Roster/components/Settings/index.tsx
... ... @@ -2,7 +2,7 @@ import usePagination from &#39;@/hooks/usePagination&#39;;
2 2 import moment from 'moment';
3 3 import React, { useState } from 'react';
4 4 import * as API from '../../api';
5   -import { Button, Popconfirm, Select, Table, message } from 'antd';
  5 +import { Badge, Button, Divider, Popconfirm, Select, Table, message } from 'antd';
6 6 import SaveModal from './SaveModal';
7 7 import DetailModal from './DetailModal';
8 8 import TableArrayColumnFormat from '@/pages/ehr/components/TableArrayColumnFormat';
... ... @@ -37,6 +37,20 @@ export default function Settings() {
37 37 });
38 38 }
39 39  
  40 + function confirmItem(id: number) {
  41 + const hide = message.loading('确认中,请稍后...', 0);
  42 + API.confirmSettingItemApi(id)
  43 + .then((res) => {
  44 + hide();
  45 + message.success(res.result);
  46 + setLoading(true);
  47 + })
  48 + .catch((error) => {
  49 + hide();
  50 + message.error(error.message ?? '确认失败');
  51 + });
  52 + }
  53 +
40 54 return (
41 55 <>
42 56 <div
... ... @@ -71,72 +85,81 @@ export default function Settings() {
71 85 </Button>
72 86 </div>
73 87 <Table loading={loading} dataSource={list} pagination={paginationConfig} rowKey="id">
74   - <Column
75   - title="适用门店"
76   - dataIndex="shops"
77   - render={(shops?: API.Shop[]) => <TableArrayColumnFormat data={shops ?? []} key="shopId" showKey="shopName" unit="个门店" />}
78   - />
79   - <Column
80   - title="适用岗位"
81   - dataIndex="posts"
82   - render={(posts?: API.Post[]) => <TableArrayColumnFormat data={posts ?? []} key="postId" showKey="postName" unit="个岗位" />}
83   - />
84   - <Column title="月休息天数" dataIndex="monthRestCnt" width="10%" align="center" render={(text, row: any) => <div>{row.monthRestCnt}天</div>} />
85   - <Column
86   - title="最大连续休息天数"
87   - dataIndex="restContinuousCnt"
88   - width="10%"
89   - align="center"
90   - render={(text, row: any) => (
91   - <div>
92   - {row.restContinuousCnt
93   - ? row.continuousType === 0
94   - ? `${row.restContinuousCnt}天`
95   - : `${Math.floor((row.restContinuousCnt * row.monthRestCnt) / 100)}天(百分比计算)`
96   - : '--'}
97   - </div>
  88 + <Table.Column
  89 + title="适用范围"
  90 + render={(record: API.SettingItem) => (
  91 + <span>
  92 + <span className="span_limit_1">
  93 + <span style={{ color: '#999' }}>适用门店:</span>
  94 + <TableArrayColumnFormat data={record.shops ?? []} key="shopId" showKey="shopName" unit="个门店" />
  95 + </span>
  96 + <span className="span_limit_1">
  97 + <span style={{ color: '#999' }}>适用岗位:</span>
  98 + <TableArrayColumnFormat data={record.posts ?? []} key="postId" showKey="postName" unit="个岗位" />
  99 + </span>
  100 + </span>
98 101 )}
99 102 />
100   - <Column
101   - title={`排班表设置时间(${moment(date).subtract(1, 'M').format('YYYY年MM月')}倒数后多少天)`}
102   - dataIndex="scheduleDays"
103   - width="16%"
104   - align="center"
105   - render={(text, row: any) => <div>{row.scheduleDays}天</div>}
  103 + <Table.Column
  104 + title="配置"
  105 + render={(record: API.SettingItem) => (
  106 + <span>
  107 + <span className="span_limit_1">
  108 + <span style={{ color: '#999' }}>月休息天数:</span>
  109 + <span style={{ color: '#333' }}>{record.monthRestCnt || '-'}天</span>
  110 + </span>
  111 + <span className="span_limit_1">
  112 + <span style={{ color: '#999' }}>最大连续休息天数:</span>
  113 + <span style={{ color: '#333' }}>
  114 + {record.restContinuousCnt
  115 + ? record.continuousType === 0
  116 + ? `${record.restContinuousCnt}天`
  117 + : `${Math.floor((record.restContinuousCnt * record.monthRestCnt) / 100)}天(百分比计算)`
  118 + : '--'}
  119 + </span>
  120 + </span>
  121 + <span className="span_limit_1">
  122 + <span style={{ color: '#999' }}>{`排班表设置时间(${moment(date).subtract(1, 'M').format('YYYY年MM月')}倒数后多少天)`}:</span>
  123 + <span style={{ color: '#333' }}>{record.scheduleDays || '-'}天</span>
  124 + </span>
  125 + <span className="span_limit_1">
  126 + <span style={{ color: '#999' }}>每月可主动调休次数:</span>
  127 + <span style={{ color: '#333' }}>{record.changeRestCnt || '-'}次</span>
  128 + </span>
  129 + </span>
  130 + )}
106 131 />
107 132 <Column
108   - title="每月可主动调休次数"
109   - dataIndex="changeRestCnt"
110   - width="16%"
111   - align="center"
112   - render={(text, row: any) => <div>{row.changeRestCnt ? `${row.changeRestCnt}次` : '--'}</div>}
  133 + title="状态"
  134 + dataIndex="confirmType"
  135 + render={(confirmType: number) =>
  136 + Number.isFinite(confirmType) ? <Badge color={API.ConfirmTypeColor[confirmType]} text={API.ConfirmType[confirmType]} /> : '-'
  137 + }
113 138 />
114   - {/* <Column
115   - title="最大连续上班天数(可跨月)"
116   - dataIndex="restFrequency"
117   - width="16%"
118   - align="center"
119   - render={(text, row: any) => <div>{row.restFrequency ? `${row.restFrequency}天/次` : '--'}</div>}
120   - /> */}
121 139 <Column
122   - width="10%"
123 140 title="操作"
124 141 align="center"
125 142 render={(text, record: API.SettingItem) => (
126 143 <>
127   - <Button
128   - type="link"
  144 + {record.confirmType === API.ConfirmType.未确认 ? (
  145 + <>
  146 + <Popconfirm placement="top" title="确定确认?" onConfirm={() => confirmItem(record.id)}>
  147 + <a>确认</a>
  148 + </Popconfirm>
  149 + <Divider type="vertical" />
  150 + </>
  151 + ) : null}
  152 + <a
129 153 onClick={() => {
130 154 setItem(record);
131 155 setVisible(true);
132 156 }}
133 157 >
134 158 编辑
135   - </Button>
  159 + </a>
  160 + <Divider type="vertical" />
136 161 <Popconfirm placement="top" title="确认删除?" onConfirm={() => deleteItem(record.id)}>
137   - <Button type="link" danger>
138   - 删除
139   - </Button>
  162 + <a style={{ color: 'red' }}>删除</a>
140 163 </Popconfirm>
141 164 </>
142 165 )}
... ...
src/pages/attendance/Attend/subpages/Roster/components/SpecialSettings/index.tsx
1 1 import React, { useEffect, useState } from 'react';
2 2 import * as API from '../../api';
3 3 import usePagination from '@/hooks/usePagination';
4   -import { Button, Divider, Form, Modal, Popconfirm, Popover, Select, Spin, Table, message } from 'antd';
  4 +import { Badge, Button, Divider, Form, Modal, Popconfirm, Popover, Select, Spin, Table, message } from 'antd';
5 5 import { formatObjText } from '@/utils/utils';
6 6 import ShopSelectNew from '@/components/ShopSelectNew';
7 7 import PostSelectNew from '@/components/PostSelectNew';
... ... @@ -46,6 +46,20 @@ export default function SpecialSettings() {
46 46 });
47 47 }
48 48  
  49 + function confirmItem(id: number) {
  50 + const hide = message.loading('确认中,请稍后...', 0);
  51 + API.confirmSpecialSettingItemApi(id)
  52 + .then((res) => {
  53 + hide();
  54 + message.success(res.result);
  55 + pagination.setLoading(true);
  56 + })
  57 + .catch((error) => {
  58 + hide();
  59 + message.error(error.message ?? '确认失败');
  60 + });
  61 + }
  62 +
49 63 function closeModal() {
50 64 setOpen(false);
51 65 setCurrent(undefined);
... ... @@ -106,9 +120,24 @@ export default function SpecialSettings() {
106 120 render={(restMode: number[]) => (restMode?.length ? restMode.map((mode) => API.RestMode[mode]).join(' + ') : '-')}
107 121 />
108 122 <Table.Column
  123 + title="状态"
  124 + dataIndex="confirmType"
  125 + render={(confirmType: number) =>
  126 + Number.isFinite(confirmType) ? <Badge color={API.ConfirmTypeColor[confirmType]} text={API.ConfirmType[confirmType]} /> : '-'
  127 + }
  128 + />
  129 + <Table.Column
109 130 title="操作"
110 131 render={(record: API.SepcialSettingsItem) => (
111 132 <>
  133 + {record.confirmType === API.ConfirmType.未确认 ? (
  134 + <>
  135 + <Popconfirm placement="top" title="确定确认?" onConfirm={() => confirmItem(record.id ?? -1)}>
  136 + <a>确认</a>
  137 + </Popconfirm>
  138 + <Divider type="vertical" />
  139 + </>
  140 + ) : null}
112 141 <a onClick={() => openModal(record)}>编辑</a>
113 142 <Divider type="vertical" />
114 143 <Popconfirm title="确定删除该配置?" onConfirm={() => deleteItem(record.id ?? -1)}>
... ...