Преглед изворни кода

检查不能重复申请,企业用户只能添加一条

yuedefeng пре 6 година
родитељ
комит
c063e18a65

+ 54 - 0
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -63,3 +63,57 @@ func (s *OilSupplierService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName
 
 	return total
 }
+
+func (s *OilSupplierService) CheckRepeatApplyInfo(supplierTableName, supplierCertTableName, typeCode, SupplierName, CommercialNo, OrganCode, BankAccount, CompanyUrl string, entitiesPtr interface{}) {
+
+	//获取分页信息
+
+
+
+	where2 := " b.SupplierTypeCode = '" + typeCode + "'"
+
+	where := ""
+	if SupplierName != "" {
+		where = where + " or a.SupplierName = '" + SupplierName + "'"
+	}
+
+	if CommercialNo != "" {
+		where = where + " or a.CommercialNo = '" + CommercialNo + "'"
+	}
+
+	if OrganCode != "" {
+		where = where + " or a.OrganCode = '" + OrganCode + "'"
+	}
+
+	if BankAccount != "" {
+		where = where + " or a.BankAccount = '" + BankAccount + "'"
+	}
+
+	if CompanyUrl != "" {
+		where = where + " or a.CompanyUrl = '" + CompanyUrl + "'"
+	}
+
+	if len(where) > 0 {
+		where2 += " and (1=0 " + where + ")"
+		var sql string
+		sql = `select a.*, b.Id as CertId, b.AccessCardNo, b.SupplierTypeCode, b.SupplierTypeName, `
+		sql += ` b.WorkerTotal, `
+		sql += ` b.ContractNum, `
+		sql += ` b.UniversityNum, `
+		sql += ` b.TechnicalNum, `
+		sql += ` b.AboveProfNum, `
+		sql += ` b.MiddleProfNum, `
+		sql += ` b.NationalRegNum, `
+		sql += ` b.NationalCertTotal, `
+		sql += ` b.DesignerTotal, `
+		sql += ` b.SkillerTotal, `
+		sql += ` b.Status, `
+		sql += ` b.WorkflowId `
+		sql += ` from ` + supplierTableName + ` a `
+		sql += ` right join ` + supplierCertTableName + " b on b.SupplierId = a.Id"
+		sql += ` where ` + where2
+		s.DBE.SQL(sql).Find(entitiesPtr)
+	}
+
+
+}

+ 19 - 1
src/dashoo.cn/backend/api/business/oilsupplier/suppliercert/oilsuppliercertService.go

@@ -3,6 +3,7 @@ package suppliercert
 import (
 	"dashoo.cn/backend/api/business/workflow"
 	. "dashoo.cn/backend/api/mydb"
+	"dashoo.cn/business/parameter"
 	"github.com/go-xorm/xorm"
 )
 
@@ -39,4 +40,21 @@ func (s *OilSupplierCertService) StartAudit(certId string, userNames string, org
 	s.UpdateEntityByIdCols(certId, supplierCertEntity, cols)
 
 	return
-}
+}
+
+//查询已经申请的准入记录
+func (s *OilSupplierCertService) IsCanApplyByExtOrganizeUser(applyType, departmentId, userId string) (bool){
+
+	parameterSvc := baseparameter.GetBaseparameterService(s.DBE) //取出外部门ID
+	extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
+	if extOrganizeId == departmentId {
+		where := " SupplierTypeCode = '" + applyType +"'"
+		where += " and a.CreateUserId = '" + userId + "'"
+		var model OilSupplierCert
+		count, _ := s.GetCount(&model, where)
+		if count > 0 {
+			return false
+		}
+	}
+	return true
+}

