|
@@ -1,316 +1,137 @@
|
|
|
<template>
|
|
|
- <el-dialog @close="closeDialog" :title="state.ruleForm.id ? '编辑证书' : '新增证书'" v-model="state.dialogVisible" width="60%">
|
|
|
- <!-- <el-tabs v-model="state.activeName" @tab-click="onTabClick"> -->
|
|
|
- <!-- <el-tab-pane label="基本信息" name="1"> -->
|
|
|
- <el-form :rules="state.rules" ref="ruleForm" :model="state.ruleForm" label-width="120px">
|
|
|
- <el-form-item label="证书标准" prop="standard">
|
|
|
- <el-select v-model="state.ruleForm.standard" placeholder="请选择证书标准">
|
|
|
+ <!-- 编辑证书/新增证书 -->
|
|
|
+ <el-dialog @close="closeDialog" :title="ruleForm.id ? $t('message.certificate.actions.editCertificate') : $t('message.certificate.actions.addCertificate')" v-model="dialogVisible" width="60%">
|
|
|
+ <el-form :rules="rules" ref="ruleFormRef" :model="ruleForm" :label-width="currentLocale === 'en' ? '150px' : '120px'">
|
|
|
+ <!-- 证书标准 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.standard')" prop="standard">
|
|
|
+ <!-- 请选择证书标准 -->
|
|
|
+ <el-select v-model="ruleForm.standard" class="w100" :placeholder="$t('message.certificate.placeholders.standard')">
|
|
|
<el-option v-for="dict in network_certificate" :key="dict.value" :label="dict.label" :value="dict.value"> </el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="证书名称" prop="name">
|
|
|
- <el-input v-model.trim="state.ruleForm.name"></el-input>
|
|
|
+ <!-- 证书名称 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.certificateName')" prop="name">
|
|
|
+ <el-input v-model.trim="ruleForm.name"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="证书文件" prop="fileContent">
|
|
|
- <el-input disabled v-if="state.ruleForm.fileContent" v-model="state.ruleForm.fileContent"></el-input>
|
|
|
+ <!-- 证书文件 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.fileContent')" prop="fileContent">
|
|
|
+ <el-input disabled v-if="ruleForm.fileContent" v-model="ruleForm.fileContent"></el-input>
|
|
|
<uploadFile @update="updateFile"></uploadFile>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="证书公钥" prop="publicKeyContent">
|
|
|
- <el-input disabled type="textarea" :rows="6" v-model="state.ruleForm.publicKeyContent"></el-input>
|
|
|
+ <!-- 证书公钥 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.publicKeyContent')" prop="publicKeyContent">
|
|
|
+ <el-input disabled type="textarea" :rows="6" v-model="ruleForm.publicKeyContent"></el-input>
|
|
|
<el-upload class="upload-demo" action="" accept=".txt" :on-change="beforePublicUpload" :auto-upload="false">
|
|
|
- <el-button size="small" type="primary">上传</el-button>
|
|
|
+ <!-- 上传 -->
|
|
|
+ <el-button size="small" type="primary">{{$t('message.certificate.actions.upload')}}</el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="证书私钥" prop="privateKeyContent">
|
|
|
- <el-input disabled type="textarea" :rows="6" v-model="state.ruleForm.privateKeyContent"></el-input>
|
|
|
+ <!-- 证书私钥 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.privateKeyContent')" prop="privateKeyContent">
|
|
|
+ <el-input disabled type="textarea" :rows="6" v-model="ruleForm.privateKeyContent"></el-input>
|
|
|
<el-upload class="upload-demo" action="" accept=".txt" :on-change="beforePrivateUpload" :auto-upload="false">
|
|
|
- <el-button size="small" type="primary">上传</el-button>
|
|
|
+ <!-- 上传 -->
|
|
|
+ <el-button size="small" type="primary">{{$t('message.certificate.actions.upload')}}</el-button>
|
|
|
</el-upload>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="说明">
|
|
|
- <el-input type="textarea" :rows="6" v-model="state.ruleForm.description"></el-input>
|
|
|
+ <!-- 说明 -->
|
|
|
+ <el-form-item :label="$t('message.certificate.labels.description')">
|
|
|
+ <el-input type="textarea" :rows="6" v-model="ruleForm.description"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button type="default" @click="closeDialog">取 消</el-button>
|
|
|
- <el-button type="primary" @click="submitData(ruleForm)">提 交</el-button>
|
|
|
+ <!-- 取消 -->
|
|
|
+ <el-button type="default" @click="closeDialog">{{ $t('message.certificate.actions.cancel') }}</el-button>
|
|
|
+ <!-- 提交 -->
|
|
|
+ <el-button type="primary" @click="submitData(ruleFormRef)">{{ $t('message.certificate.actions.submit') }}</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { reactive, ref, getCurrentInstance } from 'vue'
|
|
|
-import { FormInstance } from 'element-plus'
|
|
|
+import { ref, getCurrentInstance, computed } from 'vue'
|
|
|
import uploadFile from '/@/components/upload/uploadFile.vue'
|
|
|
+import { useI18n } from 'vue-i18n'
|
|
|
+
|
|
|
+const { locale, t } = useI18n();
|
|
|
|
|
|
import api from '/@/api/certificateManagement'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
const emit = defineEmits(['update'])
|
|
|
+const currentLocale = computed(() => locale.value)
|
|
|
+const ruleFormRef = ref();
|
|
|
+const dialogVisible = ref(false);
|
|
|
+const rules = computed(() => ({
|
|
|
+ name: [{ required: true, message: t('message.certificate.validate.certificateName'), trigger: 'blur' }],
|
|
|
+ standard: [{ required: true, message: t('message.certificate.validate.standard'), trigger: ['blur', 'change'] }],
|
|
|
+ fileContent: [{ required: true, message: t('message.certificate.validate.fileContent'), trigger: 'blur' }],
|
|
|
+ publicKeyContent: [{ required: true, message: t('message.certificate.validate.publicKeyContent'), trigger: ['blur', 'change'] }],
|
|
|
+ privateKeyContent: [{ required: true, message: t('message.certificate.validate.privateKeyContent'), trigger: ['blur', 'change'] }],
|
|
|
+}))
|
|
|
+const ruleForm = ref({
|
|
|
+ id: "",
|
|
|
+ standard: "",
|
|
|
+ name: "",
|
|
|
+ fileContent: "",
|
|
|
+ publicKeyContent: "",
|
|
|
+ privateKeyContent: "",
|
|
|
+ description: ""
|
|
|
+});
|
|
|
|
|
|
-const ruleForm = ref<FormInstance>()
|
|
|
-
|
|
|
-const state = reactive({
|
|
|
- dialogVisible: false,
|
|
|
- activeName: '1',
|
|
|
- id: 0,
|
|
|
- ruleForm: {},
|
|
|
- rules: {
|
|
|
- name: [{ required: true, message: '证书名称不能为空', trigger: 'blur' }],
|
|
|
- standard: [{ required: true, message: '证书标准不能为空', trigger: ['blur', 'change'] }],
|
|
|
- fileContent: [{ required: true, message: '证书文件不能为空', trigger: 'blur' }],
|
|
|
- publicKeyContent: [{ required: true, message: '证书公钥不能为空', trigger: ['blur', 'change'] }],
|
|
|
- privateKeyContent: [{ required: true, message: '证书私钥不能为空', trigger: ['blur', 'change'] }],
|
|
|
- },
|
|
|
- columns: [
|
|
|
- {
|
|
|
- columnId: 29,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'business_type',
|
|
|
- columnComment: '0其它 1新增 2修改 3删除',
|
|
|
- columnType: 'varchar(1)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'BusinessType',
|
|
|
- jsonField: 'businessType',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '0',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'datetime',
|
|
|
- dictType: '',
|
|
|
- sort: 3,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 31,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'method',
|
|
|
- columnComment: '请求方法',
|
|
|
- columnType: 'varchar(255)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'Method',
|
|
|
- jsonField: 'method',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '0',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'input',
|
|
|
- dictType: '',
|
|
|
- sort: 4,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 33,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'oper_name',
|
|
|
- columnComment: '操作人员',
|
|
|
- columnType: 'varchar(255)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'OperName',
|
|
|
- jsonField: 'operName',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '1',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'LIKE',
|
|
|
- htmlType: 'input',
|
|
|
- dictType: '',
|
|
|
- sort: 5,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 35,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'oper_url',
|
|
|
- columnComment: '操作url',
|
|
|
- columnType: 'varchar(255)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'OperUrl',
|
|
|
- jsonField: 'operUrl',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '0',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'input',
|
|
|
- dictType: '',
|
|
|
- sort: 6,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 37,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'oper_ip',
|
|
|
- columnComment: '操作IP',
|
|
|
- columnType: 'varchar(255)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'OperIp',
|
|
|
- jsonField: 'operIp',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '0',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'input',
|
|
|
- dictType: '',
|
|
|
- sort: 7,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 41,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'status',
|
|
|
- columnComment: '0=正常,1=异常',
|
|
|
- columnType: 'varchar(1)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'string',
|
|
|
- goField: 'Status',
|
|
|
- jsonField: 'status',
|
|
|
- htmlField: '',
|
|
|
- isPk: '0',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '1',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '1',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'radio',
|
|
|
- dictType: '',
|
|
|
- sort: 10,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- {
|
|
|
- columnId: 42,
|
|
|
- tableId: 3,
|
|
|
- TableName: '',
|
|
|
- columnName: 'oper_id',
|
|
|
- columnComment: '',
|
|
|
- columnType: 'bigint(20)',
|
|
|
- columnKey: '',
|
|
|
- goType: 'int64',
|
|
|
- goField: 'OperId',
|
|
|
- jsonField: 'operId',
|
|
|
- htmlField: '',
|
|
|
- isPk: '1',
|
|
|
- isIncrement: '',
|
|
|
- isRequired: '0',
|
|
|
- isInsert: '1',
|
|
|
- isEdit: '0',
|
|
|
- isList: '1',
|
|
|
- isQuery: '1',
|
|
|
- queryType: 'EQ',
|
|
|
- htmlType: 'input',
|
|
|
- dictType: '',
|
|
|
- sort: 1,
|
|
|
- linkTableName: '',
|
|
|
- linkTableClass: '',
|
|
|
- linkTablePackage: '',
|
|
|
- linkLabelId: '',
|
|
|
- linkLabelName: '',
|
|
|
- },
|
|
|
- ],
|
|
|
-})
|
|
|
const { proxy } = getCurrentInstance() as any
|
|
|
const { network_certificate } = proxy.useDict('network_certificate')
|
|
|
// 打开弹窗
|
|
|
const openDialog = (row: any) => {
|
|
|
if (row) {
|
|
|
- state.ruleForm = row
|
|
|
+ ruleForm.value = row
|
|
|
}
|
|
|
- state.dialogVisible = true
|
|
|
+ dialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
// 关闭弹窗
|
|
|
const closeDialog = () => {
|
|
|
- state.dialogVisible = false
|
|
|
- state.ruleForm = {}
|
|
|
- ruleForm.value?.clearValidate()
|
|
|
+ dialogVisible.value = false
|
|
|
+ resetForm()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const resetForm = () => {
|
|
|
+ ruleForm.value = {
|
|
|
+ id: "",
|
|
|
+ standard: "",
|
|
|
+ name: "",
|
|
|
+ fileContent: "",
|
|
|
+ publicKeyContent: "",
|
|
|
+ privateKeyContent: "",
|
|
|
+ description: ""
|
|
|
+ }
|
|
|
+ ruleFormRef.value?.clearValidate()
|
|
|
+ ruleFormRef.value?.resetFields()
|
|
|
}
|
|
|
-// 取消
|
|
|
-// const onCancel = () => {
|
|
|
-// closeDialog()
|
|
|
-// }
|
|
|
|
|
|
const submitData = async (formEl: any | undefined) => {
|
|
|
if (!formEl) return
|
|
|
await formEl.validate((valid: any) => {
|
|
|
if (valid) {
|
|
|
- if (state.ruleForm.id) {
|
|
|
+ if (ruleForm.value.id) {
|
|
|
// 编辑
|
|
|
- api.certificateManagement.edit(state.ruleForm).then(() => {
|
|
|
- ElMessage.success('证书编辑成功')
|
|
|
- state.dialogVisible = false
|
|
|
+ api.certificateManagement.edit(ruleForm.value).then(() => {
|
|
|
+ ElMessage.success(t('message.certificate.messages.editSuccess'))
|
|
|
+ dialogVisible.value = false
|
|
|
emit('update')
|
|
|
- state.ruleForm = {}
|
|
|
+ resetForm()
|
|
|
})
|
|
|
} else {
|
|
|
// 新增
|
|
|
- api.certificateManagement.add(state.ruleForm).then(() => {
|
|
|
- ElMessage.success('证书添加成功')
|
|
|
- state.dialogVisible = false
|
|
|
+ api.certificateManagement.add(ruleForm.value).then(() => {
|
|
|
+ ElMessage.success(t('message.certificate.messages.addSuccess'))
|
|
|
+ dialogVisible.value = false
|
|
|
emit('update')
|
|
|
- state.ruleForm = {}
|
|
|
+ resetForm()
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -323,7 +144,7 @@ const beforePublicUpload = (response: any, file: any) => {
|
|
|
reader.onload = function (e: any) {
|
|
|
let val = e.target.result //获取数据
|
|
|
let rtulist = val.split('\r\n')
|
|
|
- state.ruleForm.publicKeyContent = rtulist[0]
|
|
|
+ ruleForm.value.publicKeyContent = rtulist[0]
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -333,11 +154,11 @@ const beforePrivateUpload = (response: any, file: any) => {
|
|
|
reader.onload = function (e: any) {
|
|
|
let val = e.target.result //获取数据
|
|
|
let rtulist = val.split('\r\n')
|
|
|
- state.ruleForm.privateKeyContent = rtulist[0]
|
|
|
+ ruleForm.value.privateKeyContent = rtulist[0]
|
|
|
}
|
|
|
}
|
|
|
const updateFile = (url: string) => {
|
|
|
- state.ruleForm.fileContent = url
|
|
|
+ ruleForm.value.fileContent = url
|
|
|
}
|
|
|
|
|
|
defineExpose({ openDialog })
|