2
This commit is contained in:
@@ -25,14 +25,14 @@
|
|||||||
<a-select
|
<a-select
|
||||||
v-if="modalSatus == 'add'"
|
v-if="modalSatus == 'add'"
|
||||||
v-model="modalForm.pharmacy_id"
|
v-model="modalForm.pharmacy_id"
|
||||||
placeholder="请选择所属药房"
|
placeholder="选择药品后自动匹配药房"
|
||||||
allow-search
|
disabled
|
||||||
:style="{ width: '300px' }"
|
:style="{ width: '300px' }"
|
||||||
>
|
>
|
||||||
<a-option
|
<a-option
|
||||||
v-for="item in pharmacyList"
|
v-for="item in pharmacyList"
|
||||||
:key="item.pharmacy_id"
|
:key="item.pharmacy_id"
|
||||||
:value="item.pharmacy_id"
|
:value="String(item.pharmacy_id)"
|
||||||
:label="item.pharmacy_name"
|
:label="item.pharmacy_name"
|
||||||
>
|
>
|
||||||
{{ item.pharmacy_name }} ({{ item.pharmacy_code }})
|
{{ item.pharmacy_name }} ({{ item.pharmacy_code }})
|
||||||
@@ -264,11 +264,53 @@ const medinceList = ref([]);
|
|||||||
const pharmacyList = ref([]);
|
const pharmacyList = ref([]);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
// 自动匹配并设置所属药房
|
||||||
|
const matchAndSetPharmacy = (target = {}) => {
|
||||||
|
if (!target) return;
|
||||||
|
const pid = target.pharmacy_id ?? target.pharmacy?.pharmacy_id;
|
||||||
|
const pcode = target.pharmacy_code ?? target.pharmacy?.pharmacy_code;
|
||||||
|
const pname = target.pharmacy_name ?? target.pharmacy?.pharmacy_name;
|
||||||
|
|
||||||
|
let matched = null;
|
||||||
|
if (pid !== undefined && pid !== null && pid !== '') {
|
||||||
|
matched = pharmacyList.value.find((p) => String(p.pharmacy_id) === String(pid));
|
||||||
|
}
|
||||||
|
if (!matched && pcode) {
|
||||||
|
const codeStr = String(pcode).trim().toLowerCase();
|
||||||
|
matched = pharmacyList.value.find(
|
||||||
|
(p) => p.pharmacy_code && String(p.pharmacy_code).trim().toLowerCase() === codeStr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matched) {
|
||||||
|
modalForm.value.pharmacy_id = String(matched.pharmacy_id);
|
||||||
|
modalForm.value.pharmacy_name = matched.pharmacy_name;
|
||||||
|
modalForm.value.pharmacy_code = matched.pharmacy_code;
|
||||||
|
} else if (pid !== undefined && pid !== null && pid !== '') {
|
||||||
|
modalForm.value.pharmacy_id = String(pid);
|
||||||
|
modalForm.value.pharmacy_name = pname || '';
|
||||||
|
modalForm.value.pharmacy_code = pcode || '';
|
||||||
|
if (!pharmacyList.value.some((p) => String(p.pharmacy_id) === String(pid))) {
|
||||||
|
pharmacyList.value.push({
|
||||||
|
pharmacy_id: String(pid),
|
||||||
|
pharmacy_name: modalForm.value.pharmacy_name || '所属药房',
|
||||||
|
pharmacy_code: modalForm.value.pharmacy_code || '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (pcode) {
|
||||||
|
modalForm.value.pharmacy_code = pcode;
|
||||||
|
if (pname) modalForm.value.pharmacy_name = pname;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const fetchPharmacyList = async () => {
|
const fetchPharmacyList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getPharmacyList();
|
const res = await getPharmacyList();
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
pharmacyList.value = res.data || [];
|
pharmacyList.value = res.data || [];
|
||||||
|
if (modalForm.value && (modalForm.value.pharmacy_id || modalForm.value.pharmacy_code)) {
|
||||||
|
matchAndSetPharmacy(modalForm.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('获取药房列表异常:', e);
|
console.error('获取药房列表异常:', e);
|
||||||
@@ -286,7 +328,7 @@ watch(() => props.modalVisible, (val) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
pharmacy_id: [{ required: true, message: '请选择所属药房' }],
|
pharmacy_id: [{ required: true, message: '请先选择药品以匹配所属药房' }],
|
||||||
product_platform_id: [{ required: true, message: '请输入药品名称' }],
|
product_platform_id: [{ required: true, message: '请输入药品名称' }],
|
||||||
product_price: [{ required: true, message: '请输入药品价格' }],
|
product_price: [{ required: true, message: '请输入药品价格' }],
|
||||||
product_platform_code: [{ required: true, message: '请输入处方平台编码' }],
|
product_platform_code: [{ required: true, message: '请输入处方平台编码' }],
|
||||||
@@ -309,7 +351,7 @@ const handleClose = () => {
|
|||||||
};
|
};
|
||||||
const handAdd = async () => {
|
const handAdd = async () => {
|
||||||
if (!modalForm.value.pharmacy_id) {
|
if (!modalForm.value.pharmacy_id) {
|
||||||
Message.warning('请选择所属药房');
|
Message.warning('所属药房不能为空,请先选择药品以匹配药房');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
delete modalForm.value.avatar;
|
delete modalForm.value.avatar;
|
||||||
@@ -344,15 +386,12 @@ const handleEditStatus=async(status)=>{
|
|||||||
}
|
}
|
||||||
//详情
|
//详情
|
||||||
const handleDetail = async (product_platform_id) => {
|
const handleDetail = async (product_platform_id) => {
|
||||||
const currentPharmacyId = modalForm.value.pharmacy_id;
|
|
||||||
const { code, data, message } = await getMedinceDetail(product_platform_id);
|
const { code, data, message } = await getMedinceDetail(product_platform_id);
|
||||||
|
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
Object.assign(modalForm.value, data);
|
Object.assign(modalForm.value, data);
|
||||||
modalForm.value.stock = data.stock;
|
modalForm.value.stock = data.stock;
|
||||||
if (currentPharmacyId) {
|
matchAndSetPharmacy(data);
|
||||||
modalForm.value.pharmacy_id = currentPharmacyId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handList= async(value)=>{
|
const handList= async(value)=>{
|
||||||
@@ -367,12 +406,24 @@ const handList= async(value)=>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const changeMedince = (value) => {
|
const changeMedince = (value) => {
|
||||||
|
if (!value) {
|
||||||
|
modalForm.value.product_platform_id = '';
|
||||||
|
modalForm.value.pharmacy_id = '';
|
||||||
|
modalForm.value.pharmacy_name = '';
|
||||||
|
modalForm.value.pharmacy_code = '';
|
||||||
|
modalForm.value.product_spec = '';
|
||||||
|
modalForm.value.product_pharmacy_code = '';
|
||||||
|
modalForm.value.manufacturer = '';
|
||||||
|
return;
|
||||||
|
}
|
||||||
let arr = medinceList.value.filter((item) => item.product_platform_id == value);
|
let arr = medinceList.value.filter((item) => item.product_platform_id == value);
|
||||||
|
if (!arr.length) return;
|
||||||
modalForm.value.product_platform_id = arr[0].product_platform_id;
|
modalForm.value.product_platform_id = arr[0].product_platform_id;
|
||||||
console.log(arr[0]);
|
console.log(arr[0]);
|
||||||
modalForm.value.product_spec=arr[0].product_spec;
|
modalForm.value.product_spec = arr[0].product_spec;
|
||||||
modalForm.value.product_pharmacy_code=arr[0].product_pharmacy_code;
|
modalForm.value.product_pharmacy_code = arr[0].product_pharmacy_code;
|
||||||
modalForm.value.manufacturer=arr[0].manufacturer;
|
modalForm.value.manufacturer = arr[0].manufacturer;
|
||||||
|
matchAndSetPharmacy(arr[0]);
|
||||||
handleDetail(arr[0].product_platform_id);
|
handleDetail(arr[0].product_platform_id);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -147,8 +147,8 @@
|
|||||||
{ title: '单价(元)', dataIndex: 'product_price', slotName: 'product_price',width: 150 },
|
{ title: '单价(元)', dataIndex: 'product_price', slotName: 'product_price',width: 150 },
|
||||||
{ title: '批准文号', dataIndex: 'license_number',width:200 },
|
{ title: '批准文号', dataIndex: 'license_number',width:200 },
|
||||||
{ title: '生产厂家', dataIndex: 'manufacturer',width:200 },
|
{ title: '生产厂家', dataIndex: 'manufacturer',width:200 },
|
||||||
{ title: '药店编码', dataIndex: 'product_pharmacy_code',width:100 },
|
{ title: '第三方药房药品编码', dataIndex: 'product_pharmacy_code',width:160,ellipsis: true },
|
||||||
{ title: '第三方药房编码', dataIndex: 'pharmacy_code', width: 160, ellipsis: true },
|
{ title: '药店编码', dataIndex: 'pharmacy_code', width: 100, ellipsis: true },
|
||||||
// { title: '启用状态', dataIndex: 'status', slotName: 'status' },
|
// { title: '启用状态', dataIndex: 'status', slotName: 'status' },
|
||||||
{ title: '操作', slotName: 'action', fixed: "right", width: 180 },
|
{ title: '操作', slotName: 'action', fixed: "right", width: 180 },
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user