Jelajahi Sumber

年审审核时间判断

huahaiyan 6 tahun lalu
induk
melakukan
1fe8089353

+ 72 - 11
src/dashoo.cn/backend/api/controllers/oilsupplier/annualaudit.go

@@ -291,6 +291,68 @@ func (this *AnnualAuditController) GetEntity() {
 	this.ServeJSON()
 }
 
+// @Title 添加
+// @Description 直接新增年审
+// @Success	200	{object} controllers.Request
+// @router /adddirect [post]
+func (this *AnnualAuditController) AddEntityDirect() {
+	var model annualaudit.OilAnnualAudit
+	var errinfo ErrorDataInfo
+	var jsonBlob = this.Ctx.Input.RequestBody
+	svc := annualaudit.GetOilAnnualAuditService(utils.DBE)
+	firstAudit := this.GetString("firstAudit")
+	json.Unmarshal(jsonBlob, &model)
+	supwhere := "a.Id = " + utils.ToStr(model.SupplierId) + " and b.SupplierTypeCode = '" + model.SupplierTypeName+ "' and b.Status = '8' "
+	supsvc := supplier.GetOilSupplierService(utils.DBE)
+	var list []supplier.OilSupplierView
+	supsvc.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 1, 1, "a.Id", true, &list, supwhere)
+	var suppliermodel supplier.OilSupplierView
+	suppliermodel = list[0]
+	model.AccessCardNo = suppliermodel.AccessCardNo
+	model.RecUnitId = suppliermodel.RecUnitId
+	model.CerId, _ = strconv.Atoi(suppliermodel.CertId)
+	model.ApplyTime = suppliermodel.ApplyTime
+	model.Status = "0"
+	model.Step = 1
+	model.BackReason = suppliermodel.BackReason
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	//添加一条年审记录
+	_, err := svc.InsertEntityBytbl(""+OilAnnualAuditName, &model)
+	annualId := model.Id
+	svcActiviti := workflow.GetActivitiService(utils.DBE)
+	//启动工作流
+	businessKey := utils.ToStr(annualId) + "-" + strconv.Itoa(model.AuditIndex)
+	processInstanceId := svcActiviti.StartProcess(workflow.OIL_AUDIT_APPLY, businessKey, this.User.Id)
+	var auditmodel annualaudit.OilAnnualAudit
+	auditmodel.WorkflowId = processInstanceId
+	auditmodel.FirstAudit, _ = strconv.Atoi(firstAudit)
+	auditmodel.AuditIndex = model.AuditIndex
+	auditmodel.BusinessKey = businessKey
+	cols := []string{
+		"Id",
+		"WorkflowId",
+		"FirstAudit",
+		"AuditIndex",
+		"BusinessKey",
+	}
+	_, err = svc.UpdateEntityByIdCols(annualId, auditmodel, cols)
+	if err == nil {
+		//新增
+		errinfo.Message = "添加成功!"
+		errinfo.Code = 0
+		errinfo.Item = model.Id
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
 // @Title 添加
 // @Description 新增年审
 // @Success	200	{object} controllers.Request
@@ -333,17 +395,16 @@ func (this *AnnualAuditController) AddEntity() {
 		this.ServeJSON()
 		return
 	}
-	//先不要年审时间的判断
-	//aplytime := suppliermodel.ApplyTime
-	//subtime := this.getTimeSub(aplytime, time.Now())
-	//lefttime := subtime - 3
-	//if subtime > 3 {
-		//errinfo.Message = "还不到年审时间!请" + utils.ToStr(lefttime) + "个月后再来申请"
-		//errinfo.Code = -1
-		//this.Data["json"] = &errinfo
-		//this.ServeJSON()
-		//return
-	//}
+	aplytime := suppliermodel.ApplyTime
+	subtime := this.getTimeSub(aplytime, time.Now())
+	lefttime := subtime - 3
+	if subtime > 3 {
+		errinfo.Message = "还不到年审时间!请" + utils.ToStr(lefttime) + "个月后再来申请"
+		errinfo.Code = -3
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
 	model.AccessCardNo = suppliermodel.AccessCardNo
 	model.RecUnitId = suppliermodel.RecUnitId
 	model.CerId, _ = strconv.Atoi(suppliermodel.CertId)

+ 7 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/annualaudit.js

@@ -51,6 +51,13 @@ export default {
       data: formData
     })
   },
