From ecd4e0f81c47fcb4ae41e7b4377f49b8a326c0d9 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期三, 27 九月 2023 17:33:27 +0800 Subject: [PATCH] 上架规则、库存调整模块接口联调 --- src/views/warehouseManage/listingRules/index.vue | 191 +++++++++++++++++++++++++++++++++++------------ 1 files changed, 143 insertions(+), 48 deletions(-) diff --git a/src/views/warehouseManage/listingRules/index.vue b/src/views/warehouseManage/listingRules/index.vue index ee066a3..b84d797 100644 --- a/src/views/warehouseManage/listingRules/index.vue +++ b/src/views/warehouseManage/listingRules/index.vue @@ -19,7 +19,18 @@ :product-table-list="tableList" @inputContent="inputContent" @tableRowClick="tableRowClick" + @selLocationClick="selLocationClick" + @selProductClick="selProductClick" > + <template slot="tableButton"> + <el-table-column label="鎿嶄綔" width="90" fixed="right" align="center"> + <template slot-scope="scope"> + <el-button v-if="scope.row.isEdit" @click.stop="delClick(scope)" type="text" size="small" + >鍒犻櫎</el-button + > + </template> + </el-table-column> + </template> </CommonFormTableView> </div> <div class="btn-pager"> @@ -32,7 +43,12 @@ <script> import CommonFormTableView from "@/components/makepager/CommonFormTableView" import pageMixin from "@/components/makepager/pager/mixin/pageMixin" -import { getLocationList } from "@/api/warehouseManage/warehouse" +import { + getListingRulesList, + addListingRules, + updateListingRules, + deleteListingRules +} from "@/api/warehouseManage/listingRules" export default { name: "listingRules", props: {}, @@ -69,7 +85,11 @@ searchOptions: [], countId: 0, isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨 - isRowClick: false + isRowClick: false, + areaId: 0, + productId: 0, + subLocationId: 0, + currentRowId: 0 } }, created() { @@ -79,16 +99,41 @@ methods: { setTable() { this.tableList = { - tableData: this.tableData, + tableData: [], selectBox: true, tableColumn: [ - { label: "褰撲骇鍝佸埌杈�", prop: "location", location: true }, + { label: "褰撲骇鍝佸埌杈�", prop: "areaName", location: true }, { label: "浜у搧", prop: "productName", product: true }, - // { label: "浜у搧绫诲埆", prop: "productCategory", productCategory: true }, - { label: "瀛樺偍鍒板瓙浣嶇疆", prop: "subLocation", location: true }, - { label: "鍏徃", prop: "companyName", company: true } + { label: "浜у搧绫诲埆", prop: "productCategory" }, + { label: "瀛樺偍鍒板瓙浣嶇疆", prop: "subLocation", location: true } + // { label: "鍏徃", prop: "companyName", company: true } ] } + }, + // 璇锋眰鏁版嵁 + async getData() { + await getListingRulesList({ + // keyword: this.keyword, + page: this.pagerOptions.currPage, + pageSize: this.pagerOptions.pageSize + }).then((res) => { + if (res.code === 200) { + const list = res.data.map((item) => { + return { + ...item, + areaName: item.area.jointName, + subLocation: item.location.jointName, + productName: item.product.name, + productCategory: item.productCategory.name, + isSet: false, + isEdit: true + } + }) + this.tableList.tableData = list || [] + this.tableData = list || [] + this.pagerOptions.totalCount = res.total + } + }) }, // 鎿嶄綔杈撳叆 inputContent(val, prop, row) { @@ -107,30 +152,60 @@ this.addTitle = "淇濆瓨" this.showDiscard = true this.isRowClick = false + this.currentRowId = 0 this.countId++ this.tableData.push({ countId: this.countId, + areaId: 0, + areaName: "", + locationId: 0, productId: "", - location: 0, subLocation: "", productName: "", companyName: "", isSet: true, isEdit: false }) - } else if (this.isNoProduct && this.addTitle === "淇濆瓨") { - this.addTitle = "鏂板缓" - this.showDiscard = false - this.tableData.map((item) => { - item.isEdit = true - console.log(item) - if (typeof item.location === "object") { - item.location = item.location.name - } - if (typeof item.subLocation === "object") { - item.location = item.subLocation.name - } - }) + this.areaId = 0 + this.subLocationId = 0 + this.productCategoryId = 0 + this.productId = 0 + } else { + if (this.areaId === 0) { + this.$message.error("璇烽�夋嫨褰撳墠浜у搧鍒拌揪浣嶇疆") + } else if (this.productId === 0) { + this.$message.error("璇烽�夋嫨浜у搧") + } else if (this.subLocationId === 0) { + this.$message.error("璇烽�夋嫨瀛樺偍鍒板瓙浣嶇疆") + } else { + this.addTitle = "鏂板缓" + this.showDiscard = false + this.tableData.map((item) => { + item.isEdit = true + console.log(item) + if (typeof item.location === "object") { + item.location = item.location.name + } + if (typeof item.subLocation === "object") { + item.location = item.subLocation.name + } + }) + let requestUrl = this.currentRowId === 0 ? addListingRules : updateListingRules + requestUrl({ + id: this.currentRowId, + areaId: this.areaId, + locationId: this.subLocationId, + productCategoryId: this.productCategoryId, + productId: this.productId + }).then((res) => { + console.log(res) + if (res.code === 200) { + let tipStr = this.currentRowId === 0 ? "娣诲姞鎴愬姛" : "淇敼鎴愬姛" + this.$message.success(tipStr) + this.getData() + } + }) + } } }, // 鏄惁閫夋嫨浜у搧 @@ -189,35 +264,30 @@ }, // 琛岀偣鍑� tableRowClick(row, rowIndex) { - console.log(row, rowIndex) - this.addTitle = "淇濆瓨" - this.showDiscard = true - this.isRowClick = true + console.log("11111") this.isSel() - if (!this.isNoProduct) { - this.tableData.splice(this.tableData.length - 1, 1) + if (!this.isNoProduct && this.currentRowId === 0) { + this.$message.error("璇峰畬鎴愬綋鍓嶆柊寤烘垨鍙栨秷鏂板缓") + } else { + this.currentRowId = row.id + this.addTitle = "淇濆瓨" + this.showDiscard = true + this.isRowClick = true + if (!this.isNoProduct) { + this.tableData.splice(this.tableData.length - 1, 1) + } + this.tableData.map((item, index) => { + if (index === rowIndex) { + item.isEdit = false + } else { + item.isEdit = true + } + }) + this.areaId = row.areaId + this.subLocationId = row.locationId + this.productCategoryId = row.productCategoryId + this.productId = row.productId } - this.tableData.map((item, index) => { - if (index === rowIndex) { - item.isEdit = false - } else { - item.isEdit = true - } - }) - }, - // 璇锋眰鏁版嵁 - async getData() { - await getLocationList({ - keyword: this.keyword, - page: this.pagerOptions.currPage, - pageSize: this.pagerOptions.pageSize - }).then((res) => { - if (res.code === 200) { - const list = res.data ? res.data : [] - this.tableList.tableInfomation = list - this.pagerOptions.totalCount = res.total - } - }) }, // 鎼滅储 getList(val) { @@ -241,6 +311,31 @@ } this.editConfig.visible = true this.editConfig.title = "鏂板缓" + }, + // 閫夋嫨浣嶇疆鏂规硶 + selLocationClick(item, prop) { + console.log(item, prop) + if (prop === "areaName") { + this.areaId = item.value + } else if (prop === "subLocation") { + this.subLocationId = item.value + } + }, + // 閫変腑浜у搧鏂规硶 + selProductClick(item) { + console.log(item) + this.productId = item.value + this.productCategoryId = item.categoryId + }, + // 鍒犻櫎 + async delClick(scope) { + console.log(scope) + await deleteListingRules(scope.row.id).then((res) => { + if (res.code === 200) { + this.$message.success("鍒犻櫎鎴愬姛") + this.getData() + } + }) } } } -- Gitblit v1.8.0