yangfeng
2023-11-03 47121dff8da689923f2f1af9daf63854f385c395
查看产品、产品类别弹窗调整上架规则
4个文件已修改
256 ■■■■■ 已修改文件
src/views/productManage/product/AddProductDialog.vue 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/product/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/productCategory/AddProductCategoryDialog.vue 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/warehouseManage/listingRules/index.vue 119 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/product/AddProductDialog.vue
@@ -43,6 +43,7 @@
            :show-procure="showProcure"
            :countObject="statisticsMap"
            :show-sale="showSale"
            @listingRulesClick="listingRulesClick"
          />
          <div class="bottom">
            <el-tabs v-model="activeName" type="card">
@@ -558,22 +559,24 @@
    /**
     * 非必填项后端返回的是数字 0,表单需要空串才能视为未选择回显
     */
    setOptionalFieldsToEmpty(){
      ['productType','categoryId']
          .filter(filed => this.editConfig.infomation[filed] === 0)
          .forEach(filed => {
            this.editConfig.infomation[filed] = ''
          })
    setOptionalFieldsToEmpty() {
      let arr = ["productType", "categoryId"]
      arr
        .filter((filed) => this.editConfig.infomation[filed] === 0)
        .forEach((filed) => {
          this.editConfig.infomation[filed] = ""
        })
    },
    /**
     * 后端只接受数字形式, 保存时还得再转回去
     */
    unsetFieldsToNumber(){
      ['productType','categoryId']
          .filter(filed => this.editConfig.infomation[filed] === '')
          .forEach(filed => {
            this.editConfig.infomation[filed] = 0
          })
    unsetFieldsToNumber() {
      let arr = ["productType", "categoryId"]
      arr
        .filter((filed) => this.editConfig.infomation[filed] === "")
        .forEach((filed) => {
          this.editConfig.infomation[filed] = 0
        })
    },
    // 获取产品类别
    async getProductCategoryList() {
@@ -645,7 +648,7 @@
              this.$message.success("添加成功")
              this.$parent.getData()
            }
          },console.error)
          }, console.error)
        }
      })
    },
@@ -779,6 +782,20 @@
        })
      }
    },
    // 上架规则
    listingRulesClick() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$router.push({
            path: "/warehouseManage/listingRules",
            query: {
              productName: this.editConfig.infomation.name,
              productId: this.editConfig.title === "新建" ? "" : this.editConfig.infomation.id
            }
          })
        }
      })
    },
    // 可销售/可采购
    checkboxChange(val, param) {
      if (val === "采购") {
src/views/productManage/product/index.vue
@@ -125,7 +125,6 @@
      this.pagerOptions.currPage = 1
      this.searchTaskMap = query.id ? [{ categoryId: this.categoryId, title: query.categoryName }] : []
    }
    this.getData()
  },
  methods: {
src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -38,7 +38,12 @@
        size="mini"
      >
        <div class="basic-info">
          <FormBtnsView :showProduct="true" :countObject="statisticsMap" @productClick="productClick" />
          <FormBtnsView
            :showProduct="true"
            :countObject="statisticsMap"
            @productClick="productClick"
            @listingRulesClick="listingRulesClick"
          />
          <div class="basic-info-view">
            <!-- <el-row> -->
            <!-- <el-col :span="24">
@@ -173,7 +178,7 @@
import { addProductCategory, updateProductCategory, deleteProductCategory } from "@/api/product/productCategory"
import { getDataByType } from "@/api/data"
import {getProductList} from "@/api/product/product";
import { getProductList } from "@/api/product/product"
export default {
  name: "AddProductCategoryDialog",
  props: {
@@ -184,7 +189,7 @@
          visible: false,
          title: "新建",
          infomation: { type: [] },
          autoEdit: false,
          autoEdit: false
        }
      }
    },
