<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>

<script>
import { Alert } from "element-ui";
import { queryallanswer } from "./api/answer";
export default {
  name: "App",
  data() {
    return {
      grade: 0,
    };
  },
  created() {
    this.queryallanswer();
  },
  methods: {
    //请求正确答案
    // async queryallanswer() {
    //   let { data } = await queryallanswer();
    //   let arr = [];
    //   arr = data.data;
    //   arr.forEach((item) => {
    //     item.answer = JSON.parse(item.answer);
    //   });
    //   console.log(arr);
    //   let obj = {
    //     cjdpz_beilv: "2",
    //     cjdpz_cjsjlx: "uint16",
    //     cjdpz_dxsx: "只读131111",
    //     cjdpz_jcqdz: "8195",
    //     cjdpz_mc: "产量",
    //     cjdpz_sjq: "4X (Holding Register)",
    //     cjdpz_tagid: "MachinePamHID910",
    //     cjdpz_zjx: "Null",
    //     ippz_dns_by: "114.114.114.114",
    //     ippz_dns_sx: "8.8.8.8",
    //     ippz_ip: "192.168.32.3",
    //     ippz_mac: "3C:2D:50:20:30:3D",
    //     ippz_mrwg: "192.168.32.1",
    //     ippz_wangkou: "ETH1",
    //     ippz_zwym: "255.255.255.192",
    //     mqtt_cjd_sbmc: "有线区精雕1",
    //     mqtt_cjd_tagid: "MachinePamHID910",
    //     mqtt_ip: "124.70.210.118",
    //     mqtt_port: "1883",
    //     mqtt_qiyong: "1",
    //     mqtt_qos: "qos1",
    //     mqtt_retained: "0",
    //     mqtt_scms: "周期上传",
    //     mqtt_sczq: "5",
    //     mqtt_sjgl: "采集成功",
    //     mqtt_sssjfbzt: "dbzn/gateway/iotlite/2000808010",
    //     mqtt_wgsn: "2000808010",
    //     sbpz_jdzxz: "1",
    //     sbpz_jysb: "0",
    //     sbpz_mac: "3C:2D:50:20:30:3D",
    //     sbpz_sbid: "有线区加工设备1",
    //     sbpz_sbmc: "有线区精雕1",
    //     tdpz_050F: "auto",
    //     tdpz_0610: "auto",
    //     tdpz_cfcs: "3",
    //     tdpz_cjsylxdz: "1",
    //     tdpz_cssj: "500",
    //     tdpz_dxzkb: "1:1",
    //     tdpz_ip: "192.168.32.2",
    //     tdpz_jgsj: "500",
    //     tdpz_lxsj: "0",
    //     tdpz_port: "502",
    //     tdpz_qdmc: "ModbusTCPClient",
    //     tdpz_td: "网口",
    //     tdpz_tdmc: "有线区Channel1",
    //     tdpz_watchtime: "1",
    //     wgpz_wgid: "LAN-BOX1",
    //     wgpz_wglx: "MODBUS网关",
    //     wgpz_wgmc: "有线区网关1",
    //   };
    //   let newArr = [
    //     {
    //       cskey: "MachinePamHID917",
    //       csname: "主轴转速",
    //       pcz: "100",
    //       sdz: "2000",
    //       sfbjbz: "是",
    //       sfyxbz: "是",
    //       sswg: "lan-box2",
    //       xsws: "0",
    //     },
    //     {
    //       cskey: "MachinePamHID910",
    //       csname: "产量",
    //       pcz: "5",
    //       sdz: "20",
    //       sfbjbz: "是",
    //       sfyxbz: "是",
    //       sswg: "lan-box1",
    //       xsws: "0",
    //     },
    //     {
    //       cskey: "MachinePamHID909",
    //       csname: "急停状态",
    //       pcz: "0",
    //       sdz: "1",
    //       sfbjbz: "是",
    //       sfyxbz: "是",
    //       sswg: "wlan-box1",
    //       xsws: "0",
    //     },
    //     {
    //       cskey: "MachinePamHID928",
    //       csname: "切削速度",
    //       pcz: "50",
    //       sdz: "500",
    //       sfbjbz: "是",
    //       sfyxbz: "是",
    //       sswg: "wlan-box2",
    //       xsws: "0",
    //     },
    //   ];
    //   // console.log(this.getAllGrades(arr[0].answer, obj, arr[0].r1));
    //   console.log(this.getAllGrades(newArr, newArr, arr[9].r1));
    //   // this.getAllGrades(arr[9].answer, newArr, arr[9].r1);
    // },
    //obj1:答案对象   obj：用户对象   r1 模块分数
    // getAllGrades(obj1, obj2, r1) {
    //   var arr = [];
    //   let grade = 0;
    //   if (!Array.isArray(obj1)) {
    //     const keys = Object.keys(obj1);
    //     for (let key of keys) {
    //       if (obj1[key] !== obj2[key]) {
    //         arr.push({
    //           [key]: {
    //             answer: obj1[key],
    //             user: obj2[key],
    //           },
    //         });
    //       }
    //     }
    //     if (arr.length > 0) {
    //       grade = 0;
    //     } else {
    //       grade = r1;
    //     }
    //   } else {
    //     if (obj1.length !== obj2.length) {
    //       return false;
    //     }
    //     let flagArr = [];
    //     for (let i = 0; i < obj1.length; i++) {
    //       for (let j = 0; j < obj2.length; j++) {
    //         let flag = this.isArrEqual(
    //           Object.values(obj1[i]),
    //           Object.values(obj2[j])
    //         );
    //         flagArr.push(flag);
    //       }
    //     }
    //     let counter = 0;
    //     let target = true;
    //     for (let a of flagArr) {
    //       if (a == target) {
    //         counter++;
    //       }
    //     }
    //     if (counter == obj1.length) {
    //       grade = r1;
    //       console.log(grade);
    //     } else {
    //       grade = 0;
    //     }
    //   }
    //   // 返回此模块分数以及错误的字段;
    //   return {
    //     arr,
    //     grade: Number(grade),
    //   };
    // },
    // isArrEqual(arr1, arr2) {
    //   return (
    //     arr1.length === arr2.length && arr1.every((ele) => arr2.includes(ele))
    //   );
    // },
  },
  mounted() { },
  components: {},
};
</script>

