2 Commits

Author SHA1 Message Date
luobinjie 6130e1e899 Merge branch 'master' of http://140.143.162.39:3000/shentun/peisweb 4 months ago
luobinjie cad7af85f1 报表 4 months ago
  1. 178
      src/utlis/Export3Excel.js
  2. 13
      src/views/basic-dictionary/ApplicableGender.vue
  3. 23
      src/views/basic-dictionary/CharacterCategories.vue
  4. 23
      src/views/basic-dictionary/CommonCharacters.vue
  5. 21
      src/views/basic-dictionary/CustomerOrgType.vue
  6. 23
      src/views/basic-dictionary/DiagnosisLevel.vue
  7. 23
      src/views/basic-dictionary/DiagnosisPostfix.vue
  8. 23
      src/views/basic-dictionary/DiseaseScreening.vue
  9. 17
      src/views/basic-dictionary/GuideType.vue
  10. 22
      src/views/basic-dictionary/ItemDefaultResult.vue
  11. 19
      src/views/basic-dictionary/MaritalStatus.vue
  12. 20
      src/views/basic-dictionary/MedicalConclusion.vue
  13. 20
      src/views/basic-dictionary/MedicalConclusionType.vue
  14. 22
      src/views/basic-dictionary/MedicalReportType.vue
  15. 15
      src/views/basic-dictionary/ResultStatus.vue
  16. 13
      src/views/basic-dictionary/Sex.vue
  17. 4
      src/views/customerReport/personnelPositive.vue

178
src/utlis/Export3Excel.js

