Преглед на файлове

feature/设备记录调整

dy преди 1 година
родител
ревизия
3ceafb3207
променени са 3 файла, в които са добавени 130 реда и са изтрити 12 реда
  1. 1 1
      .env.development
  2. 16 1
      src/api/prosteps/shebeijilu.ts
  3. 113 10
      src/views/pro-steps/components/shebeijilu.vue

+ 1 - 1
.env.development

@@ -11,7 +11,7 @@ VITE_APP_BASE_API = '/dev-api'
 VITE_APP_UPLOAD_URL = 'http://192.168.101.4:9000'
 
 # 开发接口地址
-VITE_APP_API_URL = 'http://192.168.0.107:8079'
+VITE_APP_API_URL = 'http://192.168.0.110:8079'
 # Websocket地址
 VITE_WEBSOCKET_URL = 'ws://192.168.101.4:8079'
 ``

+ 16 - 1
src/api/prosteps/shebeijilu.ts

@@ -8,7 +8,23 @@ export function equitList(data: any) {
     data,
   });
 }
+//批量插入设备信息
 
+export function batchDevice(data: any) {
+  return request({
+    url: "/api/v1/process/equit/batchDevice",
+    method: "post",
+    data: data,
+  });
+}
+//获取当前类型设备列表
+export function devicelist(data: any) {
+  return request({
+    url: "/api/v1/device/list",
+    method: "post",
+    data: data,
+  });
+}
 //更新
 export function equitUpdate(data: any) {
   return request({
@@ -25,4 +41,3 @@ export function queryByCode(data: any) {
     data: data,
   });
 }
-

+ 113 - 10
src/views/pro-steps/components/shebeijilu.vue

@@ -9,15 +9,54 @@
         </div>
       </div>
       <!-- 变量控制样式 -->
-      <div class="footerBtn">
-        <el-button
+      <div class="select">
+        <div class="describeText" style="width: 130px">绑定设备:</div>
+
+        <el-select
           v-if="!item.equitCode"
+          multiple
+          @click="getdevicelist(item.equitType, item)"
+          v-model="item.inputValueVal"
+          placeholder="选择固有设备请点击"
+          size="large"
+          v-loading="item.loading"
+        >
+          <el-option
+            v-for="item in options"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+          />
+        </el-select>
+      </div>
+      <div class="selectBtn" v-if="!item.equitCode">
+        <el-button
+          class="btn"
+          v-if="item.selectStatus"
+          style="background-color: #0a59f7"
+          @click="binding(item)"
+          :disabled="item.scanStatus"
+          >确认绑定</el-button
+        >
+        <el-button
+          class="btn"
+          v-if="item.selectStatus"
+          type="info"
+          @click="cancel(item)"
+          :disabled="item.scanStatus"
+          >取消</el-button
+        >
+      </div>
+      <div class="footerBtn" v-if="!item.selectStatus">
+        <el-button
+          v-if="!item.equitCode && !item.selectStatus"
           class="bottomBtn"
           style="background-color: #0a59f7"
+          :disabled="item.selectStatus"
           @click="openScanCode(index)"
-          >点击扫描设备</el-button
+          >点击扫描其它设备</el-button
         >
-        <div v-else class="infoBox">
+        <div v-if="item.equitCode" class="infoBox">
           <div class="info">
             <div>
               <div class="describeText" style="text-align: left">
@@ -52,12 +91,49 @@
 </template>
 
 <script lang="ts" setup>
-import { equitList, equitUpdate, queryByCode } from "@/api/prosteps/shebeijilu";
+import {
+  equitList,
+  equitUpdate,
+  queryByCode,
+  devicelist,
+  batchDevice,
+} from "@/api/prosteps/shebeijilu";
 import { useProcessStore } from "@/store";
 defineOptions({ name: "Shebeijilu" });
+const selectStatus = ref(false);
+const scanStatus = ref(false);
+const binding = async (item: any) => {
+  try {
+    const { data } = await batchDevice({
+      deviceNoList: item.inputValueVal,
+      recordId: item.id,
+    });
+    ElMessage.success("绑定成功!");
+    getEquitList();
+  } catch {
+  } finally {
+    selectStatus.value = false;
+  }
+};
+const cancel = (item: any) => {
+  item.selectStatus = false;
+  item.inputValueVal = [];
+};
+const selectLoading = ref(false);
 const store = useProcessStore();
 const equitListData = ref([]);
 const selectIndex = ref(null);
+const getdevicelist = async (type: any, item: any) => {
+  item.selectStatus = true;
+  item.loading = true;
+  try {
+    const { data } = await devicelist({ deviceType: type });
+    option.value = data;
+  } catch {
+  } finally {
+    item.loading = false;
+  }
+};
 const getEquitList = async () => {
   const { data } = await equitList({
     seqNo: store.scanInfo.seqNo,
@@ -73,6 +149,17 @@ const showStatusVal = ref(false);
 const equitCheck = async () => {
   await equitUpdate({});
 };
+const option = ref([]);
+const options = computed(() => {
+  let array = [];
+  for (let i = 0; i < option.value.length; i++) {
+    array.push({
+      value: option.value[i].deviceNo,
+      label: option.value[i].deviceNo,
+    });
+  }
+  return array;
+});
 const openScanCode = (index) => {
   showStatusVal.value = true;
   selectIndex.value = index;
@@ -97,32 +184,48 @@ onMounted(() => {
 <style lang="scss" scoped>
 .recordBox {
   min-width: 600px;
-  height: 210px;
   background-color: white;
   border-radius: 16px;
   display: flex;
   padding: $p20;
   flex-direction: column;
   justify-content: space-between;
-
+  .select {
+    display: flex;
+    align-items: center;
+    padding: 0 5px;
+  }
   .headerText {
   }
 
   .describeBox {
   }
+  .selectBtn {
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    margin-top: 10px;
+    .btn {
+      width: 150px;
+      color: white;
+      height: 50px;
+      border-radius: 16px;
+      font-size: $f20;
+    }
+  }
 
-  //按钮样式
   .footerBtn {
     width: 100%;
-    height: 70px;
     background-color: #00000015;
     border-radius: 16px;
     overflow: hidden;
+    height: 50px;
+    margin-top: 10px;
 
     .bottomBtn {
       width: 100%;
       height: 100%;
-      font-size: $f24;
+      font-size: $f20;
       color: white;
     }