修改消息模板加密方式

This commit is contained in:
fengachen
2021-09-23 14:05:54 +08:00
parent 06f9637461
commit 792c480de6
2 changed files with 18 additions and 15 deletions
+4 -1
View File
@@ -112,6 +112,8 @@ export const transitRESTful = {
const getContactsByCompany = (params) => getAction('/company/payContactsManagement/queryByCompanyMeeting', params) const getContactsByCompany = (params) => getAction('/company/payContactsManagement/queryByCompanyMeeting', params)
// 通过联系人id获取联系人信息 // 通过联系人id获取联系人信息
const getContactsById = (param) => getAction('/company/payContactsManagement/queryByIdMeeting', param) const getContactsById = (param) => getAction('/company/payContactsManagement/queryByIdMeeting', param)
// 加密获取key 与 iv
const getKeyIv = (param) => getAction('/sys/getEncryptedString',param)
export { export {
addRole, addRole,
@@ -173,7 +175,8 @@ export {
getContactsByCompany, getContactsByCompany,
queryallRoles, queryallRoles,
getContactsById, getContactsById,
getFileInfo getFileInfo,
getKeyIv
} }
@@ -85,8 +85,8 @@
import pick from 'lodash.pick' import pick from 'lodash.pick'
import { duplicateCheck } from '@/api/api' import { duplicateCheck } from '@/api/api'
import JEditor from '@/components/jero/JEditor' import JEditor from '@/components/jero/JEditor'
import {getRSAPublicKey} from '@/api/login.js' import { encryption } from '@/utils/encryption/aesEncrypt'
import {JSEncrypt} from 'jsencrypt' import { getKeyIv } from '@/api/api'
export default { export default {
name: 'SysMessageTemplateModal', name: 'SysMessageTemplateModal',
@@ -123,7 +123,11 @@
useEditor:false, useEditor:false,
templateEditorContent:'', templateEditorContent:'',
// 加密公钥 // 加密公钥
rsaPublicKey:'' rsaPublicKey:'',
// 加密要的key
key:'',
// 加密要的iv
iv:''
} }
}, },
created() { created() {
@@ -135,7 +139,7 @@
}, },
edit(record) { edit(record) {
this.form.resetFields() this.form.resetFields()
this.getPublicKey() this.getKey()
this.model = Object.assign({}, record) this.model = Object.assign({}, record)
this.useEditor = (record.templateType==2 || record.templateType==4) this.useEditor = (record.templateType==2 || record.templateType==4)
if(this.useEditor){ if(this.useEditor){
@@ -175,11 +179,8 @@
//时间格式化 //时间格式化
if(this.useEditor){ if(this.useEditor){
formData.rsaPublicKey = that.rsaPublicKey // 加密
let encrypt = new JSEncrypt() formData.templateContent = encryption(this.templateEditorContent,this.key,this.iv)
encrypt.setPublicKey(formData.rsaPublicKey)
// 公钥加密
formData.templateContent = encrypt.encrypt(this.templateEditorContent)
// formData.templateContent=this.templateEditorContent // formData.templateContent=this.templateEditorContent
} }
console.log(formData) console.log(formData)
@@ -199,11 +200,10 @@
} }
}) })
}, },
//获取RSA公钥 getKey(){
getPublicKey(){ getKeyIv().then(res => {
// 获取公钥 this.key = res.result.key
getRSAPublicKey().then(res => { this.iv = res.result.iv
this.rsaPublicKey = res.result
}) })
}, },
validateTemplateCode(rule, value, callback){ validateTemplateCode(rule, value, callback){