web/src/components/manger/Auth.vue

90 lines
2.1 KiB
Vue

<template>
<div class="auth">
<el-form ref="ruleFormRef" model="ciphertext" label-width="auto"
class="demo-ruleForm" status-icon>
<el-input
v-model="ciphertext"
maxlength="400"
placeholder="Please input"
show-word-limit
:autosize="{ minRows: 8, maxRows: 20 }"
type="textarea"
@input="parsing"
/>
<div class="btn">
<el-button type="primary" @click="save">保存</el-button>
</div>
</el-form>
<el-descriptions title="解析后的数据" size="small" :column="2" border v-if="flag">
<el-descriptions-item
align="center"
label="定点机构编码"
:span="2"
>
{{ decryptedText.fixmedinsCode }}
</el-descriptions-item>
<el-descriptions-item
align="center"
label="证书创建时间"
>
{{ decryptedText.createDate }}
</el-descriptions-item>
<el-descriptions-item
align="center"
label="证书过期时间"
>
{{ decryptedText.expiryDate }}
</el-descriptions-item>
</el-descriptions>
</div>
</template>
<script setup lang="ts">
import {post} from "@/utils/request.ts";
import {onMounted, onUnmounted, ref} from "vue";
import {ElMessage} from "element-plus";
const decryptedText = ref<any>({})
const ciphertext = ref<string>('')
const flag = ref<any>(false)
const parsing = () => {
if (ciphertext.value) {
post("common/config/parsing", {ciphertext: ciphertext.value}).then((res: any) => {
decryptedText.value = res;
flag.value = true;
})
} else {
flag.value = false;
}
}
const save = () => {
if (ciphertext.value) {
post("common/config/setcert", {encryptedText: ciphertext.value}).then((res: any) => {
ElMessage.success("保存成功")
})
}
}
const get = () => {
}
onMounted(async () => {
post("common/config/get", {key: 'common_cert'}).then((res: any) => {
ciphertext.value = res.val;
parsing()
})
})
</script>
<style scoped lang="scss">
.auth {
margin: 0 auto;
.btn {
margin: 24px 0;
display: flex;
justify-content: center;
}
}
</style>