|
@@ -14,18 +14,78 @@
|
|
|
</byTable>
|
|
|
</div>
|
|
|
|
|
|
- <el-dialog title="入库" v-if="dialogVisible" v-model="dialogVisible" width="400" v-loading="loadingDialog">
|
|
|
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
|
|
|
- <template #file>
|
|
|
- <div style="width: 100%">
|
|
|
- <el-upload v-model:fileList="formData.data.fileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com" multiple
|
|
|
- :on-preview="onPreviewFile">
|
|
|
- <!-- <el-button type="primary" plain disabled>选择</el-button> -->
|
|
|
+ <el-dialog title="入库" v-if="dialogVisible" v-model="dialogVisible" width="1300" v-loading="loadingDialog">
|
|
|
+ <div style="width:100%;display:flex">
|
|
|
+ <div style="flex:1;overflow:auto;height:calc(100vh - 270px)">
|
|
|
+ <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
|
|
|
+ <template #details>
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-button type="primary" @click="clickAdd()">添加明细</el-button>
|
|
|
+ <el-table :data="formData.data.stockWaitDetailsList" show-summary :summary-method="getSummaries" style=" margin-top: 16px">
|
|
|
+ <el-table-column type="index" width="60" align="center" />
|
|
|
+ <el-table-column label="是否扫码" width="80">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <div>
|
|
|
+ <span style="padding: 4px" :class="[row.isScan == 1 ? 'active' : 'disActive']">
|
|
|
+ {{
|
|
|
+ proxy.dictValueLabel(row.isScan, scanData)
|
|
|
+ }}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="productCode" label="产品编码" width="140" />
|
|
|
+ <el-table-column prop="productName" label="产品名称" min-width="160" />
|
|
|
+ <el-table-column prop="productSpec" label="规格型号" width="120" />
|
|
|
+ <el-table-column prop="productUnit" label="单位" width="80" :formatter="
|
|
|
+ (row) => dictValueLabel(row.productUnit, productUnit)
|
|
|
+ " />
|
|
|
+ <el-table-column label="入库数量" width="160" prop="quantity">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-form-item :prop="'stockWaitDetailsList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
|
|
|
+ <el-input-number v-model="row.quantity" placeholder="请输入出库数量" style="width: 100%" :precision="0" :controls="false" :min="1"
|
|
|
+ :disabled="row.isScan =='1'" onmousewheel="return false;" />
|
|
|
+ </el-form-item>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column align="center" label="操作" width="80" fixed="right">
|
|
|
+ <template #default="{ row, $index }">
|
|
|
+ <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template #file>
|
|
|
+ <div style="width: 100%">
|
|
|
+ <el-upload v-model:fileList="formData.data.fileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com" multiple
|
|
|
+ :on-preview="onPreviewFile">
|
|
|
+ <!-- <el-button type="primary" plain disabled>选择</el-button> -->
|
|
|
+
|
|
|
+ </el-upload>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </byForm>
|
|
|
+ </div>
|
|
|
+ <div style="width:300px;margin-left:20px">
|
|
|
+ <el-card class="box-card" style="height:100%;position: relative;">
|
|
|
+ <div class="box">
|
|
|
+ <img src="@/assets/images/scanz.png" class="img" v-if="!isScan" />
|
|
|
+ <img src="@/assets/images/scaning.gif" class="img" v-if="isScan" />
|
|
|
+ <div class="titlea" @click.stop="handleClickScan">
|
|
|
+ {{btnTitle}}
|
|
|
+ </div>
|
|
|
+ <el-input v-model="scanValue" type="password" :disabled="!isScan" ref="scanInput" style="ime-mode:active"
|
|
|
+ @change="handleScanValueChange" @blur="handleScanBlur" class="input" />
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
|
|
|
- </el-upload>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </byForm>
|
|
|
<template #footer>
|
|
|
<el-button @click="dialogVisible = false" size="large">取 消</el-button>
|
|
|
<el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
|
|
@@ -408,13 +468,18 @@ const formConfig = computed(() => {
|
|
|
required: true,
|
|
|
data: warehouseList.value,
|
|
|
},
|
|
|
+ // {
|
|
|
+ // type: "number",
|
|
|
+ // prop: "warehousingQuantity",
|
|
|
+ // label: "入库数量",
|
|
|
+ // precision: 0,
|
|
|
+ // min: 1,
|
|
|
+ // controls: false,
|
|
|
+ // },
|
|
|
{
|
|
|
- type: "number",
|
|
|
- prop: "warehousingQuantity",
|
|
|
- label: "入库数量",
|
|
|
- precision: 0,
|
|
|
- min: 1,
|
|
|
- controls: false,
|
|
|
+ type: "slot",
|
|
|
+ slotName: "details",
|
|
|
+ label: "入库明细",
|
|
|
},
|
|
|
{
|
|
|
type: "slot",
|
|
@@ -429,6 +494,7 @@ const rules = ref({
|
|
|
warehousingQuantity: [
|
|
|
{ required: true, message: "请输入入库数量", trigger: "blur" },
|
|
|
],
|
|
|
+ quantity: [{ required: true, message: "请输入入库数量", trigger: "blur" }],
|
|
|
});
|
|
|
const submitForm = () => {
|
|
|
submit.value.handleSubmit(() => {
|
|
@@ -439,21 +505,29 @@ const submitForm = () => {
|
|
|
// type: "info",
|
|
|
// });
|
|
|
// }
|
|
|
- let stockWaitDetailsList = [
|
|
|
- {
|
|
|
- id: formData.data.id,
|
|
|
- productId: formData.data.productId,
|
|
|
- quantity: formData.data.warehousingQuantity,
|
|
|
- isScan: "0",
|
|
|
- purchaseDetailId: "",
|
|
|
- },
|
|
|
- ];
|
|
|
+ if (!(formData.data.stockWaitDetailsList.length > 0)) {
|
|
|
+ return ElMessage({
|
|
|
+ message: "请添加入库明细",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const total = formData.data.stockWaitDetailsList.reduce(
|
|
|
+ (val, x) => (val += x.quantity),
|
|
|
+ 0
|
|
|
+ );
|
|
|
+ if (Number(total) > Number(formData.data.waitQuantity)) {
|
|
|
+ return ElMessage({
|
|
|
+ message: "入库数量不可大于待入库数量",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
proxy
|
|
|
.post("/stockWait/add", {
|
|
|
id: formData.data.stockWaitId,
|
|
|
warehouseId: formData.data.warehouseId,
|
|
|
quantity: formData.data.warehousingQuantity,
|
|
|
- stockWaitDetailsList,
|
|
|
+ stockWaitDetailsList: formData.data.stockWaitDetailsList,
|
|
|
})
|
|
|
.then(
|
|
|
() => {
|
|
@@ -472,9 +546,12 @@ const submitForm = () => {
|
|
|
});
|
|
|
};
|
|
|
const showType = ref(-1);
|
|
|
+const rowDataOne = ref({});
|
|
|
const clickOperation = (row) => {
|
|
|
+ rowDataOne.value = row;
|
|
|
showType.value = row.businessType;
|
|
|
formData.data = row;
|
|
|
+ formData.data.stockWaitDetailsList = [];
|
|
|
loadingDialog.value = false;
|
|
|
dialogVisible.value = true;
|
|
|
if (showType.value == 2) {
|
|
@@ -551,17 +628,193 @@ const handlePrintOne = (row) => {
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+
|
|
|
+const clickAdd = () => {
|
|
|
+ formData.data.stockWaitDetailsList.push({
|
|
|
+ id: formData.data.id,
|
|
|
+ isScan: "0",
|
|
|
+ productCode: formData.data.productCode,
|
|
|
+ productId: formData.data.productId,
|
|
|
+ productName: formData.data.productName,
|
|
|
+ productSpec: formData.data.productSpec,
|
|
|
+ productUnit: formData.data.productUnit,
|
|
|
+ quantity: undefined,
|
|
|
+ purchaseDetailId: "",
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const getSummaries = (param) => {
|
|
|
+ const { columns, data } = param; //columns是每列的信息,data是每行的信息
|
|
|
+ const sums = [];
|
|
|
+ columns.forEach((column, index) => {
|
|
|
+ if (index === 0) {
|
|
|
+ sums[index] = "合计"; //此处是在index=0的这一列显示为“合计”
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const values = data.map((item) => Number(item[column.property]));
|
|
|
+ if (column.property === "quantity") {
|
|
|
+ sums[index] = values.reduce((prev, curr) => {
|
|
|
+ const value = Number(curr);
|
|
|
+ if (!isNaN(value)) {
|
|
|
+ return Number(parseFloat(prev + curr).toFixed(4));
|
|
|
+ } else {
|
|
|
+ return prev;
|
|
|
+ }
|
|
|
+ }, 0);
|
|
|
+ sums[index];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return sums;
|
|
|
+};
|
|
|
+
|
|
|
+const scanData = ref([
|
|
|
+ {
|
|
|
+ label: "是",
|
|
|
+ value: "1",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "否",
|
|
|
+ value: "0",
|
|
|
+ },
|
|
|
+]);
|
|
|
+const scanValue = ref("");
|
|
|
+const isScan = ref(false);
|
|
|
+const btnTitle = ref("扫码入库");
|
|
|
+const scanInput = ref(null);
|
|
|
+const handleClickScan = () => {
|
|
|
+ isScan.value = !isScan.value;
|
|
|
+ btnTitle.value = isScan.value ? "扫码中···" : "扫码入库";
|
|
|
+ if (isScan.value) {
|
|
|
+ scanInput.value.focus();
|
|
|
+ }
|
|
|
+};
|
|
|
+const handleScanBlur = () => {
|
|
|
+ setTimeout(() => {
|
|
|
+ scanValue.value = "";
|
|
|
+ isScan.value = false;
|
|
|
+ btnTitle.value = "扫码入库";
|
|
|
+ }, 100);
|
|
|
+};
|
|
|
+
|
|
|
+const timer = ref(null);
|
|
|
+const handleScanValueChange = (val) => {
|
|
|
+ if (val) {
|
|
|
+ let value = val;
|
|
|
+ let arr = [];
|
|
|
+ if (value.includes("sn")) {
|
|
|
+ arr = value.split("=");
|
|
|
+ }
|
|
|
+ scanValue.value = "";
|
|
|
+ timer.value && clearTimeout(timer.value);
|
|
|
+ timer.value = setTimeout(() => {
|
|
|
+ if (arr.length > 1) {
|
|
|
+ return proxy
|
|
|
+ .post("/productionTaskDetail/snInfo", {
|
|
|
+ productSn: arr[arr.length - 1],
|
|
|
+ })
|
|
|
+ .then(
|
|
|
+ (res) => {
|
|
|
+ if (res.productId != rowDataOne.value.productId) {
|
|
|
+ ElMessage({
|
|
|
+ message: "请扫正确的产品",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formData.data.stockWaitDetailsList.push({
|
|
|
+ id: rowDataOne.value.id,
|
|
|
+ isScan: "1",
|
|
|
+ productCode: res.productCode,
|
|
|
+ productId: res.productId,
|
|
|
+ productName: res.productName,
|
|
|
+ productSpec: res.productSpec,
|
|
|
+ productUnit: res.productUnit,
|
|
|
+ quantity: 1,
|
|
|
+ purchaseDetailId: "",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {}
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ proxy.post("/purchaseDetail/detail", { id: value }).then(
|
|
|
+ (res) => {
|
|
|
+ if (res.bussinessId != rowDataOne.value.productId) {
|
|
|
+ ElMessage({
|
|
|
+ message: "请扫正确的产品",
|
|
|
+ type: "info",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formData.data.stockWaitDetailsList.push({
|
|
|
+ id: rowDataOne.value.id,
|
|
|
+ isScan: "1",
|
|
|
+ productCode: res.productCode,
|
|
|
+ productId: res.bussinessId,
|
|
|
+ productName: res.productName,
|
|
|
+ productSpec: res.productSpec,
|
|
|
+ productUnit: res.productUnit,
|
|
|
+ quantity: 1,
|
|
|
+ purchaseDetailId: val,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ (err) => {}
|
|
|
+ );
|
|
|
+ }, 301);
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const handleDelete = (index) => {
|
|
|
+ formData.data.stockWaitDetailsList.splice(index, 1);
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+.active {
|
|
|
+ background: #a6dd82;
|
|
|
+ color: #fff;
|
|
|
+ border-radius: 4px;
|
|
|
+}
|
|
|
+
|
|
|
.tenant {
|
|
|
padding: 20px;
|
|
|
}
|
|
|
::v-deep(.el-input-number .el-input__inner) {
|
|
|
text-align: left;
|
|
|
}
|
|
|
-.active {
|
|
|
- background: #a6dd82;
|
|
|
+
|
|
|
+.box {
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ transform: translate(0, -50%);
|
|
|
+ .img {
|
|
|
+ width: 260px;
|
|
|
+ height: 260px;
|
|
|
+ object-fit: contain;
|
|
|
+ vertical-align: middle;
|
|
|
+ // cursor: pointer;
|
|
|
+ z-index: 10;
|
|
|
+ }
|
|
|
+ .titlea {
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
+ font-size: 30px;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #5df5e9;
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ .input {
|
|
|
+ opacity: 0;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.disActive {
|
|
|
+ background: #fa9841;
|
|
|
color: #fff;
|
|
|
border-radius: 4px;
|
|
|
}
|