2025-11-03 18:07:12 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<!-- 计算项目表达式生成向导 -->
|
2025-12-12 15:49:03 +08:00
|
|
|
|
<el-dialog :model-value="visible" @update:model-value="handleVisibleChange" title="计算项目表达式生成向导" width="600px"
|
|
|
|
|
|
:close-on-click-modal="false" :draggable="true" @close="onClose" @open="onOpen">
|
2025-11-06 18:22:18 +08:00
|
|
|
|
<el-row class="input-text">
|
2025-11-07 17:50:06 +08:00
|
|
|
|
<el-input type="textarea" v-model="inputText"></el-input>
|
2025-11-06 18:22:18 +08:00
|
|
|
|
</el-row>
|
2025-12-16 17:54:51 +08:00
|
|
|
|
<el-row :gutter="10">
|
2025-11-06 18:22:18 +08:00
|
|
|
|
<el-col :span="12">
|
2025-12-16 17:54:51 +08:00
|
|
|
|
<el-input v-model="searchKey" ref="searchInput" size="small" placeholder="快速搜索(支持简拼)" class="mb5" clearable
|
2025-12-15 18:06:42 +08:00
|
|
|
|
@clear="filterDataHandle" @input="filterDataHandle" />
|
2025-12-16 17:54:51 +08:00
|
|
|
|
<VxeTable ref="tableRefs" :data="filterData" :columns="columns" class="mytable-style"
|
|
|
|
|
|
:scrollYConfig="{ enabled: true, rSize: 30, height: '350', }" @current-change="rowHandle"
|
2025-12-12 15:49:03 +08:00
|
|
|
|
:enableColumnDrag="true" @column-drag-end="handleColumnDragEnd" />
|
2025-11-06 18:22:18 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="12" class="right">
|
|
|
|
|
|
<el-button type="" @click="bClickAdd">+ 加</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickSub">- 减</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickMul">* 乘</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickDiv">/ 除</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickLeft">(</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickRight">)</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickPower">^次方</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickSex">性别</el-button>
|
|
|
|
|
|
<el-button type="" @click="bClickAge">年龄</el-button>
|
|
|
|
|
|
<h4>说明:</h4>
|
|
|
|
|
|
<h4>1.计算公式中不可包括其他计算项目,若有需要,</h4>
|
|
|
|
|
|
<h4>一律转换为最原始的计算公式</h4>
|
|
|
|
|
|
<h4>2.所有项目代号必须使用“[”和“]”括起来</h4>
|
|
|
|
|
|
<h4>3.表达式可以为一个常数或空字符串</h4>
|
|
|
|
|
|
</el-col>
|
2025-11-03 18:07:12 +08:00
|
|
|
|
</el-row>
|
2025-11-04 15:14:07 +08:00
|
|
|
|
<!-- 底部按钮(可选) -->
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button type="primary" @click="handleOk">确定</el-button>
|
2025-11-06 18:22:18 +08:00
|
|
|
|
<el-button @click="handleCancel">取消</el-button>
|
2025-11-04 15:14:07 +08:00
|
|
|
|
</template>
|
2025-11-03 18:07:12 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-12-16 17:54:51 +08:00
|
|
|
|
import VxeTable from '@/components/vxeTable/index.vue'
|
2025-11-06 18:22:18 +08:00
|
|
|
|
import { queryXmInfoNew } from '@/api/liswork/labItem/labItemApi'
|
2025-12-16 17:54:51 +08:00
|
|
|
|
import { getFirstLetter } from '@/utils/pinyin';
|
2025-12-15 18:06:42 +08:00
|
|
|
|
|
2025-11-06 18:22:18 +08:00
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
2025-12-12 15:49:03 +08:00
|
|
|
|
formData: {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
type: Object,
|
|
|
|
|
|
default: {}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-11-03 18:07:12 +08:00
|
|
|
|
|
2025-11-04 15:14:07 +08:00
|
|
|
|
let visible = ref<boolean>()
|
2025-12-15 18:06:42 +08:00
|
|
|
|
const currentIndex = ref(0)
|
|
|
|
|
|
const searchKey = ref('');
|
|
|
|
|
|
const filterData = ref<{ [key: string]: any; pinyinMap: Record<string, string> }[]>([]);
|
2025-11-04 15:14:07 +08:00
|
|
|
|
const tableData = ref()
|
2025-11-03 18:07:12 +08:00
|
|
|
|
const inputText = ref('')
|
2025-12-15 18:06:42 +08:00
|
|
|
|
const tableRefs = ref()
|
2025-11-04 15:14:07 +08:00
|
|
|
|
const emit = defineEmits(['update:model-value', 'confirm'])
|
2025-11-03 18:07:12 +08:00
|
|
|
|
|
2025-11-04 15:14:07 +08:00
|
|
|
|
const columns = ref([
|
2025-12-16 17:54:51 +08:00
|
|
|
|
{ field: 'xmdh', title: '项目代号', align: 'center', resizable: true, width: 100 },
|
|
|
|
|
|
{ field: 'xmmc', title: '项目名称', resizable: true, }
|
2025-11-04 15:14:07 +08:00
|
|
|
|
])
|
2025-12-16 17:54:51 +08:00
|
|
|
|
|
2025-11-03 18:07:12 +08:00
|
|
|
|
|
2025-11-07 17:50:06 +08:00
|
|
|
|
//向外暴露数据
|
2025-12-12 15:49:03 +08:00
|
|
|
|
defineExpose({ inputText })
|
2025-11-07 17:50:06 +08:00
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
() => props.formData.jsgs, // 监听的目标:formData.jsgs
|
2025-12-12 15:49:03 +08:00
|
|
|
|
(newVal: any) => {
|
2025-11-07 17:50:06 +08:00
|
|
|
|
inputText.value = newVal // 当新值变化时,更新 inputText
|
|
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true } // 立即执行一次(确保初始化时也能同步)
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-11-04 15:14:07 +08:00
|
|
|
|
const handleColumnDragEnd = (newColumns: any) => {
|
|
|
|
|
|
columns.value = newColumns.columns
|
2025-11-03 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-15 18:06:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-11-06 18:22:18 +08:00
|
|
|
|
const rowHandle = (row: any) => {
|
2025-12-12 15:49:03 +08:00
|
|
|
|
inputText.value += '[' + row.xmdh + ']'
|
2025-11-03 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-04 15:14:07 +08:00
|
|
|
|
const onClose = () => {
|
2025-12-16 17:54:51 +08:00
|
|
|
|
searchKey.value = ''
|
2025-11-04 15:14:07 +08:00
|
|
|
|
emit('update:model-value', false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleOk = () => {
|
2025-12-12 15:49:03 +08:00
|
|
|
|
emit('confirm', inputText.value) // 通知外部执行确认操作
|
2025-11-04 15:14:07 +08:00
|
|
|
|
emit('update:model-value', false) // 确认后关闭
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-03 18:07:12 +08:00
|
|
|
|
const handleCancel = () => {
|
2025-11-04 15:14:07 +08:00
|
|
|
|
emit('update:model-value', false)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const handleVisibleChange = (newVisible: boolean) => {
|
|
|
|
|
|
// 通知父组件:状态变为 newVisible(可能是 true 或 false)
|
|
|
|
|
|
emit('update:model-value', newVisible)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickAdd = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '+'
|
2025-11-03 18:07:12 +08:00
|
|
|
|
}
|
2025-11-04 15:14:07 +08:00
|
|
|
|
|
|
|
|
|
|
const bClickSub = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '-'
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickMul = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '*'
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickDiv = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '/'
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickLeft = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '('
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickRight = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += ')'
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickPower = () => {
|
2025-11-06 18:22:18 +08:00
|
|
|
|
inputText.value += '^'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickSex = () => {
|
|
|
|
|
|
inputText.value += '[SEX]'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const bClickAge = () => {
|
|
|
|
|
|
inputText.value += '[AGE]'
|
2025-11-04 15:14:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-12 15:49:03 +08:00
|
|
|
|
const onOpen = async () => {
|
2025-11-07 17:50:06 +08:00
|
|
|
|
const res = await queryXmInfoNew(props.formData.xmgl);
|
2025-12-15 18:06:42 +08:00
|
|
|
|
tableData.value = processTableData(res.data)
|
|
|
|
|
|
filterData.value = [...tableData.value]
|
|
|
|
|
|
}
|
|
|
|
|
|
// 预处理数据:生成拼音信息
|
|
|
|
|
|
const processTableData = (data: object[]) => {
|
|
|
|
|
|
return data.map((item: any) => {
|
|
|
|
|
|
const pinyinMap: Record<string, string> = {};
|
|
|
|
|
|
// 处理label字段拼音
|
|
|
|
|
|
if (item.xmmc) {
|
|
|
|
|
|
pinyinMap.xmmc = getFirstLetter(item.xmmc).toLowerCase();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (item.xmdh) {
|
|
|
|
|
|
pinyinMap.xmdh = getFirstLetter(item.xmdh).toLowerCase();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { ...item, pinyinMap };
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 搜索过滤逻辑
|
|
|
|
|
|
const filterDataHandle = () => {
|
|
|
|
|
|
const key = searchKey.value.trim().toLowerCase();
|
|
|
|
|
|
|
|
|
|
|
|
if (!key) {
|
|
|
|
|
|
// 空搜索时显示全部预处理数据
|
|
|
|
|
|
filterData.value = [...tableData.value];
|
|
|
|
|
|
return;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
currentIndex.value = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
filterData.value = tableData.value.filter((item: any) => {
|
|
|
|
|
|
// 1. 原文本匹配
|
|
|
|
|
|
const matchLabel = item.xmmc?.toString().toLowerCase().includes(key);
|
|
|
|
|
|
const matchValue = item.xmdh?.toString().toLowerCase().includes(key);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 拼音匹配
|
|
|
|
|
|
const matchLabelPinyin = item.pinyinMap.xmmc?.includes(key);
|
|
|
|
|
|
const matchValuePinyin = item.pinyinMap.xmdh?.includes(key);
|
|
|
|
|
|
|
|
|
|
|
|
return matchLabel || matchValue || matchLabelPinyin || matchValuePinyin;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (filterData.value.length > 0) {
|
|
|
|
|
|
tableRefs.value.setCurrentRow(filterData.value[0]);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-11-06 18:22:18 +08:00
|
|
|
|
|
2025-11-03 18:07:12 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2025-11-06 18:22:18 +08:00
|
|
|
|
.input-text {
|
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
|
}
|
2025-12-12 15:49:03 +08:00
|
|
|
|
|
2025-11-06 18:22:18 +08:00
|
|
|
|
// .right {
|
|
|
|
|
|
// margin-left: 2px;
|
|
|
|
|
|
// }
|
|
|
|
|
|
.el-button {
|
|
|
|
|
|
margin-bottom: 5px;
|
|
|
|
|
|
}
|
2025-11-03 18:07:12 +08:00
|
|
|
|
</style>
|