@ -0,0 +1,178 @@
import * as XLSX from 'xlsx';
import XLSXStyle from 'xlsx-style';
import { saveAs } from 'file-saver';
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
// 根据dom导出表格
export function exportToExcel(idSelector, fileName, isNew, list, titleNum = 1) {
let table = document.querySelector(idSelector).cloneNode(true);
// 因为element-ui的表格的fixed属性导致多出一个table,会下载重复内容,这里删除掉
if (table.querySelector('.el-table__fixed-right')) {
table.removeChild(table.querySelector('.el-table__fixed-right'));
}
if (table.querySelector('.el-table__fixed')) {
table.removeChild(table.querySelector('.el-table__fixed'));
}
// 直接从DOM中提取表格数据,而不是转换整个表格
const rows = [];
const tableRows = table.querySelectorAll('tr');
tableRows.forEach((tr, rowIndex) => {
const row = [];
const cells = tr.querySelectorAll('th, td');
cells.forEach((cell, cellIndex) => {
let cellValue = '';
// 检测包含多个div的单元格(这通常表示有多行内容)
const divs = cell.querySelectorAll('div');
if (divs.length > 0) {
// 将多个div的内容用\r\n连接(这是Excel兼容的换行符)
const divContents = Array.from(divs).map(div => div.textContent.trim());
cellValue = divContents.join('\r\n').replace(/^.*\r\n/, "").replace(/\r\n?$/, '');
} else {
// 否则直接获取文本内容
cellValue = cell.innerText || cell.textContent;
// 清理多余的空白字符,但保留换行符
cellValue = cellValue
.replace(/\s+/g, (match) => match.includes('\n') ? '\n' : ' ')
.trim();
// 确保换行符是Excel兼容的格式
cellValue = cellValue.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n');
}
row.push(cellValue);
});
rows.push(row);
});
// 使用XLSX.utils.aoa_to_sheet(数组到工作表)而不是从DOM转换
const ws = XLSX.utils.aoa_to_sheet(rows);
// 为包含换行符的单元格设置wrapText: true样式
const range = XLSX.utils.decode_range(ws['!ref']);
for (let R = range.s.r; R <= range.e.r; ++R) {
for (let C = range.s.c; C <= range.e.c; ++C) {
const cell_address = XLSX.utils.encode_cell({ c: C, r: R });
const cell = ws[cell_address];
if (cell && typeof cell.v === 'string' && cell.v.includes('\r\n')) {
// 设置单元格样式以支持文本换行
if (!cell.s) cell.s = {};
cell.s = {
alignment: {
wrapText: true, // 启用自动换行
vertical: 'center', // 垂直居中对齐
horizontal: 'left' // 水平左对齐
}
};
// 确保单元格类型为字符串类型,以支持换行
cell.t = 's';
}
}
}
// 创建工作簿并添加工作表
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
// 计算列宽
let cWidth = [];
for (let C = range.s.c; C <= range.e.c; ++C) {
let len = 100; //默认列宽
let len_max = 400; //最大列宽
for (let R = range.s.r; R <= range.e.r; ++R) {
const cell_address = XLSX.utils.encode_cell({ c: C, r: R });
const cell = ws[cell_address];
if (cell) {
// 动态自适应:计算列宽
let va = cell.v;
// 确保va是字符串类型再进行处理
if (typeof va === 'string') {
// 替换回车符为换行符进行计算 - 统一使用 \n 计算宽度
va = va.replace(/\r\n/g, '\n');
var card1 = va.match(/[\u4e00-\u9fa5]/g); //匹配中文
var card11 = "";
if (card1) {
card11 = card1.join("");
}
var card2 = va.replace(/([^\u0000-\u00FF])/g, ""); //剔除中文
let st = 0;
if (card11) {
// st += card11.length * 16 //中文字节码长度
st += card11.length * 20 //中文字节码长度
}
if (card2) {
// st += card2.length * 8 //非中文字节码长度
st += card2.length * 10 //非中文字节码长度
}
if (st > len) {
len = st;
}
}
}
}
if (len > len_max) { //最大宽度
len = len_max;
}
cWidth.push({ 'wpx': len }); //列宽
}
ws['!cols'] = cWidth;
// 根据内容行数调整行高,以适应多行文本
const rowHeights = [];
for (let R = range.s.r; R <= range.e.r; ++R) {
let maxLineCount = 1; // 默认一行
for (let C = range.s.c; C <= range.e.c; ++C) {
const cell_address = XLSX.utils.encode_cell({ c: C, r: R });
const cell = ws[cell_address];
if (cell && typeof cell.v === 'string') {
// 统一使用 \n 计算行数,因为原始内容使用 \n 作为换行符
const lineCount = (cell.v.replace(/\r\n/g, '\n').match(/\n/g) || []).length + 1;
if (lineCount > maxLineCount) {
maxLineCount = lineCount;
}
}
}
// 如果有多行内容,设置更大的行高
if (maxLineCount > 1) {
rowHeights[R] = { hpt: maxLineCount * 18 }; // 每行18磅高度,给换行留出更多空间
}
}
ws['!rows'] = rowHeights;
// 检查是否可以使用xlsx-style,否则使用标准xlsx
let wbout;
try {
// 尝试使用xlsx-style(如果已安装)
if (typeof XLSXStyle !== 'undefined' && XLSXStyle && XLSXStyle.write) {
wbout = XLSXStyle.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true });
} else {
// 如果xlsx-style不可用,使用标准xlsx并设置参数以支持样式
wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true });
}
} catch (e) {
// 如果xlsx-style失败,回退到标准xlsx
wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: false, type: 'binary', cellStyles: true });
}
try {
saveAs(new Blob([s2ab(wbout)], { type: '' }), `${fileName}.xlsx`)
} catch (e) {
if (typeof console !== 'undefined') {
console.log(e, wbout)
}
}
return wbout
}

13
src/views/basic-dictionary/ApplicableGender.vue

