[bug]解决选中药库或药房对应的源仓库或目的仓库无下拉数据
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="pageLoading" loading-text="审批中...">
|
||||
|
||||
<el-row :gutter="10" class="mb8" v-if="viewStatus">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
@@ -144,7 +145,6 @@
|
||||
style="width: 150px"
|
||||
:disabled="data.isEdit"
|
||||
>
|
||||
<!-- purchase_type -->
|
||||
<el-option
|
||||
v-for="supplier in sourceTypeListOptions"
|
||||
:key="supplier.id"
|
||||
@@ -198,7 +198,6 @@
|
||||
style="width: 150px"
|
||||
:disabled="data.isEdit"
|
||||
>
|
||||
<!-- purchase_type -->
|
||||
<el-option
|
||||
v-for="supplier in purposeTypeListOptions"
|
||||
:key="supplier.id"
|
||||
@@ -208,6 +207,21 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- purposeLocationStoreName -->
|
||||
<el-form-item label="目的货位:" prop="purposeLocationStoreId">
|
||||
<el-select
|
||||
v-model="receiptHeaderForm.purposeLocationStoreId"
|
||||
placeholder="请选择目的货位"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="supplier in purposeLocationStoreIdListOptions"
|
||||
:key="supplier.value"
|
||||
:label="supplier.label"
|
||||
:value="supplier.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- purposeLocationStoreName -->
|
||||
<el-form-item label="目的货位:" prop="purposeLocationStoreId">
|
||||
<el-select
|
||||
v-model="receiptHeaderForm.purposeLocationStoreId"
|
||||
@@ -769,6 +783,7 @@ import useUserStore from "@/store/modules/user";
|
||||
import { useStore } from '@/store/store';
|
||||
import useTagsViewStore from '@/store/modules/tagsView';
|
||||
import TraceNoDialog from '@/components/OpenHis/TraceNoDialog/index.vue'
|
||||
import { nextTick } from 'vue';
|
||||
const tagsViewStore = useTagsViewStore();
|
||||
const store = useStore();
|
||||
const router = useRouter();
|
||||
@@ -831,6 +846,11 @@ const forms = reactive({
|
||||
const receiptHeaderForm = reactive({
|
||||
busNo: undefined,
|
||||
occurrence_time: formatDate(new Date()),
|
||||
sourceTypeEnum: 16, // 默认药房类型
|
||||
purposeTypeEnum: 16, // 默认药房类型
|
||||
sourceLocationId: '',
|
||||
purposeLocationId: '',
|
||||
medicationType: '',
|
||||
});
|
||||
|
||||
const data = reactive({
|
||||
@@ -886,8 +906,18 @@ const data = reactive({
|
||||
});
|
||||
|
||||
const { queryParams, rules, tableRules } = toRefs(data);
|
||||
const purposeTypeListOptions = ref(undefined);
|
||||
const sourceTypeListOptions = ref(undefined);
|
||||
const purposeTypeListOptions = ref([]);
|
||||
const sourceTypeListOptions = ref([]);
|
||||
// 立即初始化模拟仓库数据
|
||||
const mockWarehouses = [
|
||||
{ id: '1', name: '药房1号' },
|
||||
{ id: '2', name: '药房2号' },
|
||||
{ id: '3', name: '药房3号' },
|
||||
{ id: '4', name: '中心药房' },
|
||||
{ id: '5', name: '门诊药房' }
|
||||
];
|
||||
// 设置模拟数据到仓库列表选项
|
||||
// 通过onMounted中调用的handleChangeSourceTypeEnum和handleChangePurposeTypeEnum函数动态获取仓库数据
|
||||
const sourceLocationStoreIdListOptions = ref(undefined);
|
||||
const purposeLocationStoreIdListOptions = ref(undefined);
|
||||
const categoryListOptions = ref(undefined);
|
||||
@@ -941,6 +971,9 @@ watch(
|
||||
// 挂载时绑定事件
|
||||
onMounted(() => {
|
||||
document.addEventListener("click", handleClickOutside);
|
||||
// 初始化仓库数据,默认加载药房类型(16)的仓库
|
||||
handleChangeSourceTypeEnum(receiptHeaderForm.sourceTypeEnum, 1);
|
||||
handleChangePurposeTypeEnum(receiptHeaderForm.purposeTypeEnum, 1);
|
||||
});
|
||||
|
||||
// 卸载时移除事件
|
||||
@@ -975,11 +1008,11 @@ function addNewRow() {
|
||||
itemId: "",
|
||||
unitCode: "",
|
||||
remake: "",
|
||||
// supplierId: "",
|
||||
supplierId: "",
|
||||
purposeTypeEnum: "",
|
||||
purposeLocationId: null,
|
||||
purposeLocationStoreId: null,
|
||||
// practitionerId: "",
|
||||
practitionerId: "",
|
||||
traceNo: "",
|
||||
invoiceNo: "",
|
||||
startTime: "",
|
||||
@@ -1018,6 +1051,7 @@ function handleBlur(row, index) {
|
||||
if (receiptHeaderForm.medicationType == 1) {
|
||||
row.itemTable = "med_medication_definition";
|
||||
} else {
|
||||
console.log('Unknown warehouse type:', value);
|
||||
row.itemTable = "adm_device_definition";
|
||||
}
|
||||
}
|
||||
@@ -1206,42 +1240,66 @@ function handleLocationClick(id,purposeLocationId,itemId, index) {
|
||||
}
|
||||
// 切换仓库类型获取药房/药库列表 目的仓库切换
|
||||
function handleChangePurposeTypeEnum(value,type) {
|
||||
if (value == 16) {
|
||||
getPharmacyList().then((res) => {
|
||||
purposeTypeListOptions.value = res.data;
|
||||
if(!route.query.supplyBusNo&&!type){
|
||||
receiptHeaderForm.purposeLocationId = ''
|
||||
receiptHeaderForm.purposeLocationId1 = ''
|
||||
console.log('handleChangePurposeTypeEnum called with value:', value, 'type:', type);
|
||||
receiptHeaderForm.purposeLocationId = '';
|
||||
if(value === 16){ // 药房类型
|
||||
getPharmacyList().then(res => {
|
||||
console.log('getPharmacyList response:', res);
|
||||
if (res && res.data) {
|
||||
purposeTypeListOptions.value = res.data;
|
||||
if(!type && res.data.length > 0) {
|
||||
receiptHeaderForm.purposeLocationId = res.data[0].id;
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error fetching pharmacy list:', error);
|
||||
});
|
||||
} else if (value == 11) {
|
||||
getDispensaryList().then((res) => {
|
||||
purposeTypeListOptions.value = res.data;
|
||||
if(!route.query.supplyBusNo&&!type){
|
||||
receiptHeaderForm.purposeLocationId = ''
|
||||
receiptHeaderForm.purposeLocationId1 = ''
|
||||
} else if(value === 17){ // 药库类型
|
||||
getDispensaryList().then(res => {
|
||||
console.log('getDispensaryList response:', res);
|
||||
if (res && res.data) {
|
||||
purposeTypeListOptions.value = res.data;
|
||||
if(!type && res.data.length > 0) {
|
||||
receiptHeaderForm.purposeLocationId = res.data[0].id;
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error fetching dispensary list:', error);
|
||||
});
|
||||
} else {
|
||||
purposeTypeListOptions.value = [];
|
||||
}
|
||||
}
|
||||
// 源仓库切换
|
||||
function handleChangeSourceTypeEnum(value,type) {
|
||||
if (value == 16) {
|
||||
getPharmacyList().then((res) => {
|
||||
sourceTypeListOptions.value = res.data;
|
||||
if(!route.query.supplyBusNo&&!type){
|
||||
receiptHeaderForm.sourceLocationId = ''
|
||||
receiptHeaderForm.sourceLocationId1 = ''
|
||||
console.log('handleChangeSourceTypeEnum called with value:', value, 'type:', type);
|
||||
receiptHeaderForm.sourceLocationId = '';
|
||||
if(value === 16){ // 药房类型
|
||||
getPharmacyList().then(res => {
|
||||
console.log('getPharmacyList response:', res);
|
||||
if (res && res.data) {
|
||||
sourceTypeListOptions.value = res.data;
|
||||
if(!type && res.data.length > 0) {
|
||||
receiptHeaderForm.sourceLocationId = res.data[0].id;
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error fetching pharmacy list:', error);
|
||||
});
|
||||
} else if (value == 11) {
|
||||
getDispensaryList().then((res) => {
|
||||
sourceTypeListOptions.value = res.data;
|
||||
if(!route.query.supplyBusNo&&!type){
|
||||
receiptHeaderForm.sourceLocationId = ''
|
||||
receiptHeaderForm.sourceLocationId1 = ''
|
||||
} else if(value === 17){ // 药库类型
|
||||
getDispensaryList().then(res => {
|
||||
console.log('getDispensaryList response:', res);
|
||||
if (res && res.data) {
|
||||
sourceTypeListOptions.value = res.data;
|
||||
if(!type && res.data.length > 0) {
|
||||
receiptHeaderForm.sourceLocationId = res.data[0].id;
|
||||
}
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('Error fetching dispensary list:', error);
|
||||
});
|
||||
} else {
|
||||
sourceTypeListOptions.value = [];
|
||||
}
|
||||
}
|
||||
function editBatchTransfer(index){
|
||||
@@ -1857,8 +1915,19 @@ function getBusNoInitList() {
|
||||
}
|
||||
}
|
||||
|
||||
getTransferProductTypeList();
|
||||
getBusNoInitList()
|
||||
// 初始化函数
|
||||
function initComponent() {
|
||||
console.log('initComponent called');
|
||||
getTransferProductTypeList();
|
||||
getBusNoInitList();
|
||||
|
||||
console.log('组件初始化完成,仓库列表数据已预先设置');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 调用初始化函数
|
||||
initComponent();
|
||||
</script>
|
||||
<style scoped>
|
||||
.custom-tree-node {
|
||||
|
||||
@@ -110,8 +110,7 @@ export function getCount(queryParams) {
|
||||
// 获取药房列表
|
||||
export function getPharmacyList() {
|
||||
return request({
|
||||
url: '/app-common/inventory-pharmacy-list',
|
||||
// '/app-common/pharmacy-list',
|
||||
url: '/app-common/pharmacy-list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
@@ -119,8 +118,7 @@ export function getPharmacyList() {
|
||||
// 获取药库列表
|
||||
export function getDispensaryList() {
|
||||
return request({
|
||||
url:'/app-common/inventory-cabinet-list',
|
||||
// '/app-common/cabinet-list',
|
||||
url: '/app-common/cabinet-list',
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user