110 库房管理-》领用管理-》领用退库的升级(可参考开源代码移植)
This commit is contained in:
@@ -125,6 +125,23 @@
|
||||
/>
|
||||
</el-select>
|
||||
</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-select
|
||||
v-model="receiptHeaderForm.supplierId"
|
||||
@@ -148,21 +165,6 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="addNewRow">添加行</el-button>
|
||||
</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-button
|
||||
type="danger"
|
||||
@@ -174,10 +176,23 @@
|
||||
>
|
||||
</el-col>
|
||||
</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-table
|
||||
v-loading="loading"
|
||||
:data="form.purchaseinventoryList"
|
||||
:data="filteredPurchaseinventoryList"
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick"
|
||||
ref="tableRef"
|
||||
@@ -267,65 +282,6 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</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">
|
||||
<template #default="scope">
|
||||
<el-form-item
|
||||
@@ -609,6 +565,7 @@ const form = reactive({
|
||||
const receiptHeaderForm = reactive({
|
||||
busNo: undefined,
|
||||
occurrenceTime: formatDate(new Date()),
|
||||
warehouseId: undefined,
|
||||
});
|
||||
|
||||
const data = reactive({
|
||||
@@ -663,6 +620,7 @@ const emit = defineEmits(['refresh']);
|
||||
const tableRef = ref(undefined); // 表格引用
|
||||
const currentRow = ref(undefined); // 当前操作的行
|
||||
const medicineSearchKey = ref('');
|
||||
const detailSearchKey = ref('');
|
||||
const itemType = ref('');
|
||||
const rowList = ref([]);
|
||||
|
||||
@@ -694,9 +652,25 @@ watch(
|
||||
},
|
||||
{ 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(() => {
|
||||
document.addEventListener('click', handleClickOutside);
|
||||
getTransferProductTypeList();
|
||||
getPharmacyCabinetList().then((res) => {
|
||||
purposeTypeListOptions.value = res.data || [];
|
||||
});
|
||||
});
|
||||
|
||||
// 卸载时移除事件
|
||||
@@ -719,8 +693,7 @@ function addNewRow() {
|
||||
occurrenceTime: '',
|
||||
typeEnum_enumText: '',
|
||||
statusEnum_enumText: '',
|
||||
purposeLocationId: '', // 源仓库
|
||||
purposeLocationId: '', //目的仓库
|
||||
purposeLocationId: '',
|
||||
sourceLocationName: '',
|
||||
purposeLocationName: '',
|
||||
approverId_dictText: '',
|
||||
@@ -730,13 +703,6 @@ function addNewRow() {
|
||||
itemTable: '',
|
||||
itemQuantity: '',
|
||||
itemId: '',
|
||||
unitCode: '',
|
||||
remake: '',
|
||||
supplierId: '',
|
||||
purposeTypeEnum: '',
|
||||
purposeLocationId: '',
|
||||
purposeLocationStoreId: '',
|
||||
practitionerId: '',
|
||||
ybNo: '',
|
||||
invoiceNo: '',
|
||||
startTime: '',
|
||||
@@ -744,7 +710,6 @@ function addNewRow() {
|
||||
price: '',
|
||||
totalPrice: '',
|
||||
objQuantity: '',
|
||||
itemQuantity: '',
|
||||
// sellPrice: "",
|
||||
// minSellPrice: "",
|
||||
unitList: {}, // 单位列表
|
||||
@@ -775,49 +740,40 @@ function handleBlur(row, index) {
|
||||
}
|
||||
}
|
||||
|
||||
// 单据号
|
||||
row.busNo = receiptHeaderForm.busNo;
|
||||
// 申请时间
|
||||
row.occurrenceTime = receiptHeaderForm.occurrenceTime;
|
||||
|
||||
// 部门
|
||||
let sourceLocation = issueDepartmentDto.value.filter((e) => {
|
||||
return (
|
||||
e.locationId == receiptHeaderForm.sourceLocationId ||
|
||||
e.locationId == receiptHeaderForm.sourceLocationId1
|
||||
);
|
||||
});
|
||||
console.log(
|
||||
'sourceLocation',
|
||||
issueDepartmentDto,
|
||||
receiptHeaderForm.sourceLocationId,
|
||||
sourceLocation
|
||||
);
|
||||
// 部门
|
||||
row.sourceLocationId = sourceLocation[0].locationId;
|
||||
// 源仓库类型
|
||||
row.sourceTypeEnum = sourceLocation[0].typeEnum;
|
||||
if (receiptHeaderForm.sourceLocationId) {
|
||||
let sourceLocation = issueDepartmentDto.value.filter((e) => {
|
||||
return e.locationId == receiptHeaderForm.sourceLocationId;
|
||||
});
|
||||
if (sourceLocation && sourceLocation.length > 0) {
|
||||
row.purposeLocationId = sourceLocation[0].locationId;
|
||||
row.purposeTypeEnum = 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;
|
||||
|
||||
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;
|
||||
|
||||
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) {
|
||||
receiptHeaderForm.practitionerId = e.practitionerId;
|
||||
@@ -845,11 +805,12 @@ function getTransferProductDetails() {
|
||||
|
||||
if (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]
|
||||
.totalQuantity
|
||||
? form.purchaseinventoryList[index].totalQuantity
|
||||
@@ -1051,6 +1012,7 @@ function handleSearch(value) {
|
||||
medicineSearchKey.value = value;
|
||||
}
|
||||
|
||||
|
||||
// 选择药品
|
||||
function selectRow(rowValue, index) {
|
||||
rowIndex.value = index;
|
||||
@@ -1321,67 +1283,69 @@ function handleScan(row,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 = [];
|
||||
|
||||
form.purchaseinventoryList.map((row, index) => {
|
||||
form.purchaseinventoryList.forEach((row) => {
|
||||
if (row) {
|
||||
handleBlur(row);
|
||||
proxy.$refs['receiptHeaderRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
let rows = JSON.parse(JSON.stringify(row));
|
||||
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('row data:', row.name, row.unitCode, row.itemQuantity, row);
|
||||
if (row.name && row.unitCode && row.itemQuantity) {
|
||||
handleBlur(row);
|
||||
let rows = JSON.parse(JSON.stringify(row));
|
||||
delete rows.itemMaxQuantity;
|
||||
rowList.value.push(rows);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
console.log('rowList:', rowList.value);
|
||||
if (rowList.value.length > 0) {
|
||||
addTHTransferProducts(rowList.value);
|
||||
} else {
|
||||
proxy.$message.warning('请检查表格数据是否填写完整');
|
||||
}
|
||||
}
|
||||
function addTHTransferProducts(rowList) {
|
||||
addTHTransferProduct(JSON.parse(JSON.stringify(rowList))).then((res) => {
|
||||
// 当前行没有id视为首次新增
|
||||
// if (!row.id) {
|
||||
// data.isAdding = false; // 允许新增下一行
|
||||
// }
|
||||
if (res.data) {
|
||||
proxy.$message.success('保存成功!');
|
||||
form.purchaseinventoryList.map((row, index) => {
|
||||
form.purchaseinventoryList[index].id = res.data[index];
|
||||
form.purchaseinventoryList[index].isSave = true;
|
||||
});
|
||||
// form.purchaseinventoryList[index].id = res.data;
|
||||
// form.purchaseinventoryList[index].isSave = true;
|
||||
}
|
||||
});
|
||||
addTHTransferProduct(JSON.parse(JSON.stringify(rowList)))
|
||||
.then((res) => {
|
||||
console.log('保存响应:', res);
|
||||
if (res.code === 200 || res.data) {
|
||||
proxy.$message.success('保存成功!');
|
||||
form.purchaseinventoryList.forEach((row, index) => {
|
||||
if (res.data && res.data[index]) {
|
||||
form.purchaseinventoryList[index].id = res.data[index];
|
||||
form.purchaseinventoryList[index].isSave = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
proxy.$message.error(res.msg || '保存失败');
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('保存错误:', err);
|
||||
proxy.$message.error('保存失败,请重试');
|
||||
});
|
||||
}
|
||||
/** 选择条数 */
|
||||
function handleSelectionChange(selection) {
|
||||
@@ -1594,7 +1558,6 @@ function getTransferProductTypeList() {
|
||||
});
|
||||
}
|
||||
|
||||
const locationList = ref([]);
|
||||
function getBusNoInitList() {
|
||||
if (route.query.supplyBusNo) {
|
||||
receiptHeaderForm.busNo = route.query.supplyBusNo;
|
||||
|
||||
Reference in New Issue
Block a user