Переглянути джерело

工资单-生成工资单验证是否存在当月工资单

jingbb 1 рік тому
батько
коміт
43ccc76658

+ 54 - 22
src/views/oa/salary_management/personnelSalary/modules/uploadModal.vue

@@ -57,6 +57,16 @@
                 </a-form-model>
             </div>
       </a-modal>
+      <a-modal
+        width="30%"
+        title="请确认"
+        :visible="visibleOk"
+        @ok="handleOkPayroll"
+        @cancel="handleCancelPayroll"
+        :getContainer ='()=>$refs.replyModal'
+        >
+            <p>{{ ModalText }}</p>
+    </a-modal>
     </div>
 </template>
 <script>
@@ -78,12 +88,13 @@
                 DateTime:[],
                 yearWith:''
               },
-              DateTime:[],
               open: false,
               isopen:false,
               dataSource: [{}],
               mode2: ['month', 'month'],
               visible:false,
+              visibleOk:false,
+              ModalText:'',
               loading:false,    
               validatorRules: {
                 type: [{required: true, message: '请选择!' }],
@@ -102,7 +113,9 @@
                 this.visible = false
                 this.formState={
                     type:'月度工资单',
-                    yearWithMonth:moment().subtract(1, 'months')
+                    yearWithMonth:moment().subtract(1, 'months'),
+                    DateTime:[],
+                    yearWith:''
                 }
                 // this.DateTime = []
             },
@@ -126,7 +139,6 @@
                 }
             },
             handleOk(){
-              
                 this.$refs.form.validate((valid,err) => {
                     if (valid) {
                         if(this.formState.type=='加班工资单'){
@@ -140,35 +152,55 @@
                         if(this.formState.type=='年休工资单'){
                             this.formState.yearWith = moment(this.formState.yearWith).format('YYYY')
                         }
-                        
                         this.loading = true
                         let that = this;
-                        postAction('/salary/salaryManagement/generatePayroll', this.formState).then((res) => {
+                        postAction('/salary/salaryManagement/generatePayrollBefore',this.formState).then((res) => {
                             if (res.success) {
-                              
-                                if(res.data.ZZ){
-                                   that.handleDownload(res.data.ZZ,that.formState.type,"正织");
-                                }
-                                if(res.data.MFY){
-                                   that.handleDownload(res.data.MFY,that.formState.type,"马菲羊");
-                                }
-                                if(res.data.NBSY){
-                                   that.handleDownload(res.data.NBSY,that.formState.type,"宁波森语");
-                                }
-                                
-                                this.$message.success(res.message);
-                                this.handleCancel()
-                                this.$emit('ok')
+                               this.generatePayroll(this.formState)
                             } else {
-                                this.$message.error(res.message);
-                            }   
+                                this.ModalText = res.message
+                                this.visibleOk = true
+                            }
                         }).finally(() => {
                             this.loading = false
-                        })
+                        }) 
                     }
                 })
 
             },
+            handleOkPayroll(){
+                this.ModalText = ''
+                this.visibleOk = false
+                this.generatePayroll(this.formState)
+            },
+            handleCancelPayroll(){
+                this.ModalText = ''
+                this.visibleOk = false
+            },
+            generatePayroll(data){
+                this.loading = true
+                let that = this;
+                postAction('/salary/salaryManagement/generatePayroll',data).then((res) => {
+                    if (res.success) {
+                        if(res.data&&res.data.ZZ){
+                             that.handleDownload(res.data.ZZ,that.formState.type,"正织");
+                        }
+                        if(res.data&&res.data.MFY){
+                             that.handleDownload(res.data.MFY,that.formState.type,"马菲羊");
+                        }
+                        if(res.data&&res.data.NBSY){
+                            that.handleDownload(res.data.NBSY,that.formState.type,"宁波森语");
+                        } 
+                        this.$message.success(res.message);
+                        this.handleCancel()
+                        this.$emit('ok')
+                    } else {
+                        this.$message.error(res.message);
+                    }
+                }).finally(() => {
+                    this.loading = false
+                })
+            },
             handleDownload(id,type,name){
               downFile('/salary/salaryManagement/exportXls2',{id:id,type:type}).then(data => {