ZZJ
2021-11-09 ccee429d379e0108b7445f72ade8d97c110a6fb3
src/pages/systemSettings/views/keyboardLanguage.vue
@@ -2,26 +2,42 @@
  <div class="all">
    <div class="cluster-content">
      <div class="cluster-center" ref="left">
        <div class="menu-item" @click="openRight('lang')">
          <div>系统语言</div>
        </div>
        <div class="menu-item" @click="openRight('keyboard')">
          <div>键盘管理</div>
        <div
          class="menu-item"
          v-for="(item, i) in tabList"
          :key="i"
          @click="openRight(item, i)"
          ref="leftbar"
        >
          <div>{{ item.name }}</div>
        </div>
      </div>
      <div class="cluster-right">
        <div class="lang" v-if="activePage=='lang'">
        <div class="lang" v-if="activePage == '系统语言'">
          <div class="title">语言列表</div>
          <div class="bar" v-for="(item, i) in langList" :key="i">
            <span class="name">{{ item.name }}</span>
            <span class="icon iconfont">&#xe646;</span>
          <div
            class="bar"
            v-for="(item, i) in langList"
            :key="i"
            @click="pickLang(item, i)"
          >
            <span class="name">{{ item.Name }}</span>
            <span class="icon iconfont" v-show="activeLang == item.Lang"
              >已选</span
            >
          </div>
        </div>
        <div class="lang" v-if="activePage=='keyboard'">
        <div class="lang" v-if="activePage == '键盘管理'">
          <div class="title">键盘布局</div>
          <div class="bar" v-for="(item, i) in keyboardList" :key="i">
          <div
            class="bar"
            v-for="(item, i) in keyboardList"
            :key="i"
            @click="pickKb(item, i)"
          >
            <span class="name">{{ item.name }}</span>
            <span class="icon iconfont">&#xe646;</span>
            <span class="icon iconfont" v-show="activeKb == item.id">已选</span>
            <!-- <span class="icon iconfont">&#xe646;</span> -->
          </div>
        </div>
      </div>
@@ -46,87 +62,105 @@
  addESNode,
  getEsClusterInfo,
} from "@/api/clusterManage";
import cloudNode from "../components/CloudNode";
import ipInput from "@/components/subComponents/IPInput";
import {
  getLangs,
  setLang,
  getLang,
  getKeyboardLayouts,
  getCurKeyboardLayout,
  setKeyboardLayout,
} from "@/api/system";
import { isIPv4 } from "@/scripts/validate";
import switchBar from "../components/switchBar";
export default {
  data() {
    const checkPwd = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("密码不能为空"));
      }
      setTimeout(() => {
        if (value.length != 6) {
          callback(new Error("密码应为6位!"));
        } else {
          callback();
        }
      }, 1000);
    };
    return {
      isHighClass: false,
      ruleForm: {
        deviceName: "",
        port: "",
      },
      wifiForm: {
        name: "",
        password: "",
      },
      wireArr: [{ name: "有线网络1" }, { name: "有线网络2" }],
      activeLang: "",
      activeKb: "",
      inWifiDetail: false,
      wifiList: [{ name: "无线网络1" }, { name: "无线网络2" }],
      isOpenWifi: false,
      inWireDetail: false,
      wireForm: {},
      langList: [
        { name: "简体中文" },
        { name: "英文" },
        { name: "繁体中文(香港)" },
      ],
        keyboardList: [
        { name: "Hanyu Pinyin(algtr)" },
        { name: "ENG" },
      ],
      wireFormRules: {},
      activePage: "lang",
      langList: [],
      keyboardList: [],
      tabList: [{ name: "系统语言" }, { name: "键盘管理" }],
      activePage: "系统语言",
      rules: {
        deviceName: [
          { required: true, message: "请输入设备名称", trigger: "change" },
        ],
      },
      ipv4Form: {},
      ipv6Form: {},
      ipv4FormRules: {},
      ipv6FormRules: {},
      options: [
        {
          value: "选项1",
          label: "手动",
        },
        {
          value: "选项2",
          label: "自动",
        },
      ],
      value: "",
    };
  },
  components: {
    cloudNode,
    ipInput,
    switchBar,
  mounted() {
    this.fetchLangList();
    this.getCurLang();
    this.fetchKeyBoardList();
    this.getCurKb();
  },
  mounted() {},
  beforeDestroy() {},
  props: ["barName"],
  methods: {
    openRight(typ) {
      this.activePage = typ;
    getCurKb() {
      getCurKeyboardLayout().then((res) => {
        this.activeKb = res.data.keyboard;
      });
    },
    getCurLang() {
      getLang().then((res) => {
        if (res && res.success) {
          this.activeLang = res.data.lang;
        }
      });
    },
    fetchLangList() {
      getLangs().then((res) => {
        if (res && res.success) {
          this.langList = res.data;
        }
      });
    },
    fetchKeyBoardList() {
      getKeyboardLayouts().then((res) => {
        if (res && res.success) {
          this.keyboardList = res.data.slice(0, 5);
        }
      });
    },
    pickLang(item) {
      setLang({
        lang: item.Lang,
      }).then(
        (res) => {
          this.getCurLang();
          this.$message.success(res.data);
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    pickKb(item) {
      setKeyboardLayout({
        layout: item.id,
      }).then(
        (res) => {
          this.getCurKb()
          this.$message.success(res.data);
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    openRight(item, i) {
      this.activePage = item.name;
      this.$refs["leftbar"].forEach((x) => {
        x.style.backgroundColor = "rgba(248, 248, 248, 1)";
        x.style.color = "#333";
      });
      this.$refs["leftbar"][i].style.backgroundColor = "rgb(61, 104, 225)";
      this.$refs["leftbar"][i].style.color = "white";
    },
    wifiControl(val) {},
    checkWifi() {
@@ -156,7 +190,8 @@
    overflow: auto;
    box-sizing: border-box;
    flex-shrink: 0;
    padding: 10px;    border-right: 5px solid #f8f8f8;
    padding: 10px;
    border-right: 5px solid #f8f8f8;
    // background-color: lavender;
    .menu-item {