|
@@ -63,6 +63,7 @@
|
|
type="primary"
|
|
type="primary"
|
|
@click="openProduct = true"
|
|
@click="openProduct = true"
|
|
style="margin: 10px 0"
|
|
style="margin: 10px 0"
|
|
|
|
+ v-if="ids.length == 0"
|
|
>
|
|
>
|
|
添加货品
|
|
添加货品
|
|
</el-button>
|
|
</el-button>
|
|
@@ -72,11 +73,20 @@
|
|
label="货品类型"
|
|
label="货品类型"
|
|
:formatter="(row) => (row.goodType == 1 ? '产品' : '物料')"
|
|
:formatter="(row) => (row.goodType == 1 ? '产品' : '物料')"
|
|
/>
|
|
/>
|
|
- <el-table-column prop="code" label="货品编码" />
|
|
|
|
- <el-table-column prop="name" label="货品名称" min-width="150" />
|
|
|
|
- <el-table-column prop="spec" label="规格型号" />
|
|
|
|
- <el-table-column prop="unit" label="单位" />
|
|
|
|
- <el-table-column prop="count" label="申购数量" />
|
|
|
|
|
|
+ <el-table-column prop="productCode" label="货品编码" />
|
|
|
|
+ <el-table-column prop="productName" label="货品名称" />
|
|
|
|
+ <el-table-column prop="productSpec" label="规格型号" />
|
|
|
|
+ <el-table-column prop="productUnit" label="单位" />
|
|
|
|
+ <el-table-column
|
|
|
|
+ prop="subscribeCount"
|
|
|
|
+ label="申购数量"
|
|
|
|
+ v-if="ids.length > 0"
|
|
|
|
+ />
|
|
|
|
+ <el-table-column
|
|
|
|
+ prop="purchaseCount"
|
|
|
|
+ label="已采购数量"
|
|
|
|
+ v-if="ids.length > 0"
|
|
|
|
+ />
|
|
<el-table-column prop="count" label="本次采购" min-width="150">
|
|
<el-table-column prop="count" label="本次采购" min-width="150">
|
|
<template #default="{ row, $index }">
|
|
<template #default="{ row, $index }">
|
|
<el-form-item
|
|
<el-form-item
|
|
@@ -88,28 +98,30 @@
|
|
v-model="row.count"
|
|
v-model="row.count"
|
|
:precision="4"
|
|
:precision="4"
|
|
:controls="false"
|
|
:controls="false"
|
|
- :min="1"
|
|
|
|
|
|
+ :min="0"
|
|
|
|
+ @change="handleChangeAmount"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column prop="count" label="单价" min-width="150">
|
|
|
|
|
|
+ <el-table-column prop="price" label="单价" min-width="150">
|
|
<template #default="{ row, $index }">
|
|
<template #default="{ row, $index }">
|
|
<el-form-item
|
|
<el-form-item
|
|
- :prop="'purchaseDetailList.' + $index + '.count'"
|
|
|
|
- :rules="rules.count"
|
|
|
|
|
|
+ :prop="'purchaseDetailList.' + $index + '.price'"
|
|
|
|
+ :rules="rules.price"
|
|
:inline-message="true"
|
|
:inline-message="true"
|
|
>
|
|
>
|
|
<el-input-number
|
|
<el-input-number
|
|
- v-model="row.count"
|
|
|
|
|
|
+ v-model="row.price"
|
|
:precision="4"
|
|
:precision="4"
|
|
:controls="false"
|
|
:controls="false"
|
|
:min="0"
|
|
:min="0"
|
|
|
|
+ @change="handleChangeAmount"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column prop="count" label="金额" />
|
|
|
|
|
|
+ <el-table-column prop="amount" label="金额" />
|
|
<el-table-column prop="zip" label="操作" width="100">
|
|
<el-table-column prop="zip" label="操作" width="100">
|
|
<template #default="{ $index }">
|
|
<template #default="{ $index }">
|
|
<el-button type="primary" link @click="handleRemove($index)"
|
|
<el-button type="primary" link @click="handleRemove($index)"
|
|
@@ -119,6 +131,17 @@
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="4">
|
|
|
|
+ <el-form-item label="采购金额" prop="amount">
|
|
|
|
+ <el-input
|
|
|
|
+ v-model="formData.data.amount"
|
|
|
|
+ placeholder="请输入"
|
|
|
|
+ disabled
|
|
|
|
+ />
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
</el-form>
|
|
</el-form>
|
|
</div>
|
|
</div>
|
|
<el-dialog v-model="openProduct" title="选择货品" width="70%" append-to-body>
|
|
<el-dialog v-model="openProduct" title="选择货品" width="70%" append-to-body>
|
|
@@ -152,6 +175,7 @@ let rules = ref({
|
|
],
|
|
],
|
|
supplyId: [{ required: true, message: "请选择供应商", trigger: "change" }],
|
|
supplyId: [{ required: true, message: "请选择供应商", trigger: "change" }],
|
|
count: [{ required: true, message: "请输入本次采购数量", trigger: "blur" }],
|
|
count: [{ required: true, message: "请输入本次采购数量", trigger: "blur" }],
|
|
|
|
+ price: [{ required: true, message: "请输入单价", trigger: "blur" }],
|
|
remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
|
|
remark: [{ required: true, message: "请输入备注", trigger: "blur" }],
|
|
});
|
|
});
|
|
|
|
|
|
@@ -167,10 +191,15 @@ const handleRemove = (index) => {
|
|
|
|
|
|
const pushGoods = (goods) => {
|
|
const pushGoods = (goods) => {
|
|
const arr = goods.map((x) => ({
|
|
const arr = goods.map((x) => ({
|
|
- ...x,
|
|
|
|
|
|
+ goodType: x.goodType,
|
|
|
|
+ productCode: x.code,
|
|
|
|
+ productName: x.name,
|
|
|
|
+ productSpec: x.spec,
|
|
|
|
+ productUnit: x.unit,
|
|
|
|
+ count: 0,
|
|
|
|
+ price: 0,
|
|
bussinessId: x.id,
|
|
bussinessId: x.id,
|
|
- count: "",
|
|
|
|
- remark: "",
|
|
|
|
|
|
+ amount: 0,
|
|
}));
|
|
}));
|
|
formData.data.purchaseDetailList =
|
|
formData.data.purchaseDetailList =
|
|
formData.data.purchaseDetailList.concat(arr);
|
|
formData.data.purchaseDetailList.concat(arr);
|
|
@@ -185,6 +214,36 @@ const handleSubmit = async () => {
|
|
const vaild = await formDom.value.validate();
|
|
const vaild = await formDom.value.validate();
|
|
if (vaild) {
|
|
if (vaild) {
|
|
if (formData.data.purchaseDetailList.length > 0) {
|
|
if (formData.data.purchaseDetailList.length > 0) {
|
|
|
|
+ const list = formData.data.purchaseDetailList;
|
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
|
+ const e = list[i];
|
|
|
|
+ if (ids.value.length > 0) {
|
|
|
|
+ if (Number(e.subscribeCount) - Number(e.purchaseCount) > 0) {
|
|
|
|
+ if (e.count == 0) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "本次采购数量不能为0!",
|
|
|
|
+ type: "info",
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (e.count + Number(e.purchaseCount) > Number(e.subscribeCount)) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "本次采购数量和已采购数量和不可大于申购数量!",
|
|
|
|
+ type: "info",
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (e.count == 0) {
|
|
|
|
+ ElMessage({
|
|
|
|
+ message: "本次采购数量不能为0!",
|
|
|
|
+ type: "info",
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
ElMessage({
|
|
ElMessage({
|
|
@@ -203,7 +262,29 @@ onMounted(() => {
|
|
formData.data.deptName = userInfo.dept.deptName;
|
|
formData.data.deptName = userInfo.dept.deptName;
|
|
formData.data.purchaseName = userInfo.nickName;
|
|
formData.data.purchaseName = userInfo.nickName;
|
|
getSupplierList();
|
|
getSupplierList();
|
|
|
|
+ if (props.queryData.ids) {
|
|
|
|
+ ids.value = props.queryData.ids.split(",") || [];
|
|
|
|
+ getDetails();
|
|
|
|
+ }
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+// 接收父组件的传值
|
|
|
|
+const props = defineProps({
|
|
|
|
+ queryData: String,
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+const ids = ref([]);
|
|
|
|
+const getDetails = () => {
|
|
|
|
+ proxy.post("/subscribeDetail/detail", { ids: ids.value }).then((res) => {
|
|
|
|
+ formData.data.purchaseDetailList = res.map((x) => ({
|
|
|
|
+ ...x,
|
|
|
|
+ subscribeCount: x.count,
|
|
|
|
+ count: 0,
|
|
|
|
+ price: null,
|
|
|
|
+ amount: null,
|
|
|
|
+ }));
|
|
|
|
+ });
|
|
|
|
+};
|
|
// 获取供应商数据
|
|
// 获取供应商数据
|
|
const supplierData = ref([]);
|
|
const supplierData = ref([]);
|
|
const getSupplierList = async (req) => {
|
|
const getSupplierList = async (req) => {
|
|
@@ -217,6 +298,16 @@ const getSupplierList = async (req) => {
|
|
const handleChangeSupplier = (val) => {
|
|
const handleChangeSupplier = (val) => {
|
|
console.log(val, "as");
|
|
console.log(val, "as");
|
|
};
|
|
};
|
|
|
|
+// 计算采购总金额
|
|
|
|
+const handleChangeAmount = () => {
|
|
|
|
+ let sum = 0;
|
|
|
|
+ for (let i = 0; i < formData.data.purchaseDetailList.length; i++) {
|
|
|
|
+ const e = formData.data.purchaseDetailList[i];
|
|
|
|
+ e.amount = e.count * e.price;
|
|
|
|
+ sum += e.amount;
|
|
|
|
+ }
|
|
|
|
+ formData.data.amount = sum;
|
|
|
|
+};
|
|
// 向父组件暴露
|
|
// 向父组件暴露
|
|
defineExpose({
|
|
defineExpose({
|
|
submitData: formData.data,
|
|
submitData: formData.data,
|