Parcourir la source

限制银行账号唯一性

baichengfei il y a 5 ans
Parent
commit
8bab3c378e

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

@@ -2287,4 +2287,54 @@ func (this *OilSupplierController) GetSceneFileList() {
 	this.ServeJSON()
 
 
+}
+
+// @Title 获取已使用的银行账号
+// @Description
+// @Success	200	{object} controllers.Request
+// @router /getBankAccount [get]
+func (this *OilSupplierController) GetBankAccountIsExist() {
+	bankAccount := this.GetString("bankAccount")
+	supplierId := this.GetString("supId")
+	sqlStr := "SELECT BankAccount FROM OilSupplier where BankAccount='" + bankAccount + "'"
+	if supplierId != "" {
+		sqlStr += " and Id !=" + supplierId
+	}
+	svc := supplier.GetOilSupplierService(utils.DBE)
+	list, _ := svc.DBE.QueryString(sqlStr)
+	var errorInfo ErrorDataInfo
+	if list != nil {
+		errorInfo.Item = true
+		this.Data["json"] = &errorInfo
+		this.ServeJSON()
+	} else {
+		errorInfo.Item = false
+		this.Data["json"] = &errorInfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 获取已使用的统一社会信用代码
+// @Description
+// @Success	200	{object} controllers.Request
+// @router /getCommercialNo [get]
+func (this *OilSupplierController) GetCommercialNoIsExist() {
+	commercialNo := this.GetString("commercialNo")
+	supplierId := this.GetString("supId")
+	sqlStr := "SELECT CommercialNo FROM OilSupplier where CommercialNo='" + commercialNo + "'"
+	if supplierId != "" {
+		sqlStr += " and Id !=" + supplierId
+	}
+	svc := supplier.GetOilSupplierService(utils.DBE)
+	list, _ := svc.DBE.QueryString(sqlStr)
+	var errorInfo ErrorDataInfo
+	if list != nil {
+		errorInfo.Item = true
+		this.Data["json"] = &errorInfo
+		this.ServeJSON()
+	} else {
+		errorInfo.Item = false
+		this.Data["json"] = &errorInfo
+		this.ServeJSON()
+	}
 }

+ 23 - 1
src/dashoo.cn/frontend_web/src/components/oilsupplier/goodsinfo.vue

@@ -927,6 +927,28 @@ export default {
       }
     }
 
+    var checkBankAccount = (rule, value, callback) => {
+      if (value === '') {
+        callback(new Error('请输入银行账号'))
+      } else {
+        if (value.length < 15) {
+          callback(new Error('请填写正确位数的银行账号'))
+        } else {
+          this.$axios.get('/supplier/getBankAccount?bankAccount=' + value + '&supId=' + this.formData.Id, {})
+            .then(res => {
+              if (res.data.item) {
+                callback(new Error('该银行账号与其他公司重复'))
+              } else {
+                callback()
+              }
+            })
+            .catch(err => {
+              console.error(err)
+            })
+        }
+      }
+    }
+
     return {
       subfileList: [],
       manufacturerList: [],
@@ -1107,7 +1129,7 @@ export default {
         }],
         BankAccount: [{
           required: true,
-          message: '请输入银行账号',
+          validator: checkBankAccount,
           trigger: 'change'
         }],
         ContactName: [{

+ 25 - 1
src/dashoo.cn/frontend_web/src/pages/oilsupplier/infochangech/_opera/operation.vue

@@ -1060,6 +1060,27 @@
           }
         }
       }
+      var checkBankAccount = (rule, value, callback) => {
+        if (value === '') {
+          callback(new Error('请输入银行账号'))
+        } else {
+          if (value.length < 15) {
+            callback(new Error('请填写正确位数的银行账号'))
+          } else {
+            this.$axios.get('/supplier/getBankAccount?bankAccount=' + value + '&supId=' + this.formData.Id, {})
+              .then(res => {
+                if (res.data.item) {
+                  callback(new Error('该银行账号与其他公司重复'))
+                } else {
+                  callback()
+                }
+              })
+              .catch(err => {
+                console.error(err)
+              })
+          }
+        }
+      }
       return {
         firOptions: [],
         btnloading: false,
@@ -1498,7 +1519,10 @@
             {required: true, message: '资质名称不能为空', trigger: 'blur'}
           ],
           EffectDate:
-            [{ required: true, validator: effectDate, trigger: 'change' }]
+            [{ required: true, validator: effectDate, trigger: 'change' }],
+          BankAccount: [
+            {required: true, validator: checkBankAccount, trigger: 'change'}
+          ]
         }
       }
     },