Jelajahi Sumber

1、修改品牌的停用逻辑

zhoux 1 tahun lalu
induk
melakukan
73ce2f129e

+ 1 - 0
api/pages/common/common.js

@@ -28,6 +28,7 @@ module.exports = {
         getStaff: 'get_staff', //员工
         getOrg: 'get_org', //业务部门
         getRole: 'get_role', //角色
+        getGoods:'get_goods',// 获取商品档案
         getGoodsCategoryNoPage: 'get_goods_category_no_page', //商品种类不带分页
         getGoodsBrandNoPage: 'get_goods_brand_no_page', //商品品牌不带分页  
         getGoodsCategoryTree:'get_goods_category_tree',//商品种类 树形查询

+ 117 - 105
package-basic-data/pages/product-attribute/product-attribute.js

@@ -44,7 +44,7 @@ Page({
     buttonSaveList: [{ code: 'add', title: '新建', width: '120rpx', }],
     contentSaveList: [],
     formDataName: mixins.$t('goodsBrandSys'),
-    formDataTitle:mixins.$t('goodsBrand'),
+    formDataTitle: mixins.$t('goodsBrand'),
     popContent:
       [
         // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
@@ -88,46 +88,58 @@ Page({
     let item = e.detail.item
     let service = null
     let id = null
-
-    console.log('item', item)
     if (this.data.formDataName == mixins.$t('goodsBrandSys')) {
       service = this.data.goodsBrandService
       id = 'brandId'
-
-      let that = this
-      if (item.supplierIds) {
-
-        //提示信息
-        Dialog.confirm({
-          message: '已经有供应商引用了品牌,不允许停用,是否跳转到供应商页面?',
-        }).then(() => {
-          //跳转
-          wx.navigateTo({
-            url: '/package-purchase/pages/supplier-list/supplier-list',
-            success: function (res) {
-              res.eventChannel.emit('params', { formMode: Constants.formMode.index })
+      let goodService = app.globalData['commonService']
+      // 启用直接调用
+      if (!item.flgValid) {
+        //执行接口
+        this.handleMoreDataIsValid(service, item, id)
+      } else {
+        this.excute(goodService, goodService.getGoods, { brandId: item.brandId }).then(res => {
+          if (res.data.code == Constants.SUCESS_CODE) {
+            console.log('ree', res.data);
+            if (res.data && res.data.data && res.data.data.length > 0) {
+              //提示信息
+              Dialog.confirm({
+                message: '已有商品档案引用了品牌,不允许停用,是否跳转到商品档案页面?',
+              }).then(() => {
+                //跳转
+                wx.navigateTo({
+                  url: '/package-basic-data/pages/product-file/product-file',
+                  success: function (res) {
+                    res.eventChannel.emit('params', { formMode: Constants.formMode.index, item: { brandId: item.brandId } })
+                  }
+                })
+              }).catch(() => {
+              })
+              return;
             }
-          })
-        }).catch(() => {
+            //执行接口
+            this.handleMoreDataIsValid(service, item, id)
+          }
         })
-        return
       }
-
     }
     if (this.data.formDataName == mixins.$t('goodsCategorySys')) {
       service = this.data.goodsCategoryService
       id = 'catId'
+      //执行接口
+      this.handleMoreDataIsValid(service, item, id)
     }
     if (this.data.formDataName == mixins.$t('goodsSeriesSys')) {
       service = this.data.goodsSeriesService
       id = 'seriesId'
+      //执行接口
+      this.handleMoreDataIsValid(service, item, id)
     }
     if (this.data.formDataName == mixins.$t('unitSys')) {
       service = this.data.unitService
       id = 'unitId'
+      //执行接口
+      this.handleMoreDataIsValid(service, item, id)
     }
-    //执行接口
-    this.handleMoreDataIsValid(service, item, id)
   },
 
   /**
@@ -186,7 +198,7 @@ Page({
     let id = null
     let service = null
     if (this.data.formDataName == mixins.$t('goodsBrandSys')) { //商品品牌
-      params.supplierIds = params.supplierIds?params.supplierIds:null
+      params.supplierIds = params.supplierIds ? params.supplierIds : null
       service = this.data.goodsBrandService
       id = params.brandId
     } else if (this.data.formDataName == mixins.$t('goodsCategorySys')) { //商品种类
@@ -211,7 +223,7 @@ Page({
           this.searchData()
           // 编辑后关闭窗体
           this.setData({
-            showPop:false
+            showPop: false
           })
         }
       });;
@@ -226,11 +238,11 @@ Page({
 
           // console.log('dataItem', this.data.dataItem)
           this.setData({
-            dataItem:null
+            dataItem: null
           })
           // 商品种类
-          if(this.data.formDataName == mixins.$t('goodsCategorySys')){
-            console.log('dddttt',this.data.dataItem);
+          if (this.data.formDataName == mixins.$t('goodsCategorySys')) {
+            console.log('dddttt', this.data.dataItem);
           }
           //清除组件数据
           this.selectComponent('#popup').setFormNull()
@@ -260,7 +272,7 @@ Page({
     }
     this.setData({
       formDataName: this.data.sidebarList[detail].kindCode,
-      formDataTitle:this.data.sidebarList[detail].kindName
+      formDataTitle: this.data.sidebarList[detail].kindName
     })
     this.searchData()
   },
@@ -373,109 +385,109 @@ Page({
     let popContent = this.data.popContent
     let routeObjNameGoTo = this.data.routeObjNameGoTo
     if (formDataName == mixins.$t('goodsBrandSys')) {//商品品牌
-      if(dataItem){
-        if(this.data.gradeCode == Constants.gradeCode.STD){
+      if (dataItem) {
+        if (this.data.gradeCode == Constants.gradeCode.STD) {
 
           popContent =
-          [
-            { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
-            { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
-            // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-          ]
-        }else{
+            [
+              { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
+              { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+            ]
+        } else {
           popContent =
-          [
-            { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
-            { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
-            // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-            { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') },
-  
-            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-          ]
+            [
+              { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
+              { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') },
+
+              { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+            ]
         }
-     
-      }else{
-        if(this.data.gradeCode == Constants.gradeCode.STD){
+
+      } else {
+        if (this.data.gradeCode == Constants.gradeCode.STD) {
           popContent =
-          [
-            // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
-            { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
-            // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-          ]
-        }else{
+            [
+              // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
+              { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+            ]
+        } else {
           popContent =
-          [
-            // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
-            { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
-            // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
-            { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') }, 
-            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-          ]
+            [
+              // { code: 'brandCode', type: 'str', title: mixins.$t('brandCode'), required: false, readonly: true, },
+              { code: 'brandName', type: 'str', title: mixins.$t('brandName'), required: true },
+              // { code: 'shortName', type: 'str', title: mixins.$t('abbreviation'), required: false },
+              { code: 'supplierIds', name: 'supplierNames', title: 'supplier', type: 'choose', required: true, dropType: 'supplier', required: true, urlKey: 'selectProductAttributeSuppliers', code: 'supplierIds', formMode: 'index', idKey: 'roleId', title: mixins.$t('supplier') },
+              { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+            ]
         }
       }
-     
+
       routeObjNameGoTo = 'goodsBrand'
     }
     if (formDataName == mixins.$t('goodsCategorySys')) { //商品种类
-      if(dataItem){
+      if (dataItem) {
         popContent =
-        [
-          { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true },
-          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes',notClear:true },
-          { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
-      }else{
+          [
+            { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true },
+            { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes', notClear: true },
+            { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
+      } else {
         popContent =
-        [
-          // { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true, },
-          { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes',notClear:true },
-          { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
+          [
+            // { code: 'catCode', type: 'str', title: mixins.$t('catCode'), required: false, readonly: true, },
+            { code: 'parentId', name: 'parentName', title: mixins.$t('parent'), type: 'choose', required: false, urlKey: 'selectProductTypes', notClear: true },
+            { code: 'catName', type: 'str', title: mixins.$t('catName'), required: true },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
       }
-     
+
       routeObjNameGoTo = 'goodsCategory'
     }
     if (formDataName == mixins.$t('goodsSeriesSys')) { //商品系列
-      if(dataItem){
+      if (dataItem) {
         popContent =
-        [
-          { code: 'seriesCode', type: 'str', title: mixins.$t('seriesCode'), required: false, readonly: true, },
-          { code: 'seriesName', type: 'str', title: mixins.$t('seriesName'), required: true },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
-      }else{
+          [
+            { code: 'seriesCode', type: 'str', title: mixins.$t('seriesCode'), required: false, readonly: true, },
+            { code: 'seriesName', type: 'str', title: mixins.$t('seriesName'), required: true },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
+      } else {
         popContent =
-        [
-          // { code: 'seriesCode', type: 'str', title: mixins.$t('seriesCode'), required: false, readonly: true, },
-          { code: 'seriesName', type: 'str', title: mixins.$t('seriesName'), required: true },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
+          [
+            // { code: 'seriesCode', type: 'str', title: mixins.$t('seriesCode'), required: false, readonly: true, },
+            { code: 'seriesName', type: 'str', title: mixins.$t('seriesName'), required: true },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
       }
 
     }
     if (formDataName == mixins.$t('unitSys')) { //计量单位
-      if(dataItem){
+      if (dataItem) {
         popContent =
-        [
-          { code: 'unitCode', type: 'str', title: mixins.$t('unitCode'), required: false, readonly: true, },
-          { code: 'unitName', type: 'str', title: mixins.$t('unitName'), required: true },
-          { code: 'decimalPlaces', max: 6, type: 'number', sign: "", digits: 0, title: mixins.$t('decimalPlaces'), required: true, formatThousandth: false },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
-      }else{
+          [
+            { code: 'unitCode', type: 'str', title: mixins.$t('unitCode'), required: false, readonly: true, },
+            { code: 'unitName', type: 'str', title: mixins.$t('unitName'), required: true },
+            { code: 'decimalPlaces', max: 6, type: 'number', sign: "", digits: 0, title: mixins.$t('decimalPlaces'), required: true, formatThousandth: false },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
+      } else {
         popContent =
-        [
-          // { code: 'unitCode', type: 'str', title: mixins.$t('unitCode'), required: false, readonly: true, },
-          { code: 'unitName', type: 'str', title: mixins.$t('unitName'), required: true },
-          { code: 'decimalPlaces', max: 6, type: 'number', sign: "", digits: 0, title: mixins.$t('decimalPlaces'), required: true, formatThousandth: false },
-          { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
-        ]
+          [
+            // { code: 'unitCode', type: 'str', title: mixins.$t('unitCode'), required: false, readonly: true, },
+            { code: 'unitName', type: 'str', title: mixins.$t('unitName'), required: true },
+            { code: 'decimalPlaces', max: 6, type: 'number', sign: "", digits: 0, title: mixins.$t('decimalPlaces'), required: true, formatThousandth: false },
+            { code: 'remarks', type: 'str', title: mixins.$t('remarks'), required: false }
+          ]
       }
-  
+
     }
     this.setData({
       popContent: popContent,

+ 14 - 4
package-basic-data/pages/product-file/product-file.js

@@ -80,7 +80,20 @@ Page({
    * @date : 2024/1/23 9:16
    */
   loadInit() {
-    this.getGoodsBrandNoPage()
+    // 获取品牌
+    this.getGoodsBrandNoPage().then(res=>{
+      let item = this.data.item
+      if(item && item.brandId){
+        let sidebarList = this.data.sidebarList;
+        let index = sidebarList.findIndex(it=>it.brandId == item.brandId)
+        this.setData({
+          sideKey:index,
+          brandId:item.brandId
+        })
+        // 重新根据品牌进行查询
+        this.searchData();
+      }
+    })
   },
   /**
    * @desc : 获取品牌
@@ -88,7 +101,6 @@ Page({
    * @date : 2024/1/23 9:16
    */
   getGoodsBrandNoPage() {
-    let param = {}
     let excute = this.excute(this.data.commonService, this.data.commonService.getGoodsBrandNoPage, {});
     excute.then(res => {
       if (res.data.code === Constants.SUCESS_CODE) { 
@@ -106,8 +118,6 @@ Page({
     return excute;
   },
 
-
-
   /**
    * @desc : 设置查询参数
    * @author : 王英杰