123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- /*
- * @Author: code4eat awesomedema@gmail.com
- * @Date: 2023-03-03 11:30:33
- * @LastEditors: code4eat awesomedema@gmail.com
- * @LastEditTime: 2023-10-20 17:32:10
- * @FilePath: /KC-MiddlePlatform/src/pages/platform/setting/pubDicTypeMana/index.tsx
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- import { createFromIconfontCN } from '@ant-design/icons';
- import {
- ProFormDependency,
- ProFormDigit,
- ProFormRadio,
- ProFormSelect,
- } from '@ant-design/pro-components';
- import { ModalForm, ProFormText } from '@ant-design/pro-form';
- import FormItem from 'antd/es/form/FormItem';
- import {DatePicker,Input} from 'antd';
- import { useEffect, useRef, useState } from 'react';
- import { getData, downloadTemplateReq, importDataPost } from './service';
- import './style.less';
- import moment from 'moment';
- import 'moment/locale/zh-cn';
- import locale from 'antd/es/date-picker/locale/zh_CN';
- import KCIMPagecontainer from '@/components/KCIMPageContainer';
- import { KCIMTable } from '@/components/KCIMTable';
- import KCIMUpload from '@/components/KCIMUpload';
- const IconFont = createFromIconfontCN({
- scriptUrl: '',
- });
- const currentData = `${new Date().getFullYear()}-${(new Date().getMonth()+1).toString().padStart(2, '0')}`
- export default function empCostDataImport() {
- const [computeDate,set_computeDate] = useState(currentData);
- const [tableDataFilterParams, set_tableDataFilterParams] = useState({computeDate:currentData});
- const [tableDataSearchKeywords, set_tableDataSearchKeywords] = useState('');
- const tableRef = useRef();
- const columns = [
- {
- title: '工号',
- dataIndex: 'empCode',
- },
- {
- title: '姓名',
- dataIndex: 'empName',
- },
- {
- title: '总工时',
- dataIndex: 'hour',
- },
- {
- title: '固定薪资',
- dataIndex: 'salary',
- },
- {
- title: '变动薪资',
- dataIndex: 'variableCompensation',
- },
- {
- title: '总成本',
- dataIndex: 'cost',
- },
- ];
- const getTableData = async (params) => {
- const resp = await getData({ ...params,...tableDataFilterParams});
- const { status, data } = resp;
- if (status == 200) {
- const { list, totalCount, pageSize, totalPage } = data;
- if (resp.totalCount == 0 && resp.currPage != 1) {
- return getTableData({ ...params, current: resp.currPage - 1 });
- } else {
- return {
- data: list,
- success: true,
- total: totalCount,
- pageSize: pageSize,
- totalPage: totalPage,
- };
- }
- }
- return [];
- };
- const tableDataSearchHandle = (paramName) => {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- [`${paramName}`]: tableDataSearchKeywords
- })
- }
- const downloadTemplate = async () => {
- await downloadTemplateReq();
- };
- const importData = () => {
- return (
- <ModalForm
- width={360}
- title={`导入数据`}
- trigger={
- <a className="import" key="3">
- 导入
- </a>
- }
- submitter={{
- render: (props, defaultDoms) => {
- const needBtn = defaultDoms.filter((b) => {
- return b.key != 'rest';
- });
- return [
- // <Button
- // key="ok"
- // onClick={auditType == '0' ? () => downloadTemplate(index) : () => { }}
- // >
- // 下载模板
- // </Button>,
- ...needBtn,
- ];
- },
- }}
- onFinish={async (values) => {
- const {
- importFile: { fileList },
- } = values;
- let formData = new FormData();
- formData.append('file', fileList[0].originFileObj);
- formData.append('computeDate',computeDate);
- const resp = await importDataPost(formData);
- if (resp) {
- tableRef.current?.reload();
- return true;
- }
- }}
- >
- <FormItem name={'importFile'}>
- <KCIMUpload downloadTemplateFile={() => downloadTemplate()} />
- </FormItem>
- </ModalForm>
- );
- };
- useEffect(() => {}, []);
- return (
- <KCIMPagecontainer className="empCostDataImport" title={false}>
- <div className="toolBar">
- <div className="filter">
- <div className="filterItem">
- {
- <div className="search">
- <span>核算年月:</span>
- <DatePicker
- onChange={(data, dateString) => {
- set_computeDate(dateString);
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- computeDate: dateString,
- });
- }}
- picker="month"
- locale={locale}
- defaultValue={moment(`${new Date().getFullYear()}-${(new Date().getMonth()+1).toString().padStart(2, '0')}`, 'YYYY-MM')}
- format="YYYY-MM"
- placeholder="选择年月"
- />
- </div>
- }
- </div>
- <div className='filterItem' style={{ marginLeft: 16, width: 205 }}>
- <span className='label' style={{ whiteSpace: 'nowrap' }}> 检索:</span>
- <Input placeholder={'输入工号,姓名'} allowClear
- suffix={
- <IconFont type="iconsousuo" style={{ color: '#99A6BF' }} onClick={() => tableDataSearchHandle('filter')} />
- }
- onChange={(e) => {
- set_tableDataSearchKeywords(e.target.value);
- if (e.target.value.length == 0) {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- filter: ''
- });
- }
- }}
- onPressEnter={(e) => {
- set_tableDataFilterParams({
- ...tableDataFilterParams,
- filter: e.target.value
- });
- }}
- />
- </div>
- </div>
- <div className="btnGroup">{importData()}</div>
- </div>
- <div style={{ marginTop: 16 }}>
- <KCIMTable
- columns={columns}
- actionRef={tableRef}
- rowKey="id"
- params={tableDataFilterParams}
- request={(params) => getTableData(params)}
- />
- </div>
- </KCIMPagecontainer>
- );
- }
|