2
3
Преглед на файлове

准入列表企业资质编辑选项重复不可添加

lijq преди 6 години
родител
ревизия
e173efb349
променени са 1 файла, в които са добавени 20 реда и са изтрити 2 реда
  1. 20 2
      src/dashoo.cn/backend/api/controllers/oilsupplier/supplierfile.go

+ 20 - 2
src/dashoo.cn/backend/api/controllers/oilsupplier/supplierfile.go

@@ -75,7 +75,6 @@ func (this *SupplierfileController) AddSubfile() {
 		hasField += list[i].NeedFileType + ","
 	}
 
-
 	var errinfo ErrorDataInfo
 	if strings.Contains(hasField, model.NeedFileType+",") {
 		//已存在,不能重复添加
@@ -119,10 +118,29 @@ func (this *SupplierfileController) EditSubfile() {
 	var model supplierfile.OilSupplierFile
 	var jsonblob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonblob, &model)
+	svc := supplierfile.GetSupplierfileService(utils.DBE)
+
+	var list []supplierfile.OilSupplierFile
+	where := "SupplierId = '" + strconv.Itoa(model.SupplierId) + "'"
+	svc.GetEntitysByWhere(OilSupplierFileName, where, &list)
+	hasField := ""
+	for i := 0; i < len(list); i++ {
+		hasField += list[i].NeedFileType + ","
+	}
+
+	if strings.Contains(hasField, model.NeedFileType+",") {
+		//已存在,不能重复添加
+		errinfo.Message = "操作失败!不能重复添加"
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+
 	var entity supplierfile.OilSupplierFile
 	model.ModifiedBy = this.User.Realname
 	model.ModifiedUserId, _ = utils.StrTo(this.User.Id).Int()
-	svc := supplierfile.GetSupplierfileService(utils.DBE)
+
 	opdesc := "编辑文件上传-" + model.NeedFileType
 	var cols []string = []string{"SupplierCertSubId", "CertSubName", "NeedFileType", "NeedFileCode", "FileName", "EffectDate", "FileUrl", "OtherRemark", "Remark", "IsDelete", "ModifiedBy", "ModifiedUserId"}
 	err := svc.UpdateOperationAndWriteLogBytbl(OilSupplierFileName, BaseOperationLogName, id, &model, &entity, cols, utils.ToStr(this.User.Id), this.User.Username, opdesc, this.User.AccCode, "文件上传")