@@ -197,13 +202,13 @@
  },
  components: {},
  computed: {
    modalTitle(){
      if (this.editConfig.title === '编辑' && this.editConfig.autoEdit){
        return '编辑'
      }else if (this.editConfig.title === '编辑') {
        return !this.showEdit ? '编辑' : '查看'
      }else {
        return '新建'
    modalTitle() {
      if (this.editConfig.title === "编辑" && this.editConfig.autoEdit) {
        return "编辑"
      } else if (this.editConfig.title === "编辑") {
        return !this.showEdit ? "编辑" : "查看"
      } else {
        return "新建"
      }
    }
  },
@@ -225,7 +230,7 @@
      showEdit: false, // 是否显示编辑按钮
      isDelClick: false, // 删除按钮是否可点击
      showFooter: false, // 是否显示取消保存,
      statisticsMap:{
      statisticsMap: {
        product: 0 // 产品数量
      }
    }
@@ -233,7 +238,7 @@
  created() {
    this.setBottonView()
    this.getProductCount()
    if (this.editConfig.autoEdit){
    if (this.editConfig.autoEdit) {
      this.editClick()
    }
    this.setOptionalFieldsToEmpty()
@@ -242,40 +247,44 @@
    /**
     * 非必填项后端返回的是数字 0,表单需要空串才能视为未选择回显
     */
    setOptionalFieldsToEmpty(){
      ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy']
          .filter(filed => this.editConfig.infomation[filed] === 0)
          .forEach(filed => {
            this.editConfig.infomation[filed] = ''
          })
    setOptionalFieldsToEmpty() {
      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
      arr
        .filter((filed) => this.editConfig.infomation[filed] === 0)
        .forEach((filed) => {
          this.editConfig.infomation[filed] = ""
        })
    },
    /**
     * 后端只接受数字形式, 保存时还得再转回去
     */
    unsetFieldsToNumber(){
      ['parentId','costingMethod','inventoryValuation','forceRemovalStrategy']
          .filter(filed => this.editConfig.infomation[filed] === '')
          .forEach(filed => {
            this.editConfig.infomation[filed] = 0
          })
    unsetFieldsToNumber() {
      let arr = ["parentId", "costingMethod", "inventoryValuation", "forceRemovalStrategy"]
      arr
        .filter((filed) => this.editConfig.infomation[filed] === "")
        .forEach((filed) => {
          this.editConfig.infomation[filed] = 0
        })
    },
    // 获取产品数量
    getProductCount(){
    getProductCount() {
      getProductList({
        keyWord: '',
        keyWord: "",
        categoryId: this.editConfig.title === "新建" ? null : this.editConfig.infomation.id,
        page: 1,
        pageSize: 1
      }).then((res) => {
        if (res.code === 200) {
          this.statisticsMap.product = res?.total ?? 0
        }else{
          this.statisticsMap.product = 0
        }
      }).catch(err=>{
        console.error(err)
        this.statisticsMap.product = 0
      })
        .then((res) => {
          if (res.code === 200) {
            this.statisticsMap.product = res?.total ?? 0
          } else {
            this.statisticsMap.product = 0
          }
        })
        .catch((err) => {
          console.error(err)
          this.statisticsMap.product = 0
        })
    },
    // 设置删除/打印/编辑是否显示
    setBottonView() {
@@ -374,6 +383,20 @@
          })
        }
      })
    },
    // 上架规则
    listingRulesClick() {
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$router.push({
            path: "/warehouseManage/listingRules",
            query: {
              categoryName: this.editConfig.infomation.name,
              id: this.editConfig.title === "新建" ? "" : this.editConfig.infomation.id
            }
          })
        }
      })
    }
  }
}
src/views/warehouseManage/listingRules/index.vue
@@ -4,12 +4,14 @@
      <SearchCommonView
        :add-title="addTitle"
        :show-discard="showDiscard"
        :placeholder="'请输入位置/产品'"
        :placeholder="'请输入产品/产品类别'"
        :amount-view="false"
        :search-task-map="searchTaskMap"
        @addCommonClick="addProductClick"
        @searchClick="getList"
        @discardBtnClick="discardBtnClick"
        @applyBtnClick="applyBtnClick"
        @delSelectClick="delSelectClick"
      />
    </div>
    <div class="list-view">
