<script setup lang="ts">
import { ref } from "vue";
import titHeader from "./components/tit-header.vue";
import ConfigDataAndDevice from "./components/configDataAndDevice.vue";
import { useWebSocket } from "@vueuse/core";
import { useCommonStoreHook } from "@/store";
import { getProjectById, getTestProjectList } from "@/api/project";
import { CheckboxValueType } from "element-plus";
import {
  searchExcutingGlobalData,
  searchExcutingInstrumentConfig,
  searchExecuteStatistics,
  searchInstrumentStatus,
  searchTestMachineConfig,
  searhTestType,
  startExecuteProjects,
  stopExecuteProjects,
} from "@/api/project/excute";

defineOptions({
  name: "RunTesting",
});

const route = useRoute();

interface VersionItem {
  testLocation: string;
  productCode: string;
  testType: string;
}

const formLabelAlign = ref<VersionItem>({
  testLocation: "",
  productCode: "",
  testType: "",
});
// 选择的执行终端
const selectedExcutingMachine = ref<any>();

const drawer = ref(false);

// 测试工程信息
const engineeringObj = ref<any>();
onMounted(async () => {
  getProjectById(route.params.engineerId as string).then((res) => {
    engineeringObj.value = res.data;
  });
  getAllTestTypes();
  getExcutingMachines();
  getTestProjectTopList();
  getSattisticData();
});

const topProAllList = ref<any[]>([]);
const topProSelectedList = ref<any[]>([]);
const checkAll = ref(false);
const isIndeterminate = ref(true);
// 根据状态改变已经选择的项目的上方的名字
const getSelectedStatusValue = (status: number) => {
  // 1：未测试 2：正在测试 3：测试合格 4：测试不合格
  let value = ["", "", ""]; //上方名字  中间icon class
  switch (status) {
    case 1:
      value = ["未开始", "", "bg-normal"];
      break;
    case 2:
      value = ["测试中", "Frame", "bg-progress"];
      break;
    case 3:
      value = ["合格", "gougou", "bg-success"];
      break;
    case 4:
      value = ["不合格", "chacha", "bg-error"];
      break;
    default:
      value = ["未开始", "", "bg-normal"];
  }

  return value;
};

const handleCheckAllChange = (val: CheckboxValueType) => {
  topProSelectedList.value = val
    ? topProAllList.value.map((item) => item.id)
    : [];
  isIndeterminate.value = false;
};
const handletopProSelectedListChange = (value: CheckboxValueType[]) => {
  const checkedCount = value.length;
  checkAll.value = checkedCount === topProAllList.value.length;
  isIndeterminate.value =
    checkedCount > 0 && checkedCount < topProAllList.value.length;
};
// 获取顶部测试项目
const getTestProjectTopList = () => {
  getTestProjectList({ engineeringId: route?.params?.engineerId })
    .then((result) => {
      topProAllList.value = result.data;
      topProSelectedList.value = result.data.map((item) => item.id); // 默认选中全部
      setTestingData();
    })
    .finally(() => {
      getExcutingGlobalMachines();
      getExcutingGlobalData();
    });
};

// 顶部展示的项目 是弹窗选中的项目
const topOnShowProList = computed(() => {
  return topProAllList.value.filter((item) =>
    topProSelectedList.value.includes(item.id)
  );
});

// 下面左边第一列
const allTestTypes = ref<any[]>([]);
const getAllTestTypes = () => {
  searhTestType().then((result) => {
    allTestTypes.value = result.data;
  });
};

// 下边第二列
const excutingMachinesList = ref<any[]>([]); // 所有执行终端
const getExcutingMachines = () => {
  searchTestMachineConfig(route?.params?.engineerId as string).then(
    (result) => {
      excutingMachinesList.value = result.data;
    }
  );
};

// 如果上面选择的项目改变了  要重新调这两个接口
// todo
const ConfigDataAndDeviceRef = ref();
const testingMachines = ref<any[]>([]); // 所有routeData里面的测试仪器
const getExcutingGlobalMachines = async () => {
  let res = await searchExcutingInstrumentConfig(
    route?.params?.engineerId as string,
    topProAllList.value.map((item) => item.id)
  );
  testingMachines.value = res.data;
  //   拿到仪器数据之后 调用接口查看仪器是否在线
  // let status = await searchInstrumentStatus(testingMachines.value);
};

// 最下方全局数据
const excutingGlobalData = ref<any[]>([]);
const getExcutingGlobalData = async () => {
  let res = await searchExcutingGlobalData(
    route?.params?.engineerId as string,
    topProAllList.value.map((item) => item.id)
  );
  excutingGlobalData.value = res.data;
};

// 配置这次执行的工程相关的数据和仪器
const configDrawerVisible = ref(false);
const onClickGlobalConfig = () => {
  configDrawerVisible.value = true;
  nextTick(() => {
    ConfigDataAndDeviceRef.value && ConfigDataAndDeviceRef.value.openDrawer();
  });
};
// 开始测试相关
const isTesting = ref(false);
const usedTime = ref(0);
let interval = 0;
const currentTestingProject = ref<any>();
const startToRunTest = async () => {
  if (!checkStartEnable()) return;

  let params = {
    configList: testingMachines.value,
    engineeringId: route.params.engineerId,
    globalDataList: excutingGlobalData.value,
    projectList: topProSelectedList.value,
    ...formLabelAlign.value,
    executeTerminal: selectedExcutingMachine.value.id,
  };

  let res = await startExecuteProjects(params);

  wsClient.open();

  currentTestingProject.value = res.data;
  isTesting.value = true;

  usedTime.value = 0;
  interval = setInterval(() => {
    usedTime.value += 1;
  }, 1000);
};

onUnmounted(async () => {
  clearInterval(interval);
});

const stopTesting = async () => {
  let res = await stopExecuteProjects(currentTestingProject.value?.id);
  isTesting.value = false;
  currentTestingProject.value = {};
  getSattisticData();
};

// 查询下边统计数据
const statisticsData = ref<object>();
const getSattisticData = () => {
  searchExecuteStatistics(route?.params?.engineerId as string).then(
    (result) => {
      statisticsData.value = result.data;
    }
  );
};

// ===== websocket ====
const logList = ref<any[]>([]); //日志数据
const testingWSData = ref();
const setTestingData = () => {
  let data = {};
  topProSelectedList.value.forEach((id) => {
    // 根据id去所有的数据中找对应的项目
    let project = topProAllList.value.find((item) => item.id == id);
    data[project.projectName] = [];
  });
  testingWSData.value = data;

  // testingWSData.value = {
  //   电源测试: [
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //   ],
  //   wanger: [
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //     {
  //       dataItem: "测试值0嘟嘟嘟嘟嘟嘟",
  //       dataContent: "dddddafvdafgvjf多发点顺丰水电费阿道夫爸的阿凡达深V啊",
  //     },
  //   ],
  // };
};
watch(topProSelectedList, () => {
  setTestingData();
});

const wsClient = useWebSocket(import.meta.env.VITE_WEBSOCKET_URL as string, {
  autoReconnect: {
    retries: 300,
    delay: 3000,
    onFailed() {
      console.log("长链接失败");
    },
  },
  // heartbeat: {
  //   message: "ping",
  //   interval: 1000,
  //   pongTimeout: 1000,
  // },
  heartbeat: false,
  onConnected: () => {
    console.log("长链接成功");
  },
  onDisconnected: () => {
    console.log("长链接断开");
  },
  onMessage: (msg) => {
    handleWSMessage();
  },
});

