songshankun
2023-10-19 fbe9459ed908eef6c25c3bcd244d0a7e74dfa792
src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -38,7 +38,7 @@
        size="mini"
      >
        <div class="basic-info">
          <FormBtnsView :showProduct="true" @productClick="productClick" />
          <FormBtnsView :showProduct="true" :countObject="statisticsMap" @productClick="productClick" />
          <div class="basic-info-view">
            <!-- <el-row> -->
            <!-- <el-col :span="24">
@@ -88,7 +88,7 @@
                    style="width: 85%"
                    :disabled="!showFooter"
                  >
                    <el-option v-for="item in productCategoryList" :key="item.id" :label="item.name" :value="item.id">
                    <el-option v-for="item in productCategoryListWithDefault" :key="item.id" :label="item.name" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
@@ -173,6 +173,7 @@
import { addProductCategory, updateProductCategory, deleteProductCategory } from "@/api/product/productCategory"
import { getDataByType } from "@/api/data"
import {getProductList} from "@/api/product/product";
export default {
  name: "AddProductCategoryDialog",
  props: {
@@ -194,7 +195,12 @@
    }
  },
  components: {},
  computed: {},
  computed: {
    productCategoryListWithDefault(){
      console.log(this.productCategoryList)
      return [{id:0,name:'请选择'},...(this.productCategoryList?? [])]
    }
  },
  data() {
    return {
      dialogWidth: "50%",
@@ -212,13 +218,35 @@
      showButton: true,
      showEdit: false, // 是否显示编辑按钮
      isDelClick: false, // 删除按钮是否可点击
      showFooter: false // 是否显示取消保存
      showFooter: false, // 是否显示取消保存,
      statisticsMap:{
        product: 0 // 产品数量
      }
    }
  },
  created() {
    this.setBottonView()
    this.getProductCount()
  },
  methods: {
    // 获取产品数量
    getProductCount(){
      getProductList({
        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
      })
    },
    // 设置删除/打印/编辑是否显示
    setBottonView() {
      if (this.editConfig.title === "新建") {