@@ -89,15 +91,32 @@
      isRowClick: false,
      areaId: 0,
      productId: 0,
      productCategoryId:0,
      productCategoryId: 0,
      subLocationId: 0,
      currentRowId: 0,
      rowIndex:-1,
      RuleType:0,
      rowIndex: -1,
      RuleType: 0,
      queryProductId: null,
      categoryId: null,
      searchTaskMap: []
    }
  },
  created() {
    this.setTable()
    let query = this.$route.query
    if (query) {
      console.log("aaaaaaaaaaaaa", query)
      this.queryProductId = query.productId?.length ? query.productId : null
      this.categoryId = query.id ? Number(query.id) : null
      this.pagerOptions.currPage = 1
      this.searchTaskMap =
        query?.id > 0
          ? [{ categoryId: this.categoryId, title: query.categoryName }]
          : query.productId?.length > 0
          ? [{ productId: this.queryProductId, title: query.productName }]
          : []
      console.log(this.searchTaskMap)
    }
    this.getData()
  },
  methods: {
@@ -109,7 +128,7 @@
        tableColumn: [
          { label: "当产品到达", prop: "areaName", location: true },
          { label: "产品", prop: "productName", product: true },
          { label: "产品类别", prop: "productCategory",productType: true },
          { label: "产品类别", prop: "productCategory", productType: true },
          { label: "存储到子位置", prop: "subLocation", location: true }
          // { label: "公司", prop: "companyName", company: true }
        ]
@@ -118,7 +137,8 @@
    // 请求数据
    async getData() {
      await getListingRulesList({
        // keyword: this.keyword,
        productId: this.queryProductId ? this.queryProductId : null,
        productCategoryId: this.categoryId ? this.categoryId : null,
        page: this.pagerOptions.currPage,
        pageSize: this.pagerOptions.pageSize
      }).then((res) => {
@@ -151,8 +171,8 @@
    },
    // 新增
    addProductClick() {
      this.tableList.tableColumn[1].product=true
      this.tableList.tableColumn[2].productType=true
      this.tableList.tableColumn[1].product = true
      this.tableList.tableColumn[2].productType = true
      console.log(this.tableData)
      this.isSel()
      if (this.isNoProduct && this.addTitle === "新建") {
@@ -181,7 +201,7 @@
      } else {
        if (this.areaId === 0) {
          this.$message.error("请选择当前产品到达位置")
        } else if (this.productId === 0 && this.productCategoryId==='') {
        } else if (this.productId === 0 && this.productCategoryId === "") {
          this.$message.error("请选择产品或产品类别")
        } else if (this.subLocationId === 0) {
          this.$message.error("请选择存储到子位置")
@@ -200,12 +220,12 @@
          })
          let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules
          requestUrl({
              RuleType:this.RuleType,
              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) {
@@ -230,8 +250,8 @@
    },
    // 取消
    discardBtnClick() {
      this.tableList.tableColumn[1].product=true
      this.tableList.tableColumn[2].productType=true
      this.tableList.tableColumn[1].product = true
      this.tableList.tableColumn[2].productType = true
      if (this.isRowClick) {
        this.tableData.map((item) => {
          item.isEdit = true
@@ -275,12 +295,12 @@
    },
    // 行点击
    tableRowClick(row, rowIndex) {
      this.rowIndex=rowIndex
      this.rowIndex = rowIndex
      this.isSel()
      if (!this.isNoProduct && this.currentRowId === 0) {
        this.$message.error("请完成当前新建或取消新建")
      } else {
        this.tableList.tableColumn[2].productType=true
        this.tableList.tableColumn[2].productType = true
        this.currentRowId = row.id
        this.addTitle = "保存"
        this.showDiscard = true
@@ -300,14 +320,17 @@
        this.subLocationId = row.locationId
        this.productCategoryId = row.productCategoryId
        this.productId = row.productId
        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
        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
        }
    }
      }
    },
    // 搜索
    getList(val) {
@@ -343,22 +366,22 @@
    },
    // 选中产品方法
    selProductClick(item) {
      console.log(item,"产品")
      this.RuleType=1
      this.tableList.tableColumn[2].productType=false
      console.log(item, "产品")
      this.RuleType = 1
      this.tableList.tableColumn[2].productType = false
      this.productId = item.value
      this.productCategoryId = item.categoryId
    },
    // 选中产品类型方法
    selProductTypeClick(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
      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
      }
    },
    // 删除
@@ -370,16 +393,22 @@
          this.getData()
        }
      })
    },
    // 删除产品类型
    delSelectClick() {
      this.categoryId = 0
      this.queryProductId = ""
      this.getData()
    }
  },
  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
  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
      }
    }
  }