web/src/components/common/service/ServiceDetail.vue

153 lines
4.5 KiB
Vue

<template>
<Panel title="服务项目">
<el-table v-if="itemDetail.length>0" :data="itemDetail" max-height="150">
<el-table-column prop="itemName" label="项目名称">
<template #default="scope">
<el-popover
width="485"
@show="show(scope.row)"
@hide="hide"
>
<template #reference>
{{ scope.row.itemName }}
</template>
<div class="detail">
<div style="display: flex;justify-content: space-between">
<div style="font-size: 18px;font-weight: 500;color: #000">{{
itemInfo.name
}}[{{ chrgitm_lv[itemInfo.chrgitmLv as keyof typeof chrgitm_lv || '-'] || '-' }}]
</div>
<div>¥{{ scope.row.unitPrice }}/{{ scope.row.unit }}</div>
</div>
<div style="display: flex;justify-content: space-between">
<div>限制条件:{{ itemInfo.lmtUsedFlag == 0 ? '否' : itemInfo.lmtUsedFlag == 1 ? '是' : '-' }}</div>
<div> 医保码:{{ scope.row.itemSocialCode || '-' }}</div>
</div>
</div>
</el-popover>
</template>
</el-table-column>
<el-table-column label="单价">
<template #default="scope">
¥{{ scope.row.selectedPrice }}
</template>
</el-table-column>
<el-table-column label="数量">
<template #default="scope">
<el-input-number v-if="props.status" v-model="scope.row.selectedNum" :min="0"
@change="handleNumChange" size="small"></el-input-number>
<span v-else>{{ scope.row.selectedNum }}</span>
{{ scope.row.selectedUnit }}
</template>
</el-table-column>
<el-table-column label="小计">
<template #default="scope">
¥{{ scope.row.selectedNum * scope.row.selectedPrice }}
</template>
</el-table-column>
<el-table-column label="操作" v-if="props.status">
<template #default="scope">
<el-button type="danger" link @click="delService(scope.row)">X</el-button>
</template>
</el-table-column>
</el-table>
<div class="bottom">
<div class="search">
<SearchInput
@focus="focus"
:placeholder="'请输入药服务项目或拼音码'"
:request-api="serviceSearchApi"
:show-config="serviceShowConfig"
@selectedCallBack="serviceSelect" v-if="status"></SearchInput>
</div>
<span>合计:¥{{ getTotalPrice() || 0 }}</span>
</div>
</Panel>
</template>
<script setup lang="ts">
import {defineProps, watchEffect, ref} from "vue";
import SearchInput from "@/components/SearchInput.vue";
import Panel from "@/components/common/Panel.vue";
import {post} from "@/utils/request.ts";
import chrgitm_lv from "@/assets/config/directory/chrgitmLv.json"
import {ElMessage} from "element-plus";
const props = defineProps({
status: {
type: Boolean,
default: 0
}
})
const itemDetail = defineModel<any>();
const delService = (item: any) => {
itemDetail.value = itemDetail.value.filter((i: any) => i.id != item.id)
}
const serviceSearchApi = "item/search";
const serviceShowConfig = [
{
label: "服务名称",
prop: "itemName",
},
{
label: "服务医保码",
prop: "itemSocialCode",
},
{
label: "售价",
prop: "unitPrice",
},
]
const emit = defineEmits(['totalPriceChange','focus'])
const serviceSelect = (row: any) => {
row.selectedNum = 1
row.selectedUnit = row.unit
row.selectedPrice = row.unitPrice
if (itemDetail.value.find((i: any) => i.id == row.id)) {
ElMessage.warning("数据已存在,只能加数量")
return
}
itemDetail.value.push(row)
emit('totalPriceChange')
}
const handleNumChange = () => {
emit('totalPriceChange')
}
const getTotalPrice = () => {
let totalPrice = 0;
if (itemDetail.value) {
itemDetail.value.forEach((item: any) => {
totalPrice += item.selectedNum * item.selectedPrice
})
}
return totalPrice;
}
const focus = (e: any) => {
emit('focus', e)
}
const itemInfo = ref<any>({});
const show = (item: any) => {
post('social/directory/getItemByCode', {code: item.itemSocialCode}).then((res: any) => {
itemInfo.value = res
})
}
const hide = () => {
itemInfo.value = {}
}
</script>
<style scoped lang="scss">
:deep(.el-table__cell) {
padding: 0 4px;
}
.bottom {
text-align: right;
border-top: 1px solid #EAEAEC ;
display: flex;
.search{
flex: 1;
}
}
</style>