From 8396695ccec67407b465a6f30503298df7803d84 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期二, 09 四月 2024 14:59:05 +0800
Subject: [PATCH] 产品,添加单位管理
---
src/api/product/product.js | 9 ++++
src/views/productManage/product/components/bomDialog.vue | 28 +++++++-------
src/views/productManage/product/AddProductDialog.vue | 65 +++++++++++++-------------------
3 files changed, 50 insertions(+), 52 deletions(-)
diff --git a/src/api/product/product.js b/src/api/product/product.js
index 7af33ac..12cc022 100644
--- a/src/api/product/product.js
+++ b/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
+ })
+}
+
diff --git a/src/views/productManage/product/AddProductDialog.vue b/src/views/productManage/product/AddProductDialog.vue
index 6de1c2b..3be77ba 100644
--- a/src/views/productManage/product/AddProductDialog.vue
+++ b/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
})
}
}
diff --git a/src/views/productManage/product/components/bomDialog.vue b/src/views/productManage/product/components/bomDialog.vue
index 3e75b28..343cdea 100644
--- a/src/views/productManage/product/components/bomDialog.vue
+++ b/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" ? "淇敼鎴愬姛锛�" : "娣诲姞鎴愬姛锛�",
--
Gitblit v1.8.0