Преглед на файлове

update sys_crypto_config

deason преди 3 години
родител
ревизия
cdfc08ef7b
променени са 1 файла, в които са добавени 133 реда и са изтрити 10 реда
  1. 133 10
      src/modules/basic/view/sys_crypto_config.vue

+ 133 - 10
src/modules/basic/view/sys_crypto_config.vue

@@ -1,28 +1,151 @@
 <template>
-  <section style="margin-top: 0px">todo</section>
+  <section style="margin-top: 0px">
+    <div>
+      <div style="width: 644px; padding: 10px 0px">
+        <el-alert title="算法代号" type="warning" show-icon>
+          <el-breadcrumb separator="|" style="font-size: 9px">
+            <el-breadcrumb-item>AES(带向量) 简写 A</el-breadcrumb-item>
+            <el-breadcrumb-item>AES(无向量) 简写 C</el-breadcrumb-item>
+            <el-breadcrumb-item>Base64 简写 B</el-breadcrumb-item>
+            <el-breadcrumb-item>RSA 简写 R</el-breadcrumb-item>
+          </el-breadcrumb>
+        </el-alert>
+      </div>
+
+      <el-transfer
+        v-model="enableCryptoConfigs"
+        :data="allCryptoConfigs"
+        :titles="['禁用组合列表', '启用组合列表']"
+        :button-texts="['禁用', '启用']"
+        :format="{
+          noChecked: '${total}',
+          hasChecked: '${checked}/${total}',
+        }"
+      >
+        <el-button
+          slot="right-footer"
+          class="transfer-footer"
+          type="primary"
+          size="small"
+          round
+          @click="updateCryptoConfigs()"
+          >保存</el-button
+        >
+      </el-transfer>
+    </div>
+  </section>
 </template>
 
 <script>
+import { mapState } from "vuex";
+import { CORE_API } from "@/constants/constants.js";
+
 export default {
   data() {
     return {
       loading: false,
+      allCryptoConfigs: [],
+      enableCryptoConfigs: [],
     };
   },
-  computed: {},
-  created() {},
-  methods: {},
+  computed: {
+    ...mapState({ user: (state) => state.user }),
+    isSuperAdmin() {
+      return this.user.roleList.some((role) => role.roleCode === "SUPER_ADMIN");
+    },
+  },
+  created() {
+    if (this.isSuperAdmin) {
+      this.loadCryptoConfigs();
+    }
+  },
+  methods: {
+    loadCryptoConfigs() {
+      this.loading = true;
+      let url = CORE_API + "/crypto/config/list";
+      this.$http.post(url).then(
+        (response) => {
+          let data = response.data;
+
+          for (let n = 0; n < data.length; n++) {
+            let obj = data[n];
+            this.allCryptoConfigs.push({
+              key: obj.combination,
+              label: obj.combination,
+              disabled: false,
+            });
+
+            if (obj.enable) {
+              this.enableCryptoConfigs.push(obj.combination);
+            }
+          }
+
+          this.loading = false;
+        },
+        () => {
+          this.$notify({
+            type: "error",
+            message: "获取组合配置失败!",
+          });
+          this.loading = false;
+        }
+      );
+    },
+    updateCryptoConfigs() {
+      let params = [];
+      for (let n = 0; n < this.allCryptoConfigs.length; n++) {
+        let obj = this.allCryptoConfigs[n];
+
+        let enable = false;
+        if (this.enableCryptoConfigs.indexOf(obj.key) > -1) {
+          enable = true;
+        }
+
+        params.push({ combination: obj.key, enable: enable });
+      }
+
+      if (params.length === 0) {
+        return;
+      }
+
+      this.$confirm("确认保存?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        let url = CORE_API + "/crypto/config/update";
+        this.$http.post(url, params).then(
+          () => {
+            this.$notify({
+              type: "success",
+              message: "保存成功!",
+            });
+          },
+          () => {
+            this.$notify({
+              type: "error",
+              message: "保存失败!",
+            });
+          }
+        );
+      });
+    },
+  },
 };
 </script>
 
 <style scoped>
-.page {
-  margin-top: 10px;
+.transfer-footer {
+  margin-left: 70px;
 }
-.pull-right {
-  float: right;
+</style>
+
+<style>
+.el-transfer-panel {
+  height: 390px;
 }
-.w180 {
-  width: 180px;
+.el-transfer-panel__list {
+  min-height: 310px;
+  height: 310px;
 }
 </style>