dev
This commit is contained in:
parent
330f626672
commit
1ea06612d1
|
|
@ -1,17 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<Mask :is-show="isShow" @close="close" title="添加组套" :show-footer="true">
|
<Mask :is-show="isShow" @close="close" title="添加组套" :show-footer="true" :width="1200" :height="800">
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<div class="form-info">
|
<div class="form-info">
|
||||||
<el-form :model="form" label-width="auto" ref="formRef" style="width: 100%;height: 100%">
|
<el-form :model="form" label-width="0" ref="formRef" style="width: 100%;height: 100%">
|
||||||
<el-descriptions
|
<el-descriptions
|
||||||
:column="2"
|
:column="2"
|
||||||
direction="vertical"
|
|
||||||
border
|
border
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-descriptions-item label="组套名称">
|
<el-descriptions-item label="组套名称">
|
||||||
<el-form-item prop="itemName">
|
<el-form-item prop="name">
|
||||||
<el-input v-model="form.itemName"/>
|
<el-input v-model="form.name"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="单位">
|
<el-descriptions-item label="单位">
|
||||||
|
|
@ -69,6 +68,12 @@
|
||||||
</el-input>
|
</el-input>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="数量" prop="number">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-input v-model="scope.row.number" type="number">
|
||||||
|
</el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="80">
|
<el-table-column label="操作" width="80">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span @click="removeTableRow(scope.row)" class="small-btn">删除</span>
|
<span @click="removeTableRow(scope.row)" class="small-btn">删除</span>
|
||||||
|
|
@ -97,22 +102,28 @@ import ItemSearch from "@/components/settings/item/ItemSearch.vue";
|
||||||
const createSearchRef = ref<any>('')
|
const createSearchRef = ref<any>('')
|
||||||
import {itemUnitList} from "@/utils/unitList.ts"
|
import {itemUnitList} from "@/utils/unitList.ts"
|
||||||
import UnitSelector from "@/components/inventory/UnitSelector.vue";
|
import UnitSelector from "@/components/inventory/UnitSelector.vue";
|
||||||
|
import {post} from "@/utils/request.ts";
|
||||||
|
|
||||||
const isShow = ref<any>(false)
|
const isShow = ref<any>(false)
|
||||||
const list = ref<any[]>([])
|
const list = ref<any[]>([])
|
||||||
const id = ref<any>('')
|
const id = ref<any>('')
|
||||||
const init = (row: any) => {
|
const init = (row: any) => {
|
||||||
isShow.value = true
|
isShow.value = true
|
||||||
form.value = default_form
|
form.value = {...default_form}
|
||||||
|
list.value = []
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
id.value = row.id
|
id.value = row.id
|
||||||
form.value.name = row.name
|
post("item/getGroup",{id: row.id}).then((res: any)=>{
|
||||||
|
form.value={...res.info}
|
||||||
|
console.log(form.value)
|
||||||
|
list.value = res.list
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const openSearchDialog = () => {
|
const openSearchDialog = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
createSearchRef.value?.init(form.value.itemName);
|
createSearchRef.value?.init("");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,6 +132,7 @@ const createConfirm = (data: any) => {
|
||||||
id: null,
|
id: null,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
unit: data.unit,
|
unit: data.unit,
|
||||||
|
number: "1",
|
||||||
socialCode: data.code,
|
socialCode: data.code,
|
||||||
purchaseUnitPrice: 0,
|
purchaseUnitPrice: 0,
|
||||||
unitPrice: 0,
|
unitPrice: 0,
|
||||||
|
|
@ -143,13 +155,19 @@ const default_form = {
|
||||||
}
|
}
|
||||||
const form = ref<any>(default_form)
|
const form = ref<any>(default_form)
|
||||||
const calculateTotalPrices = () => {
|
const calculateTotalPrices = () => {
|
||||||
const totalPurchasePrice = list.value.reduce((sum, item) => sum + parseFloat(item.purchaseUnitPrice || 0), 0);
|
const totalPurchasePrice = list.value.reduce((sum, item) =>
|
||||||
const totalPrice = list.value.reduce((sum, item) => sum + parseFloat(item.unitPrice || 0), 0);
|
sum + parseFloat(item.purchaseUnitPrice || 0) * parseFloat(item.number || 1), 0);
|
||||||
form.value.purchaseUnitPrice = totalPurchasePrice.toFixed(2); // 可以保留两位小数
|
const totalPrice = list.value.reduce((sum, item) =>
|
||||||
|
sum + parseFloat(item.unitPrice || 0) * parseFloat(item.number || 1), 0);
|
||||||
|
form.value.purchaseUnitPrice = totalPurchasePrice.toFixed(2); // 保留两位小数
|
||||||
form.value.unitPrice = totalPrice.toFixed(2);
|
form.value.unitPrice = totalPrice.toFixed(2);
|
||||||
};
|
};
|
||||||
const save = () => {
|
const save = () => {
|
||||||
|
post("item/saveGroup",{info: form.value,list:list.value}).then(
|
||||||
|
()=>{
|
||||||
close()
|
close()
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const removeTableRow = (row: any) => {
|
const removeTableRow = (row: any) => {
|
||||||
list.value = list.value.filter((item: any) => item.id !== row.id);
|
list.value = list.value.filter((item: any) => item.id !== row.id);
|
||||||
|
|
@ -164,6 +182,7 @@ const changePage= (value:any) => {
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => list.value.map(item => ({
|
() => list.value.map(item => ({
|
||||||
|
number: item.number,
|
||||||
purchaseUnitPrice: item.purchaseUnitPrice,
|
purchaseUnitPrice: item.purchaseUnitPrice,
|
||||||
unitPrice: item.unitPrice
|
unitPrice: item.unitPrice
|
||||||
})),
|
})),
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,24 @@
|
||||||
<span class="default-btn" @click="add">添加组套</span>
|
<span class="default-btn" @click="add">添加组套</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<el-table :data="tableList" @row-click="rowClick">
|
<el-table :data="tableList">
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="name"
|
prop="itemName"
|
||||||
label="组套名称">
|
label="组套名称">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="purchaseUnitPrice"
|
prop="purchaseUnitPrice"
|
||||||
label="总进货价">
|
label="原价">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
prop="unitPrice"
|
prop="unitPrice"
|
||||||
label="总售价">
|
label="售价">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button type="primary" link @click="editGroup(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="primary" link @click="deleteGroup(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -43,9 +49,24 @@ import {ref, nextTick} from "vue";
|
||||||
import {post} from '@/utils/request.ts'
|
import {post} from '@/utils/request.ts'
|
||||||
import Mask from "@/components/common/Mask.vue";
|
import Mask from "@/components/common/Mask.vue";
|
||||||
import GroupAdd from "@/components/settings/item/group/GroupAdd.vue";
|
import GroupAdd from "@/components/settings/item/group/GroupAdd.vue";
|
||||||
|
import {ElMessage, ElMessageBox} from "element-plus";
|
||||||
let current_page = ref(1)
|
let current_page = ref(1)
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const emit = defineEmits(["confirm"])
|
const emit = defineEmits(["confirm"])
|
||||||
|
const deleteGroup=(row: any)=>{
|
||||||
|
ElMessageBox.confirm('确定删除该组套?', '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
}).then(() => {
|
||||||
|
post("item/deleteGroup", {id: row.id}).then((res: any) => {
|
||||||
|
init();
|
||||||
|
})
|
||||||
|
}).catch((err) => {
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
const init = () => {
|
const init = () => {
|
||||||
|
|
||||||
post("item/groupList", {
|
post("item/groupList", {
|
||||||
|
|
@ -70,7 +91,7 @@ const tableList = ref<any>([
|
||||||
])
|
])
|
||||||
|
|
||||||
const addGroupRef = ref<any>(null);
|
const addGroupRef = ref<any>(null);
|
||||||
const rowClick = (row: any) => {
|
const editGroup = (row: any) => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
addGroupRef.value?.init(row);
|
addGroupRef.value?.init(row);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue