Explorar o código

'选中删除功能'

蒋珅 hai 1 ano
pai
achega
4c5fbbcdf0

+ 1 - 1
index.html

@@ -5,7 +5,7 @@
     <meta charset="UTF-8" />
     <link rel="icon" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>发电能力分析平台</title>
+    <title>taos管理</title>
     <script src="./static/config/modeConfig.js"></script>
 </head>
 

+ 2 - 1
src/App.vue

@@ -1,8 +1,9 @@
+
 <template>
   <router-view />
 </template>
 
-<script lang="ts" setup>
+<script  setup>
 // import dotList from './data.json'
 const res = {
   data: {

+ 8 - 0
src/api/config.js

@@ -7,6 +7,14 @@ const config = {
     taosURL: 'http://192.168.10.9:5085',
     taosetURL: 'ws://192.168.10.9:5085'
 }
+// const config = {
+//     baseURL: 'http://10.0.118.76:6041',
+//     socketURL: 'ws://10.0.118.76:6041',
+//     redisURL: 'http://10.0.118.76:5087',
+//     redisetURL: 'ws://10.0.118.76:5087',
+//     taosURL: 'http://10.0.118.76:5085',
+//     taosetURL: 'ws://10.0.118.76:5085'
+// }
 
 // const config = {
 //     baseURL: 'http://192.168.10.28:5087',

+ 1 - 1
src/components/Header.vue

@@ -8,7 +8,7 @@
         <el-icon v-if="!collapse"><Fold /></el-icon>
         <el-icon v-else><Expand /></el-icon>
       </div>
-      <div class="logo">发电能力分析平台</div>
+      <div class="logo">taos管理</div>
     </div>
     <div class="header-right">
       <div class="header-user-con">

+ 89 - 43
src/pages/buildTable/create/index.vue

@@ -1,7 +1,7 @@
 <script setup name="prepare">
 import treeCop from "@/components/tree.vue";
 import { useRouter } from "vue-router";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import { onMounted, ref, reactive, onActivated, nextTick } from "vue";
 
 import {
@@ -23,7 +23,6 @@ const treeHeight = ref(window.innerHeight - 260 + "px"); //tree高度
 const excelHeight = ref(window.innerHeight - 260 + "px"); //excel高度
 const tableHeight = ref(window.innerHeight - 260 + "px");
 
-
 /**tree 开始 */
 const treeData = ref([]);
 
@@ -48,7 +47,6 @@ const funRepeatMap = (arr) => {
   });
 };
 
-
 const funStationGet = async (point) => {
   const res = await request.post(
     "/rest/sql",
@@ -62,7 +60,12 @@ const funGetTree = async () => {
   treeData.value = [];
   const res = await request.post("/rest/sql", "show databases;");
   const databaseNameArray = res.data || [];
-  const blackList = ["information_schema", "performance_schema", "'mydbinfo'"];
+  const blackList = [
+    "information_schema",
+    "performance_schema",
+    "mydbinfo",
+    "log",
+  ];
 
   let resultDatabaesArray = [];
 
@@ -110,7 +113,6 @@ const funGetTree = async () => {
   // nextTick(()=>{
   //    treeData.value=tempTreeData;
   // })
-
 };
 
 const funCurrentChange = async ({ current, currentNode }) => {
@@ -168,7 +170,7 @@ const funCurrentChange = async ({ current, currentNode }) => {
     "/rest/sql",
     `SELECT DISTINCT station FROM ${databaseName}.${tableName}`
   );
-  console.log('69966', ros);
+  // console.log('69966', ros);
   let nbdata = [];
   ros.data.forEach((ele) => {
     ele?.[0] && nbdata.push(ele[0]);
@@ -177,7 +179,7 @@ const funCurrentChange = async ({ current, currentNode }) => {
 
   stationList.value = nbdata;
 
-  console.log(7777777777, stationList.value);
+  // console.log(7777777777, stationList.value);
   if (stationList.value.length) {
     queryForm.station = stationList.value[0];
   }
@@ -204,8 +206,8 @@ const nbsubmit = async () => {
     const res = await request.post(
       "/rest/sql",
       `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${
-        tableData.value[0].databaseName
-      }.${tableData.value[0].tableName}
+        myData.nxxy
+      }.${myData.nxxy1}
    where ${
      queryForm.station === "all"
        ? ""
@@ -218,7 +220,7 @@ const nbsubmit = async () => {
         queryForm.uniformcode === ""
           ? ""
           : "and uniformcode=" + queryForm.uniformcode
-      } limit ${pagenumber.value - 1}, ${pagenb.value - 1}
+      } limit ${pagenumber.value - 1}, ${pagenb.value}
    `
     );
 
@@ -244,7 +246,7 @@ const nbsubmit = async () => {
       // dateItem.databaseName = databaseName;
       // dateItem.tableName = tableName;
       newdata.push(dateItem);
-      console.log('nbnbnb',newdata);
+      console.log("nbnbnb", newdata);
     });
     console.log(999999, newdata);
     tableData.value = newdata;
@@ -264,10 +266,8 @@ const nbsubmit = async () => {
 //   document.body.removeChild(el);
 // };
 
-
 //导出Excel
 const exportDepReceRank = () => {
-
   // const requestUrl = config[urlKey];
   // console.log('nnnnnnnnn');
 
@@ -279,12 +279,11 @@ const exportDepReceRank = () => {
   exportMethod(myObj);
 };
 
-const uploadRef = ref();
+const upload = ref();
 const fslist = async (urlKey) => {
   const requestUrl = config[urlKey];
   const res = await request.post(`${requestUrl}/taos/uploadexcel`);
   console.log("nbnbnbnbn", res);
-  
 };
 
 // 路由传递数据
@@ -315,18 +314,19 @@ const funSubmit = async (params) => {
   }
 };
 
-
-
 let pagenumber = ref(1); //当前的页数
 const pagenb = ref(100); //当前的条数
 let myData = JSON.parse(sessionStorage.getItem("myData"));
 
-console.log("hahhah", pagenumber.value);
+// console.log("hahhah", pagenumber.value);
+
 const left1 = async () => {
   pagenumber.value -= 1;
+  let nbfist = (pagenumber.value - 1) * 100;
+  pagenb.value = nbfist + 99;
   const res = await request.post(
     "/rest/sql",
-    `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${myData.nxxy}.${myData.nxxy1} limit 99;`
+    `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${myData.nxxy}.${myData.nxxy1} limit ${nbfist}, ${pagenb.value};`
   );
   let newdata = [];
 
@@ -352,11 +352,14 @@ const left1 = async () => {
   });
   tableData.value = newdata;
 };
+
 const right1 = async () => {
   pagenumber.value += 1;
+  let nbfist = (pagenumber.value - 1) * 100;
+  pagenb.value = nbfist + 99;
   const res = await request.post(
     "/rest/sql",
-    `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${myData.nxxy}.${myData.nxxy1} limit 99;`
+    `SELECT tbname as point,description,ts,val,station,category,facility,uniformcode,rate,remark FROM ${myData.nxxy}.${myData.nxxy1} limit ${nbfist}, ${pagenb.value};`
   );
   let newdata = [];
   const map = {
@@ -380,7 +383,6 @@ const right1 = async () => {
   });
   tableData.value = newdata;
 };
-
 const formlist = reactive({
   cedian: "",
   miaoshu: "",
@@ -392,7 +394,6 @@ const formlist = reactive({
   beizhu: "",
 });
 
-
 let dialogFormVisible = ref(false);
 let editIndex = ref(-1);
 //编辑
@@ -408,7 +409,7 @@ const handleEdit = (index) => {
   formlist.beilv = tableData.value[editIndex.value].rate;
   formlist.beizhu = tableData.value[editIndex.value].remark;
 };
-
+    
 const queren = () => {
   dialogFormVisible.value = false;
   tableData.value[editIndex.value].point = formlist.cedian;
@@ -427,20 +428,58 @@ const handleDelete = (index) => {
   tableData.value.splice(editIndex.value, 1);
 };
 
+//  选中
+let selectedRows = reactive([]);
+const handleSelectionChange = (selection) => {
+  console.log("991", selection);
+  selectedRows = selection;
+  console.log("992", selectedRows);
+};
+
+// 选中删除
+const bdhandleDelete = () => {
+  ElMessageBox.confirm(
+    '确认要删除吗?',
+    'Warning',
+    {
+      confirmButtonText: '确定',
+      cancelButtonText: '取消',
+      type: 'warning',
+    }
+  )
+    .then(() => {
+      ElMessage({
+        type: 'success',
+        message: '删除成功',
+      })
+       selectedRows.forEach((selectedRows) => {
+       const index = tableData.value.indexOf(selectedRows); // 获取选中数据在原数组中的索引
+       if (index > -1) {
+       tableData.value.splice(index, 1); // 从原数组中删除选中的数据
+    }
+  });
+    })
+    .catch(() => {
+      ElMessage({
+        type: 'info',
+        message: '删除失败',
+      })
+    })
+};
+   
+  
 /**mounted */
 onMounted(() => {
   tableHeight.value = window.innerHeight - 260 + "px";
   excelHeight.value = window.innerHeight - 260 + "px";
   treeHeight.value = window.innerHeight - 260 + "px";
-  window.addEventListener("resize", () => {
+  window.addEventListener("resize", () => {  
     tableHeight.value = window.innerHeight - 260 + "px";
     excelHeight.value = window.innerHeight - 260 + "px";
     treeHeight.value = window.innerHeight - 260 + "px";
   });
-
   console.log("asasa", config);
 });
-
 /**activated */
 onActivated(() => {
   funGetTree();
@@ -496,19 +535,17 @@ onActivated(() => {
           <el-button type="primary">选择文件</el-button>
         </template>
       </el-upload>
-
+      
       <el-form-item class="!mb-0 ml-5">
         <el-button @click="fslist('redisURL')" type="success">上传</el-button>
       </el-form-item>
       <el-form-item class="!mb-0 ml-5">
-        <el-button @click="exportDepReceRank" type="primary"
-          >下载建点、修改点模板</el-button
-        >
+        <el-button @click="exportDepReceRank" type="primary">下载建点、修改点模板</el-button>
       </el-form-item>
     </div>
+
     <div
-      class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[20px] pb-[10px]"
-    >
+      class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[20px] pb-[10px]">
       <el-row :gutter="10">
         <el-col :span="4">
           <tree-cop
@@ -521,15 +558,21 @@ onActivated(() => {
           </tree-cop>
         </el-col>
 
-        <el-col :span="19">
+        <el-col :span="20">
           <div>
             <el-scrollbar max-height="650px">
               <el-table
                 :data="tableData"
                 style="width: 100% ,height:650px"
                 @cell-dblclick="dbclick"
+                @row-contextmenu="handleContextMenu"
+                @selection-change="handleSelectionChange"
               >
                 <el-table-column
+                  type="selection"
+                  align="center"
+                ></el-table-column>
+                <el-table-column
                   prop="point"
                   label="测点"
                   align="center"
@@ -552,7 +595,7 @@ onActivated(() => {
 
                 <el-table-column prop="val" label="值" align="center" />
                 <el-table-column prop="station" label="场站" align="center" />
-                <el-table-column prop="category " label="类别" align="center" />
+                <el-table-column prop="category" label="类别" align="center" />
                 <el-table-column
                   prop="equipment"
                   label="设备id"
@@ -576,9 +619,9 @@ onActivated(() => {
                     />
 
                     <el-button
-                       type="danger"
-                       :icon="Delete"
-                       circle
+                      type="danger"
+                      :icon="Delete"
+                      circle
                       @click="handleDelete(scope.$index, scope.row)"
                     />
                   </template>
@@ -587,15 +630,17 @@ onActivated(() => {
             </el-scrollbar>
           </div>
 
-          <el-button @click="left1" :disabled="pagenumber <= 1"
-            >上一页</el-button
-          >
-          <span class="pl-2"> {{ pagenumber }} </span>
-          <el-button @click="right1">下一页</el-button>
+          <div v-if="tableData?.length">
+            <el-button @click="left1" :disabled="pagenumber <= 1"
+              >上一页</el-button
+            >
+            <span class="pl-2"> {{ pagenumber }} </span>
+            <el-button class="ml-2" @click="right1">下一页</el-button>
+            <el-button class="ml-2" @click="bdhandleDelete">选中删除</el-button>
+          </div>
         </el-col>
       </el-row>
     </div>
-
     <el-dialog v-model="dialogFormVisible">
       <el-form :model="formlist">
         <el-form-item label="测点">
@@ -630,5 +675,6 @@ onActivated(() => {
         </span>
       </template>
     </el-dialog>
+  
   </div>
 </template>

+ 84 - 3
src/pages/look/create/index.vue

@@ -68,9 +68,7 @@
         <el-button type="primary" @click="onSubmit">导出</el-button>
       </el-form-item>
     </el-form>
-
   </div>
-
   <div
     class="relative shadow rounded-[6px] shadow-blue-500 px-[10px] pt-[20px] pb-[10px]">
     <el-table :data="tableData" border style="width: 100%">
@@ -78,7 +76,18 @@
       <el-table-column prop="ts" label="时间" width="200" align="center" />
       <el-table-column prop="val" label="值" align="center" />
     </el-table>
+    <div v-if="tableData?.length">
+            <el-button
+              @click="left1"
+              :disabled="pagenumber.value >= 1"
+              class="ml-5"
+              >上一页</el-button
+            >
+            <span class="pl-2">{{ pagenumber }}</span>
+            <el-button @click="right1" class="ml-5">下一页</el-button>
+          </div>
   </div>
+   
 </template>
 
 <script setup name="look">
@@ -114,7 +123,7 @@ const looksubmit = async (point) => {
         queryForm.tableName
       } where ts between ${new Date(
         timedata.value[0]
-      ).getTime()} and ${new Date(timedata.value[1]).getTime()}`
+      ).getTime()} and ${new Date(timedata.value[1]).getTime()} order by ts desc limit ${pagenumber.value-1}, ${pagenb.value}`
     );
 
     //映射数组中的数据,做数据处理相对应的结果
@@ -138,6 +147,77 @@ const looksubmit = async (point) => {
   }
 };
 
+
+let pagenumber = ref(1); //当前的页数
+let pagenb = ref(99); //当前的条数
+
+console.log(666666, pagenumber.value);
+const left1 =async () => {
+  pagenumber.value -= 1
+  let nbfist=(pagenumber.value-1)*100
+  pagenb.value=nbfist+99
+  const res = await request.post(
+      "/rest/sql",
+      `select * from ${myData.nxxy}.${
+        queryForm.tableName
+      } where ts between ${new Date(
+        timedata.value[0]
+      ).getTime()} and ${new Date(timedata.value[1]).getTime()} order by ts desc limit ${nbfist}, ${pagenb.value}`
+    );
+
+    //映射数组中的数据,做数据处理相对应的结果
+    let newdata = [];
+    const map = {
+      0: "ts",
+      1: "val",
+    };
+    res.data.forEach((ele) => {
+      let dateItem = {};
+      for (let key in ele) {
+        dateItem[map[key]] = ele[key];
+      }
+      newdata.push(dateItem);
+    });
+
+    // console.log(6666,newdata);
+    tableData.value = newdata;
+    console.log(88, tableData.value);
+    
+};
+
+const right1 =async () => {
+  pagenumber.value += 1;
+  let nbfist=(pagenumber.value-1)*100
+  pagenb.value=nbfist+99
+  const res = await request.post(
+      "/rest/sql",
+      `select * from ${myData.nxxy}.${
+        queryForm.tableName
+      } where ts between ${new Date(
+        timedata.value[0]
+      ).getTime()} and ${new Date(timedata.value[1]).getTime()} order by ts desc limit ${nbfist}, ${pagenb.value}`
+    );
+
+    //映射数组中的数据,做数据处理相对应的结果
+    let newdata = [];
+    const map = {
+      0: "ts",
+      1: "val",
+    };
+    res.data.forEach((ele) => {
+      let dateItem = {};
+      for (let key in ele) {
+        dateItem[map[key]] = ele[key];
+      }
+      newdata.push(dateItem);
+    });
+
+    // console.log(6666,newdata);
+    tableData.value = newdata;
+    console.log(88, tableData.value);
+    
+  };
+
 const route = useRoute();
 onMounted(() => {
   //路由传过来的数据
@@ -147,6 +227,7 @@ onMounted(() => {
   // console.log(666666666666,queryForm.databaseName);
   // console.log(666666666666,queryForm.tableName);
 });
+
 </script>
 
 <style scoped>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 130 - 38
src/pages/search/create/index.vue


+ 1 - 1
src/router/index.js

@@ -163,7 +163,7 @@ const router = createRouter({
 })
 
 router.beforeEach((to, from, next) => {
-    document.title = `${to.meta.title} | 发电能力分析平台`
+    document.title = `${to.meta.title} | taos管理`
     // const role = sessionStorage.getItem('ms_chinesename')
     // if (!role && to.path !== '/login') {
     //     next('/login')