فهرست منبع

对接快递柜

liwei19941102 2 سال پیش
والد
کامیت
a385c3a7ff
3فایلهای تغییر یافته به همراه326 افزوده شده و 243 حذف شده
  1. 36 0
      src/api/data.ts
  2. 1 1
      src/views/car/work/schedule.vue
  3. 289 242
      src/views/yunying/kdg/index.vue

+ 36 - 0
src/api/data.ts

@@ -8,3 +8,39 @@ export const getpassenger = () => {
     });
   };
 
+export const getBoxInfo = (code) =>{
+  return request({
+    url: '/system/common/cabinet/'+code+'/allbox/info',
+    method: 'post'
+  });
+}
+
+export const getLock = (code,lockAddress) =>{
+  return request({
+    url: '/system/common/cabinet/'+code+'/openlock/'+lockAddress,
+    method: 'post'
+  });
+}
+
+export const openall = (code) =>{
+  return request({
+    url: '/system/common/cabinet/'+code+'/lock/openall',
+    method: 'post'
+  });
+}
+
+// export const openall = (code) =>{
+//   return request({
+//     url: '/system/common/cabinet/{code}/box/{boxuuid}/clear',
+//     method: 'post'
+//   });
+// }
+
+// export const openall = (code) =>{
+//   return request({
+//     url: '/system/common/cabinet/{code}/box/{boxuuid}/openclear',
+//     method: 'post'
+//   });
+// }
+
+

+ 1 - 1
src/views/car/work/schedule.vue

@@ -12,7 +12,7 @@
             </p>
             <div></div>
           </div>
-        </template>
+        </template>aw
       </el-calendar>
       <div>注:</div>
       <div style="display: flex;flex-direction: row;margin-top: 5px;">

+ 289 - 242
src/views/yunying/kdg/index.vue

@@ -21,8 +21,9 @@
             <el-option v-for="item in carPathList" :key="item.id" :label="item.name" :value="item.id" />
           </el-select>
           <el-input style="margin-top: 10px;" v-model="filterText" placeholder="输入关键字" />
-          <el-tree-v2 v-if="showTree" style="margin-top: 10px" ref="treeRef" class="filter-tree" :height="gettreeheight()" :data="data"
-            :indent="treeIndent" :props="defaultProps" :filter-method="filterNode" @node-click="treeclick">
+          <el-tree-v2 v-if="showTree" style="margin-top: 10px" ref="treeRef" class="filter-tree"
+            :height="gettreeheight()" :data="data" :indent="treeIndent" :props="defaultProps"
+            :filter-method="filterNode" @node-click="treeclick">
             <template v-slot:default="{ node }">
               <element-tree-line :node="node" :treeData="data" :showLabelLine="false" :indent="treeIndent">
               </element-tree-line>
@@ -32,9 +33,10 @@
       </div>
       <div style="width: 77%; margin-left: 2%">
         <div class="card-header">
-          <div style="display: flex; flex-direction: row;position: relative">
-            <div style="width: 4px; height: 19px; opacity: 1; background: #409eff"></div>
-            <span style="
+          <div style="display: flex; flex-direction: row;position: relative;">
+            <div style="display: flex; flex-direction: row;">
+              <div style="width: 4px; height: 19px; opacity: 1; background: #409eff"></div>
+              <span style="
                   font-family: PingFang SC;
                   font-size: 14px;
                   font-weight: normal;
@@ -42,9 +44,13 @@
                   height: 19px;
                   margin-left: 5px;
                 ">快递柜设备</span>
-            <span style="margin-left: 30px; font-size: 14px">{{ currentdata?.label }}</span>
-
-
+              <span style="margin-left: 30px; font-size: 14px">{{ currentdata?.label }}</span>
+            </div>
+            <div style="display: flex;flex-direction: row;margin-left: 25vw;">
+              <div style="margin-left: 1vw;"><el-button type="primary" @click="openAllBox">打开所有</el-button></div>
+              <!-- <div style="margin-left: 1vw;"><el-button type="primary">清理柜子(打开)</el-button></div>
+              <div style="margin-left: 1vw;"><el-button type="primary">清理柜子(不打开)</el-button></div> -->
+            </div>
           </div>
           <!-- <el-button v-if="tableData.length > 0 && tableData.length < 4" type="primary"
             style="position: absolute;right: 20px;" @click="goAdd">添加设备</el-button> -->
