领取规则维护

This commit is contained in:
wyuu 2025-09-12 11:06:51 +08:00
parent e61104d7c3
commit 9859df5a4d
6 changed files with 683 additions and 39 deletions

View File

@ -77,4 +77,55 @@ export function xmfeeDel(query?: Object) {
method: 'delete', method: 'delete',
params: query, params: query,
}); });
}
// 报告领取规则维护列表
export function rptgetruleList(query?: Object) {
return request({
url: 'rptgetrule/query',
method: 'get',
params: query,
});
}
// 报告领取规则明细列表
export function rptgetruleDetail(query?: Object) {
return request({
url: 'rptgetrule/queryDetail',
method: 'get',
params: query,
});
}
// 报告领取规则新增
export function rptgetruleadd(query?: Object) {
return request({
url: 'rptgetrule/add',
method: 'post',
data: query,
});
}
// 报告领取规则修改
export function rptgetruleUpdate(query?: Object) {
return request({
url: 'rptgetrule/update',
method: 'post',
data: query,
});
}
// 报告领取规则删除
export function rptgetruleDel(query?: Object) {
return request({
url: 'rptgetrule/del',
method: 'delete',
params: query,
});
}
// 报告领取规则明细删除
export function rptgetruleDelDetail(query?: Object) {
return request({
url: 'rptgetrule/delDetail',
method: 'delete',
params: query,
});
} }

View File

