From 8324cf9233ff1b7642ea862f88fd7d62134655db Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Wed, 18 Sep 2024 20:00:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/company/index.js | 8 + src/api/repair/stockTransfer/stockTransfer.js | 11 ++ .../stockTransfer/Components/StInfo.vue | 143 +++++++++++--- .../stockTransfer/Components/StTable.vue | 183 ++++++++++++++++-- 4 files changed, 305 insertions(+), 40 deletions(-) diff --git a/src/api/base/company/index.js b/src/api/base/company/index.js index 538be6a..886eac5 100644 --- a/src/api/base/company/index.js +++ b/src/api/base/company/index.js @@ -102,3 +102,11 @@ export function getCompanyList(){ method: 'get' }) } + +// 当前登录用户的门店信息 +export function getNowCompany(){ + return request({ + url: "/base/company/now", + method: "get" + }) +} diff --git a/src/api/repair/stockTransfer/stockTransfer.js b/src/api/repair/stockTransfer/stockTransfer.js index 543ea86..1ae0e55 100644 --- a/src/api/repair/stockTransfer/stockTransfer.js +++ b/src/api/repair/stockTransfer/stockTransfer.js @@ -1 +1,12 @@ import request from '@/utils/request' + +const preUrl = '/repair/st' + +// 新增 +export function createSt(data){ + return request({ + url: preUrl + "/create", + method: "post", + data + }) +} diff --git a/src/views/repair/stockTransfer/Components/StInfo.vue b/src/views/repair/stockTransfer/Components/StInfo.vue index 98c147a..298e0cb 100644 --- a/src/views/repair/stockTransfer/Components/StInfo.vue +++ b/src/views/repair/stockTransfer/Components/StInfo.vue @@ -3,15 +3,15 @@ - - + + - - + + - + @@ -19,43 +19,43 @@ - - + + - + - + - - + + - - + + - - + + - - + + - - + + - 结算 + 结算 @@ -68,6 +68,8 @@ import StaffChoose from "@/views/repair/Components/StaffChoose.vue"; import PartChoose from "@/views/repair/Components/PartChoose.vue"; import StTable from "@/views/repair/stockTransfer/Components/StTable.vue"; import {createUniqueCodeByHead} from "@/utils/createUniqueCode"; +import {getNowCompany} from "@/api/base/company"; +import {createSt} from "@/api/repair/stockTransfer/stockTransfer"; export default { name: "StInfo", @@ -81,20 +83,35 @@ export default { return { formData: { stNo: null, + newCorp: null, + oldCorp: null, + stTime: Date.now(), + user: null, + goodsList: [], + totalPrice: 0, + discountPrice: 0, + thisCollection: 0, + thisDebt: 0, + remark: null, + itemCount: 0, + stStatus: "01" }, partList: [] } }, mounted() { - this.formData.stNo = createUniqueCodeByHead("DB") + this.init() }, methods: { - // 选择员工 - getStaff(data) { - + // TODO 同调用 init方法,初始化当前门店 + async companyInit() { + try { + const res = await getNowCompany() + } catch { + } }, // 选择商品 - async getPart(data){ + async getPart(data) { const flag = this.partList.find(item => item.id === data.id) if (flag) { try { @@ -107,8 +124,80 @@ export default { } }, // 删除商品 - deleteItem(index){ + deleteItem(index) { this.partList.splice(index, 1) + }, + // 表格的数据 + tableData(data) { + const tempPrice = data.reduce((x, y) => { + return x + y.totalPrice + }, 0) + const itemCount = data.reduce((x, y) => { + return x + y.goodsCount + }, 0) + this.formData.totalPrice = tempPrice + this.formData.thisDebt = tempPrice + this.formData.itemCount = itemCount + this.formData.goodsList = data.map(item => { + return { + ...item, + goodsId: item.id, + goodsCount: item.goodsCount, + goodsPrice: item.goodsPrice, + remark: item.remark + } + }) + }, + // 优惠变化计算 + handleDiscountPriceChange() { + this.formData.thisDebt -= this.formData.discountPrice + }, + // 付款变化计算 + handleThisCollection() { + this.formData.thisDebt -= this.formData.thisCollection + }, + // 提交 + async handleSubmit() { + try { + this.createInit() + await createSt(this.formData) + this.$modal.msgSuccess("新增成功") + this.init() + } catch { + } + }, + // 提交前的处理 + createInit() { + const data = this.formData + this.formData = { + ...data, + outCorpId: data.oldCorp.id, + inCorpId: data.newCorp.id, + userId: data.user.id, + userName: data.user.name, + } + }, + // 组件初始化 + init(){ + // TODO 数据库有问题,先抛异常,后面在解决 + // this.companyInit() + this.formData = { + stNo: null, + newCorp: null, + oldCorp: null, + stTime: Date.now(), + user: null, + goodsList: [], + totalPrice: 0, + discountPrice: 0, + thisCollection: 0, + thisDebt: 0, + remark: null, + itemCount: 0, + stStatus: "01" + } + this.formData.stNo = createUniqueCodeByHead("DB") + this.partList = [] } } } diff --git a/src/views/repair/stockTransfer/Components/StTable.vue b/src/views/repair/stockTransfer/Components/StTable.vue index 8bdd154..680826e 100644 --- a/src/views/repair/stockTransfer/Components/StTable.vue +++ b/src/views/repair/stockTransfer/Components/StTable.vue @@ -1,20 +1,42 @@