@@ -339,295 +345,336 @@
 </template>
 
 <script setup name="CarInfo" lang="ts">
-import { TreeNode } from "element-plus";
-import { useRoute, useRouter } from "vue-router";
-import EZUIKit from 'ezuikit-js';
-import { getCameraPlayerConfig } from '@/api/gpsData';
-import { listCarPath, getCarPath, delCarPath, addCarPath, updateCarPath } from '@/api/carPath';
-import { updateData, listData } from "@/api/system/dict/data";
-import imgulock from "@/assets/images/unlock@2x.png";
-
-const { proxy } = getCurrentInstance() as ComponentInternalInstance;
-
-const sites = ref([]);
-
-const showTree = ref(true)
-
-const type = ref([])
+  import { TreeNode } from "element-plus";
+  import { useRoute, useRouter } from "vue-router";
+  import EZUIKit from 'ezuikit-js';
+  import { getCameraPlayerConfig } from '@/api/gpsData';
+  import { listCarPath, getCarPath, delCarPath, addCarPath, updateCarPath } from '@/api/carPath';
+  import { updateData, listData } from "@/api/system/dict/data";
+  import imgulock from "@/assets/images/unlock@2x.png";
+  import { getBoxInfo, getLock, openall } from "@/api/data"
 
+  const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
-const formdata = ref({
-  name: "",
-  type: "",
-  code: ""
-})
+  const sites = ref([]);
 
+  const showTree = ref(true)
 
-const route = useRoute();
-const router = useRouter();
+  const type = ref([])
 
-const tableData = ref([]);
-const carPathList = ref([]);
-const line = ref([]);
+  const boxData = ref([])
+  const boxCode = ref(null)
 
-const activeName = ref("camera")
 
-const filterText = ref("");
-const treeRef = ref(null);
-const dialogVisible = ref(false);
-
-const gettreeheight = () => {
-  return document.body.clientHeight - 100;
-}
-
-const goAdd = () => {
-  dialogVisible.value = true
-  formdata.value = {
+  const formdata = ref({
     name: "",
     type: "",
     code: ""
-  }
-}
+  })
+
 
-const clickCabinet = (value) => {
-  ElMessage.success(value + "号柜远程开启成功");
-}
+  const route = useRoute();
+  const router = useRouter();
 
-const initData = async () => {
-  const res = await listCarPath({ pageSize: 1000 });
-  carPathList.value = res.rows;
-}
+  const tableData = ref([]);
+  const carPathList = ref([]);
+  const line = ref([]);
 
+  const activeName = ref("camera")
 
-const defaultProps = {
-  children: "children",
-  label: "label",
-  value: 'id',
-};
-const treeIndent = ref(40);
+  const filterText = ref("");
+  const treeRef = ref(null);
+  const dialogVisible = ref(false);
 
