zuozhengqing
2024-04-09 8396695ccec67407b465a6f30503298df7803d84
产品,添加单位管理
3个文件已修改
102 ■■■■ 已修改文件
src/api/product/product.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/product/AddProductDialog.vue 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/product/components/bomDialog.vue 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/product/product.js
@@ -47,3 +47,12 @@
    data
  })
}
// 保存单位
export function saveUnitDict(data) {
  return request({
    url: "/api-wms/v1/product/saveUnitDict",
    method: "post",
    data
  })
}
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
      })
    }
  }
src/views/productManage/product/components/bomDialog.vue
@@ -32,7 +32,8 @@
        style="margin-left: 16px; color: #fff; background-color: #ee790c"
        >新增</el-button
      > -->
      <el-button @click="shutdown">取消</el-button><el-button type="primary" @click="handleConfirmSave()"
      <el-button @click="shutdown">取消</el-button>
      <el-button type="primary" @click="handleConfirmSave()"
        style="margin-left: 16px; color: #fff; background-color: #2a78fb">确定</el-button>
    </div>
  </el-dialog>
@@ -52,6 +53,7 @@
      default: () => {
        return {
          editDialogVisible: false,
          BomTableData:[]
        };
      },
    },
@@ -64,7 +66,9 @@
      thatEditRow:this.editRow,
      isTableShow: true,
      form: {},
      // BomTableData: JSON.parse(this.thatEditRow.BomTableData),
      // BomTableData:[],
      BomTableData: this.editRow.BomTableData,
      // BomTableData: JSON.parse(this.editRow.BomTableData),
      // BomTableData: [{ id: 303, createdAt: "2024-02-05 18:02:47", updatedAt: "2024-02-05 18:02:47",name: "kg", isDefault: false }],
      work: 1,
      flag: "add",
@@ -101,16 +105,6 @@
    };
  },
  watch: {
    // editDialogVisible(newVal) {
    //   console.log(newVal,"看看val")
    //   if (newVal) {
    //     this.BomTableData = this.workList;
    //   }
    // },
    // workList(newVal) {
    //   console.log(newVal)
    //   this.BomTableData = this.workList;
    // },
  },
  created() {
    console.log(this.thatEditRow,"thatEditRow")
@@ -118,12 +112,18 @@
  mounted() { },
  methods: {
    handleAdd() {
      this.BomTableData=this.thatEditRow.BomTableData
      this.BomTableData.push({ name: "", isDefault: false });
    },
    handleDelete(id) {
      this.BomTableData = this.BomTableData.filter((i) => {
      if (this.BomTableData.length === 1) {
        this.$message.warning("至少保留一条数据");
        return;
      }
      this.BomTableData = this.thatEditRow.BomTableData.filter((i) => {
        return i.id != id;
      });
      this.thatEditRow.BomTableData=this.BomTableData
    },
    async getCodeStandardList() {
      const res = await getCodeStandardList(this.obj);
@@ -186,7 +186,7 @@
        let fn = this.flag == "set" ? updateMaterial : addMaterial;
        const res = await fn(this.form);
        this.shutdown();
        this.$sucessSet("sucessSet");
        // this.$sucessSet("sucessSet");
        if (res.code == 200) {
          this.$message({
            message: this.flag == "set" ? "修改成功!" : "添加成功!",