2
3
wd 4 жил өмнө
parent
commit
92e1183d92

+ 80 - 18
src/dashoo.cn/backend/api/controllers/oilsupplier/hsescore.go

@@ -279,13 +279,13 @@ func (this *HSEScoreController) ImportExcel() {
 			continue
 		}
 		if supplierName1 != "" {
-			svc.GetEntityByWhere(HSEScoreName, "SupplierName = '"+supplierName1+"' and TestNumber = "+sheet.Rows[i].Cells[2].String(), &hseUpdate)
+			svc.GetEntityByWhere(HSEScoreName, "SupplierName = '"+supplierName1+"' and Name = '" + sheet.Rows[i].Cells[3].String() + "'", &hseUpdate)
 			if hseUpdate.Id > 0 {
 				hseUpdate.EndTime = hseTime.EndTime
 				hseUpdate.ApplyTime = hseTime.ApplyTime
 				hseUpdate.StartTime = hseTime.StartTime
 				hseUpdate.SupplierId = supplier.Id
-				hseUpdate.Name = sheet.Rows[i].Cells[3].String()
+				hseUpdate.TestNumber, _ = strconv.Atoi(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()
@@ -386,14 +386,16 @@ func (this *HSEScoreController) AddHSEScore() {
 		this.ServeJSON()
 		return
 	}
-	where := "IdNumber = '" + model.IdNumber + "'"
-	num := svc.GetCounts(where)
-	if num >= 1 {
-		errinfo.Message = "身份证号不能重复"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
+	if model.IdNumber != "" {
+		where := "IdNumber = '" + model.IdNumber + "'"
+		num := svc.GetCounts(where)
+		if num >= 1 {
+			errinfo.Message = "身份证号不能重复"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
 	}
 	model.ApplyTime = model.ApplyTime.AddDate(3, 0, 0)
 	model.SupplierName = supplier.SupplierName
@@ -452,14 +454,16 @@ func (this *HSEScoreController) UpdateHSEScore() {
 		return
 	}
 
-	where := "IdNumber = '" + model.IdNumber + "' and Id != " + id
-	num := svc.GetCounts(where)
-	if num >= 1 {
-		errinfo.Message = "身份证号不能重复"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
+	if model.IdNumber != "" {
+		where := "IdNumber = '" + model.IdNumber + "' and Id != " + id
+		num := svc.GetCounts(where)
+		if num >= 1 {
+			errinfo.Message = "身份证号不能重复"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
 	}
 
 	model.SupplierName = supplier.SupplierName
@@ -483,6 +487,64 @@ func (this *HSEScoreController) UpdateHSEScore() {
 	}
 }
 
+// @Title 用户修改
+// @Description 修改
+// @Success	200	{object}
+// @router /updateHSEIdNumber/:id [post]
+func (this *HSEScoreController) UpdateHSEIdNumber() {
+	id := this.Ctx.Input.Param(":id")
+	var errinfo ErrorInfo
+	if id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	var model hsescore.HSEScore
+	var model1 hsescore.HSEScore
+	var supplier supplier.OilSupplier
+	var jsonBlob = this.Ctx.Input.RequestBody
+	svc := hsescore.GetHSEScoreService(utils.DBE)
+	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 model.IdNumber != "" {
+		where := "IdNumber = '" + model.IdNumber + "' and Id != " + id
+		num := svc.GetCounts(where)
+		if num >= 1 {
+			errinfo.Message = "身份证号不能重复"
+			errinfo.Code = -2
+			this.Data["json"] = &errinfo
+			this.ServeJSON()
+			return
+		}
+	}
+
+	model1.IdNumber = model.IdNumber
+	var err error
+	_, err = svc.UpdateEntityById(id, &model1)
+	if err == nil {
+		errinfo.Message = "修改成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "修改失败"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
 // @Title 删除单条信息
 // @Description
 // @Success 200 {object} ErrorInfo

+ 1 - 1
src/dashoo.cn/backend/api/controllers/toolbox/toolbox.go

@@ -14,7 +14,7 @@ func TimingTask() {
 	c := new(oilsupplier.OilSupplierCertController)
 	invoice := new(invoice.OilInvoiceController)
 	todo := new(oilsupplier.TodoListController)
-	supplier := new(oilsupplier.OilSupplierController)
+	//supplier := new(oilsupplier.OilSupplierController)
 
 	//tkInFlag := toolbox.NewTask("myTaskInFlag", "0 0 1 * * *", func() error {
 	//	c.UpdataInFlag()

+ 8 - 0
src/dashoo.cn/frontend_web/src/api/hsescore/hsescore.js

@@ -53,6 +53,14 @@ export default {
       data: params
     })
   },
+  // 修改身份证号
+  updateIdNumber (id, params, myAxios) {
+    return myAxios({
+      url: '/hse/updateHSEIdNumber/' + id,
+      method: 'post',
+      data: params
+    })
+  },
   // 打印
   exportWord (id, params, myAxios) {
     return myAxios({

+ 81 - 5
src/dashoo.cn/frontend_web/src/pages/select/hsescore/index.vue

@@ -76,8 +76,9 @@
         <el-table-column label="操作" width="250px" align="center" fixed="right" show-overflow-tooltip>
           <template slot-scope="scope">
             <el-button type="primary" plain title="打印证书" size="mini" @click="download(scope.row)">打印证书</el-button>
-            <el-button :disabled="disabled" type="primary" plain title="修改" size="mini" @click="update(scope.row)">修改</el-button>
-            <el-button :disabled="disabled" type="danger" plain title="删除" size="mini" @click="deleteRow(scope.row.Id)">删除</el-button>
+            <el-button v-if="disabled" type="primary" plain title="修改身份证号" size="mini" @click="updateIdNumber(scope.row)">修改身份证号</el-button>
+            <el-button v-if="!disabled" type="primary" plain title="修改" size="mini" @click="update(scope.row)">修改</el-button>
+            <el-button v-if="!disabled" type="danger" plain title="删除" size="mini" @click="deleteRow(scope.row.Id)">删除</el-button>
           </template>
         </el-table-column>
         <!--内框表格剩余栏显示-->
@@ -87,8 +88,9 @@
           </template>
         </el-table-column>
         <el-table-column label="企业名称" min-width="300px" prop="SupplierName" sortable align="center"></el-table-column>
-        <el-table-column label="身份证号" width="200px" prop="IdNumber" sortable align="center"></el-table-column>
         <el-table-column label="姓名" width="120px" prop="Name" sortable align="center"></el-table-column>
+        <el-table-column label="考号" width="120px" prop="TestNumber" sortable align="center"></el-table-column>
+        <el-table-column label="身份证号" width="200px" prop="IdNumber" sortable align="center"></el-table-column>
         <el-table-column label="有效期" width="120px" prop="ApplyTime" sortable align="center">
           <template slot-scope="scope">
             {{ jstimehandle(scope.row.ApplyTime+'') }}
@@ -136,6 +138,11 @@
               <el-input style="width:100%" v-model="updateData.Name" placeholder="请填写姓名"></el-input>
             </el-form-item>
           </el-col>
+          <el-col :span="24">
+            <el-form-item label="考号" prop="TestNumber">
+              <el-input style="width:100%" v-model="updateData.TestNumber" placeholder="请填写考号"></el-input>
+            </el-form-item>
+          </el-col>
           <el-col :span="24">
             <el-form-item label="身份证号" prop="IdNumber">
               <el-input style="width:100%" v-model="updateData.IdNumber" placeholder="请填写身份证号"></el-input>
@@ -177,6 +184,21 @@
         <el-button type="primary" @click="addOrUpdate()" :loading="addLoading">确 定</el-button>
       </span>
     </el-dialog>
+    <el-dialog title="修改身份证号" :close-on-click-modal="false" :visible.sync="addDialog1" width="400px">
+      <el-form label-width="100px" :model="updateData" ref="EntityForm" :rules="rules1">
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="身份证号" prop="IdNumber">
+              <el-input style="width:100%" v-model="updateData.IdNumber" placeholder="请填写身份证号"></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="addDialog1 = false">取 消</el-button>
+        <el-button type="primary" @click="addOrUpdate1()" :loading="addLoading">确 定</el-button>
+      </span>
+    </el-dialog>
     <el-dialog title="上传文件" :close-on-click-modal="false" width="600px" :visible.sync="uploadShow">
       <el-form label-width="100px">
         <el-row>
@@ -250,6 +272,7 @@ export default {
       uploadShow: false,
       id: 0,
       addDialog: false,
+      addDialog1: false,
       tableLoading: false,
       addLoading: false,
       status: false,
@@ -272,6 +295,11 @@ export default {
         EndTime: [
           {required: true, validator: validStartDate, trigger: 'blur'}
         ],
+        TestNumber: [
+          {required: true, message: '请填写考号', trigger: 'blur'}
+        ]
+      },
+      rules1: {
         IdNumber: [
           {required: true, validator: checkIdNumber, trigger: 'change'}
         ]
@@ -291,6 +319,7 @@ export default {
         SupplierId: '',
         Name: '',
         IdNumber: '',
+        TestNumber: '',
         Score: 0,
         StartTime: '',
         EndTime: '',
@@ -318,6 +347,14 @@ export default {
     addOrUpdate() {
       this.$refs['EntityForm'].validate((valid) => {
         if (valid) {
+          let re1 = /(^\d{18}$)|(^\d{17}(\d|X|x)$)/
+          if (this.updateData.IdNumber && !re1.test(this.updateData.IdNumber)) {
+            this.$message.error({
+              duration: 10000,
+              message: '请输入正确格式的身份证号'
+            })
+            return
+          }
           console.log(this.updateData, 'this.updateData----')
           if (this.updateData.EndTime <=  this.updateData.StartTime) {
             this.$message({
@@ -391,6 +428,36 @@ export default {
         }
       })
     },
+    addOrUpdate1() {
+      this.$refs['EntityForm'].validate((valid) => {
+        if (valid) {
+          this.addLoading = true
+          hseApi.updateIdNumber(this.id, this.updateData, this.$axios).then(res => {
+            if (res.data.code === 0) {
+              // 刷新列表
+              this.initDatas()
+              this.$message({
+                duration: 10000,
+                type: 'success',
+                message: res.data.message
+              })
+              this.addDialog1 = false
+            } else {
+              this.$message({
+                duration: 10000,
+                type: 'warning',
+                message: res.data.message
+              })
+            }
+            this.addLoading = false
+          }).catch(err => {
+            console.error(err)
+          })
+        } else {
+          return false
+        }
+      })
+    },
     importExcel() {
       this.uploadShow = true
     },
@@ -424,6 +491,7 @@ export default {
       this.addDialog = true
       this.status = false
       this.updateData.IdNumber = ''
+      this.updateData.TestNumber = ''
       this.updateData.Name = ''
       this.updateData.Score = 0
       this.updateData.SupplierId = ''
@@ -461,6 +529,14 @@ export default {
       this.updateData.Score = row.Score
       this.updateData.IdNumber = row.IdNumber
       this.updateData.Name = row.Name
+      this.updateData.TestNumber = row.TestNumber
+      this.id = row.Id
+    },
+    updateIdNumber(row) {
+      this.addDialog1 = true
+      this.status = true
+      this.updateData.IdNumber = row.IdNumber
+      this.updateData.SupplierId = row.SupplierId
       this.id = row.Id
     },
     deleteRow(id) {
@@ -532,8 +608,8 @@ export default {
         this.currentPage = 1
       }
       let params = {
-        size: this.size,
-        currentPage: this.currentPage,
+        _size: this.size,
+        _currentPage: this.currentPage,
         Order: this.Column.Order,
         Prop: this.Column.Prop
       }