-watch(filterText, (val) => {
-  if (treeRef.value) {
-    treeRef.value.filter(val);
+  const gettreeheight = () => {
+    return document.body.clientHeight - 100;
   }
-});
-
-const savedata = () => {
-  //保存数据
-  var data = {
-    dictCode: currentdata.value.dictCode,
-    dictValue: currentdata.value.dictValue,
-    dictLabel: currentdata.value.dictLabel,
-    dictType: "tbl_sites",
-    remark: JSON.stringify(tableData.value)
+
+  const goAdd = () => {
+    dialogVisible.value = true
+    formdata.value = {
+      name: "",
+      type: "",
+      code: ""
+    }
   }
-  updateData(data).then(res => {
-    ElMessage.success("成功!");
-    getSites();
 
-  })
-}
-
-const getLineSites = () => {
-  console.log(line.value)
-  var sitesList = []
-  for (var index in carPathList.value) {
-    if (carPathList.value[index].id == line.value) {
-      sitesList = JSON.parse(carPathList.value[index].stationList)
+  const openBox = (value, lockCode) => {
+    getLock(boxCode.value, lockCode).then(res => {
+      console.log(res.code)
+      if (res.code == 0) {
+        ElMessage.success(value + "号柜远程开启成功");
+      }
+    })
+  }
+
+  const clickCabinet = (value, lockCode) => {
+    for (var index in boxData.value) {
+      if (boxData.value[index].box_name == value) {
+        //  console.log(boxData.value[index].box_lock_address)
+        openBox(value, boxData.value[index].box_lock_address);
+      }
     }
+    // ElMessage.success(value + "号柜远程开启成功");
   }
-  console.log(sitesList)
-  var sites = []
-  for (var i in sitesList) {
-    sites.push({ id: i, label: sitesList[i].data.dictLabel })
+
+  const initData = async () => {
+    const res = await listCarPath({ pageSize: 1000 });
+    carPathList.value = res.rows;
   }
-  console.log(sites)
-  data.value = [{
-    id: 1,
-    label: "站点",
-  },];
-  data.value[0].children = sites
-  console.log(data.value)
-  showTree.value = false;
-  setTimeout(() => {
-    showTree.value = true
-  }, 100);
 
-}
 
+  const defaultProps = {
+    children: "children",
+    label: "label",
+    value: 'id',
+  };
+  const treeIndent = ref(40);
 
-const getSites = () => {
-  listData({ dictType: "tbl_sites" }).then(res2 => {
-    sites.value = res2.rows;
+  watch(filterText, (val) => {
+    if (treeRef.value) {
+      treeRef.value.filter(val);
+    }
+  });
 
-    var index = 1;
+  const savedata = () => {
+    //保存数据
+    var data = {
+      dictCode: currentdata.value.dictCode,
+      dictValue: currentdata.value.dictValue,
+      dictLabel: currentdata.value.dictLabel,
+      dictType: "tbl_sites",
+      remark: JSON.stringify(tableData.value)
+    }
+    updateData(data).then(res => {
+      ElMessage.success("成功!");
+      getSites();
+
+    })
+  }
+
+  const getLineSites = () => {
+    console.log(line.value)
+    var sitesList = []
+    for (var index in carPathList.value) {
+      if (carPathList.value[index].id == line.value) {
+        sitesList = JSON.parse(carPathList.value[index].stationList)
+      }
+    }
+    console.log(sitesList)
+    var sites = []
+    for (var i in sitesList) {
+      sites.push({ id: i, label: sitesList[i].data.dictLabel })
+    }
+    console.log(sites)
     data.value = [{
       id: 1,
       label: "站点",
-      children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
     },];
-  });
-}
-
-const deleteDevice = (datac) => {
-  tableData.value = tableData.value.filter(i => i.type != datac.type);
-  var data = {
-    dictCode: currentdata.value.dictCode,
-    dictValue: currentdata.value.dictValue,
-    dictLabel: currentdata.value.dictLabel,
-    dictType: "tbl_sites",
-    remark: JSON.stringify(tableData.value)
-  }
-  updateData(data).then(res => {
-    ElMessage.success("成功!");
-  })
-}
+    data.value[0].children = sites
+    console.log(data.value)
+    showTree.value = false;
+    setTimeout(() => {
+      showTree.value = true
+    }, 100);
 
-const handleTabClick = () => {
+  }
 
-}
 
-const filterNode = (value: string, node: TreeNode) => {
-  if (node.id == 1) return true;
-  console.log(node.label.indexOf(value) != -1)
-  return node.label.indexOf(value) != -1;
-};
+  const getSites = () => {
+    listData({ dictType: "tbl_sites" }).then(res2 => {
+      sites.value = res2.rows;
 
-const currentdata = ref(null)
+      var index = 1;
+      data.value = [{
+        id: 1,
+        label: "站点",
+        children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
+      },];
+    });
+  }
 
-const treeclick = (data: TreeNodeData, node: TreeNode) => {
+  const openAllBox = () => {
+    let code = boxCode.value
+    openall(code).then(res => {
+      console.log(res)
+      if (res.code == 0) {
+        ElMessage.success("打开所有柜子成功");
+      }
+    })
+  }
 
-  currentdata.value = sites.value.filter(i => {
-    return i.dictLabel == data.label
-  })[0];
-  console.log(currentdata.value)
-  tableData.value = JSON.parse(currentdata.value.remark)
-  if (currentdata.value) {
-    var cabinets = tableData.value.filter(i => i.type == 'cabinet');
-    if (cabinets.length > 0) {
-      type.value = cabinets[0].cabinetType
-    }else {
-      type.value = 4
+  const deleteDevice = (datac) => {
+    tableData.value = tableData.value.filter(i => i.type != datac.type);
+    var data = {
+      dictCode: currentdata.value.dictCode,
+      dictValue: currentdata.value.dictValue,
+      dictLabel: currentdata.value.dictLabel,
+      dictType: "tbl_sites",
+      remark: JSON.stringify(tableData.value)
     }
+    updateData(data).then(res => {
+      ElMessage.success("成功!");
+    })
   }
 
-}
+  const handleTabClick = () => {
 
+  }
+
+  const filterNode = (value: string, node: TreeNode) => {
+    if (node.id == 1) return true;
+    console.log(node.label.indexOf(value) != -1)
+    return node.label.indexOf(value) != -1;
+  };
+
+  const currentdata = ref(null)
+
+  const treeclick = (data: TreeNodeData, node: TreeNode) => {
+
+    currentdata.value = sites.value.filter(i => {
+      return i.dictLabel == data.label
+    })[0];
+    // console.log(currentdata.value)
+    tableData.value = JSON.parse(currentdata.value.remark)
+    if (currentdata.value) {
+      var cabinets = tableData.value.filter(i => i.type == 'cabinet');
+      // console.log(cabinets)
+      boxCode.value = cabinets[0].code
+      getBoxInfoData(cabinets[0].code)
+      if (cabinets.length > 0) {
+        type.value = cabinets[0].cabinetType
+      } else {
+        type.value = 4
+      }
+    }
 
-const addDevice = () => {
-  dialogVisible.value = false;
-  if (formdata.value.name == "") {
-    ElMessage.warning("设备名称未填写");
-    return;
   }
-  if (formdata.value.type == "") {
-    ElMessage.warning("设备类型未填写");
-    return;
+
+  const getBoxInfoData = (code) => {
+    getBoxInfo(code).then(res => {
+      boxData.value = res.data.list
+      console.log(boxData.value)
+    })
   }
-  if (formdata.value.code == "") {
-    ElMessage.warning("设备序列号未填写");
-    return;
+
+
+
+
+  const addDevice = () => {
+    dialogVisible.value = false;
+    if (formdata.value.name == "") {
+      ElMessage.warning("设备名称未填写");
+      return;
+    }
+    if (formdata.value.type == "") {
+      ElMessage.warning("设备类型未填写");
+      return;
+    }
+    if (formdata.value.code == "") {
+      ElMessage.warning("设备序列号未填写");
+      return;
+    }
+    if (tableData.value.filter(i => i.type == formdata.value.type).length > 0) {
+      ElMessage.warning("存在相同类型的设备");
+      return;
+    }
+    tableData.value.push(formdata.value);
+    var data = {
+      dictCode: currentdata.value.dictCode,
+      dictValue: currentdata.value.value,
+      dictLabel: currentdata.value.label,
+      dictType: "tbl_sites",
+      remark: JSON.stringify(tableData.value)
+    }
+    updateData(data).then(res => {
+      ElMessage.success("成功!");
+    })
+
+
   }
-  if (tableData.value.filter(i => i.type == formdata.value.type).length > 0) {
-    ElMessage.warning("存在相同类型的设备");
-    return;
+
+  const currentCabinet = ref({
+    total: 40,
+    unused: 10,
+    boxlist: []
+  })
+  const SycCabinet = (code) => {
+    //TODO 获取格数
+    // var toalnum
+    currentCabinet.value.boxlist = [];
+    for (var i = 0; i < currentCabinet.value.total; i++) {
+      // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+      //@ts-ignore
+      currentCabinet.value.boxlist.push({
+        box_id: 1,
+        box_name: (i + 1) + "",
+        box_status: i % 2
+      }
+      )
+    }
   }
-  tableData.value.push(formdata.value);
-  var data = {
-    dictCode: currentdata.value.dictCode,
-    dictValue: currentdata.value.value,
-    dictLabel: currentdata.value.label,
-    dictType: "tbl_sites",
-    remark: JSON.stringify(tableData.value)
+  const openbox = (code) => {
+    setTimeout(() => {
+      ElMessage.success("指令已发送!");
+    }, 1000);
   }
-  updateData(data).then(res => {
-    ElMessage.success("成功!");
-  })
-
 
-}
-
-const currentCabinet = ref({
-  total: 40,
-  unused: 10,
-  boxlist: []
-})
-const SycCabinet = (code) => {
-  //TODO 获取格数
-  // var toalnum
-  currentCabinet.value.boxlist = [];
-  for (var i = 0; i < currentCabinet.value.total; i++) {
-    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
-    //@ts-ignore
-    currentCabinet.value.boxlist.push({
-      box_id: 1,
-      box_name: (i + 1) + "",
-      box_status: i % 2
+  const formatIndex = (value) => {
+    if (value < 10) {
+      return '0' + value
+    } else {
+      return value
     }
-    )
   }
-}
-const openbox = (code) => {
-  setTimeout(() => {
-    ElMessage.success("指令已发送!");
-  }, 1000);
-}
-
-const formatIndex = (value) => {
-  if (value < 10) {
-    return '0' + value
-  } else {
-    return value
-  }
-}
 
-const data = computed(() => {
+  const data = computed(() => {
 
-  var index = 1;
+    var index = 1;
 
-  return [{
-    id: 1,
-    label: "站点",
-    children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
-  },]
-});
-onMounted(() => {
-  if (treeRef.value) {
-    setTimeout(() => {
-      treeRef.value.expandNode(treeRef.value.getNode(1))
-    }, 100);
-    getSites();
-    initData();
-    // treeRef.value.expandNode(treeRef.value.getNode(1))
-  }
-});
+    return [{
+      id: 1,
+      label: "站点",
+      children: sites.value.map(i => { return { id: ++index, label: i.dictLabel } }),
+    },]
+  });
+  onMounted(() => {
+    if (treeRef.value) {
+      setTimeout(() => {
+        treeRef.value.expandNode(treeRef.value.getNode(1))
+      }, 100);
+      getSites();
+      initData();
+      // treeRef.value.expandNode(treeRef.value.getNode(1))
+    }
+  });
 
 
 
 </script>
 
 <style lang="scss" scoped>
-.card-header {
-  display: flex;
-  flex-direction: row;
-  justify-content: space-between;
-}
-
-.boxunused {
-  background: #3333332d;
-}
-
-.indexDiv {
-  background-color: white;
-  width: 20px;
-  height: 10px;
-  color: #000;
-  font-weight: 600;
-  position: absolute;
-  right: 2px;
-  bottom: 1px;
-  z-index: 1000;
-  font-size: 10px;
-  text-align: center;
-}
+  .card-header {
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+  }
+
+  .boxunused {
+    background: #3333332d;
+  }
+
+  .indexDiv {
+    background-color: white;
+    width: 20px;
+    height: 10px;
+    color: #000;
+    font-weight: 600;
+    position: absolute;
+    right: 2px;
+    bottom: 1px;
+    z-index: 1000;
+    font-size: 10px;
+    text-align: center;
+  }
 </style>