ZZJ
2021-11-09 ccee429d379e0108b7445f72ade8d97c110a6fb3
src/pages/systemSettings/views/keyboardLanguage.vue
@@ -2,27 +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" @click="pickLang(item, i)">
          <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">&#xe646;</span> -->
            <span class="icon iconfont" v-show="activeLang == item.Lang">已选</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>
@@ -48,18 +63,27 @@
  getEsClusterInfo,
} from "@/api/clusterManage";
import { getLangs, setLang, getLang, getKeyboardLayouts } from "@/api/system";
import {
  getLangs,
  setLang,
  getLang,
  getKeyboardLayouts,
  getCurKeyboardLayout,
  setKeyboardLayout,
} from "@/api/system";
import { isIPv4 } from "@/scripts/validate";
export default {
  data() {
    return {
      activeLang: "",
      activeKb: "",
      inWifiDetail: false,
      inWireDetail: false,
      langList: [],
      keyboardList: [],
      activePage: "lang",
      tabList: [{ name: "系统语言" }, { name: "键盘管理" }],
      activePage: "系统语言",
      rules: {
        deviceName: [
          { required: true, message: "请输入设备名称", trigger: "change" },
@@ -71,9 +95,17 @@
  mounted() {
    this.fetchLangList();
    this.getCurLang();
    this.fetchKeyBoardList();
    this.getCurKb();
  },
  props: ["barName"],
  methods: {
    getCurKb() {
      getCurKeyboardLayout().then((res) => {
        this.activeKb = res.data.keyboard;
      });
    },
    getCurLang() {
      getLang().then((res) => {
        if (res && res.success) {
@@ -88,11 +120,19 @@
        }
      });
    },
    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) => {
@@ -100,17 +140,29 @@
        }
      );
    },
    openRight(typ) {
      this.activePage = typ;
      if (typ == "keyboard") {
        getKeyboardLayouts().then((res) => {
          if (res && res.success) {
            this.keyboardList = res.data.slice(0, 5);
          }
        });
      }
    pickKb(item) {
      setKeyboardLayout({
        layout: item.id,
      }).then(
        (res) => {
          this.getCurKb()
          this.$message.success(res.data);
        },
        (err) => {
          this.$message.error(err.msg);
        }
      );
    },
    wifiControl(val) { },
    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() {
      this.inWifiDetail = true;
    },