@ -48,7 +48,7 @@
<el-button type="primary" plain icon="Plus" @click="printHandle">生成条码</el-button> <el-button type="primary" plain icon="Plus" @click="printHandle">生成条码</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="Edit">选中所有未打印</el-button> <el-button type="danger" plain icon="Edit" @click="selectStatusRows">选中所有未打印</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain @click="printHandle1">打印</el-button> <el-button type="success" plain @click="printHandle1">打印</el-button>
@ -77,6 +77,9 @@
<CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig" :loading="loading" <CustomTable ref="tableRef" :data="tableData" :columns="columns" :config="tableConfig" :loading="loading"
@row-click="rowHandle" @selection-change="selectionChange"> @row-click="rowHandle" @selection-change="selectionChange">
<template #dy="{ row }">
{{ row.zt != 1 ? '✅' : '❌' }}
</template>
<template #jzbz="{ row }"> <template #jzbz="{ row }">
{{ row.jzbz == '1' ? '急诊' : '非急诊' }} {{ row.jzbz == '1' ? '急诊' : '非急诊' }}
</template> </template>
@ -231,6 +234,7 @@ const loading = ref(true);
const tableData = ref([]) const tableData = ref([])
// 配置项 // 配置项
const columns = ref([ const columns = ref([
{ prop: 'zt', label: '打印', visible: true, key: 0, sortable: true, slot: 'dy', },
{ prop: 'ch', label: '床号', visible: true, key: 0, sortable: true, }, { prop: 'ch', label: '床号', visible: true, key: 0, sortable: true, },
{ prop: 'brxm', label: '姓名', visible: true, key: 1, }, { prop: 'brxm', label: '姓名', visible: true, key: 1, },
{ prop: 'brxbname', label: '性别', align: 'center', visible: true, key: 2, }, { prop: 'brxbname', label: '性别', align: 'center', visible: true, key: 2, },
@ -301,7 +305,7 @@ const tableConfig = ref({
border: false, // 边框 border: false, // 边框
selection: true, // 多选框 selection: true, // 多选框
index: false, // 序号 index: false, // 序号
height: '100%', // 高度 height: '', // 高度
highlightCurrentRow: true, // 高亮当前行 highlightCurrentRow: true, // 高亮当前行
cellStyle: cellStyleHd, cellStyle: cellStyleHd,
rowClassName: rowClassNameHd, rowClassName: rowClassNameHd,
@ -325,7 +329,7 @@ const rightTableConfig = ref({
border: false, // 边框 border: false, // 边框
// selection: true, // 多选框 // selection: true, // 多选框
index: false, // 序号 index: false, // 序号
height: '100%', // 高度 height: '', // 高度
highlightCurrentRow: true, // 高亮当前行 highlightCurrentRow: true, // 高亮当前行
}) })
@ -369,10 +373,16 @@ const openBlock = async (value: string) => {
yljg: 1 yljg: 1
})); }));
const results = await Promise.all(requests); const results = await Promise.all(requests);
console.log('所有请求成功:', results); console.log('results==>', results);
if (results.some((item: any) => item.code != 0)) {
ElMessage.error('调用失败');
} else {
ElMessage.success('调用成功');
}
return results; return results;
} catch (error: any) { } catch (error: any) {
console.error('至少一个请求失败:', error.message); ElMessage.error(error.message);
throw error; throw error;
} }
@ -476,11 +486,12 @@ function adjustTableHeight() {
heightForm.value = compactForm.value.offsetHeight; heightForm.value = compactForm.value.offsetHeight;
tableConfig.value.height = `calc(72vh - ${heightForm.value}px)`; // 设置表格容器的高度 tableConfig.value.height = `calc(72vh - ${heightForm.value}px)`; // 设置表格容器的高度
rightTableConfig.value.height = `calc(76vh - ${heightForm.value}px)`; rightTableConfig.value.height = `calc(76vh - ${heightForm.value}px)`;
} }
} }
const handletime = (val: Array<string>) => { const handletime = (val: Array<string>) => {
console.log('时间', val); // console.log('时间', val);
} }
// 生成条码 // 生成条码
@ -523,6 +534,15 @@ const getList = () => {
} }
}) })
} }
const selectStatusRows = () => {
tableRef.value.clearSelection()
tableData.value.forEach((item: any) => {
if (item.zt == 1) {
tableRef.value.toggleRowSelection(item, true)
}
})
}
const printHandle1 = () => { const printHandle1 = () => {
const url = 'http://47.97.125.165:8904/lis.pdf' const url = 'http://47.97.125.165:8904/lis.pdf'
// const url = sqhs.value[0]?.pdfUrl // const url = sqhs.value[0]?.pdfUrl

View File

@ -290,7 +290,7 @@ const tableConfig = ref(
// border: true, // 边框 // border: true, // 边框
selection: true, // 多选框 selection: true, // 多选框
index: false, // 序号 index: false, // 序号
height: '100%', // 高度 height: '', // 高度
highlightCurrentRow: true, // 高亮当前行 highlightCurrentRow: true, // 高亮当前行
fit: true, fit: true,
cellStyle: cellStyleHd cellStyle: cellStyleHd

View File

@ -15,7 +15,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sflbdh')"> <template v-if="isEditing(scope.row, 'sflbdh')">
<el-input v-model="scope.row.sflbdh" size="small" @blur="handleSave(scope.row, 'sflbdh')" <el-input v-model="scope.row.sflbdh" size="small" @blur="handleSave(scope.row, 'sflbdh')"
@keyup.enter="handleSave(scope.row, 'sflbdh')" auto-focus /> @keyup.enter="handleSave(scope.row, 'sflbdh')" auto-focus :ref="getInputRef(scope.row.id, 'sflbdh')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'sflbdh' })"> <span @click.stop="handleCellClick(scope.row, { property: 'sflbdh' })">
@ -30,7 +30,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sflbmc')"> <template v-if="isEditing(scope.row, 'sflbmc')">
<el-input v-model="scope.row.sflbmc" size="small" @blur="handleSave(scope.row, 'sflbmc')" <el-input v-model="scope.row.sflbmc" size="small" @blur="handleSave(scope.row, 'sflbmc')"
@keyup.enter="handleSave(scope.row, 'sflbmc')" auto-focus /> @keyup.enter="handleSave(scope.row, 'sflbmc')" auto-focus :ref="getInputRef(scope.row.id, 'sflbmc')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'sflbmc' })"> <span @click.stop="handleCellClick(scope.row, { property: 'sflbmc' })">
@ -45,7 +45,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sflbjc')"> <template v-if="isEditing(scope.row, 'sflbjc')">
<el-input v-model="scope.row.sflbjc" size="small" @blur="handleSave(scope.row, 'sflbjc')" <el-input v-model="scope.row.sflbjc" size="small" @blur="handleSave(scope.row, 'sflbjc')"
@keyup.enter="handleSave(scope.row, 'sflbjc')" auto-focus /> @keyup.enter="handleSave(scope.row, 'sflbjc')" auto-focus :ref="getInputRef(scope.row.id, 'sflbjc')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'sflbjc' })"> <span @click.stop="handleCellClick(scope.row, { property: 'sflbjc' })">
@ -60,7 +60,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'txmlb')"> <template v-if="isEditing(scope.row, 'txmlb')">
<el-input v-model="scope.row.txmlb" size="small" @blur="handleSave(scope.row, 'txmlb')" <el-input v-model="scope.row.txmlb" size="small" @blur="handleSave(scope.row, 'txmlb')"
@keyup.enter="handleSave(scope.row, 'txmlb')" auto-focus /> @keyup.enter="handleSave(scope.row, 'txmlb')" auto-focus :ref="getInputRef(scope.row.id, 'txmlb')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'txmlb' })"> <span @click.stop="handleCellClick(scope.row, { property: 'txmlb' })">
@ -92,7 +92,8 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sampletips')"> <template v-if="isEditing(scope.row, 'sampletips')">
<el-input v-model="scope.row.sampletips" size="small" @blur="handleSave(scope.row, 'sampletips')" <el-input v-model="scope.row.sampletips" size="small" @blur="handleSave(scope.row, 'sampletips')"
@keyup.enter.ctrl="handleSave(scope.row, 'sampletips')" auto-focus /> @keyup.enter.ctrl="handleSave(scope.row, 'sampletips')" auto-focus
:ref="getInputRef(scope.row.id, 'sampletips')" />
</template> </template>
<template v-else> <template v-else>
<div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'sampletips' })"> <div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'sampletips' })">
@ -125,7 +126,8 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'printcnt')"> <template v-if="isEditing(scope.row, 'printcnt')">
<el-input-number v-model="scope.row.printcnt" :min="1" :max="9" size="small" <el-input-number v-model="scope.row.printcnt" :min="1" :max="9" size="small"
@blur="handleSave(scope.row, 'printcnt')" @keyup.enter="handleSave(scope.row, 'printcnt')" auto-focus /> @blur="handleSave(scope.row, 'printcnt')" @keyup.enter="handleSave(scope.row, 'printcnt')" auto-focus
:ref="getInputRef(scope.row.id, 'printcnt')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'printcnt' })"> <span @click.stop="handleCellClick(scope.row, { property: 'printcnt' })">
@ -172,8 +174,8 @@
<!-- 抗凝 --> <!-- 抗凝 -->
<el-table-column prop="kn" label="抗凝" width="100" align="center"> <el-table-column prop="kn" label="抗凝" width="100" align="center">
<template #default="scope"> <template #default="scope">
<el-checkbox v-model="scope.row.kn" :true-value="'1'" :false-value="'0'" @change="handleSave(scope.row, 'kn')" <el-checkbox v-model="scope.row.kn" :true-value="'1'" :false-value="'0'"
:ref="getInputRef(scope.row.id, 'kn')" /> @change="handleSave(scope.row, 'kn')" />
</template> </template>
</el-table-column> </el-table-column>
@ -181,7 +183,7 @@
<el-table-column prop="xpy" label="血培" width="100" align="center"> <el-table-column prop="xpy" label="血培" width="100" align="center">
<template #default="scope"> <template #default="scope">
<el-checkbox v-model="scope.row.xpy" :true-value="'1'" :false-value="'0'" <el-checkbox v-model="scope.row.xpy" :true-value="'1'" :false-value="'0'"
@change="handleSave(scope.row, 'xpy')" :ref="getInputRef(scope.row.id, 'xpy')" /> @change="handleSave(scope.row, 'xpy')" />
</template> </template>
</el-table-column> </el-table-column>
@ -306,11 +308,19 @@ const handleCellClick = (row: any, column: any) => {
// 强制刷新UI后聚焦 // 强制刷新UI后聚焦
nextTick(() => { nextTick(() => {
const inputKey = `${row.id}-${field}`; const inputKey = `${row.id}-${field}`;
const inputElement = inputRefs.value[inputKey]?.$el?.querySelector('input') || const inputComponent = inputRefs.value[inputKey];
inputRefs.value[inputKey]?.$el; if (!inputComponent) return;
if (inputElement) { // 不同组件的聚焦方式不同,做适配处理
inputElement.focus(); if (inputComponent.focus) {
// 基础输入组件直接调用focus方法
inputComponent.focus();
} else if (inputComponent.$el) {
// 查找内部输入元素
const inputEl = inputComponent.$el.querySelector('input, textarea') ||
inputComponent.$el.querySelector('.el-select__input') ||
inputComponent.$el;
inputEl?.focus?.();
} }
}); });
}; };
@ -381,10 +391,7 @@ const handleSave = (row: any, field: string) => {
// 清除编辑状态 // 清除编辑状态
editingState.value = { rowId: '', field: '' }; editingState.value = { rowId: '', field: '' };
console.log('originalData==>', row); console.log('originalData==>', row);
}; };
interface OperateLists { interface OperateLists {
@ -444,7 +451,7 @@ const addNewItem = () => {
printcnt: 1, printcnt: 1,
lisgroup1: '', lisgroup1: '',
lisgroup2: '', lisgroup2: '',
kn: '1', kn: '0',
xpy: '0', xpy: '0',
bkcolor: '#FFFFFF', bkcolor: '#FFFFFF',
originalData: {}, originalData: {},

View File

@ -17,7 +17,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sfxmdh')"> <template v-if="isEditing(scope.row, 'sfxmdh')">
<el-input v-model="scope.row.sfxmdh" size="small" @blur="handleSave(scope.row, 'sfxmdh')" <el-input v-model="scope.row.sfxmdh" size="small" @blur="handleSave(scope.row, 'sfxmdh')"
@keyup.enter="handleSave(scope.row, 'sfxmdh')" auto-focus /> @keyup.enter="handleSave(scope.row, 'sfxmdh')" auto-focus :ref="getInputRef(scope.row.id, 'sfxmdh')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'sfxmdh' })"> <span @click.stop="handleCellClick(scope.row, { property: 'sfxmdh' })">
@ -32,7 +32,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'sfxmmc')"> <template v-if="isEditing(scope.row, 'sfxmmc')">
<el-input v-model="scope.row.sfxmmc" size="small" @blur="handleSave(scope.row, 'sfxmmc')" <el-input v-model="scope.row.sfxmmc" size="small" @blur="handleSave(scope.row, 'sfxmmc')"
@keyup.enter="handleSave(scope.row, 'sfxmmc')" auto-focus /> @keyup.enter="handleSave(scope.row, 'sfxmmc')" auto-focus :ref="getInputRef(scope.row.id, 'sfxmmc')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'sfxmmc' })"> <span @click.stop="handleCellClick(scope.row, { property: 'sfxmmc' })">
@ -47,7 +47,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'bz')"> <template v-if="isEditing(scope.row, 'bz')">
<el-input v-model="scope.row.bz" size="small" @blur="handleSave(scope.row, 'bz')" <el-input v-model="scope.row.bz" size="small" @blur="handleSave(scope.row, 'bz')"
@keyup.enter="handleSave(scope.row, 'bz')" auto-focus /> @keyup.enter="handleSave(scope.row, 'bz')" auto-focus :ref="getInputRef(scope.row.id, 'bz')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'bz' })"> <span @click.stop="handleCellClick(scope.row, { property: 'bz' })">
@ -62,7 +62,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'dj')"> <template v-if="isEditing(scope.row, 'dj')">
<el-input-number v-model="scope.row.dj" :min="1" :max="100" size="small" @blur="handleSave(scope.row, 'dj')" <el-input-number v-model="scope.row.dj" :min="1" :max="100" size="small" @blur="handleSave(scope.row, 'dj')"
@keyup.enter="handleSave(scope.row, 'dj')" auto-focus /> @keyup.enter="handleSave(scope.row, 'dj')" auto-focus :ref="getInputRef(scope.row.id, 'dj')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'dj' })"> <span @click.stop="handleCellClick(scope.row, { property: 'dj' })">
@ -76,7 +76,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'spec')"> <template v-if="isEditing(scope.row, 'spec')">
<el-input v-model="scope.row.spec" size="small" @blur="handleSave(scope.row, 'spec')" <el-input v-model="scope.row.spec" size="small" @blur="handleSave(scope.row, 'spec')"
@keyup.enter="handleSave(scope.row, 'spec')" auto-focus /> @keyup.enter="handleSave(scope.row, 'spec')" auto-focus :ref="getInputRef(scope.row.id, 'spec')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'spec' })"> <span @click.stop="handleCellClick(scope.row, { property: 'spec' })">
@ -123,7 +123,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'bgts')"> <template v-if="isEditing(scope.row, 'bgts')">
<el-input-number v-model="scope.row.bgts" size="small" @blur="handleSave(scope.row, 'bgts')" <el-input-number v-model="scope.row.bgts" size="small" @blur="handleSave(scope.row, 'bgts')"
@keyup.enter="handleSave(scope.row, 'bgts')" auto-focus /> @keyup.enter="handleSave(scope.row, 'bgts')" auto-focus :ref="getInputRef(scope.row.id, 'bgts')" />
</template> </template>
<template v-else> <template v-else>
<span @click.stop="handleCellClick(scope.row, { property: 'bgts' })"> <span @click.stop="handleCellClick(scope.row, { property: 'bgts' })">
@ -138,7 +138,7 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'zjf')"> <template v-if="isEditing(scope.row, 'zjf')">
<el-input v-model="scope.row.zjf" size="small" @blur="handleSave(scope.row, 'zjf')" <el-input v-model="scope.row.zjf" size="small" @blur="handleSave(scope.row, 'zjf')"
@keyup.enter.ctrl="handleSave(scope.row, 'zjf')" auto-focus /> @keyup.enter.ctrl="handleSave(scope.row, 'zjf')" auto-focus :ref="getInputRef(scope.row.id, 'zjf')" />
</template> </template>
<template v-else> <template v-else>
<div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'zjf' })"> <div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'zjf' })">
@ -218,7 +218,7 @@
<template v-if="isEditing(scope.row, 'indication')"> <template v-if="isEditing(scope.row, 'indication')">
<el-input v-model="scope.row.indication" size="small" type="textarea" :rows="2" <el-input v-model="scope.row.indication" size="small" type="textarea" :rows="2"
@blur="handleSave(scope.row, 'indication')" @keyup.enter.ctrl="handleSave(scope.row, 'indication')" @blur="handleSave(scope.row, 'indication')" @keyup.enter.ctrl="handleSave(scope.row, 'indication')"
auto-focus /> auto-focus :ref="getInputRef(scope.row.id, 'indication')" />
</template> </template>
<template v-else> <template v-else>
<div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'indication' })"> <div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'indication' })">
@ -233,7 +233,8 @@
<template #default="scope"> <template #default="scope">
<template v-if="isEditing(scope.row, 'affect')"> <template v-if="isEditing(scope.row, 'affect')">
<el-input v-model="scope.row.affect" size="small" type="textarea" :rows="2" <el-input v-model="scope.row.affect" size="small" type="textarea" :rows="2"
@blur="handleSave(scope.row, 'affect')" @keyup.enter.ctrl="handleSave(scope.row, 'affect')" auto-focus /> @blur="handleSave(scope.row, 'affect')" @keyup.enter.ctrl="handleSave(scope.row, 'affect')" auto-focus
:ref="getInputRef(scope.row.id, 'affect')" />
</template> </template>
<template v-else> <template v-else>
<div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'affect' })"> <div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'affect' })">
@ -249,7 +250,7 @@
<template v-if="isEditing(scope.row, 'attention')"> <template v-if="isEditing(scope.row, 'attention')">
<el-input v-model="scope.row.attention" size="small" type="textarea" :rows="2" <el-input v-model="scope.row.attention" size="small" type="textarea" :rows="2"
@blur="handleSave(scope.row, 'attention')" @keyup.enter.ctrl="handleSave(scope.row, 'attention')" @blur="handleSave(scope.row, 'attention')" @keyup.enter.ctrl="handleSave(scope.row, 'attention')"
auto-focus /> auto-focus :ref="getInputRef(scope.row.id, 'attention')" />
</template> </template>
<template v-else> <template v-else>
<div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'attention' })"> <div class="multi-line-text" @click.stop="handleCellClick(scope.row, { property: 'attention' })">
@ -379,13 +380,22 @@ const handleCellClick = (row: any, column: any) => {
// 强制刷新UI后聚焦 // 强制刷新UI后聚焦
nextTick(() => { nextTick(() => {
const inputKey = `${row.id}-${field}`; const inputKey = `${row.id}-${field}`;
const inputElement = inputRefs.value[inputKey]?.$el?.querySelector('input') || const inputComponent = inputRefs.value[inputKey];
inputRefs.value[inputKey]?.$el; if (!inputComponent) return;
if (inputElement) { // 不同组件的聚焦方式不同,做适配处理
inputElement.focus(); if (inputComponent.focus) {
// 基础输入组件直接调用focus方法
inputComponent.focus();
} else if (inputComponent.$el) {
// 查找内部输入元素
const inputEl = inputComponent.$el.querySelector('input, textarea') ||
inputComponent.$el.querySelector('.el-select__input') ||
inputComponent.$el;
inputEl?.focus?.();
} }
}); });
}; };
// 保存编辑 // 保存编辑
@ -587,7 +597,6 @@ interface DictData {
// 字典数据存储 // 字典数据存储
const dictData = ref<DictData>({}); const dictData = ref<DictData>({});
onMounted(async () => { onMounted(async () => {
console.log('classCom ==>', classCom.decimalToHexColor("16777215"));
// 加载病人来源字典 // 加载病人来源字典
const dictRefs = await comDict('BT', 'DP', 'LISGROUP1', 'LISGROUP2'); const dictRefs = await comDict('BT', 'DP', 'LISGROUP1', 'LISGROUP2');

View File

@ -0,0 +1,557 @@
<template>
<div class="rule-management-container">
<!-- 顶部操作栏 -->
<div class="mb20">
<el-button type="primary" icon="Search" @click="handleQuery"> 查询</el-button>
<el-button type="success" icon="Plus" @click="addgz">新增</el-button>
<el-button type="primary" icon="Select" @click="saveHandle">保存</el-button>
<!-- :disabled="flag" -->
<el-button icon="Plus" @click="addDetail">新增明细</el-button>
</div>
<!-- 左右分栏区域 -->
<div class="content-wrapper">
<!-- 左侧表格 -->
<div class="left-table-area">
<el-table :data="ruleList" @row-click="handleRowClick" border style="width: 100%" highlight-current-row
class="custom-table">
<el-table-column prop="bglqdh" label="规则代号" width="100" />
<el-table-column prop="bglqmc" label="规则名称" width="200" />
<el-table-column prop="bz" label="备注" />
<el-table-column label="操作" align="center" fixed="right" width="100">
<template #default="scope">
<el-button size="small" type="danger" @click="handleDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 右侧表单与明细表格 -->
<div class="right-form-area">
<el-form :model="currentRule" label-width="80px" class="rule-form">
<el-form-item label="规则代号">
<el-input v-model="currentRule.bglqdh" disabled />
</el-form-item>
<el-form-item label="规则名称">
<el-input v-model="currentRule.bglqmc" @blur="editHandle(currentRule, 'bglqmc')"
@keyup.enter="editHandle(currentRule, 'bglqmc')" />
</el-form-item>
<el-form-item label="备注">
<el-input type="textarea" v-model="currentRule.bz" :rows="2" @blur="editHandle(currentRule, 'bz')"
@keyup.enter="editHandle(currentRule, 'bz')" />
</el-form-item>
</el-form>
<div class="detail-table-header">
<span>规则明细</span>
</div>
<el-table :data="detailList" border style="width: 100%;" class="detail-table" :cell-class-name="cellClassName">
<el-table-column prop="weekday" label="起始日期" width="120">
<template #default="scope">
<el-select v-model="scope.row.weekday" placeholder="选择星期" size="small" class="week-select"
@change="handleDetailChange(scope.row)">
<el-option v-for="day in weekDays" :key="day.value" :label="day.label" :value="day.value" />
</el-select>
</template>
</el-table-column>
<el-table-column prop="weekday1" label="截止日期" width="120">
<template #default="scope">
<el-select v-model="scope.row.weekday1" placeholder="选择星期" size="small" class="week-select"
@change="handleDetailChange(scope.row)">
<el-option v-for="day in weekDays" :key="day.value" :label="day.label" :value="day.value" />
</el-select>
</template>
</el-table-column>
<el-table-column prop="kssj" label="起始时间" width="100">
<template #default="scope">
<el-input v-model="scope.row.kssj" placeholder="HH:mm" size="small"
@input="handleTimeInput(scope.row, 'kssj')" maxlength="5" class="time-input" @focus="handleInputFocus"
@blur="handleInputBlur(scope.row, 'kssj')" />
</template>
</el-table-column>
<el-table-column prop="jssj" label="截止时间" width="100">
<template #default="scope">
<el-input v-model="scope.row.jssj" placeholder="HH:mm" size="small"
@input="handleTimeInput(scope.row, 'jssj')" maxlength="5" class="time-input" @focus="handleInputFocus"
@blur="handleInputBlur(scope.row, 'jssj')" />
</template>
</el-table-column>
<el-table-column prop="bglqsm" label="报告领取声明">
<template #default="scope">
<el-input v-model="scope.row.bglqsm" size="small" class="statement-input" @focus="handleInputFocus" />
</template>
</el-table-column>
<el-table-column prop="bgxss" label="所需小时数" width="100">
<template #default="scope">
<el-input v-model="scope.row.bgxss" placeholder="0" size="small"
@input="handleNumberInput(scope.row, 'bgxss')" class="number-input" @focus="handleInputFocus" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100">
<template #default="scope">
<el-button size="small" type="danger" @click="delDetail(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, onMounted, computed } from 'vue'
import { rptgetruleList, rptgetruleadd, rptgetruleUpdate, rptgetruleDel, rptgetruleDetail, rptgetruleDelDetail } from '@/api/mzcx/index';
import { ElMessageBox, ElMessage } from 'element-plus'
// 星期选项数据
const weekDays = [
{ label: '周一', value: '1' },
{ label: '周二', value: '2' },
{ label: '周三', value: '3' },
{ label: '周四', value: '4' },
{ label: '周五', value: '5' },
{ label: '周六', value: '6' },
{ label: '周日', value: '7' }
]
interface Rule {
bglqdh: number,
bglqmc: string,
bz: string,
status: boolean,
originalData: object,
addFlag: boolean
}
// 模拟规则列表数据
const ruleList = ref<Rule[]>([])
// 当前选中的规则数据
const currentRule = ref({
bglqdh: 1,
bglqmc: '',
bz: '',
})
interface Detail {
weekday: string,
weekday1: string,
kssj: string,
jssj: string,
bglqsm: string,
bgxss: number,
bglqdh: number,
xh: number,
detaiFlag: boolean
status: boolean // 新增:标识明细是否被修改
}
const detailList = ref<Detail[]>([])
const rptgetruledetail = ref<Detail[]>([])
// 是否正在编辑输入框
const isEditing = ref(false)
const handleQuery = () => {
getList()
}
// 处理时间输入,限制为HH:mm格式
const handleTimeInput = (row: any, field: string) => {
// 移除非数字和非冒号字符
let value = row[field].replace(/[^0-9:]/g, '')
// 自动添加冒号
if (value.length === 2 && !value.includes(':')) {
value += ':'
}
row[field] = value
}
// 处理时间输入失去焦点时的格式化
const handleInputBlur = (row: any, field: string) => {
isEditing.value = false
let value = row[field]
// 补全时间格式
if (field === 'kssj' || field === 'jssj') {
if (value.length === 1) {
value = `0${value}:00`
} else if (value.length === 2 && !value.includes(':')) {
value += ':00'
} else if (value.length === 3 && value.includes(':')) {
value += '0'
}
// 验证小时和分钟范围
if (value.includes(':')) {
const [hours, minutes] = value.split(':')
const validHours = Math.min(Math.max(parseInt(hours) || 0, 0), 23).toString().padStart(2, '0')
const validMinutes = Math.min(Math.max(parseInt(minutes) || 0, 0), 59).toString().padStart(2, '0')
value = `${validHours}:${validMinutes}`
} else {
value = '00:00'
}
row[field] = value
row.status = true;
}
czList()
}
// 处理数字输入,限制为数字
const handleNumberInput = (row: any, field: string) => {
// 只保留数字和小数点
row[field] = row[field].replace(/[^0-9.]/g, '')
// 确保只有一个小数点
const dotIndex = row[field].indexOf('.')
if (dotIndex !== -1 && row[field].lastIndexOf('.') !== dotIndex) {
row[field] = row[field].slice(0, row[field].lastIndexOf('.'))
row.status = true;
}
czList()
}
// 处理明细变化
const handleDetailChange = (row: any) => {
row.status = true;
czList()
}
// 输入框获得焦点
const handleInputFocus = () => {
isEditing.value = true
}
// 单元格样式类
const cellClassName = () => {
return 'no-edit-cell'
}
// 行点击事件,实现右侧联动
const handleRowClick = (row: any) => {
const { bglqdh, bglqmc, bz } = row
currentRule.value = row
row.originalData = JSON.parse(JSON.stringify(row));
getgzList(row)
}
const addgz = () => {
ruleList.value.unshift(
{
bglqdh: Math.max(...ruleList.value.map((item: any) => item.bglqdh), 0) + 1,
bglqmc: 'test',
bz: '',
status: true,
originalData: {},
addFlag: true
}
)
currentRule.value = ruleList.value[0]
detailList.value = [
{
bglqdh: Math.max(...ruleList.value.map((item: any) => item.bglqdh), 0),
weekday: '1',
weekday1: '2',
kssj: '09:00',
jssj: '18:00',
bglqsm: '领取声明',
bgxss: 1,
xh: detailList.value.length,
detaiFlag: true,
status: false
}
]
rptgetruledetail.value.push(...detailList.value)
}
const addDetail = () => {
detailList.value.push({
bglqdh: currentRule.value.bglqdh,
weekday: '1',
weekday1: '2',
kssj: '09:00',
jssj: '18:00',
bglqsm: '领取声明',
bgxss: 1,
xh: detailList.value.length + 1,
detaiFlag: false,
status: false
})
ruleList.value.forEach((item: any) => {
if (item.bglqdh == currentRule.value.bglqdh) {
item.status = true
}
});
rptgetruledetail.value.push(...detailList.value)
}
const editHandle = (row: any, field: string) => {
console.log('row==>', row, field);
ruleList.value.forEach((item: any) => {
if (item.bglqdh == row.bglqdh) {
item[field] = row[field]
item.status = JSON.stringify(row[field]) !== JSON.stringify(item.originalData[field]);
}
});
console.log('ruleList==>', ruleList.value);
czList()
}
const czList = () => {
ruleList.value.forEach((item: any) => {
if (item.bglqdh == currentRule.value.bglqdh) {
item.status = true
}
});
rptgetruledetail.value = rptgetruledetail.value.filter((item: any) => item.bglqdh !== currentRule.value.bglqdh)
rptgetruledetail.value.push(...detailList.value)
}
// 保存
const saveHandle = () => {
const addList = ruleList.value.filter((item: any) => item.addFlag)
const updateList = ruleList.value.filter((item: any) => item.status && !item.addFlag)
const addDetailList = rptgetruledetail.value.filter((item: any) => item.detaiFlag)
const upadteDetailList = rptgetruledetail.value.filter((item: any) => !item.detaiFlag)
// 保存成功后的回调处理
const handleSuccess = () => {
// 重置规则的新增/修改状态
ruleList.value.forEach(item => {
item.addFlag = false;
item.status = false;
});
// 重置明细的新增/修改状态
detailList.value.forEach(item => {
item.detaiFlag = false;
item.status = false;
});
ElMessage.success('保存成功');
};
if (updateList.length > 0) {
rptgetruleUpdate({ ruleList: updateList, ruleDetailList: upadteDetailList }).then((res: any) => {
if (res.code == 0) {
handleSuccess()
}
})
} if (addList.length > 0) {
rptgetruleadd({ ruleList: addList, ruleDetailList: addDetailList }).then((res: any) => {
if (res.code == 0) {
handleSuccess()
}
})
}
}
// 删除规则
const handleDelete = (row: any) => {
ElMessageBox.confirm(`确定删除该${row.bglqdh}吗?`, "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
beforeClose: (action, instance, done) => {
if (action === "confirm") {
const handleSueess = () => {
ruleList.value = ruleList.value.filter((item: any) => item.bglqdh !== row.bglqdh)
handleRowClick(ruleList.value[0])
done();
};
if (row.addFlag) {
handleSueess()
} else {
rptgetruleDel({ bglqdh: row.bglqdh }).then((res: any) => {
if (res.code == 0) {
ElMessage.success('删除成功');
handleSueess()
}
})
}
} else {
done();
}
},
}).catch(() => { });
};
// 删除规则明细
const delDetail = (row: any) => {
ElMessageBox.confirm(`确定删除该项数据吗?`, "提示", {
confirmButtonText: "确认",
cancelButtonText: "取消",
beforeClose: (action, instance, done) => {
if (action === "confirm") {
const handleSueess = () => {
detailList.value = detailList.value.filter((item: any) => item.xh !== row.xh)
done();
};
if (row.detaiFlag) {
handleSueess()
} else {
rptgetruleDelDetail({ bglqdh: row.bglqdh, xh: row.xh }).then((res: any) => {
if (res.code == 0) {
ElMessage.success('删除成功');
handleSueess()
}
})
}
} else {
done();
}
},
}).catch(() => { });
};
const getList = () => {
rptgetruleList().then((res: any) => {
if (res.code == 0) {
ruleList.value = res.data
ruleList.value.forEach((item: any) => {
item.originalData = {}
item.status = false
})
handleRowClick(ruleList.value[0])
getgzList(res.data[0])
}
})
}
const getgzList = (info: any) => {
if (info.status) {
detailList.value = rptgetruledetail.value.filter((item: any) => item.bglqdh == info.bglqdh)
} else {
rptgetruleDetail({ bglqdh: info.bglqdh }).then((res: any) => {
if (res.code == 0) {
detailList.value = res.data
}
})
}
}
getList()
// 初始化默认选中第一行
onMounted(() => {
})
// 替换原flag的定义,改为计算属性
const flag = computed(() => {
// 检查是否有新增规则
const hasNewRule = ruleList.value.some(item => item.addFlag);
// 检查是否有修改的规则
const hasUpdatedRule = ruleList.value.some(item => item.status);
// 检查是否有新增明细
const hasNewDetail = detailList.value.some(item => item.detaiFlag);
// 检查是否有修改的明细
const hasUpdatedDetail = detailList.value.some(item => item.status);
// 当存在任何新增或修改时,按钮可点击(返回false),否则禁用(返回true)
return !(hasNewRule || hasUpdatedRule || hasNewDetail || hasUpdatedDetail);
});
</script>
<style scoped>
.rule-management-container {
height: 90vh;
/* display: flex;
flex-direction: column; */
padding: 10px;
box-sizing: border-box;
/* background-color: #f0f2f5; */
}
.top-toolbar {
padding: 8px 15px;
background-color: #FFF;
border-radius: 4px;
margin-bottom: 10px;
}
/* ::v-deep .top-toolbar .el-button {
margin-right: 8px;
} */
.content-wrapper {
flex: 1;
display: flex;
gap: 10px;
height: calc(100% - 100px);
}
.left-table-area {
width: 50%;
background-color: #fff;
border: 1px solid #e6e6e6;
border-radius: 4px;
padding: 5px;
display: flex;
flex-direction: column;
}
.right-form-area {
width: 50%;
background-color: #e6f7ff;
border: 1px solid #91d5ff;
border-radius: 4px;
padding: 15px;
display: flex;
flex-direction: column;
}
.rule-form {
background-color: #fff;
padding: 15px;
border-radius: 4px;
border: 1px solid #d9d9d9;
margin-bottom: 15px;
}
.detail-table-header {
padding: 8px 0;
font-weight: 500;
color: #1890ff;
border-bottom: 1px solid #91d5ff;
margin-bottom: 5px;
}
::v-deep .custom-table th {
background-color: #f5f7fa;
}
::v-deep .detail-table th {
background-color: #f0faff;
}
::v-deep .week-select {
width: 100%;
}
::v-deep .el-table .el-table__cell {
padding: 5px 0;
}
::v-deep .el-input__inner {
padding: 5px 10px;
height: 32px;
}
/* 禁用单元格点击效果 */
/* ::v-deep .no-edit-cell {
pointer-events: none;
} */
/* 让输入框可以被点击 */
::v-deep .no-edit-cell .el-input,
::v-deep .no-edit-cell .el-select {
pointer-events: auto;
}
::v-deep .time-input,
::v-deep .number-input {
width: 100%;
}
::v-deep .statement-input {
width: 100%;
}
</style>