Browse Source

feat: 数据删除

Gaokun Wang 5 days ago
parent
commit
d72bddb348
1 changed files with 28 additions and 4 deletions
  1. 28 4
      src/views/test/index.vue

+ 28 - 4
src/views/test/index.vue

@@ -32,7 +32,6 @@
       <div class="table-header">
         <div class="header-button-lf">
           <el-button type="primary" icon="CirclePlus" @click="openDialog('新增')"> 新增 </el-button>
-          <el-button type="danger" icon="Delete" plain> 删除 </el-button>
         </div>
       </div>
       <el-table :data="paginatedData" border ref="tableRef" show-overflow-tooltip>
@@ -49,9 +48,12 @@
             <el-button link type="primary" size="small" @click="designFlow(row)">
               流程设计
             </el-button>
-            <el-button link type="primary" size="small" @click="openDialog('编辑', row)"
-              >编辑</el-button
-            >
+            <el-button link type="primary" size="small" @click="openDialog('编辑', row)">
+              编辑
+            </el-button>
+            <el-button link type="danger" icon="Delete" plain @click="deleteRow(row)">
+              删除
+            </el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -76,6 +78,7 @@ import { wsClient, wsStatus, useWebSocketManager } from '@/utils/webSocket'
 import { useCaseFlowData } from '@/store/caseFlow'
 import { PaginationParams } from '@/types/list'
 import { filterItems, frontendPaginate } from '@/utils/list'
+import { ElMessageBox } from 'element-plus'
 const { sendMessage } = useWebSocketManager()
 const useStoreCaseFlowData = useCaseFlowData()
 // 组件加载完成后发送初始消息
@@ -170,5 +173,26 @@ const designFlow = (row: Partial<CaseVO> = {}) => {
 const detail = (row: Partial<CaseVO> = {}) => {
   router.push(`/detail/${row.id}`)
 }
+
+const deleteRow = async (row: CaseVO) => {
+  ElMessageBox.confirm(`是否删除【${row.name}}】数据?`, '温馨提示', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning',
+    draggable: true
+  }).then(() => {
+    if (wsClient.value && wsStatus.value === '已连接') {
+      sendMessage({
+        serverName: 'wsClient',
+        type: 'delete',
+        data: {
+          id: row.id
+        }
+      })
+    } else {
+      console.log('WebSocket 未连接,无法发送初始消息')
+    }
+  })
+}
 </script>
 <style lang="scss" scoped></style>