110 库房管理-》领用管理-》领用退库的升级(可参考开源代码移植)

This commit is contained in:
Ranyunqiao
2026-03-24 15:58:53 +08:00
parent b31cacd930
commit 22d73e5b44

View File

@@ -125,6 +125,23 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="仓库:" prop="warehouseId">
<el-select
v-model="receiptHeaderForm.warehouseId"
placeholder="请选择仓库"
clearable
filterable
style="width: 200px"
:disabled="viewStatus == 'view'"
>
<el-option
v-for="item in purposeTypeListOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<!-- <el-form-item label="供应商:" prop="supplierId"> <!-- <el-form-item label="供应商:" prop="supplierId">
<el-select <el-select
v-model="receiptHeaderForm.supplierId" v-model="receiptHeaderForm.supplierId"
@@ -148,21 +165,6 @@
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="addNewRow">添加行</el-button> <el-button type="primary" plain icon="Plus" @click="addNewRow">添加行</el-button>
</el-col> </el-col>
<!-- <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="confirmCurrentRow"
>确认当前行</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="cancelEditRow"
>取消行编辑</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="cancelEditAllRow"
>取消所有行编辑</el-button
>
</el-col> -->
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="danger" type="danger"
@@ -174,10 +176,23 @@
> >
</el-col> </el-col>
</el-row> </el-row>
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<div></div>
<el-input
v-model="detailSearchKey"
placeholder="请输入项目|厂家/产地|产品批号"
style="width: 280px;"
clearable
>
<template #prefix>
<el-icon><Search /></el-icon>
</template>
</el-input>
</div>
<el-form :model="form" :rules="tableRules" ref="formRef" :disabled="viewStatus == 'apply'"> <el-form :model="form" :rules="tableRules" ref="formRef" :disabled="viewStatus == 'apply'">
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="form.purchaseinventoryList" :data="filteredPurchaseinventoryList"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@row-click="handleRowClick" @row-click="handleRowClick"
ref="tableRef" ref="tableRef"
@@ -267,65 +282,6 @@
</el-form-item> </el-form-item>
</template> </template>
</el-table-column> --> </el-table-column> -->
<el-table-column
label="仓库"
align="center"
key="purposeLocationId"
prop="purposeLocationId"
:show-overflow-tooltip="true"
width="180"
>
<template #default="scope">
<el-form-item
:prop="`purchaseinventoryList.${scope.$index}.purposeLocationId`"
:rules="tableRules.purposeLocationId"
required
>
<div class="select_wrapper_div">
<el-select
v-model="scope.row.purposeLocationId"
placeholder="请选择仓库"
:class="{ 'error-border': scope.row.error }"
clearable
:disabled="viewStatus == 'view'"
>
<el-option
v-for="(item, index) in purposeTypeListOptions"
:key="index"
:label="item.name"
:value="item.id"
@click="handleLocationClick(item, scope.row, scope.$index)"
/>
</el-select>
</div>
</el-form-item>
</template>
</el-table-column>
<el-table-column
label="货位"
align="center"
key="locationStoreName"
prop="locationStoreName"
width="180"
>
<template #default="scope">
<el-form-item
:prop="`purchaseinventoryList.${scope.$index}.locationStoreName`"
:rules="tableRules.locationStoreName"
>
<div class="select_wrapper_div">
<el-select
v-model="scope.row.locationStoreName"
placeholder="请选择货位"
:disabled="viewStatus == 'view'"
:class="{ 'error-border': scope.row.error }"
clearable
>
</el-select>
</div>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="单价 " align="center" key="price" prop="price" width="130"> <el-table-column label="单价 " align="center" key="price" prop="price" width="130">
<template #default="scope"> <template #default="scope">
<el-form-item <el-form-item
@@ -609,6 +565,7 @@ const form = reactive({
const receiptHeaderForm = reactive({ const receiptHeaderForm = reactive({
busNo: undefined, busNo: undefined,
occurrenceTime: formatDate(new Date()), occurrenceTime: formatDate(new Date()),
warehouseId: undefined,
}); });
const data = reactive({ const data = reactive({
@@ -663,6 +620,7 @@ const emit = defineEmits(['refresh']);
const tableRef = ref(undefined); // 表格引用 const tableRef = ref(undefined); // 表格引用
const currentRow = ref(undefined); // 当前操作的行 const currentRow = ref(undefined); // 当前操作的行
const medicineSearchKey = ref(''); const medicineSearchKey = ref('');
const detailSearchKey = ref('');
const itemType = ref(''); const itemType = ref('');
const rowList = ref([]); const rowList = ref([]);
@@ -694,9 +652,25 @@ watch(
}, },
{ immediate: true } { immediate: true }
); );
const filteredPurchaseinventoryList = computed(() => {
if (!detailSearchKey.value) {
return form.purchaseinventoryList;
}
const searchKey = detailSearchKey.value.toLowerCase();
return form.purchaseinventoryList.filter((item) => {
const nameMatch = item.name ? item.name.toLowerCase().includes(searchKey) : false;
const manufacturerMatch = item.manufacturerText ? item.manufacturerText.toLowerCase().includes(searchKey) : false;
const lotNumberMatch = item.lotNumber ? item.lotNumber.toLowerCase().includes(searchKey) : false;
return nameMatch || manufacturerMatch || lotNumberMatch;
});
});
// 挂载时绑定事件 // 挂载时绑定事件
onMounted(() => { onMounted(() => {
document.addEventListener('click', handleClickOutside); document.addEventListener('click', handleClickOutside);
getTransferProductTypeList();
getPharmacyCabinetList().then((res) => {
purposeTypeListOptions.value = res.data || [];
});
}); });
// 卸载时移除事件 // 卸载时移除事件
@@ -719,8 +693,7 @@ function addNewRow() {
occurrenceTime: '', occurrenceTime: '',
typeEnum_enumText: '', typeEnum_enumText: '',
statusEnum_enumText: '', statusEnum_enumText: '',
purposeLocationId: '', // 源仓库 purposeLocationId: '',
purposeLocationId: '', //目的仓库
sourceLocationName: '', sourceLocationName: '',
purposeLocationName: '', purposeLocationName: '',
approverId_dictText: '', approverId_dictText: '',
@@ -730,13 +703,6 @@ function addNewRow() {
itemTable: '', itemTable: '',
itemQuantity: '', itemQuantity: '',
itemId: '', itemId: '',
unitCode: '',
remake: '',
supplierId: '',
purposeTypeEnum: '',
purposeLocationId: '',
purposeLocationStoreId: '',
practitionerId: '',
ybNo: '', ybNo: '',
invoiceNo: '', invoiceNo: '',
startTime: '', startTime: '',
@@ -744,7 +710,6 @@ function addNewRow() {
price: '', price: '',
totalPrice: '', totalPrice: '',
objQuantity: '', objQuantity: '',
itemQuantity: '',
// sellPrice: "", // sellPrice: "",
// minSellPrice: "", // minSellPrice: "",
unitList: {}, // 单位列表 unitList: {}, // 单位列表
@@ -775,49 +740,40 @@ function handleBlur(row, index) {
} }
} }
// 单据号
row.busNo = receiptHeaderForm.busNo; row.busNo = receiptHeaderForm.busNo;
// 申请时间
row.occurrenceTime = receiptHeaderForm.occurrenceTime; row.occurrenceTime = receiptHeaderForm.occurrenceTime;
// 部门 if (receiptHeaderForm.sourceLocationId) {
let sourceLocation = issueDepartmentDto.value.filter((e) => { let sourceLocation = issueDepartmentDto.value.filter((e) => {
return ( return e.locationId == receiptHeaderForm.sourceLocationId;
e.locationId == receiptHeaderForm.sourceLocationId || });
e.locationId == receiptHeaderForm.sourceLocationId1 if (sourceLocation && sourceLocation.length > 0) {
); row.purposeLocationId = sourceLocation[0].locationId;
}); row.purposeTypeEnum = sourceLocation[0].typeEnum;
console.log( }
'sourceLocation', }
issueDepartmentDto,
receiptHeaderForm.sourceLocationId,
sourceLocation
);
// 部门
row.sourceLocationId = sourceLocation[0].locationId;
// 源仓库类型
row.sourceTypeEnum = sourceLocation[0].typeEnum;
// 目的仓库 if (receiptHeaderForm.practitionerId) {
let practitioner = practitionerListOptions.value.filter((e) => {
return e.value == receiptHeaderForm.practitionerId;
});
if (practitioner && practitioner.length > 0) {
row.practitionerId = practitioner[0].value;
row.practitionerName = practitioner[0].label;
}
}
let purposeLocation = purposeTypeListOptions.value.filter((e) => {
return e.id == row.purposeLocationId;
});
console.log(purposeTypeListOptions.value, row.purposeLocationId, 1212121, purposeLocation);
// 目的仓库id
row.purposeLocationId = purposeLocation[0].id;
// 目的仓库类型
row.purposeTypeEnum = purposeLocation[0].formEnum;
// 部门经手人
let practitioner = practitionerListOptions.value.filter((e) => {
return e.value == receiptHeaderForm.practitionerId;
});
console.log('practitioner', practitioner);
row.practitionerId = practitioner[0].value;
row.practitionerName = practitioner[0].label;
// 申请人
row.applicantId = userStore.id; row.applicantId = userStore.id;
if (receiptHeaderForm.warehouseId) {
let warehouse = purposeTypeListOptions.value.filter((e) => {
return e.id == receiptHeaderForm.warehouseId;
});
if (warehouse && warehouse.length > 0) {
row.sourceLocationId = warehouse[0].id;
row.sourceTypeEnum = warehouse[0].formEnum;
}
}
} }
/** /**
@@ -836,8 +792,12 @@ function getTransferProductDetails() {
e.name = e.itemName; e.name = e.itemName;
if (e.sourceLocationId) { if (e.sourceLocationId) {
receiptHeaderForm.sourceLocationId = e.sourceLocationId; // 退库仓库
receiptHeaderForm.sourceLocationName = e.sourceLocationName; receiptHeaderForm.warehouseId = e.sourceLocationId;
}
if (e.purposeLocationId) {
// 退库部门
receiptHeaderForm.sourceLocationId = e.purposeLocationId;
} }
if (e.practitionerId) { if (e.practitionerId) {
receiptHeaderForm.practitionerId = e.practitionerId; receiptHeaderForm.practitionerId = e.practitionerId;
@@ -845,11 +805,12 @@ function getTransferProductDetails() {
if (e.itemType) { if (e.itemType) {
receiptHeaderForm.medicationType = e.itemType; receiptHeaderForm.medicationType = e.itemType;
// let medicationType1 = purchase_type.value.filter(k=>{
// return k.label == e.itemType
// })
} }
getPharmacyCabinetList().then((res) => {
purposeTypeListOptions.value = res.data;
});
form.purchaseinventoryList[index].totalQuantity = form.purchaseinventoryList[index] form.purchaseinventoryList[index].totalQuantity = form.purchaseinventoryList[index]
.totalQuantity .totalQuantity
? form.purchaseinventoryList[index].totalQuantity ? form.purchaseinventoryList[index].totalQuantity
@@ -1051,6 +1012,7 @@ function handleSearch(value) {
medicineSearchKey.value = value; medicineSearchKey.value = value;
} }
// 选择药品 // 选择药品
function selectRow(rowValue, index) { function selectRow(rowValue, index) {
rowIndex.value = index; rowIndex.value = index;
@@ -1321,67 +1283,69 @@ function handleScan(row,index){
currentIndex.value = index currentIndex.value = index
} }
function handleSave(row, index) { function handleSave() {
if (!receiptHeaderForm.sourceLocationId) {
proxy.$message.warning('请选择部门');
return;
}
if (!receiptHeaderForm.practitionerId) {
proxy.$message.warning('请选择部门经手人');
return;
}
if (!receiptHeaderForm.medicationType) {
proxy.$message.warning('请选择药品类型');
return;
}
if (!receiptHeaderForm.warehouseId) {
proxy.$message.warning('请选择仓库');
return;
}
if (!form.purchaseinventoryList || form.purchaseinventoryList.length === 0) {
proxy.$message.warning('请添加明细数据');
return;
}
rowList.value = []; rowList.value = [];
form.purchaseinventoryList.map((row, index) => { form.purchaseinventoryList.forEach((row) => {
if (row) { if (row) {
handleBlur(row); console.log('row data:', row.name, row.unitCode, row.itemQuantity, row);
proxy.$refs['receiptHeaderRef'].validate((valid) => { if (row.name && row.unitCode && row.itemQuantity) {
if (valid) { handleBlur(row);
proxy.$refs['formRef'].validate((valid) => { let rows = JSON.parse(JSON.stringify(row));
if (valid) { delete rows.itemMaxQuantity;
let rows = JSON.parse(JSON.stringify(row)); rowList.value.push(rows);
delete rows.itemMaxQuantity; }
if (rows.unitCode == rows.unitList.minUnitCode) {
rows.itemQuantity = form.purchaseinventoryList[index].olditemQuantity
? form.purchaseinventoryList[index].olditemQuantity
: form.purchaseinventoryList[index].itemQuantity;
} else {
rows.itemQuantity = form.purchaseinventoryList[index].itemMaxQuantity
? form.purchaseinventoryList[index].itemMaxQuantity
: form.purchaseinventoryList[index].itemQuantity;
}
if (rows.unitCode == rows.unitCode_dictText) {
if (rows.unitCode_dictText == rows.unitList.minUnitCode_dictText) {
rows.unitCode = rows.unitList.minUnitCode;
console.log(rows.unitCode_dictText, 2323232);
} else {
rows.unitCode = rows.unitList.unitCode;
rows.unitCode_dictText = rows.unitList.unitCode_dictText;
console.log(rows.unitCode_dictText, 23232326565);
}
}
rowList.value.push(JSON.parse(JSON.stringify(rows)));
if (
rowList._rawValue &&
rowList._rawValue.length == form.purchaseinventoryList.length
) {
addTHTransferProducts(rowList._rawValue);
}
}
});
}
});
} }
}); });
console.log('rowList:', rowList.value);
if (rowList.value.length > 0) {
addTHTransferProducts(rowList.value);
} else {
proxy.$message.warning('请检查表格数据是否填写完整');
}
} }
function addTHTransferProducts(rowList) { function addTHTransferProducts(rowList) {
addTHTransferProduct(JSON.parse(JSON.stringify(rowList))).then((res) => { addTHTransferProduct(JSON.parse(JSON.stringify(rowList)))
// 当前行没有id视为首次新增 .then((res) => {
// if (!row.id) { console.log('保存响应:', res);
// data.isAdding = false; // 允许新增下一行 if (res.code === 200 || res.data) {
// } proxy.$message.success('保存成功!');
if (res.data) { form.purchaseinventoryList.forEach((row, index) => {
proxy.$message.success('保存成功!'); if (res.data && res.data[index]) {
form.purchaseinventoryList.map((row, index) => { form.purchaseinventoryList[index].id = res.data[index];
form.purchaseinventoryList[index].id = res.data[index]; form.purchaseinventoryList[index].isSave = true;
form.purchaseinventoryList[index].isSave = true; }
}); });
// form.purchaseinventoryList[index].id = res.data; } else {
// form.purchaseinventoryList[index].isSave = true; proxy.$message.error(res.msg || '保存失败');
} }
}); })
.catch((err) => {
console.error('保存错误:', err);
proxy.$message.error('保存失败,请重试');
});
} }
/** 选择条数 */ /** 选择条数 */
function handleSelectionChange(selection) { function handleSelectionChange(selection) {
@@ -1594,7 +1558,6 @@ function getTransferProductTypeList() {
}); });
} }
const locationList = ref([]);
function getBusNoInitList() { function getBusNoInitList() {
if (route.query.supplyBusNo) { if (route.query.supplyBusNo) {
receiptHeaderForm.busNo = route.query.supplyBusNo; receiptHeaderForm.busNo = route.query.supplyBusNo;