门诊采血修改
This commit is contained in:
parent
9b696abe46
commit
4f0433a134
@ -24,6 +24,7 @@
|
||||
"jquery": "^3.7.1",
|
||||
"js-beautify": "^1.14.11",
|
||||
"js-cookie": "3.0.5",
|
||||
"jsbarcode": "^3.12.1",
|
||||
"jsencrypt": "3.3.2",
|
||||
"nprogress": "0.2.0",
|
||||
"pinia": "2.1.7",
|
||||
@ -32,6 +33,7 @@
|
||||
"vue": "3.4.0",
|
||||
"vue-cropper": "1.1.1",
|
||||
"vue-router": "4.2.5",
|
||||
"vue3-print-nb": "^0.1.4",
|
||||
"vue3-select2-component": "^0.1.7",
|
||||
"vuedraggable": "^4.1.0"
|
||||
},
|
||||
|
||||
@ -8,7 +8,21 @@ export function querySQD(query) {
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询采样登记列表
|
||||
export function printBarcode(query) {
|
||||
return request({
|
||||
url: '/mzcx/printBarcode',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function printBarcodeall(data) {
|
||||
return request({
|
||||
url: '/mzcx/printBarcode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 查询采样登记详细
|
||||
export function getReqmain(sqh) {
|
||||
return request({
|
||||
|
||||
@ -48,7 +48,7 @@ import ImagePreview from "@/components/ImagePreview"
|
||||
import TreeSelect from '@/components/TreeSelect'
|
||||
// 字典标签组件
|
||||
import DictTag from '@/components/DictTag'
|
||||
|
||||
import Print from 'vue3-print-nb';
|
||||
const app = createApp(App)
|
||||
|
||||
// 全局方法挂载
|
||||
@ -74,7 +74,8 @@ app.component('Editor', Editor)
|
||||
|
||||
//VUE3标准方法注入全局方法
|
||||
app.provide('comDict', comDict);
|
||||
|
||||
app.use(Print); // 注册打印插件
|
||||
app.provide('$vuePrint', app.config.globalProperties.$vuePrint);
|
||||
app.use(router)
|
||||
app.use(store)
|
||||
app.use(plugins)
|
||||
|
||||
181
src/views/mzcx/cydj/components/BarcodePrinter.vue
Normal file
181
src/views/mzcx/cydj/components/BarcodePrinter.vue
Normal file
@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-button
|
||||
v-bind="$attrs"
|
||||
@click="handlePrint"
|
||||
>
|
||||
<template #content>
|
||||
<span v-if="$slots.default">{{ $slots.default() }}</span>
|
||||
<span v-else>打印条码</span>
|
||||
</template>
|
||||
</el-button>
|
||||
|
||||
<!-- 打印区域(隐藏) -->
|
||||
<div ref="printRef" id="printArea" v-show="false">
|
||||
<div class="print-container">
|
||||
<h3 v-if="printTitle">{{ printTitle }}</h3>
|
||||
<div
|
||||
v-for="(item, index) in printData"
|
||||
:key="index"
|
||||
class="barcode-label"
|
||||
>
|
||||
<div v-html="generateBarcodeSvg(item.sqh)"></div>
|
||||
<div class="barcode-info">
|
||||
<div v-if="showSqh">条码号:{{ item.sqh }}</div>
|
||||
<div v-if="showPatient">患者:{{ item.brxm }}</div>
|
||||
<div v-if="showItem">项目:{{ item.sqxmmc }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps, defineEmits } from 'vue';
|
||||
import JsBarcode from 'jsbarcode';
|
||||
|
||||
const props = defineProps({
|
||||
printData: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
printTitle: {
|
||||
type: String,
|
||||
default: '条码打印'
|
||||
},
|
||||
showSqh: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showPatient: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
showItem: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(['print-start', 'print-success', 'print-error']);
|
||||
const printRef = ref(null);
|
||||
|
||||
// 生成SVG条码
|
||||
const generateBarcodeSvg = (content) => {
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
||||
JsBarcode(svg, content, {
|
||||
format: 'CODE128C',
|
||||
displayValue: true,
|
||||
height: 30,
|
||||
width: 1,
|
||||
margin: 10,
|
||||
fontSize: 14
|
||||
});
|
||||
return new XMLSerializer().serializeToString(svg);
|
||||
};
|
||||
|
||||
// 处理打印(纯原生实现)
|
||||
const handlePrint = () => {
|
||||
if (props.disabled) return;
|
||||
|
||||
emits('print-start');
|
||||
|
||||
if (!props.printData || props.printData.length === 0) {
|
||||
emits('print-error', '没有可打印的数据');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 创建临时打印窗口
|
||||
const printWindow = window.open('', '_blank', 'width=800,height=600');
|
||||
if (!printWindow) {
|
||||
emits('print-error', '浏览器阻止了打印窗口,请允许弹窗后重试');
|
||||
return;
|
||||
}
|
||||
|
||||
// 准备打印内容
|
||||
const printContent = printRef.value.innerHTML;
|
||||
const printStyles = `
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; margin: 20px; }
|
||||
.print-container { text-align: center; }
|
||||
.barcode-label {
|
||||
display: inline-block;
|
||||
width: 200px;
|
||||
margin: 10px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
.barcode-info {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
@media print {
|
||||
@page { margin: 10mm; }
|
||||
body { margin: 0; }
|
||||
.no-print { display: none; }
|
||||
}
|
||||
</style>
|
||||
`;
|
||||
|
||||
// 写入打印窗口
|
||||
printWindow.document.write(`
|
||||
<html>
|
||||
<head>
|
||||
<title>${props.printTitle || '条码打印'}</title>
|
||||
${printStyles}
|
||||
</head>
|
||||
<body>
|
||||
<div class="print-container">
|
||||
${printContent}
|
||||
</div>
|
||||
<button class="no-print" onclick="window.print()">打印</button>
|
||||
<button class="no-print" onclick="window.close()">关闭</button>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
|
||||
// 打印并关闭
|
||||
printWindow.document.close();
|
||||
printWindow.onload = () => {
|
||||
// 自动触发打印
|
||||
printWindow.print();
|
||||
// 延迟关闭以允许用户取消打印
|
||||
setTimeout(() => printWindow.close(), 3000);
|
||||
};
|
||||
|
||||
emits('print-success');
|
||||
} catch (error) {
|
||||
emits('print-error', error.message || '打印失败');
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* 打印区域样式 */
|
||||
#printArea {
|
||||
.print-container {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.barcode-label {
|
||||
display: inline-block;
|
||||
width: 200px;
|
||||
padding: 15px;
|
||||
margin: 10px;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
.barcode-info {
|
||||
margin-top: 10px;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
633
src/views/mzcx/cydj/components/printtest.vue
Normal file
633
src/views/mzcx/cydj/components/printtest.vue
Normal file
@ -0,0 +1,633 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-row :gutter="5" class="compact-form" :span="24" >
|
||||
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-position="left" >
|
||||
<el-col :span="24" :xs="24">
|
||||
<el-form-item label="" label-width="0px" prop="brdh" >
|
||||
|
||||
<el-col :span="6">
|
||||
<div> 就诊卡号/病历号/磁卡号: </div>
|
||||
<el-input
|
||||
v-model="queryParams.brdh"
|
||||
placeholder="就诊卡号/病历号/磁卡号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<el-radio-group v-model="queryParams.zt" size="default">
|
||||
<el-radio v-for="(item, index) in showconfirmOptions" :key="index" :label="item.value"
|
||||
:disabled="item.disabled">{{item.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-col>
|
||||
<el-col :span="1"> <div> 申请获取期限: </div></el-col>
|
||||
<el-col :span="6">
|
||||
|
||||
<el-radio-group v-model="queryParams.subday" size="default">
|
||||
<el-radio v-for="(item, index) in subdayOptions" :key="index" :label="item.value"
|
||||
:disabled="item.disabled">{{item.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-col>
|
||||
<el-col :span="2">
|
||||
<el-select v-model="queryParams.cardtype" placeholder="卡类型" clearable :style="{width: '100%'}">
|
||||
<el-option v-for="(item, index) in cardtypeOptions" :key="index" :label="item.label"
|
||||
:value="item.value" :disabled="item.disabled"></el-option>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">读卡</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button icon="Refresh" @click="resetQuery">查找病人</el-button>
|
||||
</el-col>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="Search"
|
||||
@click="handleQuery"
|
||||
v-hasPermi="['system:reqmain:Search']"
|
||||
>查询</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Printer"
|
||||
:disabled="single"
|
||||
@click="printAll"
|
||||
v-hasPermi="['system:reqmain:add']"
|
||||
>打印</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="Printer"
|
||||
:disabled="freesingle"
|
||||
@click="printSigne"
|
||||
v-hasPermi="['system:reqmain:edit']"
|
||||
>单打条码</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Printer"
|
||||
:disabled="freesingle"
|
||||
@click="printBackpaper"
|
||||
v-hasPermi="['system:reqmain:edit']"
|
||||
>单打回单</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="Delete"
|
||||
@click="cancel"
|
||||
v-hasPermi="['system:reqmain:export']"
|
||||
>取消采样</el-button>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<barcode-printer
|
||||
:printData="printBarcodeData"
|
||||
:disabled="!hasSelectedRows"
|
||||
type="success"
|
||||
icon="Printer"
|
||||
@print-start="showLoading"
|
||||
@print-success="handlePrintSuccess"
|
||||
@print-error="handlePrintError"
|
||||
>
|
||||
打印条码
|
||||
</barcode-printer>
|
||||
</el-col>
|
||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table ref="tableRef" class="compact-form my-table" :data="reqmainList" @selection-change="handleSelectionChange" @select="handleSelect" height="530px" :cell-style="tableCellStyle">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="项目名称" align="center" prop="sqxmmc" width="200" show-overflow-tooltip/>
|
||||
<el-table-column label="项目代码" align="center" prop="sqxmdh" width="100" show-overflow-tooltip/>
|
||||
<el-table-column label="项目类别" align="center" prop="cp_xmlb" />
|
||||
<el-table-column label="样本类型" align="center" prop="yblx" />
|
||||
<el-table-column label="条码号" align="center" prop="sqh" width="150" show-overflow-tooltip/>
|
||||
<el-table-column label="申请时间" align="center" prop="sqsj" width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.sqsj, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="病人姓名" align="center" prop="brxm" show-overflow-tooltip/>
|
||||
<el-table-column label="申请医生" align="center" prop="sqys" :formatter="formatDict('SRD')" show-overflow-tooltip/>
|
||||
<el-table-column label="序号" align="center" prop="xh" show-overflow-tooltip/>
|
||||
<el-table-column label="数量" align="center" prop="sl" show-overflow-tooltip/>
|
||||
<el-table-column label="单价" align="center" prop="dj" show-overflow-tooltip/>
|
||||
<el-table-column label="状态" align="center" prop="zt" show-overflow-tooltip/>
|
||||
<el-table-column label="计价" align="center" prop="jjzt" >
|
||||
<template #default="scope">
|
||||
<el-checkbox :model-value="scope.row.jjzt === '1'" disabled>
|
||||
</el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="病人代号" align="center" prop="brdh" show-overflow-tooltip/>
|
||||
<el-table-column label="备注1" align="center" prop="detailBZ1" show-overflow-tooltip/>
|
||||
<el-table-column label="备注2" align="center" prop="detailBZ2" show-overflow-tooltip/>
|
||||
<el-table-column label="颜色" align="center" prop="cp_color" v-if="false" show-overflow-tooltip/>
|
||||
<el-table-column label="确认标识" align="center" prop="cp_cflag" v-if="false" show-overflow-tooltip/>
|
||||
<el-table-column label="科室" align="center" prop="ksdh" :formatter="formatDict('DP')" show-overflow-tooltip/>
|
||||
<el-table-column label="病人类型" align="center" prop="brly" :formatter="formatDict('PT')" show-overflow-tooltip/>
|
||||
<el-table-column label="性别" align="center" prop="brxb" :formatter="formatDict('SX')" show-overflow-tooltip/>
|
||||
<el-table-column label="生日" align="center" prop="brsr" width="180" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.brsr, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="床号" align="center" prop="ch" width="50" show-overflow-tooltip/>
|
||||
<el-table-column label="诊断" align="center" prop="zd" width="150" show-overflow-tooltip/>
|
||||
<el-table-column label="条码类别" align="center" prop="bgddh" v-if="false" show-overflow-tooltip/>
|
||||
<el-table-column label="年龄" align="center" prop="nl" show-overflow-tooltip/>
|
||||
<el-table-column label="年龄单位" align="center" prop="nldw" :formatter="formatDict('AU')" show-overflow-tooltip/>
|
||||
<el-table-column label="采样时间" align="center" prop="cysj" width="180"show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.cysj, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 汇总行 -->
|
||||
<div class="table-summary">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">条码数:</span>
|
||||
<span class="summary-value">{{ idsnew.length }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">项目数:</span>
|
||||
<span class="summary-value">{{ totalRows }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">合计金额:</span>
|
||||
<span class="summary-value">{{ totalPrice.toFixed(2) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ElMessage } from 'element-plus'; // 引入 Element Plus 消息组件
|
||||
import {querySQD, getReqmain, delReqmain, addReqmain, updateReqmain, printBarcode} from "@/api/mzcx/cydj.js";
|
||||
import BarcodePrinter from './components/BarcodePrinter.vue';
|
||||
const comDict = inject('comDict');
|
||||
// 字典数据存储
|
||||
const dictData = ref({});
|
||||
const tableRef = ref(null);
|
||||
const { proxy } = getCurrentInstance();
|
||||
// 选中的行
|
||||
const selectedRows = ref([]);
|
||||
const reqmainList = ref([]);
|
||||
const open = ref(false);
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
// 新增:计算属性,返回去重后的ids数组
|
||||
const idsnew = computed(() => {
|
||||
return [...new Set(ids.value)];
|
||||
});
|
||||
const single = ref(true);
|
||||
const freesingle = ref(true);
|
||||
const cardtypeOptions = ref([{"label": "就诊卡","value": 1},{"label": "医保卡","value": 2},{"label": "电子医保卡","value": 3},{"label": "身份证", "value": 4}])
|
||||
const showconfirmOptions = ref([{"label": "未打印", "value": 1},{"label": "已打印", "value": 11}])
|
||||
const subdayOptions = ref([{"label": "1天","value": 1},{"label": "3天", "value": 3},{"label": "1周","value": 7},{"label": "2周","value": 14},{"label": "1月", "value": 30},{"label": "3月", "value": 90},{"label": "1年","value": 365},{"label": "2年","value": 730}])
|
||||
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
brdh: null,
|
||||
stime: null,
|
||||
etime: null,
|
||||
klx: null,
|
||||
zt: 1,
|
||||
subday: 3000,
|
||||
cardtype:null
|
||||
},
|
||||
rules: {
|
||||
brdh: [
|
||||
{ required: true, message: "病人代码不能为空", trigger: "blur" }
|
||||
],
|
||||
subday: [],
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
// 标志位:是否是程序自动勾选(避免循环触发事件)
|
||||
const isAutoSelect = ref(false);
|
||||
|
||||
/**
|
||||
* 监听单选勾选/取消事件
|
||||
* @param {Array} selection 目前已选中的行
|
||||
* @param {Object} row 当前操作的行数据
|
||||
* @param {Boolean} selected 是否勾选(true=勾选,false=取消)
|
||||
*/
|
||||
const handleSelect = (selection, row, selected) => {
|
||||
if (isAutoSelect.value) return;
|
||||
|
||||
const targetSqh = row.sqh;
|
||||
const targetxh = row.xh;
|
||||
if (!targetSqh) return;
|
||||
|
||||
// 先收集需要自动勾选的行(避免在循环中修改数据)
|
||||
const rowsToSelect = reqmainList.value.filter(
|
||||
item => item.sqh === targetSqh && item.xh !== targetxh
|
||||
);
|
||||
|
||||
// 如果有需要自动勾选的行,才开启标志位
|
||||
if (rowsToSelect.length > 0) {
|
||||
|
||||
rowsToSelect.forEach(item => {
|
||||
tableRef.value.toggleRowSelection(item, selected);
|
||||
isAutoSelect.value = true;
|
||||
});
|
||||
setTimeout(() => isAutoSelect.value = false, 0);
|
||||
}
|
||||
};
|
||||
// 字典格式化方法
|
||||
const formatDict =(dictType) => {
|
||||
return (row, column, value) => {
|
||||
// 从全局字典中获取映射值
|
||||
return dictData.value[dictType].find(item => String(item.value) === String(value).trim())?.label||value ;
|
||||
};
|
||||
};
|
||||
// 定义“空数据”的判断函数
|
||||
const isEmptyData = (data) => {
|
||||
// 处理 null/undefined
|
||||
if (data === null || data === undefined) return true;
|
||||
// 处理空数组
|
||||
if (Array.isArray(data) && data.length === 0) return true;
|
||||
// 处理空对象(无任何属性)
|
||||
if (typeof data === 'object' && Object.keys(data).length === 0) return true;
|
||||
// 处理空字符串
|
||||
if (typeof data === 'string' && data.trim() === '') return true;
|
||||
return false;
|
||||
};
|
||||
/**
|
||||
* 获取指定天数偏移后的日期时间字符串
|
||||
* @param {number} days 偏移天数(正数表示未来,负数表示过去)
|
||||
* @returns {string} 格式化的日期时间字符串 'yyyy-mm-dd HH:MM:SS'
|
||||
*/
|
||||
function getDateOffset(days) {
|
||||
const now = new Date();
|
||||
const offsetTimestamp = now.getTime() + days * 24 * 60 * 60 * 1000;
|
||||
const targetDate = new Date(offsetTimestamp);
|
||||
|
||||
const year = targetDate.getFullYear();
|
||||
const month = String(targetDate.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(targetDate.getDate()).padStart(2, '0');
|
||||
// const hours = String(targetDate.getHours()).padStart(2, '0');
|
||||
// const minutes = String(targetDate.getMinutes()).padStart(2, '0');
|
||||
//const seconds = String(targetDate.getSeconds()).padStart(2, '0');
|
||||
// return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
return `${year}-${month}-${day} 00:00:00`;
|
||||
}
|
||||
function getSubday() {
|
||||
const days=0 - queryParams.value.subday;
|
||||
queryParams.value.stime=getDateOffset(days);
|
||||
queryParams.value.etime=getDateOffset(1);
|
||||
}
|
||||
/** 查询采样登记列表 */
|
||||
function getList() {
|
||||
|
||||
if(isEmptyData(queryParams.value.brdh)) proxy.$modal.alert("请刷卡或输入门诊号!");
|
||||
else {
|
||||
loading.value = true;
|
||||
getSubday();
|
||||
querySQD(queryParams.value).then(response => {
|
||||
if (isEmptyData(response.data)) proxy.$modal.alert("没有检索的数据!");
|
||||
reqmainList.value = response.data;
|
||||
loading.value = false;
|
||||
single.value=false;
|
||||
// 新增:数据加载完成后触发全选
|
||||
// 延迟执行(确保DOM已更新)
|
||||
setTimeout(() => {
|
||||
if (tableRef.value) {
|
||||
tableRef.value.toggleAllSelection(); // 调用全选方法
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
// open.value = false;
|
||||
// reset();
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
sqh: null,
|
||||
xh: null,
|
||||
sqxmdh: null,
|
||||
sqxmmc: null,
|
||||
sl: null,
|
||||
dj: null,
|
||||
detailZT: null,
|
||||
detailJJZT: null,
|
||||
ksdh: null,
|
||||
sqys: null,
|
||||
sqsj: null,
|
||||
jsys: null,
|
||||
jssj: null,
|
||||
brly: null,
|
||||
brdh: null,
|
||||
brxm: null,
|
||||
zt: null,
|
||||
jjzt: null,
|
||||
brxb: null,
|
||||
brsr: null,
|
||||
jzbz: null,
|
||||
cp_xmlb: null,
|
||||
cp_color: null,
|
||||
cp_cflag: null,
|
||||
detailBZ1: null,
|
||||
ch: null,
|
||||
detailBZ2: null,
|
||||
bz1: null,
|
||||
bz2: null,
|
||||
bz3: null,
|
||||
yblx: null,
|
||||
zxys: null,
|
||||
zxsj: null,
|
||||
bgddh: null,
|
||||
nl: null,
|
||||
nldw: null,
|
||||
zd: null,
|
||||
cysj: null
|
||||
};
|
||||
freesingle.value=false;
|
||||
single.value=false;
|
||||
proxy.resetForm("reqmainRef");
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
if (isAutoSelect.value) return;
|
||||
selectedRows.value = selection;
|
||||
ids.value = selection.map(item => item.sqh);
|
||||
//console.log('ids:', ids.value);
|
||||
// console.log('selectedRows:', selectedRows.value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 打印选择 */
|
||||
function printAll(row) {
|
||||
console.log('idsnew:', idsnew.value);
|
||||
if (idsnew.value.length=== 0) {
|
||||
return;
|
||||
}
|
||||
printBarcode({sqh:"20221201167919"}).then(response => {
|
||||
proxy.$modal.msgSuccess("打印成功");
|
||||
open.value = false;
|
||||
freesingle.value=false;
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
/** 单打条码*/
|
||||
function printSigne(row) {
|
||||
if (idsnew.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
apiprintAll(idsnew.value).then(response => {
|
||||
proxy.$modal.msgSuccess("打印成功");
|
||||
open.value = false;
|
||||
freesingle.value=false;
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/** 打印回单 */
|
||||
function printBackpaper(row) {
|
||||
if (idsnew.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
apiprintAll(idsnew.value).then(response => {
|
||||
proxy.$modal.msgSuccess("打印成功");
|
||||
open.value = false;
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const totalRows = computed(() => {
|
||||
return reqmainList.value.length || 0;
|
||||
});
|
||||
|
||||
const totalPrice = computed(() => {
|
||||
return reqmainList.value.reduce((sum, row) => {
|
||||
const price = parseFloat(row.dj) || 0;
|
||||
return sum + price;
|
||||
}, 0);
|
||||
});
|
||||
|
||||
|
||||
// 组件挂载时加载字典
|
||||
onMounted(async () => {
|
||||
// 加载病人来源字典
|
||||
const dictRefs = await comDict('PT', 'DP', 'SRD','BT','SX','AU');
|
||||
// 从 ref 中获取实际数据
|
||||
dictData.value = {
|
||||
PT: toRaw(dictRefs.PT.value) || [],
|
||||
DP: toRaw(dictRefs.DP.value) || [],
|
||||
SRD: toRaw(dictRefs.SRD.value) || [],
|
||||
BT: toRaw(dictRefs.BT.value) || [],
|
||||
SX: toRaw(dictRefs.SX.value) || [],
|
||||
AU: toRaw(dictRefs.AU.value) || []
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 表格单元格样式(仅作用于“项目类别”列)
|
||||
const tableCellStyle = ({ row, column }) => {
|
||||
// 只对“项目类别”列生效
|
||||
if (column.label === '项目类别') {
|
||||
// 1. 转换颜色(十进制→十六进制)
|
||||
const bgColor = decimalToHexColor(row.cp_color);
|
||||
// 2. 自动计算文字颜色(确保和背景色对比度足够)
|
||||
const textColor = getContrastTextColor(bgColor);
|
||||
|
||||
return {
|
||||
backgroundColor: bgColor, // 背景色(转换后的值)
|
||||
color: textColor, // 文字色(自动适配)
|
||||
textAlign: 'center', // 文字居中
|
||||
fontWeight: '500' // 文字加粗(提升可读性)
|
||||
};
|
||||
}
|
||||
return {}; // 其他列保持默认样式
|
||||
};
|
||||
|
||||
// 十进制颜色值转十六进制颜色码(适配BGR转RGB)
|
||||
const decimalToHexColor = (decimal) => {
|
||||
if (!decimal && decimal !== 0) return '#FFFFFF'; // 空值默认白色
|
||||
|
||||
// 1. 十进制转十六进制(去除前缀0x,大写)
|
||||
let hex = parseInt(decimal, 10).toString(16).toUpperCase();
|
||||
|
||||
// 2. 不足6位则前面补0(确保是6位)
|
||||
if (hex.length < 6) {
|
||||
hex = hex.padStart(6, '0'); // 例如:192→"C0"→补0为"0000C0"
|
||||
}
|
||||
|
||||
// 3. BGR转RGB(反转字节顺序:前两位和后两位交换)
|
||||
// 例:80FFFF → 拆分为80、FF、FF → 反转后FF、FF、80 → FFFF80
|
||||
const r = hex.substring(4, 6); // 取后两位
|
||||
const g = hex.substring(2, 4); // 取中间两位
|
||||
const b = hex.substring(0, 2); // 取前两位
|
||||
const rgbHex = r + g + b;
|
||||
|
||||
return `#${rgbHex}`; // 最终颜色码
|
||||
};
|
||||
// 辅助函数:根据背景色计算文字颜色(黑/白)
|
||||
const getContrastTextColor = (bgColor) => {
|
||||
// 提取RGB值(如#FFFF80 → R=255, G=255, B=128)
|
||||
const r = parseInt(bgColor.slice(1, 3), 16);
|
||||
const g = parseInt(bgColor.slice(3, 5), 16);
|
||||
const b = parseInt(bgColor.slice(5, 7), 16);
|
||||
|
||||
// 计算亮度(标准公式)
|
||||
const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
||||
// 亮度>0.5用黑色,否则用白色(确保清晰)
|
||||
return luminance > 0.5 ? '#333333' : '#FFFFFF';
|
||||
};
|
||||
|
||||
// 计算属性:检查是否有选中的行
|
||||
const hasSelectedRows = computed(() => selectedRows.value.length > 0);
|
||||
|
||||
// 计算属性:准备打印数据
|
||||
const printBarcodeData = computed(() => {
|
||||
return selectedRows.value.map(row => ({
|
||||
sqh: row.sqh,
|
||||
brxm: row.brxm || '未知患者',
|
||||
sqxmmc: row.sqxmmc || '未知项目',
|
||||
svg: '' // 将在子组件中生成
|
||||
}));
|
||||
});
|
||||
|
||||
// 处理打印事件
|
||||
const showLoading = () => {
|
||||
ElMessage({
|
||||
message: '正在准备打印...',
|
||||
type: 'loading',
|
||||
duration: 0
|
||||
});
|
||||
};
|
||||
|
||||
const handlePrintSuccess = () => {
|
||||
ElMessage.success('打印已发送至打印机');
|
||||
};
|
||||
|
||||
const handlePrintError = (errorMsg) => {
|
||||
ElMessage.error(errorMsg || '打印失败');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.compact-form .el-form-item {
|
||||
padding: 5px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.compact-form .el-form-item__label {
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
::v-deep .my-table .el-table__row td {
|
||||
padding: 1px 0; /* 减小行高 */
|
||||
}
|
||||
::v-deep .my-table .el-table__header-wrapper th {
|
||||
padding: 6px 0; /* 表头内边距 */
|
||||
background-color: #b3d8ff !important; /* 表头背景色(保留之前的设置) */
|
||||
color: #333; /* 文字颜色加深,提升可读性 */
|
||||
font-weight: 500; /* 文字加粗 */
|
||||
}
|
||||
::v-deep .my-table .el-table__cell {
|
||||
padding: 0 2px; /* 减小列间距 */
|
||||
}
|
||||
|
||||
/* 可选:调整表格整体样式 */
|
||||
::v-deep .my-table {
|
||||
font-size: 13px; /* 适当减小字体 */
|
||||
}
|
||||
|
||||
::v-deep .my-table .el-table__cell,
|
||||
::v-deep .my-table .el-table__header-wrapper th {
|
||||
border-width: 1px;
|
||||
border-color: #ebeef5;
|
||||
}
|
||||
.card-content {
|
||||
max-height: 450px; /* 设置最大高度 */
|
||||
overflow-y: auto; /* 超出高度时显示垂直滚动条 */
|
||||
padding: 5px; /* 保持与卡片默认一致的内边距 */
|
||||
}
|
||||
.clickable:hover {
|
||||
cursor: pointer; /* 鼠标悬停时显示手型 */
|
||||
transition: all 0.3s; /* 平滑过渡效果 */
|
||||
color: blue;
|
||||
|
||||
}
|
||||
/* 汇总行样式 */
|
||||
.table-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 6px 16px;
|
||||
margin-top: 8px;
|
||||
background-color: #f5f7fa;
|
||||
border: 1px solid #ebeef5;
|
||||
border-radius: 4px;
|
||||
font-weight: 500;
|
||||
line-height: 24px; /* 汇总行文字行高 */
|
||||
.summary-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 24px;
|
||||
|
||||
.summary-label {
|
||||
color: #606266;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
color: #303133;
|
||||
min-width: 40px;
|
||||
text-align: left;/* 核心:数值左对齐 */
|
||||
}
|
||||
/* 单独设置"单价合计"的值为红色 */
|
||||
&:nth-child(3) .summary-value {
|
||||
color: #f56c6c; /* Element UI 红色主题色 */
|
||||
font-weight: 600; /* 可选:加粗字体 */
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -164,7 +164,15 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { querySQD, getReqmain, delReqmain, addReqmain, updateReqmain } from "@/api/mzcx/cydj.js";
|
||||
import {
|
||||
querySQD,
|
||||
getReqmain,
|
||||
delReqmain,
|
||||
addReqmain,
|
||||
updateReqmain,
|
||||
printBarcode,
|
||||
printBarcodeall
|
||||
} from "@/api/mzcx/cydj.js";
|
||||
const comDict = inject('comDict');
|
||||
// 字典数据存储
|
||||
const dictData = ref({});
|
||||
@ -385,7 +393,7 @@ function printAll(row) {
|
||||
if (idsnew.value.length=== 0) {
|
||||
return;
|
||||
}
|
||||
apiprintAll(idsnew.value).then(response => {
|
||||
printBarcodeall(idsnew.value).then(response => {
|
||||
proxy.$modal.msgSuccess("打印成功");
|
||||
open.value = false;
|
||||
freesingle.value=false;
|
||||
@ -500,6 +508,7 @@ const getContrastTextColor = (bgColor) => {
|
||||
// 亮度>0.5用黑色,否则用白色(确保清晰)
|
||||
return luminance > 0.5 ? '#333333' : '#FFFFFF';
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user