const handleWSMessage = () => {
  // wsClient.data.value = JSON.stringify({
  //   msgtype: 5,
  //   data: {
  //     title: "这个是标题", //标题
  //     content: "I控大概发给看哦K歌发K歌发", //内容
  //     mode: "阻塞", //阻塞/非阻塞
  //     // mode: "非阻塞", //阻塞/非阻塞
  //     displayTime: "", //显示时间（s)，<=0标识一直显示,人工关闭（对非阻塞式弹窗有效）
  //   },
  // });
  if (wsClient.data.value && JSON.parse(wsClient.data.value)) {
    let megData = JSON.parse(wsClient.data.value);
    // let megData = {
    //   data: {
    //     EngineeringId: "84",
    //     dataContent: "xxxxxx",
    //     dataItem: "测试值0",
    //     projectId: "9",
    //     status: 3,
    //   },
    //   msgtype: 2,
    // };
    console.log("长链接的消息 解析json后", megData);
    let msgType = megData?.msgtype ?? "";

    // 执行过程日志
    if (msgType == 1) {
      let logData = megData?.data?.log;
      if (logData) {
        logList.value.push(logData);
      }
    }
    // 测试数据
    else if (msgType == 2) {
      let logData = megData?.data;
      if (logData) {
        //   根据 projectId 去已经选择的项目中找到名字
        let project = topProAllList.value.find(
          (item) => item.id == logData.projectId
        );
        project.status = logData.status;
        let proName = project?.projectName;
        testingWSData.value[proName].push(logData);
      }
    }
    // 测试仪器列表状态
    else if (msgType == 3) {
      let devData = megData?.data ?? [];
      devData.forEach((item) => {
        //   根据 instrumentId 去已经选择的仪器中找到名字
        let machine = testingMachines.value.find(
          (machine) => machine.instrumentId == item.instrumentId
        );
        if (machine) {
          machine.deviceState = item.deviceState; // 更新仪器状态
        }
      });
    } else if (msgType == 4) {
      isTesting.value = false;
      ElMessage.success("测试结束");
    } else if (msgType == 5) {
      let obj = megData?.data;
      if (obj) {
        msgType5Objcet.value = obj;
        handleMsgType5Data();
      }
    }
  }
};

onBeforeUnmount(() => {
  wsClient.close();
});

const checkStartEnable = (): boolean => {
  let enable = true;

  if (!selectedExcutingMachine.value) {
    ElMessage.warning("请选择执行终端");
    enable = false;
  }

  if (!formLabelAlign.value.productCode) {
    ElMessage.warning("请输入产品编号");
    enable = false;
  }

  if (!formLabelAlign.value.testType) {
    ElMessage.warning("请选择测试类型");
    enable = false;
  }

  if (!formLabelAlign.value.testLocation) {
    ElMessage.warning("请输入测试地点");
    enable = false;
  }

  if (topProSelectedList.value.length < 1) {
    ElMessage.warning("请选择测试项目");
    enable = false;
  }

  return enable;
};

// 收到msgtype为5的阻塞消息需要交互
interface MsgType5Model {
  title: string; //标题
  content: string; //内容
  mode: string; //阻塞/非阻塞
  displayTime: string; //显示时间（s)，<=0标识一直显示,人工关闭（对非阻塞式弹窗有效）
}

const msgType5DVisiable = ref(false);
const msgType5Objcet = ref<MsgType5Model>({
  title: "", //标题
  content: "", //内容
  mode: "", //阻塞/非阻塞
  displayTime: "", //显示时间（s)，<=0标识一直显示,人工关闭（对非阻塞式弹窗有效）
});
const handleMsgType5Data = (data: any) => {
  msgType5DVisiable.value = true;
  console.log("收到msgtype为5的阻塞消息", data);
};
const confirmMsgType5 = () => {
  let p = {
    msgtype: 5,
    data: {
      info: "continue", //continue/discontinue
    },
  };
  wsClient.send(JSON.stringify(p));
  msgType5DVisiable.value = false;
};
const cancelMsgType5 = () => {
  let p = {
    msgtype: 5,
    data: {
      info: "discontinue", //continue/discontinue
    },
  };
  wsClient.send(JSON.stringify(p));
  msgType5DVisiable.value = false;
};
</script>

