From deb42cf1c3b3fc80c579b140939bc459d4262604 Mon Sep 17 00:00:00 2001
From: luoyb <412940104@qq.com>
Date: 星期六, 06 三月 2021 12:30:25 +0800
Subject: [PATCH] fix(bug修复): 在职员工录入身份证校验

---
 src/views/user/archivesChange.vue |    1 
 src/utils/myUtil.js               |   15 +++++
 src/views/user/inemployees.vue    |  146 +++++++++++++++++++++++++++++++++++++-----------
 src/views/user/outemployess.vue   |    2 
 4 files changed, 129 insertions(+), 35 deletions(-)

diff --git a/src/utils/myUtil.js b/src/utils/myUtil.js
index 029e96f..586cb27 100644
--- a/src/utils/myUtil.js
+++ b/src/utils/myUtil.js
@@ -53,6 +53,13 @@
   return age
 }
 
+/**
+ * 计算日期时间间隔
+ * @param begin 起始时间
+ * @param end 结束时间
+ * @param flag 间隔单位
+ * @returns {*}
+ */
 export function dateDifference(begin, end, flag) {
   let dateSpan
   let iReturn
@@ -70,3 +77,11 @@
   }
   return iReturn
 }
+
+export function dateToString(val) {
+  val = new Date(val)
+  const year = val.getFullYear()
+  const month = val.getMonth() + 1
+  const day = val.getDate()
+  return year + '-' + month + '-' + day
+}
diff --git a/src/views/user/archivesChange.vue b/src/views/user/archivesChange.vue
index 5c84bc5..1546a7a 100644
--- a/src/views/user/archivesChange.vue
+++ b/src/views/user/archivesChange.vue
@@ -3181,7 +3181,6 @@
       this.$get('hr/empInsurance/list', {
         ...params
       }).then((r) => {
-        debugger
         const data = r.data.data
         this.insuranceDatatotal = data.total
         this.insuranceData = data.rows
diff --git a/src/views/user/inemployees.vue b/src/views/user/inemployees.vue
index 6b13571..d073d3e 100644
--- a/src/views/user/inemployees.vue
+++ b/src/views/user/inemployees.vue
@@ -834,7 +834,7 @@
 import Pagination from '@/components/Pagination'
 import Treeselect from '@riophae/vue-treeselect'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-import { calculateSeniority, toCardGetUserInfo } from '@/utils/myUtil'
+import { calculateSeniority, toCardGetUserInfo, dateToString } from '@/utils/myUtil'
 import ArchivesEdit from './archivesEdit'
 import { pages } from '@/settings'
 
@@ -894,7 +894,7 @@
         birthdate: '',
         politics: '13',
         entryDate: '',
-        education: '61',
+        education: '17',
         seniority: '',
         nativePlace: '',
         nativePlaceName: '',
@@ -1088,7 +1088,8 @@
       changeTypeOptions: [],
       dimissionTypeOptions: [],
       ageStrOptions: [],
-      sexOptions: []
+      sexOptions: [],
+      openArchivesForm: {}
     }
   },
   mounted() {
@@ -1416,6 +1417,7 @@
       this.empBaseInfoImageUrl = ''
     },
     editEmpBase(row) {
+      console.log(row)
       this.isAdd = false
       this.empBaseInfoForm.empId = row.empId
       this.empBaseInfoForm.customerId = row.customerId
@@ -1471,26 +1473,52 @@
     putEmpBase(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          if (this.isAdd) {
-            this.$post('hr/empBaseInfo', { ...this.empBaseInfoForm }).then((r) => {
-              r.data
-              this.buttonLoading = false
-              this.$message({
-                message: this.$t('tips.createSuccess'),
-                type: 'success'
-              })
-              this.cleanEmpBase()
-            })
-          } else {
-            this.$put('hr/empBaseInfo', { ...this.empBaseInfoForm }).then(() => {
-              this.$message({
-                message: this.$t('tips.updateSuccess'),
-                type: 'success'
-              })
-              this.$emit('success')
-              this.cleanEmpBase()
-            })
-          }
+          this.submitEmpInfo()
+          // if (this.isAdd) {
+          //   this.$post('hr/empBaseInfo/addInEmp', { ...this.empBaseInfoForm }).then((r) => {
+          //     if (r.data != null) {
+          //       if (r.data.data.empStatus === '0') {
+          //         this.$confirm('该员工已存在,是否修改?', '提示', {
+          //           confirmButtonText: '确定',
+          //           cancelButtonText: '取消',
+          //           type: 'warning'
+          //         }).then(() => {
+          //           this.editEmpBase(r.data.data)
+          //         })
+          //       } else {
+          //         this.$confirm('该员工已离职,是否重新打开档案?', '提示', {
+          //           confirmButtonText: '确定',
+          //           cancelButtonText: '取消',
+          //           type: 'warning'
+          //         }).then(() => {
+          //           this.openArchivesForm = {
+          //             empId: r.data.data.empId,
+          //             empName: r.data.data.empName,
+          //             certificateNumb: r.data.data.certificateNumb,
+          //             openType: 2,
+          //             openDate: this.getDateString(),
+          //             remark: ''
+          //           }
+          //           this.$post('hr/empOpenArchives', { ...this.openArchivesForm }).then(() => {
+          //             this.$message({
+          //               message: this.$t('员工档案打开成功'),
+          //               type: 'success'
+          //             })
+          //           })
+          //         })
+          //       }
+          //     }
+          //   })
+          // } else {
+          //   this.$put('hr/empBaseInfo', { ...this.empBaseInfoForm }).then(() => {
+          //     this.$message({
+          //       message: this.$t('tips.updateSuccess'),
+          //       type: 'success'
+          //     })
+          //     this.$emit('success')
+          //     this.cleanEmpBase()
+          //   })
+          // }
           this.fetch({
             ...this.queryParams,
             ...this.sort
@@ -1503,16 +1531,17 @@
     putEmpBaseContinue(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
-          if (this.isAdd) {
-            this.$post('hr/empBaseInfo', { ...this.empBaseInfoForm }).then(() => {
-              this.buttonLoading = false
-              this.$message({
-                message: this.$t('tips.createSuccess'),
-                type: 'success'
-              })
-              this.cleanEmpBase()
-            })
-          }
+          this.submitEmpInfo()
+          // if (this.isAdd) {
+          //   this.$post('hr/empBaseInfo', { ...this.empBaseInfoForm }).then(() => {
+          //     this.buttonLoading = false
+          //     this.$message({
+          //       message: this.$t('tips.createSuccess'),
+          //       type: 'success'
+          //     })
+          //     this.cleanEmpBase()
+          //   })
+          // }
           this.cleanEmpBase()
           this.fetch({
             ...this.queryParams,
@@ -1554,6 +1583,7 @@
     },
     showXzyg(val) {
       if (val === 0) {
+        // this.cleanEmpBase()
         this.isAdd = true
       }
       if (!this.dialogShowXzyg) {
@@ -1883,6 +1913,56 @@
       } else {
         return null
       }
+    },
+    getDateString() {
+      return dateToString(new Date())
+    },
+    submitEmpInfo() {
+      if (this.isAdd) {
+        this.$post('hr/empBaseInfo/addInEmp', { ...this.empBaseInfoForm }).then((r) => {
+          if (r.data != null) {
+            if (r.data.data.empStatus === '0') {
+              this.$confirm('该员工已存在,是否修改?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+              }).then(() => {
+                this.editEmpBase(r.data.data)
+              })
+            } else {
+              this.$confirm('该员工已离职,是否重新打开档案?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+              }).then(() => {
+                this.openArchivesForm = {
+                  empId: r.data.data.empId,
+                  empName: r.data.data.empName,
+                  certificateNumb: r.data.data.certificateNumb,
+                  openType: 2,
+                  openDate: this.getDateString(),
+                  remark: ''
+                }
+                this.$post('hr/empOpenArchives', { ...this.openArchivesForm }).then(() => {
+                  this.$message({
+                    message: this.$t('员工档案打开成功'),
+                    type: 'success'
+                  })
+                })
+              })
+            }
+          }
+        })
+      } else {
+        this.$put('hr/empBaseInfo', { ...this.empBaseInfoForm }).then(() => {
+          this.$message({
+            message: this.$t('tips.updateSuccess'),
+            type: 'success'
+          })
+          this.$emit('success')
+          this.cleanEmpBase()
+        })
+      }
     }
   }
 }
diff --git a/src/views/user/outemployess.vue b/src/views/user/outemployess.vue
index bd442b1..d0c1860 100644
--- a/src/views/user/outemployess.vue
+++ b/src/views/user/outemployess.vue
@@ -976,7 +976,7 @@
 <script>
 import Pagination from '@/components/Pagination'
 import ArchivesChange from './archivesChange'
-
+import { dateToString } from '@/utils/myUtil'
 export default {
   components: {
     ArchivesChange,

--
Gitblit v1.8.0