药品出货单按钮被隐藏bug修复
This commit is contained in:
@@ -1353,27 +1353,37 @@ const handleSave = async () => {
|
||||
addOrEditOrder(editData).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$message.success('新增成功');
|
||||
// 调用父组件的 getList 方法
|
||||
emit('getList');
|
||||
// 调用父组件的 getList 方法,传递 true 清除临时订单
|
||||
emit('getList', true);
|
||||
// 清空表单
|
||||
resetAllData();
|
||||
// 关闭加载
|
||||
loading.value = false;
|
||||
} else {
|
||||
proxy.$message.error(res.msg || '新增失败');
|
||||
loading.value = false;
|
||||
}
|
||||
}).catch((error) => {
|
||||
proxy.$message.error(error.message || '新增失败,请检查网络或联系管理员');
|
||||
loading.value = false;
|
||||
});
|
||||
} else if (localIsAddOrEditOrder.value.isEditOrder) {
|
||||
addOrEditOrder(editData).then((res) => {
|
||||
if (res.code === 200) {
|
||||
proxy.$message.success('保存成功');
|
||||
// 调用父组件的 getList 方法
|
||||
emit('getList');
|
||||
// 调用父组件的 getList 方法,传递 true 清除临时订单
|
||||
emit('getList', true);
|
||||
// 清空表单
|
||||
resetAllData();
|
||||
} else {
|
||||
proxy.$message.error('保存失败');
|
||||
proxy.$message.error(res.msg || '保存失败');
|
||||
}
|
||||
// 关闭加载
|
||||
loading.value = false;
|
||||
}).catch((error) => {
|
||||
proxy.$message.error(error.message || '保存失败,请检查网络或联系管理员');
|
||||
// 关闭加载
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -113,6 +113,14 @@
|
||||
<el-row :gutter="10">
|
||||
<el-scrollbar height="calc(100vh - 350px)" style="width: 100%">
|
||||
<div class="order-list-container">
|
||||
<!-- 始终显示新增单据按钮 -->
|
||||
<div class="add-order-button-container">
|
||||
<el-button type="primary" @click="handleAdd" :disabled="isAddDisabled" style="width: 100%">
|
||||
<el-icon><Plus /></el-icon>
|
||||
新增单据
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 有数据时显示列表 -->
|
||||
<template v-if="orderList.length > 0">
|
||||
<div
|
||||
@@ -161,11 +169,9 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 空状态显示 -->
|
||||
<div v-else class="empty-state">
|
||||
<el-empty description="暂无单据" :image-size="80">
|
||||
<el-button type="primary" @click="handleAdd"> 新增单据 </el-button>
|
||||
</el-empty>
|
||||
<!-- 空状态显示(仅在没有数据且没有临时单据时显示) -->
|
||||
<div v-else-if="!currentTempOrder" class="empty-state">
|
||||
<el-empty description="暂无单据" :image-size="80" />
|
||||
</div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
@@ -205,7 +211,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, nextTick } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import orderTable from './components/orderTable.vue';
|
||||
import {
|
||||
@@ -275,6 +281,8 @@ const acceptanceResultoryOptions = ref([]);
|
||||
const pharmacyListOptions = ref([]);
|
||||
// 订货单单据列表 orderList
|
||||
const orderList = ref([]);
|
||||
// 存储当前的临时订单,用于确保它不会被覆盖
|
||||
const currentTempOrder = ref(null);
|
||||
// 订货单单据列表总条数
|
||||
const tableDataTotal = ref(0);
|
||||
// 选中的单据ID
|
||||
@@ -324,10 +332,29 @@ const init = async () => {
|
||||
};
|
||||
|
||||
// 获取订货单单据列表
|
||||
const getList = async () => {
|
||||
const getList = async (clearTempOrder = false) => {
|
||||
const res = await getOrderList(queryParams.value);
|
||||
// 订货单单据列表 orderList
|
||||
orderList.value = res.data.records;
|
||||
// 获取API返回的真实订单
|
||||
const realOrders = res.data.records || [];
|
||||
|
||||
// 如果指定清除临时订单(保存成功后),清除临时订单
|
||||
if (clearTempOrder) {
|
||||
currentTempOrder.value = null;
|
||||
orderList.value = realOrders;
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否有当前的临时订单
|
||||
if (currentTempOrder.value) {
|
||||
// 如果有临时订单,保留它并添加到真实订单之后(按钮下方)
|
||||
orderList.value = [...realOrders, currentTempOrder.value];
|
||||
|
||||
// 确保选中状态仍然是临时订单
|
||||
selectedOrder.value = currentTempOrder.value;
|
||||
} else {
|
||||
// 如果没有临时订单,直接使用真实订单
|
||||
orderList.value = realOrders;
|
||||
}
|
||||
};
|
||||
|
||||
// 新增按钮
|
||||
@@ -358,6 +385,26 @@ const handleAdd = async () => {
|
||||
isEditOrder: false,
|
||||
};
|
||||
|
||||
// 创建临时新增订单对象并添加到左侧列表
|
||||
const tempOrder = {
|
||||
supplyBusNo: '新增单据',
|
||||
applicantId: userInfo.practitionerId,
|
||||
applicantId_dictText: userInfo.nickName,
|
||||
statusEnum_enumText: '新增',
|
||||
typeEnum_enumText: '药品出库',
|
||||
applyTime: new Date().getTime(),
|
||||
// 添加一个临时标识,用于后续识别和处理
|
||||
isTempOrder: true
|
||||
};
|
||||
|
||||
// 存储临时订单到单独变量
|
||||
currentTempOrder.value = tempOrder;
|
||||
|
||||
// 将临时订单添加到订单列表末尾(按钮下方)
|
||||
orderList.value = [...orderList.value, tempOrder];
|
||||
// 设置为选中状态
|
||||
selectedOrder.value = tempOrder;
|
||||
|
||||
// 延迟执行
|
||||
nextTick(() => {
|
||||
// 更新按钮状态为编辑模式
|
||||
@@ -404,6 +451,32 @@ const handleEdit = async (order) => {
|
||||
proxy.$modal.msgError('请选择要编辑的单据');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否是临时新增的订单
|
||||
if (selectedOrder.value.isTempOrder) {
|
||||
// 对于临时订单,不需要调用API获取详情,直接保持编辑状态
|
||||
isAddOrEditOrder.value = {
|
||||
isAddOrder: true,
|
||||
isEditOrder: false,
|
||||
};
|
||||
|
||||
// 更新按钮状态为编辑模式
|
||||
handleUpdateButtonState({
|
||||
isAuditDisabled: true,
|
||||
isCancelDisabled: false,
|
||||
isDeleteDisabled: true,
|
||||
isAddDisabled: true,
|
||||
isEditDisabled: true,
|
||||
isAddShow: true,
|
||||
isDeleteShow: false,
|
||||
isSaveShow: false,
|
||||
isEditShow: false,
|
||||
isOrderImport: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 对于正常订单,调用API获取详情
|
||||
const res = await getOrderDetail({
|
||||
busNo: selectedOrder.value.supplyBusNo,
|
||||
pageNo: tableForm.value.pageNo,
|
||||
@@ -640,6 +713,13 @@ const buildEditForm = (data) => {
|
||||
};
|
||||
// 取消按钮
|
||||
const handleCancel = () => {
|
||||
// 移除临时新增的订单
|
||||
orderList.value = orderList.value.filter(order => !order.isTempOrder);
|
||||
// 清空当前临时订单
|
||||
currentTempOrder.value = null;
|
||||
// 重置选中状态
|
||||
selectedOrder.value = null;
|
||||
|
||||
// 更新按钮状态为初始状态
|
||||
handleUpdateButtonState({
|
||||
// 审核 按钮禁用
|
||||
@@ -895,6 +975,17 @@ init();
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
// 新增单据按钮容器
|
||||
.add-order-button-container {
|
||||
width: 100%;
|
||||
padding: 10px 0;
|
||||
margin-bottom: 10px;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
background: #fff;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
// 订单列表项样式
|
||||
.order-item {
|
||||
width: 100%;
|
||||
|
||||
Reference in New Issue
Block a user