<template>
  <div class="runtest">
    <div class="content-A">
      <div class="drawerbtn" @click="drawer = true">
        <svg-icon icon-class="project-config" />
      </div>
      <el-scrollbar height="100%">
        <div class="test-list">
          <!--          // 1：未测试 2：正在测试 3：测试合格 4：测试不合格-->
          <div
            v-for="item in topOnShowProList"
            :key="item.id"
            class="test-list-item"
            :class="item.status == '2' ? 'active' : ''"
          >
            <div class="body" :class="['success']">
              <div
                class="line"
                :class="getSelectedStatusValue(item.status)[2]"
              ></div>
              <div class="head">
                {{ getSelectedStatusValue(item.status)[0] }}
              </div>
              <div class="icon">
                <svg-icon
                  v-if="item.status == '3'"
                  icon-class="gougou"
                  class="svg svg-success"
                />
                <svg-icon
                  v-else-if="item.status == '4'"
                  icon-class="chacha"
                  class="svg svg-error"
                />
                <svg-icon
                  v-else-if="item.status == '2'"
                  icon-class="Frame"
                  class="svg svg-progress"
                />
              </div>
              <div class="name">{{ item.projectName }}</div>
            </div>
          </div>
        </div>
      </el-scrollbar>
    </div>
    <div class="content-B">
      <div class="content-B-1">
        <titHeader icon-class="csgcxx" tit="测试工程信息" />
        <el-form
          label-position="top"
          label-width="auto"
          :model="formLabelAlign"
          ref="ruleFormRef"
        >
          <el-form-item label="产品名称">
            {{ engineeringObj?.engineeringProductName }}
          </el-form-item>
          <el-form-item label="工程类型">
            {{ engineeringObj?.engineeringType }}
          </el-form-item>
          <el-form-item label="	工程版本" label-position="left">
            {{ engineeringObj?.engineeringVersion }}
          </el-form-item>

          <el-form-item label="产品编号" prop="productCode">
            <el-input v-model="formLabelAlign.productCode" />
          </el-form-item>
          <el-form-item label="测试类型" prop="testType">
            <el-select
              v-model="formLabelAlign.testType"
              placeholder="选择测试类型"
            >
              <el-option
                v-for="item in allTestTypes"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              />
            </el-select>
          </el-form-item>
          <el-form-item label="测试地点" prop="testLocation">
            <el-input v-model="formLabelAlign.testLocation" />
          </el-form-item>
        </el-form>
      </div>

      <div class="content-B-2">
        <titHeader icon-class="zxzd-yq" tit="执行终端/仪器" />
        <el-form
          label-position="top"
          label-width="auto"
          :model="formLabelAlign"
          style="max-width: 600px"
          ref="ruleFormRef"
        >
          <el-form-item label="执行终端">
            <div class="select-div">
              <el-select
                class="select-item"
                v-model="selectedExcutingMachine"
                placeholder="选择执行终端"
              >
                <el-option
                  v-for="item in excutingMachinesList"
                  :key="item.id"
                  :label="item.instrumentName"
                  :value="item"
                />
              </el-select>
              <!--              <el-button class="test-min-btn" type="primary">-->
              <!--                <svg-icon icon-class="refresh1" size="18" />-->
              <!--              </el-button>-->
            </div>
          </el-form-item>
        </el-form>
        <div>
          <!--          <svg-icon icon-class="gougou" class="svg-success" />-->
          <span>{{ selectedExcutingMachine?.ip }}</span>
        </div>
        <div class="csyq-tit">
          <span>测试仪器</span>
          <!--                  <el-button class="test-min-btn" type="primary">-->
          <!--                    <svg-icon icon-class="project-config" size="18" />-->
          <!--                  </el-button>-->
        </div>
        <el-scrollbar class="content-B-height-2">
          <div class="csyq-list">
            <div
              v-for="(item, index) in testingMachines"
              :key="index"
              class="csyq-item"
            >
              <div>
                <span class="item-icon">
                  <svg-icon
                    v-if="item.deviceState"
                    icon-class="gougou"
                    class="svg-success"
                  />
                  <svg-icon v-else icon-class="chacha" class="svg-error" />
                </span>
                <span>{{ item.configName }}</span>
              </div>
              <div>{{ item.configIp }}</div>
            </div>
          </div>
        </el-scrollbar>
      </div>

      <div class="content-B-3">
        <titHeader icon-class="zxgcrz" tit="执行过程日志" />
        <el-scrollbar class="content-B-height-3">
          <div class="content-log">
            <div v-for="(item, index) in logList" :key="index">{{ item }}</div>
          </div>
        </el-scrollbar>
      </div>
      <div class="content-B-4">
        <!--        <el-button class="test-min-btn" type="primary">-->
        <!--          <svg-icon icon-class="refresh1" />-->
        <!--        </el-button>-->
        <titHeader icon-class="cssj" tit="测试数据" />
        <div class="cssj-row-flex">
          <span>序号</span>
          <span>数据项</span>
          <span>数据内容</span>
        </div>
        <el-scrollbar class="content-B-height-4" v-if="testingWSData">
          <div v-for="(proName, index) in Object.keys(testingWSData)">
            <div class="cssj-tit">项目名称: {{ proName }}</div>
            <el-table
              :data="testingWSData[proName]"
              show-overflow-tooltip
              :show-header="false"
            >
              <el-table-column type="index" width="55" />
              <el-table-column property="dataItem" width="160" />
              <el-table-column property="dataContent" />
            </el-table>
          </div>
        </el-scrollbar>
      </div>
    </div>

    <div class="content-C">
      <div class="left">
        <div class="test-btn progress" @click="onClickGlobalConfig">
          <svg-icon icon-class="project-config" />
          全局配置
        </div>
        <div>
          <p><span>产品：</span><span>变频模块</span></p>
          <p><span>工程类型：</span><span>变频模块</span></p>
        </div>
      </div>
      <div class="center">
        <div class="center-item">
          <div class="center-num">{{ statisticsData?.todayTestNum }}</div>
          <div class="center-tit">今日检测产品数量</div>
        </div>
        <div class="center-item">
          <div class="center-num">{{ statisticsData?.hisTestNum }}</div>

          <div class="center-tit">历史检测产品数量</div>
        </div>
      </div>
      <div class="right">
        <!--        <el-button type="primary" @click="handleWSMessage"-->
        <!--          >测试假数据</el-button-->
        <!--        >-->
        <div class="used-time" v-if="isTesting">已用时：{{ usedTime }}s</div>
        <!--        <div class="test-btn progress" @click="startToRunTest">-->
        <!--          <svg-icon icon-class="start-test" />-->
        <!--          开始测试-->
        <!--        </div>-->
        <el-button
          type="primary"
          class="test-btn progress"
          @click="startToRunTest"
          :loading="isTesting"
        >
          <template #icon>
            <svg-icon icon-class="start-test" />
          </template>
          开始测试
        </el-button>
        <div class="test-btn error" @click="stopTesting">
          <svg-icon icon-class="stop-test" />
          停止测试
        </div>
      </div>
    </div>

    <el-drawer v-model="drawer" direction="rtl" class="test-drawer">
      <template #header>
        <div class="test-drawer-header">选择测试项</div>
      </template>
      <template #default>
        <el-checkbox
          v-model="checkAll"
          :indeterminate="isIndeterminate"
          @change="handleCheckAllChange"
        >
          全选
        </el-checkbox>
        <el-scrollbar>
          <el-checkbox-group
            v-model="topProSelectedList"
            @change="handletopProSelectedListChange"
            class="drawer-list"
          >
            <div
              v-for="item in topProAllList"
              :key="item.id"
              class="drawer-list-item"
            >
              <el-checkbox label="" :value="item.id" />
              <span>{{ item.projectName }}</span>
            </div>
          </el-checkbox-group>
        </el-scrollbar>
      </template>
      <template #footer>
        <div style="flex: auto">
          <el-button>取消</el-button>
          <el-button type="primary">保存</el-button>
        </div>
      </template>
    </el-drawer>

    <el-drawer
      v-model="configDrawerVisible"
      :with-header="false"
      :append-to-body="true"
      :destroy-on-close="true"
      size="800"
      direction="ltr"
    >
      <ConfigDataAndDevice
        ref="ConfigDataAndDeviceRef"
        v-model:devices-data="testingMachines"
        v-model:data-list="excutingGlobalData"
        @close="configDrawerVisible = false"
      />
    </el-drawer>

    <!--    阻塞消息弹窗-->
    <el-dialog
      v-model="msgType5DVisiable"
      :title="msgType5Objcet.title"
      width="500"
    >
      <div>{{ msgType5Objcet.content }}</div>
      <template #footer v-if="msgType5Objcet.mode == '阻塞'">
        <div class="dialog-footer">
          <el-button @click="cancelMsgType5">取消</el-button>
          <el-button type="primary" @click="confirmMsgType5"> 确定 </el-button>
        </div>
      </template>
      <div v-text="msgType5Objcet.displayTime"></div>
    </el-dialog>
  </div>
