浏览代码

前后:黑名单

dubch 4 年之前
父节点
当前提交
9193ebf513

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

@@ -6,17 +6,9 @@ import (
 
 type BlackList struct {
 	Id             int       `xorm:"not null pk autoincr INT(11)"`
-	SupplierId     int    	 `xorm:"INT(11)"`
-	CreateOn       time.Time `xorm:"comment('创建时间') DATETIME"`
-	CreateUserId   int       `xorm:"comment('创建者编号') INT(11)"`
-	CreateBy       string    `xorm:"comment('创建者') VARCHAR(50)"`
-}
-
-type BlackListInfo struct {
-	Id             int       `xorm:"not null pk autoincr INT(11)"`
-	SupplierId     int    	 `xorm:"INT(11)"`
 	SupplierName   string    `xorm:"comment('企业名称') VARCHAR(50)"`
 	CommercialNo   string    `xorm:"comment('工商注册号') VARCHAR(50)"`
+	Remark   	   string    `xorm:"comment('备注') VARCHAR(50)"`
 	CreateOn       time.Time `xorm:"comment('创建时间') DATETIME"`
 	CreateUserId   int       `xorm:"comment('创建者编号') INT(11)"`
 	CreateBy       string    `xorm:"comment('创建者') VARCHAR(50)"`

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

@@ -397,11 +397,3 @@ func (s *OilSupplierService) GetCertIds(entitiesPtr interface{}, where string) {
 
 	s.DBE.SQL(sql).Get(entitiesPtr)
 }
-
-
-func (s *OilSupplierService) GetBlackList(entitiesPtr interface{}, where string) {
-
-	sql := "SELECT a.Id from BlackList a LEFT JOIN OilSupplier b on b.Id = a.SupplierId LEFT JOIN OilCorporateInfo c ON b.CommercialNo = c.CommercialNo where " + where
-
-	s.DBE.SQL(sql).Get(entitiesPtr)
-}

+ 10 - 21
src/dashoo.cn/backend/api/controllers/oilsupplier/blacklist.go

@@ -4,7 +4,6 @@ import (
 	BlackList "dashoo.cn/backend/api/business/oilsupplier/blacklist"
 	"dashoo.cn/backend/api/business/oilsupplier/supplier"
 	"encoding/json"
-	"strconv"
 	"strings"
 	"time"
 
@@ -31,10 +30,10 @@ func (this *BlackListController) GetList() {
 	where := " 1=1"
 
 	if SupplierName != "" {
-		where = where + " and b.SupplierName like '%" + SupplierName + "%'"
+		where = where + " and SupplierName like '%" + SupplierName + "%'"
 	}
 	if CommercialNo != "" {
-		where = where + " and b.CommercialNo like '%" + CommercialNo + "%'"
+		where = where + " and CommercialNo like '%" + CommercialNo + "%'"
 	}
 
 	if CreateOn != "" {
@@ -42,15 +41,15 @@ func (this *BlackListController) GetList() {
 		if len(dates) == 2 {
 			minDate := dates[0]
 			maxDate := dates[1]
-			where = where + " and a.CreateOn >= '" + minDate + "' and a.CreateOn <= '" + maxDate + "'"
+			where = where + " and CreateOn >= '" + minDate + "' and CreateOn <= '" + maxDate + "'"
 		}
 	}
-	orderby := "a.Id"
+	orderby := "Id"
 	asc := false
 
 	svc := BlackList.GetBlackListService(utils.DBE) //获得数据库引擎
-	var list []BlackList.BlackListInfo
-	total := svc.GetMyPagingEntitiesWithOrderBytbl1("BlackList", page.CurrentPage, page.Size, orderby, asc, &list, where)
+	var list []BlackList.BlackList
+	total := svc.GetMyPagingEntitiesWithOrderBytbl("BlackList", page.CurrentPage, page.Size, orderby, asc, &list, where)
 
 	var datainfo DataInfo
 	datainfo.Items = list
@@ -83,6 +82,7 @@ func (this *BlackListController) GetCompany() {
 // @router /add [post]
 func (this *BlackListController) AddBlackList() {
 	var model BlackList.BlackList
+	var model1 BlackList.BlackList
 	var jsonBlob = this.Ctx.Input.RequestBody
 	var errinfo ErrorDataInfo
 	svc := BlackList.GetBlackListService(utils.DBE)
@@ -91,26 +91,15 @@ func (this *BlackListController) AddBlackList() {
 	var err error
 
 	//判断名称是否已拥有
-	where := "SupplierId = " + strconv.Itoa(model.SupplierId)
-	svc.GetEntityByWhere("BlackList", where, &model)
-	if model.Id > 0 {
+	where := "CommercialNo = '" + model.CommercialNo + "'"
+	svc.GetEntityByWhere("BlackList", where, &model1)
+	if model1.Id > 0 {
 		errinfo.Message = "该企业已存在"
 		errinfo.Code = -2
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 		return
 	}
-
-	var supp supplier.OilSupplier
-	where = "Id = " + strconv.Itoa(model.SupplierId)
-	svc.GetEntityByWhere(OilSupplierName, where, &supp)
-	if supp.Id == 0 {
-		errinfo.Message = "找不到该企业"
-		errinfo.Code = -2
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()

+ 1 - 16
src/dashoo.cn/backend/api/controllers/oilsupplier/supplier.go

@@ -1561,10 +1561,7 @@ func (this *OilSupplierController) AddEntity() {
 
 	//判断在黑名单的不能申请准入
 	var black BlackList.BlackList
-	var sup supplier.OilSupplier
-	suppSvc := supplier.GetOilSupplierService(utils.DBE)
-	suppSvc.GetEntityByWhere(OilSupplierName, "CommercialNo = '" + model.CommercialNo + "'", &sup)
-	suppSvc.GetEntityByWhere("BlackList", "SupplierId = " + strconv.Itoa(sup.Id), &black)
+	serviceCert.GetEntityByWhere("BlackList", "CommercialNo = '" + model.CommercialNo + "'", &black)
 	if black.Id > 0 {
 		errinfo.Message = "在黑名单内,不可申请"
 		errinfo.Code = -1
@@ -2035,18 +2032,6 @@ func (this *OilSupplierController) IsCanApply() {
 	sql := " UserName='" + this.User.Username + "'"
 	svc.GetEntity(&registerUser, sql)
 
-	//判断在黑名单的不能申请准入
-	var black BlackList.BlackList
-	suppSvc := supplier.GetOilSupplierService(utils.DBE)
-	suppSvc.GetBlackList(&black, "c.CommercialNo = '" + registerUser.CommercialNo + "'")
-	if black.Id > 0 {
-		errinfo.Message = "在黑名单内,不可申请"
-		errinfo.Code = -1
-		this.Data["json"] = &errinfo
-		this.ServeJSON()
-		return
-	}
-
 	canApply := svc.IsCanApplyByExtOrganizeUser(Type, registerUser.CommercialNo, this.User.Id, this.User.IsCompanyUser)
 
 	if canApply {

+ 74 - 40
src/dashoo.cn/frontend_web/src/pages/oilsupplier/blacklist/index.vue

@@ -78,6 +78,10 @@
                          prop="CommercialNo"
                          align="center"
                          width="260px"></el-table-column>
+        <el-table-column label="备注"
+                         prop="Remark"
+                         align="center"
+                         width="260px"></el-table-column>
         <el-table-column label="创建时间"
                          prop="CreateOn"
                          align="center"
@@ -98,27 +102,29 @@
                      :total="currentItemCount"></el-pagination>
     </el-card>
 
-    <el-dialog title="黑名单添加" :visible.sync="addShow" width="360px">
-      <el-form label-width="90px" ref="EntityFormref">
+    <el-dialog title="黑名单添加" :visible.sync="addShow" width="400px">
+      <el-form label-width="100px" ref="EntityForm" :rules="rules" :model="saveForm">
         <el-row>
           <el-col :span="24">
-            <el-form-item label="企业名称" :rules="{ required: true, message: '企业名称不能为空', trigger: 'change'}">
-              <el-select filterable v-model="SupplierId" placeholder="请选择企业" style="width: 100%">
-                <el-option v-for="item in dataList" :key="item.Id" :label="item.SupplierName"
-                           :value="item.Id">
-                </el-option>
-              </el-select>
+            <el-form-item label="企业名称" prop="SupplierName">
+              <el-input v-model="saveForm.SupplierName" placeholder="请输入企业名称"></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="工商注册号" prop="CommercialNo">
+              <el-input v-model="saveForm.CommercialNo" placeholder="请输入工商注册号"></el-input>
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row>
+          <el-col :span="24">
+            <el-form-item label="备注">
+              <el-input v-model="saveForm.Remark" type="textarea" placeholder="请输入备注内容"></el-input>
             </el-form-item>
           </el-col>
         </el-row>
-<!--        <el-row>-->
-<!--          <el-col :span="24">-->
-<!--            <el-form-item label="备注">-->
-<!--              <el-input v-model="appendformData.Remark" type="textarea" placeholder="请输入备注内容">-->
-<!--              </el-input>-->
-<!--            </el-form-item>-->
-<!--          </el-col>-->
-<!--        </el-row>-->
       </el-form>
       <span style="float: right;margin-top:-10px;">
           <el-button size="small" @click="addShow = false">取 消</el-button>
@@ -136,9 +142,21 @@ export default {
   created () {
     // 执行初始化方法
     this.initDatas()
-    this.initCompany()
+    // this.initCompany()
   },
   data () {
+    var checkCommercialNo = (rule, value, callback) => {
+      if (value === '') {
+        callback(new Error('请填写工商注册号'))
+      } else {
+        let re4 = /^[^_IOZSVa-z\W]{2}\d{6}[^_IOZSVa-z\W]{10}$/g
+        if (!re4.test(this.saveForm.CommercialNo)) {
+          callback(new Error('请填写正确的18位工商注册号'))
+        } else {
+          callback()
+        }
+      }
+    }
     return {
       tableLoading: false,
       addLoading: false,
@@ -155,6 +173,19 @@ export default {
         SupplierName: '',
         CommercialNo: ''
       },
+      saveForm: {
+        SupplierName: '',
+        CommercialNo: '',
+        Remark: ''
+      },
+      rules: {
+        SupplierName: [
+          {required: true, message: '请填写企业名称', trigger: 'blur'}
+        ],
+        CommercialNo: [
+          {required: true, validator: checkCommercialNo, trigger: 'change'}
+        ]
+      }
 
     }
   },
@@ -193,31 +224,34 @@ export default {
         .catch(() => { })
     },
     addSup () {
-      this.addLoading = true
-      let params = {
-        SupplierId: this.SupplierId
-      }
-      api.addEntity(params, this.$axios)
-        .then(res => {
-          if (res.data.code === 0) {
-            // 刷新列表
-            this.initDatas()
-            this.$message({
-              type: 'success',
-              message: res.data.message
+      this.$refs['EntityForm'].validate((valid) => {
+        if (valid) {
+          this.addLoading = true
+          api.addEntity(this.saveForm, this.$axios)
+            .then(res => {
+              if (res.data.code === 0) {
+                // 刷新列表
+                this.initDatas()
+                this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+              } else {
+                this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+              this.addLoading = false
+              this.addShow = false
             })
-          } else {
-            this.$message({
-              type: 'warning',
-              message: res.data.message
+            .catch(err => {
+              console.error(err)
             })
-          }
-          this.addLoading = false
-          this.addShow = false
-        })
-        .catch(err => {
-          console.error(err)
-        })
+        } else {
+          return false
+        }
+      })
     },
 
     initCompany () {