<style>
* {
  margin: 0;
  padding: 0;
}

#app {
  width: 100%;
  height: 100vh;
  background-color: white !important;
}

.el-dialog__wrapper {
  background-color: transparent !important;
}

.el-dialog__header,
.el-table {
  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;
}

.el-dialog__body {
  /* border-top: 0 !important; */
  /* background-color: rgba(19, 31, 59, 0); */
  color: #FFFFFF;
  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;
}

.el-dialog__footer {
  text-align: center;
  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;
}

.el-form-item label {
  color: white;
}

.el-tree-node__content:hover {
  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;

}

.el-tree-node.is-current>.el-tree-node__content {

  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;

}

.el-tree-node:focus>.el-tree-node__content {
  background-image: url(./assets/image/bg.png);
  background-size: 100% 100%;

}

.el-dialog,
.el-pager li,
.el-tree,
.tree_menu {
  /* background-color: rgba(255, 0, 0, 0.0); */
  color: #ffffff;
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

/* //将el-dialog__header、el-dialog__body、el-dialog__footer背景设置为透明 */
.el-dialog__header .el-dialog__title,
.el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}

.el-dialog__header,
.el-table {
  color: #FFFFFF;
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

/* .el-table__header-wrapper */
.el_table .el_table_cell,
.el-dialog__body {
  /* border-top: 0 !important; */
  /* background-color: rgba(19, 31, 59, 0); */
  color: #ffffff;
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

.el-table .el-table__body-wrapper tbody tr {
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

.el-dialog__footer {
  text-align: center;
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

.el-form-item label {
  color: white;
}

.el-tree-node__content:hover {
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

.el-tree-node.is-current>.el-tree-node__content {

  background-image: url(./assets/image/bg.png);
  background-size: cover;

}

.el-tree-node:focus>.el-tree-node__content {
  background-image: url(./assets/image/bg.png);
  background-size: cover;
}

/* 弹窗 */</style>
