This commit is contained in:
ChenQiuYu 2025-05-28 16:07:32 +08:00
parent 25ddf183a1
commit 51f7c91735
3 changed files with 61 additions and 36 deletions

View File

@ -45,17 +45,7 @@
</el-table-column> </el-table-column>
<el-table-column label="使用方法" width="200"> <el-table-column label="使用方法" width="200">
<template #default="scope"> <template #default="scope">
<el-popover <Usage v-model="usage"></Usage>
placement="bottom"
title=""
:width="200"
trigger="click"
>
<template #reference>
<el-input v-model="usage" placeholder="使用方法" style="width: 100px"></el-input>
</template>
<Usage :usageObj="usageObj" @clickItem="clickItem"></Usage>
</el-popover>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="selectedPrice" label="单价" width="200"> <el-table-column prop="selectedPrice" label="单价" width="200">
@ -132,7 +122,6 @@ import {post} from "@/utils/request.ts";
import {ElMessage} from "element-plus"; import {ElMessage} from "element-plus";
import {Delete} from "@element-plus/icons-vue"; import {Delete} from "@element-plus/icons-vue";
import Usage from "./goodsDetail/Usage.vue" import Usage from "./goodsDetail/Usage.vue"
import usageObj from "@/assets/config/directory/drugMedcWayCode.json"
import {API} from "@/assets/config/API.ts"; import {API} from "@/assets/config/API.ts";
const props = defineProps({ const props = defineProps({
@ -259,9 +248,6 @@ const colosInfo = () => {
getTotalPrice() getTotalPrice()
emit('totalPriceChange') emit('totalPriceChange')
} }
const clickItem = (value: any) => {
usage.value = value
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
:deep(.el-table__cell) { :deep(.el-table__cell) {

View File

@ -1,25 +1,42 @@
<script setup lang="ts"> <script setup lang="ts">
import {defineProps, onMounted} from "vue"; import {defineModel, ref} from "vue";
import usageObj from "@/assets/config/directory/drugMedcWayCode.json"
const props = defineProps({ const isVisible = ref<any>(false)
usageObj: { const usage = defineModel()
type: Object,
default: () => []
}
});
const emit = defineEmits(['clickItem']) const emit = defineEmits(['clickItem'])
const clickItem = (item: any) => { const clickItem = (item: any) => {
console.log(item) usage.value = item[1]
emit("clickItem",item[0])
}
const focus = () => {
isVisible.value = true
}
const handlerBlur = () => {
isVisible.value = false
} }
</script> </script>
<template> <template>
<el-popover
:visible="isVisible"
placement="bottom"
title=""
:width="200"
trigger="click"
>
<template #reference>
<el-input v-model="usage" placeholder="使用方法" @focus="focus" @blur="handlerBlur"></el-input>
</template>
<div class="box"> <div class="box">
<ul class="item-list"> <div class="item-list">
<div class="item" v-for="(item, index) in Object.entries(props.usageObj)" :key="index" @click="clickItem(item)">{{ item[1] }}</div> <div class="item" v-for="(item, index) in Object.entries(usageObj)" :key="index" @click="clickItem(item)">
</ul> {{ item[1] }}
</div> </div>
</div>
</div>
</el-popover>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
@ -35,10 +52,12 @@ const clickItem=(item:any)=>{
border: 1px solid #ddd; border: 1px solid #ddd;
z-index: 999; z-index: 999;
} }
.item-list { .item-list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.item { .item {
display: flex; display: flex;
width: 160px; width: 160px;
@ -48,15 +67,18 @@ const clickItem=(item:any)=>{
border: 1px solid #ededed; border: 1px solid #ededed;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
&:hover { &:hover {
color: #fff; color: #fff;
background: #4d6de4; background: #4d6de4;
} }
&.last-item { &.last-item {
margin-right: 0; /* 最后一个元素不加右边距 */ margin-right: 0; /* 最后一个元素不加右边距 */
} }
} }
.active { .active {
background: #4d6de4 !important; background: #4d6de4 !important;
color: #fff !important; color: #fff !important;

View File

@ -16,7 +16,7 @@ function convertToTreeData(data: any, parentPath: string = '') {
if (item.path && item.comment) { if (item.path && item.comment) {
treeData.push({ treeData.push({
label: `${item.comment} (${item.path})`, label: `${item.comment}`,
path: item.path, path: item.path,
}); });
} else { } else {
@ -131,7 +131,24 @@ const apiInfo:any=ref(null);
background-color: #ffffff; background-color: #ffffff;
border-right: 1px solid #e4e7ed; border-right: 1px solid #e4e7ed;
overflow-y: auto; overflow-y: auto;
//
:deep(.el-tree-node__children) {
padding-left: 20px; //
position: relative;
&::before {
content: "";
position: absolute;
left: 10px;
top: 0;
bottom: 0;
width: 1px;
background-color: #e4e7ed;
}
.el-tree-node__content {
padding-left: 10px !important; //
}
}
:deep(.el-tree-node__content) { :deep(.el-tree-node__content) {
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;