</template>

<style scoped lang="scss">
$color-success: #8fe200;
$color-error: #f83c64;
$color-progress: #3cbaff;

.test-btn {
  width: 130px;
  height: 36px;
  line-height: 36px;
  margin: 0 auto;

  color: var(--hj-white-1);
  text-align: center;
  border-radius: 4px 4px 4px 4px;
  cursor: pointer;
}
.progress {
  background: var(--hj-bg1);
}
.error {
  background: var(--hj-bg2);
}
.test-min-btn {
  margin-left: 4px;
  flex: 0 0 36px;
  width: 25px;
  height: 30px;
  text-align: center;
  line-height: 36px;
  background: #e6f1fc;
  border-radius: 4px 4px 4px 4px;
  border: 1px solid #a3d0fd;
  font-size: var(--hj-fs-22);
  color: var(--fc-color-7);
}
.svg-normal {
  background-color: $hj-white-1;
}
.svg-success {
  color: $color-success;
}
.svg-error {
  color: $color-error;
}
.svg-progress {
  color: $color-progress;
}

.bg-normal {
  background-color: $hj-white-1;
}
.bg-error {
  background-color: $color-error;
}
.bg-success {
  background-color: $color-success;
}
.bg-progress {
  background-color: $color-progress;
}

.runtest {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-size: var(--hj-fs-12);
  .content-A {
    position: relative;
    width: 100%;
    height: 300px;
    background: linear-gradient(180deg, #404040 0%, #505050 100%);
    border-radius: 0px 0px 0px 0px;
    :deep(.el-scrollbar__view) {
      height: 100%;
    }
    .drawerbtn {
      position: absolute;
      z-index: 10;
      right: 10px;
      top: 10px;
      width: 36px;
      height: 36px;
      font-size: var(--hj-fs-22);
      color: var(--hj-white-1);
      cursor: pointer;
    }
    .test-list {
      display: flex;
      justify-content: center;
      height: 100%;
    }
    .test-list-item {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      width: 142px;
      height: 100%;
      text-align: center;
      &.active {
        background: linear-gradient(
          180deg,
          rgba(255, 255, 255, 0) 0%,
          #ffffff 100%
        );
      }

      .body {
        background: linear-gradient(180deg, #707070 0%, #515151 100%);
        box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.5);
        border: 1px solid #7e7e7e;
        border-radius: 5px;
        margin: auto;
        width: 108px;
        height: 240px;
        color: var(--hj-white-1);
        cursor: pointer;
        .line {
          width: 100%;
          height: 6px;
          border-radius: 5px 5px 0px 0px;
        }
        .head {
          margin: 0 14px;
          color: var(--fc-color-8);
          padding: 7px 0;
          border-bottom: 1px solid #a8a8a8;
        }
        .icon {
          margin: 0 auto;
          width: 36px;
          height: 36px;
          margin-top: 50px;
          margin-bottom: 50px;
          font-size: var(--hj-fs-32);
        }
        .name {
          font-weight: bold;
          font-size: var(--hj-fs-14);
        }
      }
    }
  }
  .content-B {
    width: 100%;
    //min-height: 300px;
    height: calc(100vh - $main-header-height - 300px - 64px);
    background-color: $hj-white-1;
    //margin-bottom: 70px;
    display: flex;
    .content-B {
      &-1,
      &-2,
      &-3,
      &-4 {
        margin-top: 30px;
        padding: 0 18px;
        border-left: 1px solid #afb9d0;
      }
      &-1 {
        border-left: none;
      }
    }

    .content-B-1 {
      flex: 0 0 19%;
    }
    .content-B-2 {
      flex: 0 0 22%;
      .select-div {
        display: flex;
        width: 100%;
        .select-item {
          flex: 1;
        }
      }
      .csyq-tit {
        display: flex;
        justify-content: space-between;
        height: 36px;
        line-height: 36px;
        font-size: var(--hj-fs-14);
        font-weight: bold;
        color: var(--fc-color-5);
      }
      .csyq-list {
        .csyq-item {
          font-size: var(--hj-fs-12);
          display: flex;
          justify-content: space-between;
          height: 30px;
          line-height: 30px;
          border-bottom: 1px solid var(--fc-color-5);
          .item-icon {
            font-size: var(--hj-fs-22);
            margin-right: 8px;
          }
        }
      }
    }
    .content-B-3 {
      flex: 0 0 19%;
      .content-log {
        font-weight: 400;
        font-size: var(--hj-fs-12);
        color: var(--fc-color-5);
        line-height: 18px;
      }
    }
    .content-B-4 {
      flex: 0 0 40%;
      position: relative;
      .test-min-btn {
        position: absolute;
        right: 20px;
      }
      .cssj-tit {
        height: 26px;
        line-height: 26px;
        text-align: center;
        font-weight: bolder;
        font-size: var(--hj-fs-12);
        color: var(--fc-color-5);
      }
      .cssj-row-flex {
        display: flex;
        height: 31px;
        line-height: 31px;
        border-bottom: 1px solid var(--fc-color-5);
        font-size: var(--hj-fs-14);
        > span:nth-of-type(1) {
          flex: 0 0 13%;
          text-align: center;
        }
        > span:nth-of-type(2) {
          flex: 0 0 45%;
        }
        > span:nth-of-type(3) {
          flex: 0 0 42%;
          text-align: center;
        }
      }
    }
  }
  .content-C {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 64px;
    background: linear-gradient(180deg, #434343 0%, #4f4f4f 100%);
    display: flex;
    justify-content: space-between;
    .left {
      padding: 0 12px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      p {
        display: block;
        line-height: 10px;
        color: var(--hj-white-1);
        margin-left: 15px;
        span {
          font-size: var(--hj-fs-14);
          &:nth-of-type(1) {
            font-weight: 400;
          }
          &:nth-of-type(2) {
            font-weight: bold;
          }
        }
      }
    }
    .center {
      display: flex;
      text-align: right;
      align-items: center;
      .center-item {
        min-width: 140px;
        .center-tit {
          font-size: var(--hj-fs-12);
          color: var(--hj-white-1);
          line-height: 16px;
        }

        .center-num {
          font-weight: bold;
          font-size: var(--hj-fs-18);
          color: var(--hj-white-1);
          line-height: 21px;
          border-bottom: 1px solid var(--hj-white-1);
        }
      }
    }
    .right {
      display: flex;
      align-self: center;
      align-content: center;
      align-items: center;
      font-size: var(--hj-fs-12);
      color: var(--hj-white-1);
      > div {
        margin-left: 12px;
      }
    }
  }
  :deep(.test-drawer) {
    background: linear-gradient(180deg, #434343 0%, #4f4f4f 100%);
    box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.5);
  }
  .test-drawer-header {
    font-weight: 400;
    font-size: var(--hj-fs-14);
    color: var(--hj-white-1);
    line-height: 19px;
    text-align: left;
    font-style: normal;
    text-transform: none;
  }
  .drawer-list {
    font-size: var(--hj-fs-12);
    .drawer-list-item {
      height: 36px;
      line-height: 36px;
      margin-bottom: 12px;
      padding: 0 12px;
      background: linear-gradient(180deg, #656565 0%, #555555 100%);
      box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.25);
      border-radius: 4px 4px 4px 4px;
      color: var(--hj-white-1);
    }
  }
}

.used-time {
  margin-right: 20px;
}

.content-B-height-2 {
  height: calc(100vh - $main-header-height - 300px - 64px - 228px);
}

.content-B-height-3 {
  height: calc(100vh - $main-header-height - 300px - 64px - 90px);
}

.content-B-height-4 {
  height: calc(100vh - $main-header-height - 300px - 64px - 120px);
}
</style>