+  addEntityDirect (formData, FirstAudit, myAxios) {
+    return myAxios({
+      url: '/annualaudit/adddirect?firstAudit=' + FirstAudit,
+      method: 'post',
+      data: formData
+    })
+  },
   commitauditEntity (formData, params, myAxios) {
     return myAxios({
       url: '/annualaudit/addauditcomm',

+ 50 - 8
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/basicindex.vue

@@ -11,9 +11,11 @@
             <i class="icon icon-table2"></i> 年审申请表
           </span>
           <span style="float: right;">
-            <el-button  v-if="IsCompanyUser == 0" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="addaudit">添加
+            <el-button v-if="IsCompanyUser == 0" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;"
+              @click="addaudit">添加
             </el-button>
-            <el-button  v-if="IsCompanyUser == 1" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="addauditcom">添加
+            <el-button v-if="IsCompanyUser == 1" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;"
+              @click="addauditcom">添加
             </el-button>
           </span>
           <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
@@ -225,6 +227,7 @@
 
     data() {
       return {
+        annualauditmakesure: false,
         chooseAuditorVisible: false,
         orgtreelist: [],
         orgtreeprops: {
@@ -329,7 +332,7 @@
         IsCompanyUser: 0,
         supplierList: [],
         suplen: 1,
-        certId:'',
+        certId: '',
       }
     },
     created() {
@@ -377,18 +380,20 @@
         let params = {
           SuppTypeCode: '02',
         }
-        _this.$axios.get('/suppliercertappend/getsupplier', {params})
+        _this.$axios.get('/suppliercertappend/getsupplier', {
+            params
+          })
           .then(res => {
             _this.supplierList = res.data
             if (_this.supplierList) {
               _this.suplen = _this.supplierList.length
-            }else{
+            } else {
               _this.suplen = 0
             }
             if (_this.IsCompanyUser == 1 && _this.supplierList) {
               _this.entityForm.SupplierId = parseInt(_this.supplierList[0].SupplierId)
               _this.entityForm.SupplierName = _this.supplierList[0].SupplierName
-              _this.certId  = _this.supplierList[0].SupplierCertId
+              _this.certId = _this.supplierList[0].SupplierCertId
             }
           })
           .catch(err => {
@@ -433,10 +438,12 @@
         this.entityForm.SupplierName = obj.Realname
       },
       addAnnualAudit() {
+        console.log("123456789qqqqqq")
         this.$refs['EntityFormref'].validate((valid) => {
           if (valid) {
             this.entityForm.auditer = this.auditer
             api.addEntity(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
+              console.log("--22221-",res.data.code)
               if (res.data.code === 0) {
                 //保存成功后,初始化数据,变成修改
                 this.entityForm.Id = res.data.item;
@@ -447,6 +454,12 @@
                   message: res.data.message
                 });
 
+              } else if (res.data.code === -3) {
+                this.$confirm(res.data.message + ",点击继续可继续进行年审")
+                  .then(_ => {
+                    this.addannualdirect()
+                  })
+                  .catch(_ => {});
               } else {
                 this.$message({
                   type: 'warning',
@@ -462,8 +475,31 @@
       addaudit() {
         this.addshow = true
       },
+      addannualdirect() {
+        api.addEntityDirect(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
+          if (res.data.code === 0) {
+            //保存成功后,初始化数据,变成修改
+            this.entityForm.Id = res.data.item;
+            this.initDatas();
+            this.addshow = false
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            });
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            });
+          }
+        }).catch(err => {
+          console.error(err)
+        });
+      },
       addauditcom() {
+        console.log("123456789")
         api.addEntity(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
+          console.log("--1-",res.data.code)
           if (res.data.code === 0) {
             //保存成功后,初始化数据,变成修改
             this.entityForm.Id = res.data.item;
@@ -476,14 +512,20 @@
                 //WorkflowId: ,
                 Status: 0,
                 Step: 1,
-                annualId: this.entityForm.Id ,
+                annualId: this.entityForm.Id,
               }
             })
             this.$message({
               type: 'success',
               message: res.data.message
             });
-
+          } else if (res.data.code === -3) {
+            console.log("--2-",res.data.code)
+            this.$confirm(res.data.message + ",点击继续可继续进行年审")
+              .then(_ => {
+                this.addannualdirect()
+              })
+              .catch(_ => {});
           } else {
             this.$message({
               type: 'warning',

+ 35 - 6
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/goodsindex.vue

@@ -331,7 +331,7 @@
         IsCompanyUser: 0,
         supplierList: [],
         suplen: 1,
-        certId:'',
+        certId: '',
       }
     },
     created() {
@@ -379,18 +379,20 @@
         let params = {
           SuppTypeCode: '01',
         }
-        _this.$axios.get('/suppliercertappend/getsupplier', {params})
+        _this.$axios.get('/suppliercertappend/getsupplier', {
+            params
+          })
           .then(res => {
             _this.supplierList = res.data
             if (_this.supplierList) {
               _this.suplen = _this.supplierList.length
-            }else{
+            } else {
               _this.suplen = 0
             }
             if (_this.IsCompanyUser == 1 && _this.supplierList) {
               _this.entityForm.SupplierId = parseInt(_this.supplierList[0].SupplierId)
               _this.entityForm.SupplierName = _this.supplierList[0].SupplierName
-              _this.certId  = _this.supplierList[0].SupplierCertId
+              _this.certId = _this.supplierList[0].SupplierCertId
             }
           })
           .catch(err => {
@@ -461,11 +463,32 @@
           }
         })
       },
+      addannualdirect() {
+        api.addEntityDirect(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
+          if (res.data.code === 0) {
+            //保存成功后,初始化数据,变成修改
+            this.entityForm.Id = res.data.item;
+            this.initDatas();
+            this.addshow = false
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            });
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            });
+          }
+        }).catch(err => {
+          console.error(err)
+        });
+      },
       addaudit() {
         this.addshow = true
       },
       addauditcom() {
-        console.log("---this.entityForm-",this.entityForm)
+        console.log("---this.entityForm-", this.entityForm)
         api.addEntity(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
           if (res.data.code === 0) {
             //保存成功后,初始化数据,变成修改
@@ -479,13 +502,19 @@
                 //WorkflowId: ,
                 Status: 0,
                 Step: 1,
-                annualId: this.entityForm.Id ,
+                annualId: this.entityForm.Id,
               }
             })
             this.$message({
               type: 'success',
               message: res.data.message
             });
+          } else if (res.data.code === -3) {
+            this.$confirm(res.data.message + ",点击继续可继续进行年审")
+              .then(_ => {
+                this.addannualdirect()
+              })
+              .catch(_ => {});
           } else {
             this.$message({
               type: 'warning',

+ 44 - 7
src/dashoo.cn/frontend_web/src/pages/oilsupplier/annualaudit/techindex.vue

@@ -11,9 +11,11 @@
             <i class="icon icon-table2"></i> 年审申请表
           </span>
           <span style="float: right;">
-            <el-button  v-if="IsCompanyUser == 0" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="addaudit">添加
+            <el-button v-if="IsCompanyUser == 0" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;"
+              @click="addaudit">添加
             </el-button>
-            <el-button  v-if="IsCompanyUser == 1" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="addauditcom">添加
+            <el-button v-if="IsCompanyUser == 1" type="primary" size="mini" style="margin-left:10px; margin-top: -4px;"
+              @click="addauditcom">添加
             </el-button>
           </span>
           <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
@@ -329,7 +331,7 @@
         IsCompanyUser: 0,
         supplierList: [],
         suplen: 1,
-        certId:'',
+        certId: '',
       }
     },
     created() {
@@ -377,18 +379,20 @@
         let params = {
           SuppTypeCode: '03',
         }
-        _this.$axios.get('/suppliercertappend/getsupplier', {params})
+        _this.$axios.get('/suppliercertappend/getsupplier', {
+            params
+          })
           .then(res => {
             _this.supplierList = res.data
             if (_this.supplierList) {
               _this.suplen = _this.supplierList.length
-            }else{
+            } else {
               _this.suplen = 0
             }
             if (_this.IsCompanyUser == 1 && _this.supplierList) {
               _this.entityForm.SupplierId = parseInt(_this.supplierList[0].SupplierId)
               _this.entityForm.SupplierName = _this.supplierList[0].SupplierName
-              _this.certId  = _this.supplierList[0].SupplierCertId
+              _this.certId = _this.supplierList[0].SupplierCertId
             }
           })
           .catch(err => {
@@ -447,6 +451,12 @@
                   message: res.data.message
                 });
 
+              } else if (res.data.code === -3) {
+                this.$confirm(res.data.message + ",点击继续可继续进行年审")
+                  .then(_ => {
+                    this.addannualdirect()
+                  })
+                  .catch(_ => {});
               } else {
                 this.$message({
                   type: 'warning',
@@ -459,6 +469,27 @@
           }
         })
       },
+      addannualdirect() {
+        api.addEntityDirect(this.entityForm, this.entityForm.auditer, this.$axios).then(res => {
+          if (res.data.code === 0) {
+            //保存成功后,初始化数据,变成修改
+            this.entityForm.Id = res.data.item;
+            this.initDatas();
+            this.addshow = false
+            this.$message({
+              type: 'success',
+              message: res.data.message
+            });
+          } else {
+            this.$message({
+              type: 'warning',
+              message: res.data.message
+            });
+          }
+        }).catch(err => {
+          console.error(err)
+        });
+      },
       addaudit() {
         this.addshow = true
       },
@@ -476,7 +507,7 @@
                 //WorkflowId: ,
                 Status: 0,
                 Step: 1,
-                annualId: this.entityForm.Id ,
+                annualId: this.entityForm.Id,
               }
             })
             this.$message({
@@ -484,6 +515,12 @@
               message: res.data.message
             });
 
+          } else if (res.data.code === -3) {
+            this.$confirm(res.data.message + ",点击继续可继续进行年审")
+              .then(_ => {
+                this.addannualdirect()
+              })
+              .catch(_ => {});
           } else {
             this.$message({
               type: 'warning',