@ -38,6 +38,7 @@
border:stripe="true"
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
>
@ -182,6 +183,8 @@ export default {
initTableData: [],
department: "",
quckDepartment: [],
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -202,7 +205,17 @@ export default {
.catch((_) => {});
},
rowick(row) {
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.form = row;
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.form = row;
this.eddte();
},
remoteMethodes(keyWords) {
if (keyWords) {

23
src/views/basic-dictionary/CharacterCategories.vue

@ -37,6 +37,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
ref="tableData"
@ -222,7 +223,9 @@ export default {
initTableData: [],
curRow: {},
department:"",
quckDepartment:[]
quckDepartment:[],
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -237,13 +240,17 @@ export default {
methods: {
//id
rowick(row) {
this.curRow = { ...row };
// listsid(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// // this.form = res.data;
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.edlits();
},
remoteMethodes(keyWords) {
if (keyWords) {

23
src/views/basic-dictionary/CommonCharacters.vue

@ -62,6 +62,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
:height="
window.pageHeight < 600 ? 450 : window.pageHeight - 130
@ -305,7 +306,9 @@ export default {
value: "id",
children: "treeChildren",
}, //
commonCharTypeId:""
commonCharTypeId:"",
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -328,13 +331,17 @@ export default {
},
//id
rowick(row) {
this.curRow = { ...row };
// listsid(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// // this.form = res.data;
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.edlits();
},
remoteMethodes(keyWords) {
if (keyWords) {

21
src/views/basic-dictionary/CustomerOrgType.vue

@ -16,6 +16,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
@ -214,6 +215,8 @@ export default {
dialogVisible: false,
title: 1,
curRow: {},
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -403,13 +406,17 @@ export default {
},
//id
rowick(row) {
// Containerid(row.id).then((res) => {
// console.log(res);
// this.form = res.data;
// });
// console.log(row);
// this.form = row;
this.curRow = { ...row };
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
getlist() {
serviceist().then((res) => {

23
src/views/basic-dictionary/DiagnosisLevel.vue

@ -16,6 +16,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
>
@ -198,6 +199,8 @@ export default {
},
isshow: true,
curRow: {},
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -390,15 +393,17 @@ export default {
},
//id
rowick(row) {
this.curRow = { ...row };
// diagnosisid(row.id).then((res) => {
// // console.log(res);
// // this.form = res.data;
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// });
// console.log(row);
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
getlist() {
diagsislist().then((res) => {

23
src/views/basic-dictionary/DiagnosisPostfix.vue

@ -36,6 +36,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
ref="tableData"
@ -235,7 +236,9 @@ export default {
initTableData: [],
curRow: {},
department:"",
quckDepartment:[]
quckDepartment:[],
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -250,13 +253,17 @@ export default {
methods: {
//id
rowick(row) {
this.curRow = { ...row };
// querysuffix(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// // this.form = res.data;
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
remoteMethodes(keyWords) {
if (keyWords) {

23
src/views/basic-dictionary/DiseaseScreening.vue

@ -37,6 +37,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
ref="tableData"
@ -228,7 +229,9 @@ export default {
initTableData: [],
curRow: {},
department:"",
quckDepartment:[]
quckDepartment:[],
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -243,13 +246,17 @@ export default {
methods: {
//id
rowick(row) {
this.curRow = { ...row };
// listsid(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// // this.form = res.data;
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.edlits();
},
remoteMethodes(keyWords) {
if (keyWords) {

17
src/views/basic-dictionary/GuideType.vue

@ -39,6 +39,7 @@
class="el-table__body-wrapper tbody"
border:stripe="true"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
id="table"
@ -353,7 +354,9 @@ export default {
tgetid: "",
},
department:"",
quckDepartment:[]
quckDepartment:[],
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -370,7 +373,17 @@ export default {
this.getlists();
},
rowick(row) {
this.curRow = { ...row };
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editandmofin();
},
handleSizeChange(val) {
this.pages.MaxResultCount = val;

22
src/views/basic-dictionary/ItemDefaultResult.vue

@ -16,6 +16,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
>
@ -190,7 +191,9 @@ export default {
form: {
displayName: "",
},
curRow:{}
curRow:{},
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -387,12 +390,17 @@ export default {
},
//id
rowick(row) {
this.curRow=row
// projecresutid(row.id).then((res) => {
// // console.log(res);
// // this.form = res.data;
// this.curRow={...res.data}
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
getlist() {
projectresultlist().then((res) => {

19
src/views/basic-dictionary/MaritalStatus.vue

@ -36,6 +36,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
highlight-current-row
ref="tableData"
@ -172,7 +173,9 @@ export default {
initTableData: [],
department: "",
quckDepartment: [],
curRow:{}
curRow:{},
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -186,11 +189,17 @@ export default {
},
methods: {
rowick(row) {
// commonid(row.id).then((res) => {
// console.log(res);
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = {...row};
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editreport();
},
remoteMethodes(keyWords) {
if (keyWords) {

20
src/views/basic-dictionary/MedicalConclusion.vue

@ -16,6 +16,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowclick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
>
@ -254,6 +255,8 @@ export default {
initTableData: [],
item: {},
curRow: {},
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -448,12 +451,17 @@ export default {
},
//id
rowclick(row) {
this.curRow = { ...row };
// quersmedicalid(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...res.data };
// }
// });
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
change(v) {
this.selars = v;

20
src/views/basic-dictionary/MedicalConclusionType.vue

@ -36,6 +36,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowick"
@row-dblclick="dblClick"
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
highlight-current-row
ref="tableData"
@ -222,6 +223,8 @@ export default {
tableData: [],
initTableData: [],
curRow: {},
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -361,12 +364,17 @@ export default {
},
//id
rowick(row) {
// queryconclusionid(row.id).then((res) => {
// this.form = res.data;
// });
this.curRow = row;
// this.form = row;
// console.log(row);
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
//
addoredit() {

22
src/views/basic-dictionary/MedicalReportType.vue

@ -38,6 +38,7 @@
class="el-table__body-wrapper tbody"
border:stripe="true"
@row-click="rowick"
@row-dblclick="dblClick"
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
highlight-current-row
ref="tableData"
@ -270,7 +271,9 @@ export default {
initTableData: [],
curRow: {},
department:"",
quckDepartment:[]
quckDepartment:[],
clickTime1: 0,
clickTime2: 0,
};
},
created() {
@ -285,12 +288,17 @@ export default {
methods: {
//id
rowick(row) {
// querids(row.id).then((res) => {
// if(res.code!=-1){
// this.curRow = { ...row };
// }
// });
this.curRow = { ...row };
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = { ...row };
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editreport();
},
handleSizeChange(val) {
this.pages.MaxResultCount = val;

15
src/views/basic-dictionary/ResultStatus.vue

@ -14,6 +14,7 @@
row-key="id"
class="el-table__body-wrapper tbody"
@row-click="rowclick"
@row-dblclick="dblClick"
highlight-current-row
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
ref="tableData"
@ -355,6 +356,8 @@ export default {
{ required: true, message: "请输入数据录入字体色", trigger: "blur" },
],
},
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -433,7 +436,17 @@ export default {
return "#" + temp.substring(temp.length - 6, temp.length);
},
rowclick(row) {
this.curRow = { ...row };
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.curRow = {...row};
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.curRow = {...row};
this.editpopup();
},
haxadecimal() {
let str = this.form.dataInputFontColor;

13
src/views/basic-dictionary/Sex.vue

@ -38,6 +38,7 @@
border:stripe="true"
:height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
@row-click="rowick"
@row-dblclick="dblClick"
highlight-current-row
ref="tableData"
>
@ -183,6 +184,8 @@ export default {
initTableData: [],
department: "",
quckDepartment: [],
clickTime1: 0,
clickTime2: 0
};
},
created() {
@ -203,7 +206,17 @@ export default {
.catch((_) => {});
},
rowick(row) {
this.clickTime1 = new Date().getTime();
setTimeout(() => {
if (this.clickTime1 > this.clickTime2) {
this.form = row;
}
}, 400);
},
dblClick(row) {
this.clickTime2 = new Date().getTime();
this.form = row;
this.eddte();
},
remoteMethodes(keyWords) {
if (keyWords) {

4
src/views/customerReport/personnelPositive.vue

@ -123,7 +123,7 @@ import {
tcdate,
} from "@/utlis/proFunc";
import CusOrgOCX from "../../components/report/CusOrgOCX.vue";
import { exportToExcel } from "../../utlis/Export2Excel";
import { exportToExcel } from "../../utlis/Export3Excel";
import html2canvas from "html2canvas";
import printJs from "print-js";
@ -337,7 +337,7 @@ export default {
});
},
handleExport() {
exportToExcel("#table", "人员阳性结果清单", false);
exportToExcel("#table", "人员阳性结果清单"+moment(new Date()).format("yyyyMMDDHHmmss"), false);
},
},

Loading…
Cancel
Save