160 lines
4.0 KiB
Vue
Raw Normal View History

2025-11-03 18:07:12 +08:00
<template>
<!-- 计算项目表达式生成向导 -->
2025-11-06 18:22:18 +08:00
<el-dialog :model-value="visible" @update:model-value="handleVisibleChange" title="计算项目表达式生成向导" width="600px" @close="onClose">
<el-row class="input-text">
<el-input type="textarea" v-model="formData.jsgs"></el-input>
</el-row>
2025-11-04 15:14:07 +08:00
<el-row>
2025-11-06 18:22:18 +08:00
<el-col :span="12">
<CustomTable ref="tableRefs" :data="tableData" :columns="columns" :config="tableConfig"
2025-11-04 15:14:07 +08:00
@row-click="rowHandle" :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">
import CustomTable from '@/components/elTable/index.vue'
2025-11-06 18:22:18 +08:00
import { queryXmInfoNew } from '@/api/liswork/labItem/labItemApi'
const props = defineProps({
xmgl:{
type: String,
},
text: {
type: String,
},
formData:{
type: Object,
default: {}
}
})
2025-11-03 18:07:12 +08:00
2025-11-04 15:14:07 +08:00
let visible = ref<boolean>()
const tableData = ref()
2025-11-03 18:07:12 +08:00
const inputText = 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([
{ prop: 'xmdh', label: '项目代号', align: 'center', visible: true, width: 100 },
2025-11-06 18:22:18 +08:00
{ prop: 'xmmc', label: '项目名称', align: 'center', visible: true, width: 180 }
2025-11-04 15:14:07 +08:00
])
// 表格配置
const tableConfig = ref(
{
// stripe: true, // 斑马纹
border: true, // 边框
2025-11-06 18:22:18 +08:00
height: '350', // 高度
2025-11-04 15:14:07 +08:00
highlightCurrentRow: true, // 高亮当前行
fit: true
}
)
2025-11-03 18:07:12 +08:00
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-11-06 18:22:18 +08:00
const rowHandle = (row: any) => {
inputText.value += '['+row.xmdh+']'
2025-11-03 18:07:12 +08:00
}
2025-11-04 15:14:07 +08:00
const onClose = () => {
emit('update:model-value', false)
}
const handleOk = () => {
emit('confirm',inputText.value) // 通知外部执行确认操作
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-11-06 18:22:18 +08:00
const init = async () => {
const res = await queryXmInfoNew(props.xmgl);
tableData.value = res.data
//inputText.value = props.text
}
onMounted(()=>{
init();
})
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;
}
// .right {
// margin-left: 2px;
// }
.el-button {
margin-bottom: 5px;
}
2025-11-03 18:07:12 +08:00
</style>