zuozhengqing
2024-04-09 8396695ccec67407b465a6f30503298df7803d84
src/views/productManage/product/AddProductDialog.vue
@@ -141,11 +141,12 @@
                  <el-form-item label="单位" prop="unit">
                    <el-select
                      :disabled="!showFooter"
                      v-model="editConfig.infomation.unit"
                      placeholder="单位"
                      filterable
                      @change="$forceUpdate()"
                      style="width: calc(100% - 30px)"
                      @change="Gtechange"
                      style="width: 85%"
                    >
                      <el-option
                        v-for="ele in unitList"
@@ -537,7 +538,6 @@
    <BomDialog
      ref="editDialog"
      :editRow="editRow"
      @sucessSet="handleGetBomKindDictList"
      @handleConfirmSave="handleConfirmSave"
      :workList="unitList"
      title="计量单位"
@@ -548,8 +548,8 @@
<script>
import IconCropper from "./IconCropper"
import { getProductCategoryList } from "@/api/product/productCategory"
import { getProductList, addProduct, updateProduct } from "@/api/product/product"
import { uploadFiles, getUserInfo } from "@/api/common/other"
import { getProductList, addProduct, updateProduct,saveUnitDict } from "@/api/product/product"
import { uploadFiles, getUserInfo, } from "@/api/common/other"
import codeMixin from "@/components/mixin/codeMixin"
import { getDataByType } from "@/api/data"
import BomDialog from "./components/bomDialog";
@@ -597,7 +597,7 @@
        id: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }],
        model: [{ required: true, message: "请选择物料类型", trigger: "change" }],
        // salePrice: [{ required: true, message: "请输入销售价格", trigger: "blur" }],
        unit: [{ required: true, message: "请输入单位", trigger: ["change", "blur"] }],
        unit: [{ required: true, message: "请输入单位", trigger: ["blur"] }],
        // 采购类型
        purchaseTypeList: [{ required: true, message: "请选择", trigger: "blur" }]
      },
@@ -687,39 +687,18 @@
  methods: {
    // 单位
    handleUnitShow() {
      this.handleGetBomKindDictList();
      this.editRow.editDialogVisible = true;
    },
    //  单位
    handleGetBomKindDictList(val) {
      console.log(val)
      // postGetUnitDictList().then((res) => {
      //   this.unitList = res.data;
      //   if (val) {
      //     for (let i in this.unitList) {
      //       if (this.unitList[i].isDefault) {
      //         this.form.unit = this.form.unit
      //           ? this.form.unit
      //           : this.unitList[i].name;
      //         // this.$set(this.form, "unit", this.form.unit);
      //         break;
      //       }
      //     }
      //   }
      // });
    },
    handleConfirmSave(data) {
      console.log(data)
      // postGetSaveSUnitDict({ data: data }).then((res) => {
      //   if (res.code == 200) {
      //     this.$message({
      //       message: "操作成功!",
      //       type: "success",
      //     });
      //     this.$refs.editDialog.editDialogVisible = false;
      //     this.handleGetBomKindDictList();
      //   }
      // });
    handleConfirmSave(dataList) {
      saveUnitDict({ data: dataList }).then((res) => {
        if (res.code == 200) {
          this.$message({
            message: "操作成功!",
            type: "success",
          });
          this.getUnitInfo()
        }
      });
      this.editRow.editDialogVisible = false;
    },
@@ -1000,11 +979,21 @@
        this.showSale = param
      }
    },
    Gtechange(){
      this.$forceUpdate()
    },
    // 获取单位列表数据
    async getUnitInfo(){
      await getUnitInfo().then((res)=>{
        if( this.editConfig.title==="新建"){
          res.data.map((item)=>{
            if(item.isDefault){
              this.editConfig.infomation.unit=item.name
            }
          })
        }
        this.editRow.BomTableData = res.data;
        console.log( this.editRow.BomTableData,"看下",res.data)
        this.unitList=res.data
      })
    }
  }