songshankun
2023-10-19 301cbea766080fb65b8c6af563388b61606322f3
src/views/productManage/productCategory/AddProductCategoryDialog.vue
@@ -1,14 +1,14 @@
<template>
  <div class="add-common">
    <el-dialog
      :title="editCommonConfig.title + '产品类别'"
      :title="modalTitle + '产品类别'"
      :visible.sync="editConfig.visible"
      :width="dialogWidth"
      :before-close="handleClose"
    >
      <!-- 头 -->
      <div slot="title" class="dialog-header">
        <span>{{ editCommonConfig.title + "产品类别" }}</span>
        <span>{{ modalTitle + "产品类别" }}</span>
        <div class="header_btns">
          <!-- <span class="btn">
            <i class="el-icon-printer"></i>
@@ -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: {
@@ -182,7 +183,8 @@
        return {
          visible: false,
          title: "新建",
          infomation: { type: [] }
          infomation: { type: [] },
          autoEdit: false,
        }
      }
    },
@@ -194,7 +196,20 @@
    }
  },
  components: {},
  computed: {},
  computed: {
    productCategoryListWithDefault(){
      return [{id:0,name:'请选择'},...(this.productCategoryList?? [])]
    },
    modalTitle(){
      if (this.editConfig.title === '编辑' && this.editConfig.autoEdit){
        return '编辑'
      }else if (this.editConfig.title === '编辑') {
        return !this.showEdit ? '编辑' : '查看'
      }else {
        return '新建'
      }
    }
  },
  data() {
    return {
      dialogWidth: "50%",
@@ -212,13 +227,38 @@
      showButton: true,
      showEdit: false, // 是否显示编辑按钮
      isDelClick: false, // 删除按钮是否可点击
      showFooter: false // 是否显示取消保存
      showFooter: false, // 是否显示取消保存,
      statisticsMap:{
        product: 0 // 产品数量
      }
    }
  },
  created() {
    this.setBottonView()
    this.getProductCount()
    if (this.editConfig.autoEdit){
      this.editClick()
    }
  },
  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 === "新建") {