|
|
@@ -0,0 +1,186 @@
|
|
|
+<template>
|
|
|
+ <div class="container">
|
|
|
+ <!-- 单据弹窗 -->
|
|
|
+ <ele-modal
|
|
|
+ append-to-body
|
|
|
+ :title="title"
|
|
|
+ :before-close="handleClose"
|
|
|
+ custom-class="ele-dialog-form long-dialog-form"
|
|
|
+ :visible.sync="visible"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :maxable="true"
|
|
|
+ :resizable="true"
|
|
|
+ width="50%"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ label-width="100px"
|
|
|
+ ref="form"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ style="margin-top: 30px; padding-right: 20px"
|
|
|
+ >
|
|
|
+ <el-form-item label="规则名称" prop="dataName">
|
|
|
+ <el-input placeholder="请输入" v-model="form.dataName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="保留前几位" prop="prefixKeep">
|
|
|
+ <el-input placeholder="请输入" v-model="form.prefixKeep"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="替换字符" prop="replaceChar">
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入"
|
|
|
+ v-model="form.replaceChar"
|
|
|
+ maxlength="1"
|
|
|
+ show-word-limit
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="保留后几位" prop="suffixKeep">
|
|
|
+ <el-input placeholder="请输入" v-model="form.suffixKeep"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button size="small" @click="handleClose">关 闭</el-button>
|
|
|
+ <el-button size="small" @click="sumbit" type="primary" v-click-once
|
|
|
+ >确 认</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </ele-modal>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import dictMixins from '@/mixins/dictMixins';
|
|
|
+ import { copyObj } from '@/utils/util';
|
|
|
+ import { deepClone } from '@/utils/index';
|
|
|
+ // import fileMain from '@/components/upload/fileUpload';
|
|
|
+
|
|
|
+ import {
|
|
|
+ saveDatadesensitizetype,
|
|
|
+ detailDatadesensitizetype,
|
|
|
+ updateDatadesensitizetype
|
|
|
+ } from '@/api/system/dataDesensitization';
|
|
|
+
|
|
|
+ export default {
|
|
|
+ mixins: [dictMixins],
|
|
|
+ components: {
|
|
|
+ // fileUpload
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ visible: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ isUpdate: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ default: () => ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ ruleId: '',
|
|
|
+ title: '',
|
|
|
+ form: {
|
|
|
+ dataName: '',
|
|
|
+ prefixKeep: 0,
|
|
|
+ replaceChar: '*',
|
|
|
+ suffixKeep: 0
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ dataName: [
|
|
|
+ { required: true, message: '请输入规则名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ prefixKeep: [
|
|
|
+ { required: true, message: '请输入保留位数', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ suffixKeep: [
|
|
|
+ { required: true, message: '请输入保留位数', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+
|
|
|
+ // 提交状态
|
|
|
+ loading: false
|
|
|
+ // 是否是修改
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init() {
|
|
|
+ this.title = this.isUpdate ? '修改' : '新增';
|
|
|
+ if (this.isUpdate) {
|
|
|
+ this.ruleId = this.id;
|
|
|
+ const res = await detailDatadesensitizetype(this.ruleId);
|
|
|
+ console.log(res);
|
|
|
+ this.form.dataName = res.dataName;
|
|
|
+ this.form.prefixKeep = res.prefixKeep;
|
|
|
+ this.form.replaceChar = res.replaceChar;
|
|
|
+ this.form.suffixKeep = res.suffixKeep;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ //表单验证
|
|
|
+ getValidate() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
+ if (!valid) {
|
|
|
+ reject(false);
|
|
|
+ } else {
|
|
|
+ resolve(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ //保存
|
|
|
+ async sumbit() {
|
|
|
+ this.loading = true;
|
|
|
+ let valid;
|
|
|
+ try {
|
|
|
+ const res = await this.getValidate();
|
|
|
+ valid = res;
|
|
|
+ } catch (error) {
|
|
|
+ valid = error;
|
|
|
+ }
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ if (!this.isUpdate) {
|
|
|
+ try {
|
|
|
+ await saveDatadesensitizetype(this.form);
|
|
|
+ this.$message.success('新增成功');
|
|
|
+ this.cancel();
|
|
|
+ } catch (error) {}
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ const params = Object.assign({}, this.form, { id: this.ruleId });
|
|
|
+ console.log(params);
|
|
|
+ await updateDatadesensitizetype(params);
|
|
|
+ this.$message.success('修改成功');
|
|
|
+ this.cancel();
|
|
|
+ } catch (error) {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.$emit('success');
|
|
|
+ this.$emit('update:id', '');
|
|
|
+ this.$emit('update:isUpdate', false);
|
|
|
+ this.$emit('update:visible', false);
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.cancel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+ // .container {
|
|
|
+ // padding: 10px 0;
|
|
|
+ // }
|
|
|
+</style>
|