ソースを参照

新增人事档案

HW 4 年 前
コミット
f09bceb1c7

+ 60 - 106
src/pages/personnel/archives/statistics/components/newEmployees.jsx

@@ -23,39 +23,42 @@ class NewEmployees extends Component{
   addEmployees= async (value)=>{
     message.loading({content:'保存中...',key:'addEmployees'});
     // 户籍地址
-    value.residenceProvince = value.address[0] || null;
-    value.residenceCity = value.address[1] || null;
-    value.residenceArea = value.address[2] || null;
+    value.residenceProvince = value.address ? value.address[0] || undefined : undefined;
+    value.residenceCity = value.address ? value.address[1] || undefined : undefined;
+    value.residenceArea = value.address ? value.address[2] || undefined : undefined;
     // 现住地址
-    value.nowProvince = value.userNowAddress[0] || null;
-    value.nowCity = value.userNowAddress[1] || null;
-    value.nowArea = value.userNowAddress[2] || null;
+    value.nowProvince = value.userNowAddress ? value.userNowAddress[0] || undefined : undefined;
+    value.nowCity = value.userNowAddress ? value.userNowAddress[1] || undefined : undefined;
+    value.nowArea = value.userNowAddress ? value.userNowAddress[2] || undefined : undefined;
     // 籍贯
-    value.nativePlaceProvince = value.nativePlace[0] || null;
-    value.nativePlaceCity = value.nativePlace[1] || null;
+    value.nativePlaceProvince = value.nativePlace ? value.nativePlace[0] || undefined : undefined;
+    value.nativePlaceCity = value.nativePlace ? value.nativePlace[1] || undefined : undefined;
     // 性别
-    value.sex = value.sex === '男' ? 0 : value.sex === '女' ? 1 : null;
+    value.sex = value.sex === '男' ? 0 : value.sex === '女' ? 1 : undefined;
     // 婚否
-    value.marriage = value.marriage === '未婚' ? 0 : value.marriage === '已婚' ? 1 : value.marriage === '离异' ? 2 : null
-    const msg = await addEmployees(value);
-    if(msg.error.length === 0){
-      message.success({content:'保存成功',key:'addEmployees',duration:2.5});
-      this.props.formRef.current.reload();
-      this.props.onCancel();
-    }else{
-      message.error({content:msg.error[0].message,key:'addEmployees',duration:2.5})
+    value.marriage = value.marriage === '未婚' ? 0 : value.marriage === '已婚' ? 1 : value.marriage === '离异' ? 2 : undefined
+    try {
+      const msg = await addEmployees(value);
+      if(msg.error.length === 0){
+        message.success({content:'保存成功',key:'addEmployees',duration:2.5});
+        this.props.formRef.current.reload();
+        this.props.onCancel();
+      }else{
+        message.error({content:msg.error[0].message,key:'addEmployees',duration:2.5})
+      }
+    } catch (e){
+      console.log(e)
+      return false;
     }
   }
 
   setAddressList = async () => {
-    let arr = [...addressList];
-    let arr1 = [...addressList];
-    let addressSelect = await getAddressSelect(arr);
+    let addressSelect = await getAddressSelect();
     addressSelect.unshift({
       label: '全国',
       value: 0,
     })
-    let nativePlaceSelect = await getNativePlace(arr1);
+    let nativePlaceSelect = await getNativePlace();
     this.setState({
       addressSelect,
       nativePlaceSelect
@@ -69,7 +72,6 @@ class NewEmployees extends Component{
   formRef = React.createRef();
 
   render() {
-
     return (
       <ModalForm
         formRef={this.formRef}
@@ -77,7 +79,7 @@ class NewEmployees extends Component{
         preserve={false}
         title='新增人事档案'
         modalProps={{
-          maskClosable:true,
+          destroyOnClose:true,
           onCancel: (e) => {e.stopPropagation();this.props.onCancel();},
         }}
         onFinish={this.addEmployees}
@@ -85,25 +87,33 @@ class NewEmployees extends Component{
         <ProForm.Group>
           <ProFormText
             width="m"
+            placeholder="请输入员工编号"
+            name="employeeId"
             rules={[
               {
                 required:true,
                 message:'请输入员工编号'
+              },
+              {
+                pattern: /^[^\u4e00-\u9fa5]+$/,
+                message: '员工编号不能包含中文',
               }
             ]}
-            placeholder="请输入员工编号"
-            name="employeeId"
             label="员工编号"/>
           <ProFormText
             width="m"
+            placeholder="请输入门禁编号"
+            name="doorId"
             rules={[
               {
                 required:true,
                 message:'请输入门禁编号'
+              },
+              {
+                pattern: /^[^\u4e00-\u9fa5]+$/,
+                message: '门禁编号不能包含中文',
               }
             ]}
-            placeholder="请输入门禁编号"
-            name="doorId"
             label="门禁编号"/>
         </ProForm.Group>
         <ProForm.Group>
@@ -120,46 +130,44 @@ class NewEmployees extends Component{
             label="姓名"/>
           <ProFormDatePicker
             width="m"
-            name="birthdays"
-            label="出生日期"
-            placeholder="请选择出生日期"
-          />
-        </ProForm.Group>
-        <ProForm.Group>
-          <ProFormRadio.Group
-            label="性别"
-            width="m"
-            name="sex"
-            options={['男','女']}
             rules={[
               {
                 required:true,
-                message:'请输入姓名'
+                message:'请选择出生日期'
               }
             ]}
+            name="birthdays"
+            label="出生日期"
+            placeholder="请选择出生日期"
           />
+        </ProForm.Group>
+        <ProForm.Group>
           <ProFormText
             width="m"
             rules={[
               {
                 required:true,
-                message:'请输入民族'
+                message:'请输入身份证'
+              },
+              {
+                pattern: /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/,
+                message: '不合法的身份证格式',
               }
             ]}
-            placeholder="请输入民族"
-            name="nation"
-            label="民族"/>
+            placeholder="请输入身份证"
+            name="idCard"
+            label="身份证"/>
+          <ProFormRadio.Group
+            label="性别"
+            width="m"
+            name="sex"
+            options={['男','女']}
+          />
         </ProForm.Group>
         <ProForm.Group>
           <Form.Item
             label="户籍地址:"
             name='address'
-            rules={[
-              {
-                required:true,
-                message:'请选择户籍地址'
-              }
-            ]}
           >
             <Cascader
               changeOnSelect
@@ -171,12 +179,6 @@ class NewEmployees extends Component{
           </Form.Item>
           <ProFormText
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入户籍街道地址'
-              }
-            ]}
             placeholder="请输入户籍街道地址"
             name="residenceAddress"
             label="户籍街道地址"/>
@@ -185,12 +187,6 @@ class NewEmployees extends Component{
           <Form.Item
             label="现住地址:"
             name='userNowAddress'
-            rules={[
-              {
-                required:true,
-                message:'请选择现住地址'
-              }
-            ]}
           >
             <Cascader
               changeOnSelect
@@ -202,12 +198,6 @@ class NewEmployees extends Component{
           </Form.Item>
           <ProFormText
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入现住街道地址'
-              }
-            ]}
             placeholder="请输入现住街道地址"
             name="nowAddress"
             label="现住街道地址"/>
@@ -216,12 +206,6 @@ class NewEmployees extends Component{
           <Form.Item
             label="籍贯:"
             name='nativePlace'
-            rules={[
-              {
-                required:true,
-                message:'请选择籍贯'
-              }
-            ]}
           >
             <Cascader
               changeOnSelect
@@ -233,25 +217,13 @@ class NewEmployees extends Component{
           </Form.Item>
           <ProFormText
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入身份证'
-              }
-            ]}
-            placeholder="请输入身份证"
-            name="idCard"
-            label="身份证"/>
+            placeholder="请输入民族"
+            name="nation"
+            label="民族"/>
         </ProForm.Group>
         <ProForm.Group>
           <ProFormText
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入身份证领证机关'
-              }
-            ]}
             placeholder="请输入身份证领证机关"
             name="certificationAuthority"
             label="身份证领证机关"/>
@@ -259,34 +231,16 @@ class NewEmployees extends Component{
             label="婚姻状态"
             name="marriage"
             options={['未婚','已婚','离异']}
-            rules={[
-              {
-                required:true,
-                message:'请输入姓名'
-              }
-            ]}
           />
         </ProForm.Group>
         <ProForm.Group>
           <ProFormDigit
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入儿子数量'
-              }
-            ]}
             placeholder="请输入儿子数量"
             name="son"
             label="儿子数量"/>
           <ProFormDigit
             width="m"
-            rules={[
-              {
-                required:true,
-                message:'请输入女儿数量'
-              }
-            ]}
             placeholder="请输入女儿数量"
             name="girl"
             label="女儿数量"/>

+ 24 - 0
src/pages/personnel/archives/statistics/components/personnelDetails.jsx

@@ -0,0 +1,24 @@
+import React,{Component} from 'react';
+import Modal from '@/components/common/Modal';
+
+class PersonnelDetails extends Component{
+  constructor(props) {
+    super(props);
+  }
+
+  render() {
+    const {userInfo} = this.props;
+    return (
+      <Modal
+        title={userInfo.name+'人事档案'}
+        footer={null}
+        visible={this.props.visible}
+        onCancel={(e) => {e.stopPropagation();this.props.onCancel();}}
+      >
+
+      </Modal>
+    )
+  }
+}
+
+export default PersonnelDetails;

+ 227 - 11
src/pages/personnel/archives/statistics/index.jsx

@@ -1,9 +1,11 @@
 import React,{Component} from "react";
-import {Button} from "antd";
+import {Button, message} from "antd";
 import DataTable from "@/components/common/DataTable";
 import moment from 'moment';
 import NewEmployees from './components/newEmployees';
-import AddOrganization from "@/pages/admin/organization/mechanism/components/addOrganization";
+import PersonnelDetails from './components/personnelDetails';
+import {getSelectSuperId} from "@/services/user";
+import {ProFormSelect} from "@ant-design/pro-form";
 
 class Archives extends Component{
   constructor(props) {
@@ -24,16 +26,49 @@ class Archives extends Component{
           title: "名称",
           dataIndex: "name",
           key: "name",
+          searchBool:true,
         },
         {
           title: "员工状态",
           dataIndex: "statusName",
-          key: "statusName",
+          key: "status",
+          searchBool:true,
+          valueType: 'select',
+          valueEnum: {
+            '0': {
+              text: '实习生',
+            },
+            '1': {
+              text: '在职(试用期)',
+            },
+            '2': {
+              text: '在职(合同期)',
+            },
+            '3': {
+              text: '兼职',
+            },
+            '4': {
+              text: '离职',
+            },
+          }
         },
         {
           title: "所属系统",
           dataIndex: "systemName",
-          key: "systemName",
+          key: "system",
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            '0': {
+              text: '管理系统',
+            },
+            '1': {
+              text: '营销系统',
+            },
+            '2': {
+              text: '技术系统',
+            },
+          }
         },
         {
           title: "公司名称",
@@ -59,11 +94,15 @@ class Archives extends Component{
           title: "入职时间",
           dataIndex: "entryTimes",
           key: "entryTimes",
+          valueType: 'dateRange',
+          searchBool: true,
         },
         {
           title: "转正时间",
           dataIndex: "promotionTimes",
           key: "promotionTimes",
+          valueType: 'dateRange',
+          searchBool: true,
           render: (text) => {
             let time = moment(text).valueOf();
             let today = Date.parse(new Date());
@@ -85,6 +124,16 @@ class Archives extends Component{
           title: "性别",
           dataIndex: "sex",
           key: "sex",
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            0:{
+              text:'男'
+            },
+            1:{
+              text:'女'
+            }
+          },
           render: (text) => {
             if (text === 0) {
               return "男";
@@ -96,7 +145,20 @@ class Archives extends Component{
         {
           title: "婚姻状态",
           dataIndex: "marriageName",
-          key: "marriageName",
+          key: "marriage",
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            "0":{
+              text:'未婚'
+            },
+            "1":{
+              text:'已婚'
+            },
+            "2":{
+              text:'离异'
+            }
+          },
         },
         {
           title: "子/女",
@@ -109,12 +171,47 @@ class Archives extends Component{
         {
           title: "政治面貌",
           dataIndex: "politicalOutlookName",
-          key: "politicalOutlookName",
+          key: "politicalOutlook",
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            "0":{
+              text:'群众'
+            },
+            "1":{
+              text:'中共预备党员'
+            },
+            "2":{
+              text:'中共党员'
+            },
+            "3":{
+              text:'致公党员'
+            }
+          },
         },
         {
           title: "教育经历",
           dataIndex: "educationName",
-          key: "educationName",
+          key: "education",
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            "0": {
+              text: '高中/中专'
+            },
+            "1": {
+              text: '专科/高职'
+            },
+            "2": {
+              text: '本科'
+            },
+            "3": {
+              text: '研究生'
+            },
+            "5": {
+              text: '博士'
+            },
+          }
         },
         {
           title: "毕业学校",
@@ -145,19 +242,21 @@ class Archives extends Component{
           title: "合同时间",
           dataIndex: "contractStart",
           key: "contractStart",
+          valueType: 'dateRange',
+          searchBool: true,
           render: (text, record) => {
             let end = moment(record.contractEnd).valueOf();
             let today = Date.parse(new Date());
             let sevenDay = 604800000;
-            if (text) {
+            if (record.contractStart) {
               if (end - today < sevenDay) {
                 return (
                   <span style={{ color: "red", fontWeight: 900 }}>
-                    {text + "~" + record.contractEnd}
+                    {record.contractStart + "~" + record.contractEnd}
                   </span>
                 );
               }
-              return text + "~" + record.contractEnd;
+              return record.contractStart + "~" + record.contractEnd;
             }
           },
         },
@@ -210,11 +309,28 @@ class Archives extends Component{
           title: "离职时间",
           dataIndex: "quitTime",
           key: "quitTime",
+          valueType: 'dateRange',
+          searchBool: true,
         },
         {
           title: "工作年限",
           dataIndex: "workingYear",
-          key: "workingYear",
+          key: "workingYears",
+          searchBool: true,
+          valueEnum: {
+            "0":{
+              text:'0-1年'
+            },
+            "1":{
+              text:'1-3年'
+            },
+            "2":{
+              text:'3-10年'
+            },
+            "3":{
+              text:'10年以上'
+            }
+          },
         },
         {
           title: "年龄",
@@ -246,9 +362,86 @@ class Archives extends Component{
           dataIndex: "fundEndTimes",
           key: "fundEndTimes",
         },
+        {
+          title: "所属公司",
+          dataIndex: "company",
+          key: "company",
+          hideInTable: true,
+          searchBool: true,
+          renderFormItem: () => {
+            return (
+              <ProFormSelect label='' request={this.departmentList}/>
+            );
+          },
+        },
+        {
+          title: "生日月份",
+          dataIndex: "birthdayMonth",
+          key: "birthdayMonth",
+          hideInTable: true,
+          searchBool: true,
+          valueType: 'select',
+          valueEnum: {
+            "1":{
+              text:'一月'
+            },
+            "2":{
+              text:'二月'
+            },
+            "3":{
+              text:'三月'
+            },
+            "4":{
+              text:'四月'
+            },
+            "5":{
+              text:'五月'
+            },
+            "6":{
+              text:'六月'
+            },
+            "7":{
+              text:'七月'
+            },
+            "8":{
+              text:'八月'
+            },
+            "9":{
+              text:'九月'
+            },
+            "10":{
+              text:'十月'
+            },
+            "11":{
+              text:'十一月'
+            },
+            "12":{
+              text:'十二月'
+            }
+          },
+        },
       ],
       visible:false,
+      userInfo: {},
+    }
+  }
+
+  // 部门
+  departmentList = async() => {
+    const msg = await getSelectSuperId();
+    if(msg.error.length === 0){
+      let theArr = [];
+      msg.data.forEach((item) => {
+        theArr.push({
+          label: item.name,
+          value: item.id
+        });
+      });
+      return theArr;
+    }else{
+      message.info(msg.error[0].message)
     }
+    return [];
   }
 
   render() {
@@ -263,6 +456,28 @@ class Archives extends Component{
           rowKey='id'
           scroll={{x:3500}}
           columns={this.state.columns}
+          requestProcess={(v)=>{
+            if(v && v.promotionTimes){
+              v.promotionStart = v.promotionTimes[0];
+              v.promotionEnd = v.promotionTimes[1];
+              delete v.promotionTimes;
+            }
+            if(v && v.entryTimes){
+              v.entryStart = v.entryTimes[0];
+              v.entryEnd = v.entryTimes[1];
+              delete v.entryTimes;
+            }
+            if(v && v.quitTime){
+              v.quitStart = v.quitTime[0];
+              v.quitEnd = v.quitTime[1];
+              delete v.quitTime;
+            }
+            if(v && v.contractStart){
+              v.contractEnd = v.contractStart[1];
+              v.contractStart = v.contractStart[0];
+            }
+            return v;
+          }}
           search={{
             filterType: 'query',
             labelWidth: 'auto',
@@ -301,6 +516,7 @@ class Archives extends Component{
             })
           }}
         /> }
+        <PersonnelDetails userInfo={this.state.userInfo}/>
       </>
     )
   }

+ 18 - 12
src/utils/tools.js

@@ -212,7 +212,7 @@ const citySelect = () => {
 }
 
 // 地区选择 省市区
-const getAddressSelect = async (arr) => {
+const getAddressSelect = async (arr = addressList) => {
   await arr.map((v) =>{
     v.label = v.name;
     v.value = v.id;
@@ -229,19 +229,25 @@ const getAddressSelect = async (arr) => {
 }
 
 // 籍贯选择 省市
-const getNativePlace = async (arr) => {
-  await arr.map((v) =>{
-    v.label = v.name;
-    v.value = v.id;
-    if(v.cityList){
-      v.children = v.cityList;
-      getNativePlace(v.children);
-    }
-    if(v.areaList && v.areaList.length > 0){
-      v.areaList = [];
+const getNativePlace = async (arr = addressList) => {
+  let list = [];
+  await arr.map((value) =>{
+    let obj = {};
+    if(value.cityList && value.cityList.length > 0){
+      let cityList = [];
+      value.cityList.map((v) => {
+        cityList.push({
+          label: v.name,
+          value: v.id,
+        })
+      });
+      obj.children = cityList;
     }
+    obj.label = value.name;
+    obj.value = value.id;
+    list.push(obj)
   })
-  return arr.filter(v=>v.id)
+  return list
 }
 
 // 省份转换