<template>
|
<div class="app-container">
|
<div class="search_form">
|
<div>
|
<span class="search_title ml10">产品名称:</span>
|
<el-input
|
v-model="searchForm.productName"
|
style="width: 240px"
|
placeholder="请输入产品名称"
|
clearable
|
@change="handleQuery"
|
/>
|
<span class="search_title ml10">图纸编号:</span>
|
<el-input
|
v-model="searchForm.model"
|
style="width: 240px"
|
placeholder="请输入图纸编号"
|
clearable
|
@change="handleQuery"
|
/>
|
<el-button type="primary" style="margin-left: 10px" @click="handleQuery">搜索</el-button>
|
<el-button @click="handleReset">重置</el-button>
|
</div>
|
</div>
|
|
<div class="table_list">
|
<el-table :data="tableData" border v-loading="tableLoading" style="width: 100%" height="calc(100vh - 18.5em)">
|
<el-table-column align="center" type="index" label="序号" width="60" />
|
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
|
<el-table-column prop="model" label="图纸编号" min-width="160" show-overflow-tooltip />
|
<el-table-column prop="waitAuditNum" label="待审核数量" min-width="120" align="center" />
|
<el-table-column prop="stockLocation" label="库位" min-width="180" show-overflow-tooltip />
|
<el-table-column prop="status" label="审核状态" min-width="120" align="center">
|
<template #default="scope">
|
<el-tag v-if="scope.row.status === 1 || scope.row.status === '1'" type="warning">待审核</el-tag>
|
<el-tag v-else-if="scope.row.status === 2 || scope.row.status === '2'" type="success">已入库</el-tag>
|
<el-tag v-else type="info">{{ scope.row.status }}</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" min-width="120" align="center" fixed="right">
|
<template #default="scope">
|
<el-button
|
link
|
type="primary"
|
size="small"
|
:disabled="!(scope.row.status === 1 || scope.row.status === '1')"
|
@click="openAuditDialog(scope.row)"
|
>
|
审核
|
</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<el-dialog v-model="auditDialogVisible" title="入库审核" width="620px" @close="closeAuditDialog">
|
<el-form :model="auditForm" label-width="120px" label-position="top" ref="auditFormRef">
|
<el-form-item
|
label="审核结果"
|
prop="result"
|
:rules="[{ required: true, message: '请选择审核结果', trigger: 'change' }]"
|
>
|
<el-radio-group v-model="auditForm.result">
|
<el-radio value="approved">通过</el-radio>
|
<el-radio value="rejected">不通过</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
|
<el-form-item
|
v-if="auditForm.result === 'rejected'"
|
label="实际入库数量"
|
prop="actualStockInNum"
|
:rules="[{ required: true, message: '请输入实际入库数量', trigger: 'blur' }]"
|
>
|
<el-input-number
|
v-model="auditForm.actualStockInNum"
|
:min="0"
|
:precision="0"
|
controls-position="right"
|
style="width: 100%;"
|
/>
|
</el-form-item>
|
|
<el-form-item
|
v-if="auditForm.result === 'approved' || auditForm.result === 'rejected'"
|
label="库位"
|
prop="stockLocation"
|
:rules="[{ required: true, message: '请输入库位', trigger: 'blur' }]"
|
>
|
<el-input v-model="auditForm.stockLocation" placeholder="请输入库位" clearable />
|
</el-form-item>
|
|
<el-form-item
|
v-if="auditForm.result === 'rejected'"
|
label="不通过原因"
|
prop="reason"
|
:rules="[{ required: true, message: '请输入不通过原因', trigger: 'blur' }]"
|
>
|
<el-input
|
v-model="auditForm.reason"
|
type="textarea"
|
:rows="3"
|
placeholder="请输入不通过原因"
|
clearable
|
/>
|
</el-form-item>
|
</el-form>
|
|
<template #footer>
|
<div class="dialog-footer">
|
<el-button type="primary" @click="submitAudit">确认</el-button>
|
<el-button @click="closeAuditDialog">取消</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup>
|
import { ref, reactive, toRefs, getCurrentInstance, nextTick, onMounted } from "vue";
|
import { getStockInRecordListPage, productionApprove } from "@/api/inventoryManagement/stockInRecord.js";
|
|
const { proxy } = getCurrentInstance();
|
|
const tableLoading = ref(false);
|
const tableData = ref([]);
|
|
const data = reactive({
|
searchForm: {
|
productName: "",
|
model: "",
|
},
|
});
|
const { searchForm } = toRefs(data);
|
|
const auditDialogVisible = ref(false);
|
const auditRow = ref(null);
|
const auditFormRef = ref(null);
|
const auditForm = reactive({
|
result: "",
|
stockLocation: "",
|
actualStockInNum: null,
|
reason: "",
|
});
|
|
const handleQuery = () => {
|
tableLoading.value = true;
|
const params = {
|
current: 1,
|
size: 10,
|
productType: 1,
|
status: 1,
|
productName: searchForm.value.productName,
|
model: searchForm.value.model,
|
};
|
|
getStockInRecordListPage(params)
|
.then((res) => {
|
tableData.value = res?.data?.records || res?.data || [];
|
})
|
.catch((err) => {
|
console.error("加载入库审核列表失败:", err);
|
tableData.value = [];
|
proxy.$modal.msgError("加载入库审核列表失败");
|
})
|
.finally(() => {
|
tableLoading.value = false;
|
});
|
};
|
|
const handleReset = () => {
|
searchForm.value.productName = "";
|
searchForm.value.model = "";
|
handleQuery();
|
};
|
|
const openAuditDialog = (row) => {
|
auditRow.value = row;
|
auditForm.result = "";
|
auditForm.stockLocation = row.stockLocation || "";
|
auditForm.actualStockInNum = row.waitAuditNum ?? null;
|
auditForm.reason = "";
|
auditDialogVisible.value = true;
|
nextTick(() => {
|
auditFormRef.value?.clearValidate?.();
|
});
|
};
|
|
const closeAuditDialog = () => {
|
auditDialogVisible.value = false;
|
auditRow.value = null;
|
auditForm.result = "";
|
auditForm.stockLocation = "";
|
auditForm.actualStockInNum = null;
|
auditForm.reason = "";
|
};
|
|
const submitAudit = () => {
|
auditFormRef.value?.validate((valid) => {
|
if (!valid || !auditRow.value) {
|
return;
|
}
|
|
if (auditForm.result === "rejected") {
|
if (auditForm.actualStockInNum === null || auditForm.actualStockInNum === "" || Number(auditForm.actualStockInNum) < 0) {
|
proxy.$modal.msgError("请输入实际入库数量");
|
return;
|
}
|
if (Number(auditForm.actualStockInNum) > Number(auditRow.value.waitAuditNum ?? 0)) {
|
proxy.$modal.msgError("实际入库数量不能大于待审核数量");
|
return;
|
}
|
if (!auditForm.reason || !String(auditForm.reason).trim()) {
|
proxy.$modal.msgError("请输入不通过原因");
|
return;
|
}
|
}
|
|
if (!auditForm.stockLocation || !String(auditForm.stockLocation).trim()) {
|
proxy.$modal.msgError("请输入库位");
|
return;
|
}
|
|
const payload = {
|
id: auditRow.value.id,
|
status: auditForm.result === "approved" ? 2 : 1,
|
actualStockInNum: auditForm.result === "approved"
|
? Number(auditRow.value.waitAuditNum)
|
: Number(auditForm.actualStockInNum),
|
stockLocation: String(auditForm.stockLocation || "").trim(),
|
reason: auditForm.result === "rejected" ? String(auditForm.reason).trim() : "",
|
recordId: auditForm.result === "rejected" ? (auditRow.value.recordId ?? auditRow.value.id) : undefined,
|
};
|
|
productionApprove(payload)
|
.then(() => {
|
auditRow.value.status = payload.status;
|
auditRow.value.stockLocation = payload.stockLocation;
|
if (auditForm.result === "rejected") {
|
auditRow.value.waitAuditNum = payload.actualStockInNum;
|
auditRow.value.reason = payload.reason;
|
}
|
proxy.$modal.msgSuccess("审核提交成功");
|
closeAuditDialog();
|
handleQuery();
|
})
|
.catch(() => {
|
proxy.$modal.msgError("审核提交失败");
|
});
|
});
|
};
|
|
onMounted(() => {
|
handleQuery();
|
});
|
</script>
|