From 2e0b76ed895ac774e2f638434e5440ca7e071739 Mon Sep 17 00:00:00 2001 From: shidongli Date: Wed, 10 Jul 2024 10:41:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9F=A5=E8=AF=86=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/manage/propaganda/index.vue | 819 +++++++++++++++++++++----- src/views/manage/script/index.vue | 70 +-- src/views/manage/template/index.vue | 4 +- 3 files changed, 722 insertions(+), 171 deletions(-) diff --git a/src/views/manage/propaganda/index.vue b/src/views/manage/propaganda/index.vue index 826f43e..4b88cfd 100644 --- a/src/views/manage/propaganda/index.vue +++ b/src/views/manage/propaganda/index.vue @@ -2,25 +2,55 @@
- +
- + - + - - + - - + + @@ -32,8 +62,16 @@ --> - - + + - 搜索 - 重置 + 搜索 + 重置
- 新增 + v-hasPermi="['manage:propaganda:add']" + >新增 + 导入 - +
- + - - + + - + - - + + - - - - + + + + @@ -367,9 +808,13 @@ import stationAcatar from "../../system/stationAvatar/index.vue"; import Editorxj from "../../system/Editorxj/index.vue"; import { department, listDisease } from "@/api/manage/script"; import DepartmentList from '../../components/DepartmentList.vue' +import propagandaexport from '@/views/manage/components/propagandaexport.vue' + +import { copyBaselnfo } from "@/api/system/exportinfo"; + export default { name: "Propaganda", - components: { stationAcatar, Editorxj, DepartmentList }, + components: { stationAcatar, Editorxj, DepartmentList, propagandaexport }, data() { //验证身份证 var isimgPath = (rule, value, callback) => { @@ -380,6 +825,9 @@ export default { } }; return { + // 导入弹框 + innerexport: false, + exportlist: [], maxLength: 20000, departmentName: null, diseaseTypeName: null, @@ -536,6 +984,8 @@ export default { mounted() { this.getMaxTableHeight() this.screenChange() + + }, computed: { pickerStartTime() { @@ -566,6 +1016,41 @@ export default { watch: { }, methods: { + submit(e) { + this.exportlist = e + + }, + // 导入确定按钮 + submitexport() { + var obj = { + departmentId: this.queryParams.departmentId, + departmentName: this.departmentName, + type: 'MESSAGE', + sourceTemplateIds: this.exportlist, + } + copyBaselnfo(obj).then(response => { + this.$modal.msgSuccess("导入成功"); + this.innerexport = false + this.$refs.DepartmentList.Departmentlist() + this.getList(); + }); + }, + // 导入按钮 + handleUpload() { + if (this.queryParams.departmentId) { + this.innerexport = true + if (this.exportlist.length > 0) { + this.$refs.childComponent.resetTable(); + } + this.Nameinfo = this.departmentName + } else { + this.$modal.msgError("请先选择左侧科室"); + } + }, + // 弹框取消 + exportcancel() { + this.innerexport = false + }, //接收科室列表传值 clickdepartment(item) { this.queryParams.hospitalAgencyId = item.hospitalAgencyId @@ -578,14 +1063,71 @@ export default { } this.$forceUpdate() }, - checkContentLength() { - if (this.form.propagandaContent.length - 7 > this.maxLength) { - this.$message({ - type: "error", - message: "已达到最大输入长度" - }); - } + // checkContentLength() { + // const regex = /^.{0,20000}$/; // 正则表达式,匹配最多2万个字符 + // if (!regex.test(this.form.propagandaContent)) { + // this.$message({ + // type: "error", + // message: "已达到最大输入长度" + // }); + // // this.errorMessage = '输入字符数不能超过2万个。'; + // } else { + // this.form.propagandaContent= null; + // } + // }, + + checkContentLength(event) { + // console.log(event, "kkkkk") + + // event.preventDefault(); + + + // 自定义处理逻辑,例如只获取纯文本 + // const text = event.clipboardData.getData('text'); + // if (text) { + // document.execCommand('insertText', false, text); + // } + + // e.preventDefault(); + // console.log(this.form.propagandaContent.length - 7, '0000000000') + // if (this.form.propagandaContent.length - 7 > this.maxLength) { + // this.$message({ + // type: "error", + // message: "已达到最大输入长度" + // }); + // } + // const file = event.target.files[0]; + // this.compressImage(event) + // .then(compressedBlob => { + // this.imageUrl = URL.createObjectURL(compressedBlob); + // }) + // .catch(error => { + // console.error('Error compressing image:', error); + // });}, + // compressImage(event) { + // return new Promise((resolve, reject) => { + // const reader = new FileReader(); + // reader.onload = event => { + // const img = new Image(); + // img.onload = () => { + // const canvas = document.createElement('canvas'); + // const ctx = canvas.getContext('2d'); + // const maxWidth = 800; + // const scale = Math.min(maxWidth / img.width, 1); + // canvas.width = img.width * scale; + // canvas.height = img.height * scale; + // ctx.drawImage(img, 0, 0, canvas.width, canvas.height); + // canvas.toBlob(resolve, 'image/jpeg', 0.7); + // }; + // img.src = event.target.result; + // }; + // reader.readAsDataURL(file); + // }); + + + }, + //获取医院list selectAgencyinfo() { let query = { @@ -789,7 +1331,7 @@ export default { }, // 科室名称圆点按钮 nurseclick(row) { - this.form.departmentId = row.departmentCode; + this.form.departmentId = row.id; this.form.departmentName = row.departmentName; this.departmentName = row.departmentName; this.form.diseaseTypeId = ''; @@ -932,9 +1474,10 @@ export default { }, /** 提交按钮 */ submitForm() { + console.log(this.form, 'this.form') this.form.hospitalAgencyId = this.queryParams.hospitalAgencyId this.form.hospitalAgencyName = this.queryParams.hospitalAgencyName - if (this.form.propagandaContent && this.form.propagandaContent.length - 7 > this.maxLength) { + if (this.form.propagandaContent && (this.form.propagandaContent.length - 7 > this.maxLength)) { // if (this.form.propagandaContent.length - 7 > this.maxLength) { this.$message({ type: "error", @@ -1015,6 +1558,8 @@ export default { this.getBoxHeight(mb8Div) - this.getBoxHeight(formDiv) }, + + // 压缩图片函数 async function compressImage(blob) { return new Promise((resolve, reject) => { const reader = new FileReader(); reader.onload = function (event) { const img = new Image(); img.onload = function () { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); const maxWidth = 800; // 设置最大宽度 const scale = Math.min(maxWidth / img.width, 1); // 计算缩放比例 canvas.width = img.width * scale; canvas.height = img.height * scale; ctx.drawImage(img, 0, 0, canvas.width, canvas.height); canvas.toBlob(resolve, 'image/jpeg', 0.7); // 转换为 Blob 格式并压缩质量 }; img.src = event.target.result; }; reader.readAsDataURL(blob); }); } // 将压缩后的图片插入到富文本编辑器中的方法 function insertImageIntoEditor(blob) { // 实现插入到富文本编辑器的逻辑,具体实现根据富文本编辑器的 API 进行调整 // 可以是将图片显示在编辑器中,或者将图片上传到服务器并在编辑器中插入链接等 } // 屏幕resize监听 screenChange() { // 屏幕resize监听事件:一旦屏幕宽高发生变化,就会执行resize @@ -1030,11 +1575,15 @@ export default { };