瀏覽代碼

设置开发

林旭祥 7 月之前
父節點
當前提交
459c186699
共有 5 個文件被更改,包括 167 次插入26 次删除
  1. 2 0
      .env.development
  2. 2 0
      .env.production
  3. 19 0
      src/api/module/common.ts
  4. 143 20
      src/components/WorkstationWindow/index.vue
  5. 1 6
      src/views/set/config.vue

+ 2 - 0
.env.development

@@ -5,3 +5,5 @@ VITE_APP_PORT = 80
 VITE_BUILD_COMPRESS = gzip
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'
+# 获取配置项
+VITE_APP_BASE_CTRL = 'https://allctrltst.tropsx.com'

+ 2 - 0
.env.production

@@ -5,3 +5,5 @@ VITE_APP_PORT = 80
 VITE_BUILD_COMPRESS = gzip
 # 应用访问路径 例如使用前缀 /admin/
 VITE_APP_CONTEXT_PATH = '/'
+# 获取配置项
+VITE_APP_BASE_CTRL = 'https://allctrl.tropsx.com'

+ 19 - 0
src/api/module/common.ts

@@ -139,6 +139,25 @@ export default {
     });
   },
 
+  //获取序号
+  serialNumber: (data: any) => {
+    return req({
+      url: '/gpu/get_config_exams',
+      method: 'post',
+      baseURL: import.meta.env.VITE_APP_BASE_CTRL,
+      data: data
+    });
+  },
+
+  //添加项目
+  addExamSettings: (data: any) => {
+    return req({
+      url: '/school/add_gpu_exam_setting',
+      method: 'post',
+      data: data
+    });
+  },
+
   //测试手势
   cmdtest: (data: any) => {
     return req({

+ 143 - 20
src/components/WorkstationWindow/index.vue

@@ -10,16 +10,41 @@
             <div class="title">{{ optionWindow.title }}</div>
             <div class="close" @click="close"></div>
           </div>
-          <div class="content">
-            <div class="left">工作站:</div>
-            <div class="right"> <el-select v-model="optionForm.worker" placeholder="请选择工作站">
-                <el-option v-for="(item, k) in workers" :key="item[0]" :label="k" :value="item[0]">
-                  <span style="float: left; font-size: 15px">{{ k }} <i v-if="item[3] == '待重启'"
-                      class="el-icon-refresh"></i> </span>
-                  <span style="float: right; color: #8492a6; font-size: 15px">{{ item[1] }}</span>
-                </el-option>
-              </el-select></div>
-
+          <div class="content" v-if="optionWindow.type == 'add'">
+            <div class="formList">
+              <div class="left left1">项目:</div>
+              <div class="right"> <el-select v-model="optionForm.project" placeholder="请选择项目">
+                  <el-option v-for="item in projectList" :key="item.key" :label="item.name" :value="item.key" />
+                </el-select></div>
+            </div>
+            <div class="formList">
+              <div class="left left1">工作站:</div>
+              <div class="right"> <el-select v-model="optionForm.worker" placeholder="请选择工作站">
+                  <el-option v-for="(item, k) in workers" :key="item[0]" :label="k" :value="item[0]">
+                    <span style="float: left; font-size: 15px">{{ k }} <i v-if="item[3] == '待重启'"
+                        class="el-icon-refresh"></i> </span>
+                    <span style="float: right; color: #8492a6; font-size: 15px">{{ item[1] }}</span>
+                  </el-option>
+                </el-select></div>
+            </div>
+            <div class="formList" v-if="optionForm.project">
+              <div class="left left1">序号(极值:{{ eMaxId }}):</div>
+              <div class="right"> <el-select v-model="optionForm.mIdx" placeholder="请选择序号">
+                  <el-option v-for="item in numberList" :key="item.key" :label="item.name" :value="item.key" />
+                </el-select></div>
+            </div>
+          </div>
+          <div class="content" v-else>
+            <div class="formList">
+              <div class="left">工作站:</div>
+              <div class="right"> <el-select v-model="optionForm.worker" placeholder="请选择工作站">
+                  <el-option v-for="(item, k) in workers" :key="item[0]" :label="k" :value="item[0]">
+                    <span style="float: left; font-size: 15px">{{ k }} <i v-if="item[3] == '待重启'"
+                        class="el-icon-refresh"></i> </span>
+                    <span style="float: right; color: #8492a6; font-size: 15px">{{ item[1] }}</span>
+                  </el-option>
+                </el-select></div>
+            </div>
           </div>
           <div class="bottom">
             <div class="btn" @click="confirm">
@@ -36,12 +61,15 @@
 
 </template>
 <script setup lang="ts">
+import dataDictionary from "@/utils/dataDictionary"
 const { proxy } = getCurrentInstance() as any;
 const emit = defineEmits(['returnData']);
-
+const dic: any = dataDictionary;
 const data = reactive<any>({
   optionForm: {
-    worker: ''
+    worker: '',
+    project: '',
+    eIdx: ''
   },
   optionWindow: {
     show: false,
@@ -49,17 +77,23 @@ const data = reactive<any>({
     title: "",
   },
   workers: [],
+  loginName: '',
   loading: false,
   stateLoading: false,
   timerManager: {},//计时器管理
+  serialNumberList: []
 });
 
-const { optionForm, optionWindow, workers, loading, stateLoading, timerManager } = toRefs(data);
+const { optionForm, optionWindow, workers, loginName, loading, stateLoading, timerManager, serialNumberList } = toRefs(data);
 
 //打开
 const open = (type: any, title: any) => {
   getWorkstation();
   optionForm.value.worker = '';
+  if (type == 'add') {
+    optionForm.value.project = '';
+    optionForm.value.mIdx = '';
+  }
   loading.value = false;
   optionWindow.value.type = type;
   optionWindow.value.title = title;
@@ -80,6 +114,18 @@ const getWorkstation = async () => {
   };
   let res = await proxy?.$http.common.allExams(params)
   workers.value = res.workers
+  loginName.value = res.login_name
+  if (optionWindow.value.type == 'add') {
+    getSerialNumber();
+  }
+};
+
+//获取序号
+const getSerialNumber = async () => {
+  let params: any = new FormData();
+  params.append("login_name", loginName.value);
+  let res = await proxy?.$http.common.serialNumber(params)
+  serialNumberList.value = res;
 };
 
 //确定
@@ -87,6 +133,9 @@ const confirm = () => {
   if (!optionForm.value.worker) {
     return false;
   }
+  if (optionWindow.value.type == 'add') {
+    addExamSettings();
+  }
   if (optionWindow.value.type == 'close') {
     closeWorkstation();
   }
@@ -98,6 +147,29 @@ const confirm = () => {
   }
 };
 
+//添加项目
+const addExamSettings = async () => {
+  let myInfo: any = localStorage.getItem("userInfo");
+  let userInfo = JSON.parse(myInfo);
+  let examId = optionForm.value.project + "_" + optionForm.value.mIdx;
+  let params: any = {
+    exam_id: examId,
+    school_id: userInfo.school_id,
+    wk_md5: optionForm.value.worker
+  };
+  loading.value = true;
+  let res = await proxy?.$http.common.addExamSettings(params).finally(() => {
+    loading.value = false;
+  })
+  if (res.status == 200) {
+    proxy?.$modal.msgSuccess('操作成功');
+    close();
+    emit('returnData', {});
+  } else {
+    proxy?.$modal.msgError(res.message);
+  }
+};
+
 //关闭工作站
 const closeWorkstation = async () => {
   let params: any = {
@@ -207,6 +279,47 @@ const getClearTimer = (data?: any) => {
   }
 };
 
+/**
+ * 获取项目列表
+*/
+const projectList = computed(() => {
+  let list = [];
+  let project = dic.project;
+  for (let key in project) {
+    if (project.hasOwnProperty(key)) {
+      list.push({
+        key: key,
+        name: project[key]
+      })
+    }
+  }
+  return list;
+});
+
+/**
+ * 获取序号列表
+*/
+const numberList = computed(() => {
+  let list = [];
+  let num = Number(serialNumberList.value[optionForm.value.project])
+  for (let i = 1; i <= num; i++) {
+    list.push({
+      key: i,
+      name: i
+    })
+  }
+  return list;
+});
+
+
+/**
+ * 获取极限值
+*/
+const eMaxId = computed(() => {
+  let num = Number(serialNumberList.value[optionForm.value.project])
+  return num;
+});
+
 onMounted(() => {
 })
 
@@ -269,16 +382,26 @@ defineExpose({
     .content {
       max-height: 65vh;
       margin-bottom: 2vh;
-      display: flex;
-      align-items: center;
 
-      .left {
-        flex-shrink: 0;
-      }
+      .formList {
+        display: flex;
+        align-items: center;
+        padding: 1.2vh 0;
+
+        .left {
+          flex-shrink: 0;
+          font-size: 1rem;
+        }
 
-      .right {
-        width: 100%;
+        .left1 {
+          width: 8rem;
+        }
+
+        .right {
+          width: 100%;
+        }
       }
+
     }
 
     .bottom {

+ 1 - 6
src/views/set/config.vue

@@ -17,7 +17,7 @@
       </el-table>
     </div>
     <div class="footerBtn">
-      <div class="btn" @click="addGpuExam">添加项目</div>
+      <div class="btn" @click="openWorkstation('add', '添加项目')">添加项目</div>
       <div class="btn" @click="openWorkstation('led', '关闭LED屏幕')">关闭LED屏幕</div>
       <div class="btn" @click="openWorkstation('restart', '重启工作站')">重启工作站</div>
       <div class="btn" @click="openWorkstation('close', '关闭工作站')">关闭工作站</div>
@@ -104,11 +104,6 @@ const showWorkers = (row: any) => {
   return row[2].join(",")
 };
 
-//添加项目
-const addGpuExam = (row: any) => {
-
-};
-
 //操作工作站
 const openWorkstation = (type: any, title: any) => {
   workstationWindowRef.value.open(type, title);