zuozhengqing
2023-11-03 05159702c718d8661eb457f1362b115beeaa421d
src/views/warehouseManage/listingRules/index.vue
@@ -89,9 +89,11 @@
      isRowClick: false,
      areaId: 0,
      productId: 0,
      productCategoryId:0,
      subLocationId: 0,
      currentRowId: 0,
      rowIndex:0
      rowIndex:-1,
      RuleType:0,
    }
  },
  created() {
@@ -179,8 +181,8 @@
      } else {
        if (this.areaId === 0) {
          this.$message.error("请选择当前产品到达位置")
        } else if (this.productId === 0) {
          this.$message.error("请选择产品")
        } else if (this.productId === 0 && this.productCategoryId==='') {
          this.$message.error("请选择产品或产品类别")
        } else if (this.subLocationId === 0) {
          this.$message.error("请选择存储到子位置")
        } else {
@@ -197,19 +199,13 @@
            }
          })
          let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules
          console.log({
            id: this.currentRowId,
            areaId: this.areaId,
            locationId: this.subLocationId,
            productCategoryId: this.productCategoryId,
            productId: this.productId
          },"参数")
          requestUrl({
            id: this.currentRowId,
            areaId: this.areaId,
            locationId: this.subLocationId,
            productCategoryId: this.productCategoryId,
            productId: this.productId
              RuleType:this.RuleType,
              id: this.currentRowId,
              areaId: this.areaId,
              locationId: this.subLocationId,
              productCategoryId: this.productCategoryId||'',
              productId: this.productId||''
          }).then((res) => {
            console.log(res)
            if (res.code === 200) {
@@ -225,7 +221,7 @@
    isSel() {
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].productName.length === 0) {
          this.isNoProduct = false
          this.isNoProduct = true // 暂时修改为true,如果产品以后是必填,改为false就行
          break
        } else {
          this.isNoProduct = true
@@ -279,16 +275,11 @@
    },
    // 行点击
    tableRowClick(row, rowIndex) {
      console.log("11111",row,rowIndex)
      console.log(this.isNoProduct ,this.currentRowId,"xxx")
      // this.tableList.tableColumn[1].product=true
      // this.tableList.tableColumn[2].productType=false
      this.rowIndex=rowIndex
      this.isSel()
      if (!this.isNoProduct && this.currentRowId === 0) {
        this.$message.error("请完成当前新建或取消新建")
      } else {
      if(row.productCategory!==""){
        this.tableList.tableColumn[2].productType=true
        this.currentRowId = row.id
        this.addTitle = "保存"
@@ -309,70 +300,13 @@
        this.subLocationId = row.locationId
        this.productCategoryId = row.productCategoryId
        this.productId = row.productId
      }else if(row.productCategory===""){
        this.tableList.tableColumn[2].productType=false
        this.currentRowId = row.id
        this.addTitle = "保存"
        this.showDiscard = true
        this.isRowClick = true
        if (!this.isNoProduct) {
          this.tableData.splice(this.tableData.length - 1, 1)
        if(this.tableList.tableData[rowIndex].productName===""||this.tableList.tableData[rowIndex].productName===" "){
          this.tableList.tableColumn[1].product=false
          this.tableList.tableColumn[2].productType=true
        }else{
          this.tableList.tableColumn[1].product=true
          this.tableList.tableColumn[2].productType=false
        }
        this.tableData.map((item, index) => {
          if (index === rowIndex) {
            item.isEdit = false
            item.isOrder = true
          } else {
            item.isEdit = true
          }
        })
        this.areaId = row.areaId
        this.subLocationId = row.locationId
        this.productCategoryId = row.productCategoryId
        this.productId = row.productId
      }else if(row.productId!==""){
        this.tableList.tableColumn[1].product=true
        this.currentRowId = row.id
        this.addTitle = "保存"
        this.showDiscard = true
        this.isRowClick = true
        if (!this.isNoProduct) {
          this.tableData.splice(this.tableData.length - 1, 1)
        }
        this.tableData.map((item, index) => {
          if (index === rowIndex) {
            item.isEdit = false
            item.isOrder = true
          } else {
            item.isEdit = true
          }
        })
        this.areaId = row.areaId
        this.subLocationId = row.locationId
        this.productCategoryId = row.productCategoryId
        this.productId = row.productId
      }else if(row.product===""){
        this.tableList.tableColumn[1].product=false
        this.currentRowId = row.id
        this.addTitle = "保存"
        this.showDiscard = true
        this.isRowClick = true
        if (!this.isNoProduct) {
          this.tableData.splice(this.tableData.length - 1, 1)
        }
        this.tableData.map((item, index) => {
          if (index === rowIndex) {
            item.isEdit = false
            item.isOrder = true
          } else {
            item.isEdit = true
          }
        })
        this.areaId = row.areaId
        this.subLocationId = row.locationId
        this.productCategoryId = row.productCategoryId
        this.productId = row.productId
      }
    }
    },
    // 搜索
@@ -410,17 +344,22 @@
    // 选中产品方法
    selProductClick(item) {
      console.log(item,"产品")
      this.RuleType=1
      this.tableList.tableColumn[2].productType=false
      this.productId = item.value
      this.productCategoryId = item.categoryId
    },
    // 选中产品类型方法
    selProductTypeClick(item) {
      console.log(item,"产品类型",this.tableList.tableData[this.rowIndex])
      this.tableList.tableColumn[1].product=false
      this.tableList.tableData[this.rowIndex].productName='--'
      this.productId=''
      this.productCategoryId=item
      this.RuleType=2
      if(this.currentRowId===0){
        this.productCategoryId=item.value
      }else{
        this.tableList.tableColumn[1].product=false
        this.tableList.tableData[this.rowIndex].productName=' '
        this.productId=''
        this.productCategoryId=this.tableList.tableData[this.rowIndex].productCategoryId
      }
    },
    // 删除
    async delClick(scope) {
@@ -432,6 +371,17 @@
        }
      })
    }
  },
  watch:{
    rowIndex(newVal){
      if(this.tableList.tableData[newVal].productName===" "){
        this.tableList.tableColumn[1].product=false
        this.tableList.tableColumn[2].productType=true
      }else{
        this.tableList.tableColumn[1].product=true
        this.tableList.tableColumn[2].productType=false
      }
    }
  }
}
</script>