+ 65 - 4
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -2,6 +2,7 @@ package oilsupplier
 
 import (
 	"dashoo.cn/backend/api/business/workflow"
+	"dashoo.cn/business/parameter"
 	"encoding/json"
 	"strconv"
 	"strings"
@@ -627,6 +628,13 @@ func (this *OilSupplierController) GetJoinCertEntityList() {
 		where = where + " and b.SupplierTypeCode = '" + SupplierTypeCode + "'"
 	}
 
+	//企业用户只看自己的数据记录
+	parameterSvc := baseparameter.GetBaseparameterService(utils.DBE) //取出外部门ID
+	extOrganizeId := parameterSvc.GetBaseparameterMessage("GFGL", "paramset", "ExtOrganizeId")
+	if extOrganizeId == this.User.DepartmentId {
+		where = where + " and a.CreateUserId = '" + this.User.Id + "'"
+	}
+
 	svc := supplier.GetOilSupplierService(utils.DBE)
 	var list []supplier.OilSupplierView
 
@@ -1017,12 +1025,35 @@ func (this *OilSupplierController) AddEntity() {
 	var modelCert suppliercert.OilSupplierCert
 	var modelCertVM suppliercert.OilSupplierVM
 	var jsonBlob = this.Ctx.Input.RequestBody
+
+	json.Unmarshal(jsonBlob, &model)
+	json.Unmarshal(jsonBlob, &modelCertVM)
+	serviceCert := suppliercert.GetOilSupplierCertService(utils.DBE)
+	canApply := serviceCert.IsCanApplyByExtOrganizeUser(modelCertVM.SupplierTypeCode, this.User.DepartmentId, this.User.Id)
+	var errinfo ErrorDataInfo
+	if !canApply {
+		errinfo.Message = "添加失败!供方用户只能申请一次"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var list []supplier.OilSupplierView
+	service := supplier.GetOilSupplierService(utils.DBE)
+	service.CheckRepeatApplyInfo(OilSupplierName, OilSupplierCertName, modelCertVM.SupplierTypeCode, model.SupplierName, model.CommercialNo, model.OrganCode, model.BankAccount, model.CompanyUrl, &list)
+	if len(list) > 0 {
+		errinfo.Message = "添加失败! 已存在相关企业的信息,不能重复申请"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
 	var session *xorm.Session
 	session = utils.DBE.NewSession()
 	svc := supplier.GetOilSupplierSession(session)
 	svcCert := suppliercert.GetOilSupplierCertSession(session)
 
-	json.Unmarshal(jsonBlob, &model)
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -1035,8 +1066,6 @@ func (this *OilSupplierController) AddEntity() {
 		session.Rollback()
 	}
 	modelCert.SupplierId = model.Id
-
-	json.Unmarshal(jsonBlob, &modelCertVM)
 	modelCert.SupplierTypeCode = modelCertVM.SupplierTypeCode
 	modelCert.SupplierTypeName = modelCertVM.SupplierTypeName
 	modelCert.Step = 1 //企业信息保存完成
@@ -1051,7 +1080,6 @@ func (this *OilSupplierController) AddEntity() {
 	// add Commit() after all actions
 	err = session.Commit()
 
-	var errinfo ErrorDataInfo
 	if err == nil {
 		//新增
 		errinfo.Message = "添加成功!"
@@ -1329,3 +1357,36 @@ func (this *OilSupplierController) DeleteEntity() {
 	}
 }
 
+// @Title 判断是否可以申请准入
+// @Description
+// @Success 200 {string} Count
+// @Failure 403 :id 为空
+// @router /iscanapply/:type [get]
+func (this *OilSupplierController) IsCanApply() {
+	Type := this.Ctx.Input.Param(":type")
+	var errinfo ErrorInfo
+	if Type == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
+	svc := suppliercert.GetOilSupplierCertService(utils.DBE)
+	canApply := svc.IsCanApplyByExtOrganizeUser(Type, this.User.DepartmentId, this.User.Id)
+
+	if canApply {
+		errinfo.Message = "无申请记录,可以申请"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "供方用户只能申请一次"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+

+ 6 - 0
src/dashoo.cn/frontend_web/src/api/oilsupplier/supplier.js

@@ -64,5 +64,11 @@ export default {
       url: '/supplier/delete/' + entityId,
       method: 'delete'
     })
+  },
+  isCanApply (typeCode, myAxios) {
+    return myAxios({
+      url: '/supplier/iscanapply/' + typeCode,
+      method: 'get'
+    })
   }
 }

+ 3 - 2
src/dashoo.cn/frontend_web/src/components/Headbar.vue

@@ -99,7 +99,8 @@
                 this.fullscreen = !this.fullscreen;
             },
      getdepartment(){
-         if (this.authUser.Profile.DepartmentId == "100000054") {
+       this.department = '欢迎使用'
+         /*if (this.authUser.Profile.DepartmentId == "100000054") {
           this.department = '欢迎使用'
         } else{
            this.$axios.get('/limsentrust/getshow')
@@ -123,7 +124,7 @@
           .catch(err => {
             console.error(err)
           })
-        }
+        }*/
        },
       headclearsearch() {
         this.sampcode = ''

+ 18 - 4
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplier/techlist.vue

@@ -11,7 +11,7 @@
         </span>
         <span style="float: right;">
           <router-link :to="'/oilsupplier/supplier/add/techedit'">
-            <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">添加</el-button>
+            <el-button type="primary" size="mini" v-if="canApply" style="margin-left:10px; margin-top: -4px;">准入申请</el-button>
           </router-link>
         </span>
         <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
@@ -447,6 +447,7 @@
 
     data() {
       return {
+        canApply: false,
         dialogVisible: false,
         //列表数据
         entityList: [],
@@ -892,11 +893,12 @@
         ]
       }
     },
-    created() {
+    created () {
+      this.isCanApply()
       //查询条件初始值备份
-      Object.assign(this.searchFormReset, this.searchForm);
+      Object.assign(this.searchFormReset, this.searchForm)
       //查询列表
-      this.initDatas();
+      this.initDatas()
       //this.getDictOptions()
     },
     methods: {
@@ -997,6 +999,18 @@
         });
       },
 
+      isCanApply () {
+        api.isCanApply('03', this.$axios).then(res => {
+          if (res.data.code === 0) {
+            this.canApply = true
+
+          } else {
+            this.canApply = false
+          }
+        }).catch(err => {
+          console.error(err)
+        });
+      },
       jstimehandle(val) {
         if (val === '') {
           return '----'

+ 2 - 10
src/dashoo.cn/frontend_web/src/pages/oilsupplier/supplieraudit/_opera/techedit.vue

@@ -335,16 +335,12 @@
 
             </el-form>
           </el-card>
-
         </el-tab-pane>
 
         <el-tab-pane label="企业情况">
           <el-card class="box-card">
             <div slot="header" class="clearfix">
               <span>企业人员结构情况</span>
-              <span style="float: right;">
-                <el-button type="primary" size="mini" @click="updateNumberEntity">保存人员结构情况</el-button>
-              </span>
             </div>
 
             <el-form label-width="220px" ref="EntityFormNumber" :model="formDataCert">
@@ -425,7 +421,6 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span>企业主要装备情况</span>
-              <el-button style="float: right; padding: 3px 0" type="text" @click="equipmentdialog">添加</el-button>
             </div>
             <equipment-list ref="equipmentList" :data="equipmentList" :SupplierCertId="certId" height="360px"
                             style="margin-top: 20px"></equipment-list>
@@ -434,7 +429,6 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span>近三年主要工程业绩</span>
-              <el-button style="float: right; padding: 3px 0" type="text" @click="performancedialog">添加</el-button>
             </div>
             <performance-list ref="performanceList" :data="performanceList" :SupplierCertId="certId" height="360px"
                               style="margin-top: 20px"></performance-list>
@@ -443,7 +437,6 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span>拥有专利、专有技术及工法</span>
-              <el-button style="float: right; padding: 3px 0" type="text" @click="patentdialog">添加</el-button>
             </div>
             <patent-list ref="patentList" :data="patentList" :SupplierCertId="certId" height="360px"
                          style="margin-top: 20px">
@@ -453,7 +446,6 @@
           <el-card class="box-card" style="margin-top: 10px;">
             <div slot="header" class="clearfix">
               <span>近三年获得省部级及以上主要技术、管理成果、获奖项目</span>
-              <el-button style="float: right; padding: 3px 0" type="text" @click="winningdialog">添加</el-button>
             </div>
             <winning-list ref="winningList" :data="winningList" :SupplierCertId="certId" height="360px"
                           style="margin-top: 20px">
@@ -461,12 +453,12 @@
           </el-card>
         </el-tab-pane>
 
-        <el-tab-pane label="选择准入范围">
+        <el-tab-pane label="准入审批意见">
           <business-list ref="businessList" :data="businessList" :SupplierCertId="certId" :SupplierId="serviceId"
                          :SubClassId="classId" height="360px" style="margin-top: 20px"></business-list>
         </el-tab-pane>
 
-        <el-tab-pane label="准入审批">
+        <el-tab-pane label="流程查看">
           <el-card class="box-card" style="margin-top: 20px">
             <div slot="header" class="clearfix">
               <span>审批流程</span>