Browse Source

人员档案编制节点增加保存逻辑

cyy 1 week ago
parent
commit
0d219a210a

+ 1 - 0
src/views/component/personnelFile/components/gzjlTag.vue

@@ -425,6 +425,7 @@ export default {
           this.nowDataObj = { nowData: [...this.nowData] }
         } else if (
           val === 'save' ||
+          val === 'saveWorkflow' ||
           val === 'temporaryStorage' ||
           val === 'submit' ||
           val === 'sendBack' ||

+ 99 - 24
src/views/component/personnelFile/components/jbqkTag.vue

@@ -66,14 +66,15 @@
       <div class="rowSty">
         <div class="colSty"><div class="grid-content bg-purple">年龄</div></div>
         <div class="colSty">
-          <div v-if="judgeTag()" class="grid-content bg-purple-light">
+          <!-- <div v-if="judgeTag()" class="grid-content bg-purple-light"> -->
+          <div class="grid-content bg-purple-light">
             <div>
               {{
                 nowData.hasOwnProperty('nianLing') > 0 ? nowData.nianLing : '/'
               }}
             </div>
           </div>
-          <div v-else class="grid-content bg-purple-light">
+          <!-- <div v-else class="grid-content bg-purple-light">
             <el-form-item prop="nianLing">
               <el-input-number
                 v-model.number="nowData.nianLing"
@@ -83,7 +84,7 @@
                 size="mini"
               />
             </el-form-item>
-          </div>
+          </div> -->
         </div>
         <div class="colSty">
           <div class="grid-content bg-purple">最高学历学位</div>
@@ -486,6 +487,7 @@ export default {
     return {
       activeName: 'first',
       nowData: {},
+      originData: null,
       isWatch: false,
       rules: {
         jianDangRiQi: [{ validator: option.checkTime, trigger: 'blur' }],
@@ -534,28 +536,25 @@ export default {
     // immediate: true
     // },
     //监听身份证变化
-    'nowData.shenFenZhengHao': {
-      handler(newVal) {
-        if (newVal && this.isWatch) {
-          if (newVal.length === 18) {
-            this.nowData.chuShengRiQi =
-              newVal.substring(6, 10) +
-              '-' +
-              newVal.substring(10, 12) +
-              '-' +
-              newVal.substring(12, 14)
-          }
-        }
-      },
-      immediate: false
-    },
+    // 'nowData.shenFenZhengHao': {
+    //   handler(newVal) {
+    //     if (!newVal || !this.isWatch || !this.isValidIdCard(newVal)) return
+    //     this.nowData.chuShengRiQi =
+    //       newVal.substring(6, 10) +
+    //       '-' +
+    //       newVal.substring(10, 12) +
+    //       '-' +
+    //       newVal.substring(12, 14)
+    //   },
+    //   immediate: false
+    // },
     // 监听出生日期变化
     'nowData.chuShengRiQi': {
       handler(newVal) {
-        if (newVal && this.isWatch) {
-          const ageDifMs = Date.now() - new Date(newVal).getTime()
-          const ageDate = new Date(ageDifMs)
-          this.nowData.nianLing = Math.abs(ageDate.getUTCFullYear() - 1970)
+        if (!newVal || !this.isWatch) return
+        const age = this.calculateAge(newVal)
+        if (age !== null) {
+          this.nowData.nianLing = age
         }
       }
       // immediate: true
@@ -564,9 +563,14 @@ export default {
       handler: function (val, oldVal) {
         // eslint-disable-next-line no-undef
         if (this.$utils.isNotEmpty(val)) {
+          this.isWatch = false
+          // eslint-disable-next-line no-undef
           this.nowData = structuredClone(val)
           setTimeout(() => {
             this.isWatch = true
+            this.syncBirthAndAge()
+            // eslint-disable-next-line no-undef
+            this.originData = structuredClone(this.nowData)
           }, 0)
         }
         // if(this.nowData.ruZhiShiJian){
@@ -579,13 +583,24 @@ export default {
       deep: true,
       immediate: true
     },
+    btnShow: {
+      handler(val, oldVal) {
+        if (val === false && oldVal === true) {
+          // eslint-disable-next-line no-undef
+          this.originData = structuredClone(this.nowData)
+        }
+      }
+    },
     btnType: {
       handler: function (val, oldVal) {
         if (val === 'exitEdit') {
-          // eslint-disable-next-line no-undef
-          this.nowData = structuredClone(this.planeData)
+          const source = this.$utils.isNotEmpty(this.originData)
+            ? this.originData
+            : this.planeData
+          this.resetNowData(source)
         } else if (
           val === 'save' ||
+          val === 'saveWorkflow' ||
           val === 'temporaryStorage' ||
           val === 'submit' ||
           val === 'sendBack' ||
@@ -615,6 +630,66 @@ export default {
     // this.$set(this.nowData, 'gongZuoNianXia', years > 0 ? years : '0')
     // }
     // },
+    resetNowData(data) {
+      this.isWatch = false
+      // eslint-disable-next-line no-undef
+      this.nowData = structuredClone(data)
+      this.$nextTick(() => {
+        this.isWatch = true
+      })
+    },
+    isValidIdCard(idCard) {
+      const idCardReg =
+        /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/
+      if (!idCardReg.test(idCard)) return false
+      const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
+      const checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']
+      let sum = 0
+      for (let i = 0; i < 17; i++) {
+        sum += parseInt(idCard[i], 10) * weights[i]
+      }
+      return checkCodes[sum % 11] === idCard[17].toUpperCase()
+    },
+    calculateAge(birthDateStr) {
+      if (!birthDateStr || typeof birthDateStr !== 'string') return null
+      const parts = birthDateStr.trim().substring(0, 10).split('-')
+      if (parts.length !== 3) return null
+      const year = Number(parts[0])
+      const month = Number(parts[1])
+      const day = Number(parts[2])
+      if (!year || !month || !day) return null
+      const birth = new Date(year, month - 1, day)
+      if (
+        birth.getFullYear() !== year ||
+        birth.getMonth() !== month - 1 ||
+        birth.getDate() !== day
+      ) {
+        return null
+      }
+      const today = new Date()
+      let age = today.getFullYear() - year
+      const monthDiff = today.getMonth() - (month - 1)
+      if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < day)) {
+        age--
+      }
+      if (age < 0 || age > 150) return null
+      return age
+    },
+    syncBirthAndAge() {
+      const idCard = this.nowData.shenFenZhengHao
+      if (idCard && this.isValidIdCard(idCard)) {
+        this.nowData.chuShengRiQi =
+          idCard.substring(6, 10) +
+          '-' +
+          idCard.substring(10, 12) +
+          '-' +
+          idCard.substring(12, 14)
+      }
+      const age = this.calculateAge(this.nowData.chuShengRiQi)
+      if (age !== null) {
+        this.nowData.nianLing = age
+      }
+    },
     judgeTag() {
       // return this.planeData.length>0&& this.btnShow === true && this.buttonType!==1 ? true : false
       return !!(

+ 1 - 0
src/views/component/personnelFile/components/jyjlTag.vue

@@ -387,6 +387,7 @@ export default {
           this.nowDataObj = { nowData: [...this.nowData] }
         } else if (
           val === 'save' ||
+          val === 'saveWorkflow' ||
           val === 'temporaryStorage' ||
           val === 'submit' ||
           val === 'sendBack' ||

+ 12 - 7
src/views/component/personnelFile/components/personnelInfo.vue

@@ -22,13 +22,14 @@
         <div class="contentHeader">
           <div class="contentHeaderLeft">
             <p>姓名:</p>
-            <el-input
+            <!-- <el-input
               v-if="buttonType === 1"
               v-model="submitperInfoData.name"
               class="leftFont"
               size="mini"
-            />
-            <span v-else>{{ submitperInfoData.name }}</span>
+            /> -->
+            <!-- <span v-else>{{ submitperInfoData.name }}</span> -->
+            <span>{{ submitperInfoData.name }}</span>
           </div>
           <div>
             <el-button
@@ -65,10 +66,10 @@
               >提交</el-button
             >
             <el-button
-              v-if="buttonType === 1"
+              v-if="buttonType === 1 || buttonType === 4"
               type="primary"
               icon="ibps-icon-save"
-              @click="changeButton('save')"
+              @click="changeButton(buttonType === 1 ? 'save' : 'saveWorkflow')"
               >保存</el-button
             >
             <el-button
@@ -339,8 +340,12 @@ export default {
       flowDiagramVisible: false,
       approvalHistoryVisible: false,
       moreShow: false,
-      processKey: setting?.system?.isJYB ? 'Process_0v35zf8' : 'Process_08xwabfNEW',
-      processId: setting?.system?.isJYB ? '1453020655493578752' : '1315609540510613504',
+      processKey: setting?.system?.isJYB
+        ? 'Process_0v35zf8'
+        : 'Process_08xwabfNEW',
+      processId: setting?.system?.isJYB
+        ? '1453020655493578752'
+        : '1315609540510613504'
     }
   },
   watch: {

+ 1 - 0
src/views/component/personnelFile/components/zsbTag.vue

@@ -384,6 +384,7 @@ export default {
           this.nowDataObj = { nowData: [...this.nowData] }
         } else if (
           val === 'save' ||
+          val === 'saveWorkflow' ||
           val === 'temporaryStorage' ||
           val === 'submit' ||
           val === 'sendBack' ||

+ 15 - 5
src/views/component/personnelFile/index.vue

@@ -330,9 +330,11 @@ export default {
           this.btnType === 'agree' ||
           this.btnType === 'submit' ||
           this.btnType === 'sendBack' ||
-          this.btnType === 'temporaryStorage') &&
+          this.btnType === 'temporaryStorage' ||
+          this.btnType === 'saveWorkflow') &&
         this.tipsControls === false &&
         (this.btnType === 'temporaryStorage' ||
+          this.btnType === 'saveWorkflow' ||
           this.checkData(this.personInfoData))
       ) {
         this.ensurePersonInfoLists(this.personInfoData)
@@ -340,7 +342,10 @@ export default {
           case 'ryjbqk':
             // eslint-disable-next-line no-undef
             this.personInfoData.ryjbqkInfoPoList[0] = structuredClone(val)
-            if (this.btnType !== 'temporaryStorage') {
+            if (
+              this.btnType !== 'temporaryStorage' &&
+              this.btnType !== 'saveWorkflow'
+            ) {
               this.personInfoData.ryjbqkInfoPoList[0].shiFouGuoShen =
                 this.btnType === 'submit' ||
                 (this.btnType === 'agree' &&
@@ -386,7 +391,7 @@ export default {
                   callback: (action) => {
                     this.$children[0].buttonShow = true
                     this.infoNumArr = []
-
+                    this.personInfoData.mark = 'amend'
                     this.saveData(this.personInfoData, 'Refresh')
                   }
                 })
@@ -431,6 +436,8 @@ export default {
             console.log('重置')
           } else if (this.btnType === 'temporaryStorage') {
             this.saveDraftData(this.personInfoData)
+          } else if (this.btnType === 'saveWorkflow') {
+            this.saveData(this.personInfoData, 'saveWorkflow')
           } else if (this.btnType === 'save') {
             this.personInfoData.shouQuanQianZ = this.userId
             this.personInfoData.updateTime = this.$common.getDateNow(19)
@@ -488,7 +495,9 @@ export default {
     },
     saveData(val, r) {
       setInfo(val).then((res) => {
-        this.showTF(false)
+        if (r !== 'saveWorkflow') {
+          this.showTF(false)
+        }
         if (r === 'Refresh') {
           location.reload()
         }
@@ -500,7 +509,8 @@ export default {
         val === 'agree' ||
         val === 'submit' ||
         val === 'sendBack' ||
-        val === 'temporaryStorage'
+        val === 'temporaryStorage' ||
+        val === 'saveWorkflow'
       ) {
         this.infoNumArr = []
       }