ソースを参照

添加准入范围判断

shihang 6 年 前
コミット
d8a0640274

+ 120 - 57
src/dashoo.cn/frontend_web/src/components/oilsupplier/businesslist.vue

@@ -196,61 +196,6 @@
       }
     },
     methods: {
-
-      //获取下一级所有分类
-      getChildrens(val) {
-        let _this = this
-        let Id = val[0]
-        if (Id != _this.flagId) { //判断是否是第一次,若不相等则为第一次
-          this.$axios.get('goodsaptitudeclass/getchildlist/' + Id, {})
-            .then(res => {
-              //获取下一级所有级联数据
-              if (res.data.items) { //判断是否有数据
-                let tempList = []
-                tempList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
-                //添加到上一级对应的选项中
-                for (let i = 0; i < _this.optionsList.length; i++) {
-                  if (_this.optionsList[i].id === Id) {
-                    _this.$set(_this.optionsList[i], 'children', tempList)
-                    break
-                  }
-                }
-              } else {
-                //修改上一级的children属性
-                for (let i = 0; i < _this.optionsList.length; i++) {
-                  if (_this.optionsList[i].id === Id) {
-                    _this.$set(_this.optionsList[i], 'children', '')
-                    break
-                  }
-                }
-              }
-              //做标记
-              _this.flagId = Id
-            })
-            .catch(err => {
-              console.error(err)
-            })
-        }
-      },
-
-      //获取分类级联Id
-      getGoodsCode(item) {
-        this.getCodeById(item[item.length - 1]) //根据分类Id获取Code
-      },
-
-      //根据分类Id获取Code
-      getCodeById(Id) {
-        let _this = this
-        this.$axios.get('goodsaptitudeclass/getcode/' + Id, {})
-          .then(res => {
-            _this.BusinessForm.SubClassId = Id
-            _this.BusinessForm.Code = res.data.items[0].Code
-          })
-          .catch(err => {
-            console.error(err)
-          })
-      },
-
       getvalue(SupplierId, SupplierTypeCode, certId) {
         this.SupplierId = SupplierId
         this.SupplierTypeCode = SupplierTypeCode
@@ -279,12 +224,18 @@
       },
       savedata() {
         if (this.Title === '新增准入范围') {
-          this.addBusiness()
+          if (this.BusinessForm.SupplierTypeCode == '01') {
+            this.addGoodsBus()
+          } else if (this.BusinessForm.SupplierTypeCode == '02') {
+            this.addBasicBus()
+          } else {
+            this.addBusiness()
+          }
         } else if (this.Title === '编辑准入范围') {
           this.editBusiness()
         }
       },
-      addBusiness() {
+      addGoodsBus() {
         let _this = this
         let arr = []
         arr = _this.$refs['cascader'].currentLabels
@@ -321,6 +272,66 @@
             })
         }
       },
+      addBasicBus() {
+        let _this = this
+        _this.BusinessForm.SupplierId = parseInt(_this.BusinessForm.SupplierId)
+        _this.BusinessForm.SupplierCertId = parseInt(_this.BusinessForm.SupplierCertId)
+        _this.BusinessForm.SubClassId = parseInt(_this.BusinessForm.SubClassId)
+        _this.$axios.post('/suppliercertsub/addbusiness/', _this.BusinessForm)
+          .then(res => {
+            if (res.data.code === 0) {
+              _this.$message({
+                type: 'success',
+                message: res.data.message
+              })
+              _this.BusinessForm.Id = res.data.item + ''
+              _this.visible = false
+              _this.initData()
+            } else {
+              _this.$message({
+                type: 'warning',
+                message: res.data.message
+              })
+            }
+          })
+          .catch(err => {
+            console.error(err)
+          })
+      },
+      addBusiness() {
+        let _this = this
+        _this.BusinessForm.SupplierId = parseInt(_this.BusinessForm.SupplierId)
+        _this.BusinessForm.SupplierCertId = parseInt(_this.BusinessForm.SupplierCertId)
+        _this.BusinessForm.SubClassId = parseInt(_this.BusinessForm.SubClassId)
+        //因为表单验证不能用,所以采用提示验证
+        if (_this.selectedorg.length < 1) {
+          _this.$message({
+            type: 'warning',
+            message: '名称不能为空,请选择分类!'
+          })
+        } else {
+          _this.$axios.post('/suppliercertsub/addbusiness/', _this.BusinessForm)
+            .then(res => {
+              if (res.data.code === 0) {
+                _this.$message({
+                  type: 'success',
+                  message: res.data.message
+                })
+                _this.BusinessForm.Id = res.data.item + ''
+                _this.visible = false
+                _this.initData()
+              } else {
+                _this.$message({
+                  type: 'warning',
+                  message: res.data.message
+                })
+              }
+            })
+            .catch(err => {
+              console.error(err)
+            })
+        }
+      },
       editBusiness() {
         let _this = this
         _this.BusinessForm.SupplierId = parseInt(_this.BusinessForm.SupplierId)
@@ -447,6 +458,58 @@
             })
         }
       },
+      //获取下一级所有分类
+      getChildrens(val) {
+        let _this = this
+        let Id = val[0]
+        if (Id != _this.flagId) { //判断是否是第一次,若不相等则为第一次
+          this.$axios.get('goodsaptitudeclass/getchildlist/' + Id, {})
+            .then(res => {
+              //获取下一级所有级联数据
+              if (res.data.items) { //判断是否有数据
+                let tempList = []
+                tempList = window.toolfun_gettreejson(res.data.items, 'Id', 'ParentId', 'Id,Name')
+                //添加到上一级对应的选项中
+                for (let i = 0; i < _this.optionsList.length; i++) {
+                  if (_this.optionsList[i].id === Id) {
+                    _this.$set(_this.optionsList[i], 'children', tempList)
+                    break
+                  }
+                }
+              } else {
+                //修改上一级的children属性
+                for (let i = 0; i < _this.optionsList.length; i++) {
+                  if (_this.optionsList[i].id === Id) {
+                    _this.$set(_this.optionsList[i], 'children', '')
+                    break
+                  }
+                }
+              }
+              //做标记
+              _this.flagId = Id
+            })
+            .catch(err => {
+              console.error(err)
+            })
+        }
+      },
+      //获取分类级联Id
+      getGoodsCode(item) {
+        this.getCodeById(item[item.length - 1]) //根据分类Id获取Code
+      },
+      //根据分类Id获取Code
+      getCodeById(Id) {
+        let _this = this
+        this.$axios.get('goodsaptitudeclass/getcode/' + Id, {})
+          .then(res => {
+            _this.BusinessForm.SubClassId = Id
+            _this.BusinessForm.Code = res.data.items[0].Code
+          })
+          .catch(err => {
+            console.error(err)
+          })
+      },
+
       getCode() {
         this.ClassId = this.selectedorg[this.selectedorg.length - 1]
         for (var i = 0; i < this.techList.length; i++) {