wd 4 年 前
コミット
e5c4cbbf04

+ 1 - 1
src/dashoo.cn/backend/api/business/oilsupplier/hsescore/hsescore.go

@@ -11,7 +11,7 @@ type HSEScore struct {
 	Name   		   string    `xorm:"comment('考试人员姓名') VARCHAR(50)"`
 	IdNumber       string    `xorm:"comment('身份证号') VARCHAR(50)"`
 	Score   	   int       `xorm:"comment('成绩') VARCHAR(50)"`
-	TestNumber     int       `xorm:"comment('考号') VARCHAR(50)"`
+	TestNumber     string    `xorm:"comment('考号') VARCHAR(50)"`
 	StartTime      time.Time `xorm:"comment('培训开始时间') DATE"`
 	EndTime        time.Time `xorm:"comment('培训结束时间') DATE"`
 	ApplyTime      time.Time `xorm:"comment('有效期(上半年为加三年的6.30,下半年为加三年的12.31)') DATE"`

+ 7 - 16
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -285,7 +285,8 @@ func (this *HSEScoreController) ImportExcel() {
 				hseUpdate.ApplyTime = hseTime.ApplyTime
 				hseUpdate.StartTime = hseTime.StartTime
 				hseUpdate.SupplierId = supplier.Id
-				hseUpdate.TestNumber, _ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
+				//hseUpdate.TestNumber, _ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
+				hseUpdate.TestNumber = sheet.Rows[i].Cells[2].String()
 				hseUpdate.IdNumber = sheet.Rows[i].Cells[4].String()
 				hseUpdate.Score, _ = strconv.Atoi(sheet.Rows[i].Cells[5].String())
 				hseUpdate.ModifiedOn = time.Now()
@@ -300,7 +301,7 @@ func (this *HSEScoreController) ImportExcel() {
 		hse.ApplyTime = hseTime.ApplyTime
 		hse.StartTime = hseTime.StartTime
 		hse.SupplierId = supplier.Id
-		hse.TestNumber, _ = strconv.Atoi(sheet.Rows[i].Cells[2].String())
+		hse.TestNumber= sheet.Rows[i].Cells[2].String()
 		hse.SupplierId = supplier.Id
 		hse.Name = sheet.Rows[i].Cells[3].String()
 		hse.IdNumber = sheet.Rows[i].Cells[4].String()
@@ -379,12 +380,8 @@ func (this *HSEScoreController) AddHSEScore() {
 	}
 
 	svc.GetEntityByWhere(OilSupplierName, "Id = "+strconv.Itoa(model.SupplierId), &supplier)
-	if supplier.SupplierName == "" {
-		errinfo.Message = "找不到该企业"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
+	if supplier.SupplierName != "" {
+		model.SupplierName = supplier.SupplierName
 	}
 	if model.IdNumber != "" {
 		where := "IdNumber = '" + model.IdNumber + "'"
@@ -398,7 +395,6 @@ func (this *HSEScoreController) AddHSEScore() {
 		}
 	}
 	model.ApplyTime = model.ApplyTime.AddDate(3, 0, 0)
-	model.SupplierName = supplier.SupplierName
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
@@ -438,12 +434,8 @@ func (this *HSEScoreController) UpdateHSEScore() {
 	json.Unmarshal(jsonBlob, &model)
 
 	svc.GetEntityByWhere(OilSupplierName, "Id = "+strconv.Itoa(model.SupplierId), &supplier)
-	if supplier.SupplierName == "" {
-		errinfo.Message = "找不到该企业"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
+	if supplier.SupplierName != "" {
+		model.SupplierName = supplier.SupplierName
 	}
 
 	if this.User.IsCompanyUser == 1 {
@@ -466,7 +458,6 @@ func (this *HSEScoreController) UpdateHSEScore() {
 		}
 	}
 
-	model.SupplierName = supplier.SupplierName
 	model.ApplyTime = model.ApplyTime.AddDate(3, 0, 0)
 	model.ModifiedOn = time.Now()
 	model.ModifiedBy = this.User.Realname

+ 8 - 0
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -7,6 +7,7 @@ import (
 	"dashoo.cn/backend/api/business/oilcontract/contractSumScore"
 	"dashoo.cn/backend/api/business/oilsupplier/annualaudit"
 	BlackList "dashoo.cn/backend/api/business/oilsupplier/blacklist"
+	"dashoo.cn/backend/api/business/oilsupplier/hsescore"
 	"dashoo.cn/backend/api/business/oilsupplier/infochange"
 	"dashoo.cn/backend/api/business/oilsupplier/oilcatalog"
 	"dashoo.cn/backend/api/business/oilsupplier/oilcatalogsub"
@@ -2190,6 +2191,13 @@ func (this *OilSupplierController) AddEntity() {
 	// add Commit() after all actions
 	err = session.Commit()
 
+	if model.Id > 0 {
+		hseSvc := hsescore.GetHSEScoreService(utils.DBE)
+		var hse hsescore.HSEScore
+		hse.SupplierId = model.Id
+		hseSvc.UpdateEntityBywheretbl(HSEScoreName, &hse, []string{"SupplierId"}, "SupplierId = 0 and SupplierName = '" + model.SupplierName + "'")
+	}
+
 	if err == nil {
 		//新增
 		errinfo.Message = "添加成功!"

+ 11 - 1
src/dashoo.cn/frontend_web/src/pages/select/hsescore/index.vue

@@ -127,12 +127,17 @@
       <el-form label-width="100px" :model="updateData" ref="EntityForm" :rules="rules">
         <el-row>
           <el-col :span="24">
-            <el-form-item label="企业名称" prop="SupplierId">
+            <el-form-item label="企业名称">
               <el-select ref="SupplierSelect" v-model="updateData.SupplierId" filterable placeholder="请选择企业名称" style="width: 100%">
                 <el-option :label="item.SupplierName" :value="item.Id" v-for="(item,index) of supplierSelectList" :key="index"></el-option>
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="24">
+            <el-form-item label="企业名称" prop="SupplierName">
+              <el-input style="width:100%" v-model="updateData.SupplierName" placeholder="请填写企业名称"></el-input>
+            </el-form-item>
+          </el-col>
           <el-col :span="24">
             <el-form-item label="姓名" prop="Name">
               <el-input style="width:100%" v-model="updateData.Name" placeholder="请填写姓名"></el-input>
@@ -289,6 +294,9 @@ export default {
         Name: [
           {required: true, message: '请填写姓名', trigger: 'blur'}
         ],
+        SupplierName: [
+          {required: true, message: '请填写企业名称', trigger: 'blur'}
+        ],
         StartTime: [
           {required: true, validator: validDate, trigger: 'blur'}
         ],
@@ -317,6 +325,7 @@ export default {
       },
       updateData: {
         SupplierId: '',
+        SupplierName: '',
         Name: '',
         IdNumber: '',
         TestNumber: '',
@@ -491,6 +500,7 @@ export default {
       this.addDialog = true
       this.status = false
       this.updateData.IdNumber = ''
+      this.updateData.SupplierName = ''
       this.updateData.TestNumber = ''
       this.updateData.Name = ''
       this.updateData.Score = 0