添加命令删除,修改命令部分页面

This commit is contained in:
junleea 2025-06-06 15:12:30 +08:00
parent 3d5acbe68a
commit 747e1d1895
2 changed files with 15 additions and 17 deletions

View File

@ -10,11 +10,10 @@ export const updateConfigShellService = (data) => {
} }
export const deleteConfigShellService = (data) => { export const deleteConfigShellService = (data) => {
const params = new URLSearchParams(); let reqData={
for (let key in data) { "shells": data.shells,
params.append(key, data[key])
} }
return request.post('/shell/delete', params, { "headers": { 'token': data.token } }); return request.post('/shell/delete', reqData, { "headers": { 'token': data.token } });
} }
export const addConfigShellService = (data) => { export const addConfigShellService = (data) => {

View File

@ -1,9 +1,6 @@
<script> <script>
import axios from "axios";
import router from "@/router/index.js"; import router from "@/router/index.js";
import Cookies from "js-cookie";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import CryptoJS from "crypto-js";
import Menu from "@/views/Menu.vue"; import Menu from "@/views/Menu.vue";
import { getConfigShellListService } from "@/api/shell.js"; import { getConfigShellListService } from "@/api/shell.js";
@ -16,6 +13,7 @@ export default {
return { return {
ip: "", ip: "",
tableData: [], tableData: [],
loading: false,
search_id: 2002, search_id: 2002,
ConfigShellUpdateForm: {}, ConfigShellUpdateForm: {},
keyword: "", keyword: "",
@ -56,6 +54,7 @@ export default {
methods: { methods: {
async getConfigFileList() { async getConfigFileList() {
let result = {}; let result = {};
this.loading = true;
try { try {
//search_id //search_id
let req = { let req = {
@ -65,6 +64,8 @@ export default {
result = await getConfigShellListService(req); result = await getConfigShellListService(req);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
} finally {
this.loading = false;
} }
let data = result.data; let data = result.data;
if (data !== undefined && data !== null) { if (data !== undefined && data !== null) {
@ -130,18 +131,15 @@ export default {
if (!isDelete) { if (!isDelete) {
return; return;
} }
// alert(" index: " + index);
// return ;
let is_delete_file = confirm("是否删除文件?");
let result = {}; let result = {};
try { try {
let req = { let req = {
token: this.tokenData.token, token: this.tokenData.token,
id: this.ConfigFileCurrentPageData[index].ID, shells: [{"id":this.ConfigFileCurrentPageData[index].ID}],
del_file: is_delete_file,
}; };
result = await deleteConfigFileService(req); console.log("req:", req);
result = await deleteConfigShellService(req);
if (result.code == 0) { if (result.code == 0) {
ElMessage.success("删除成功"); ElMessage.success("删除成功");
this.getConfigFileList(); this.getConfigFileList();
@ -398,7 +396,7 @@ export default {
</el-dialog> </el-dialog>
<!-- 表格 :row-style="this.tableRowClassName"--> <!-- 表格 :row-style="this.tableRowClassName"-->
<el-table :data="ConfigFileCurrentPageData" width="100%" border> <el-table :data="ConfigFileCurrentPageData" width="100%" v-loading="loading">
:row-style="tableRowClassName" :row-style="tableRowClassName"
<el-table-column prop="ID" label="id" width="80"></el-table-column> <el-table-column prop="ID" label="id" width="80"></el-table-column>
<el-table-column <el-table-column
@ -409,6 +407,7 @@ export default {
<el-table-column <el-table-column
prop="ShellContent" prop="ShellContent"
label="命令内容" label="命令内容"
show-overflow-tooltip
width="120" width="120"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
@ -436,7 +435,7 @@ export default {
label="创建用户ID" label="创建用户ID"
width="40" width="40"
></el-table-column> ></el-table-column>
<el-table-column label="操作" width="250"> <el-table-column label="操作" width="270">
<template #default="scope"> <template #default="scope">
<el-button <el-button
type="primary" type="primary"
@ -444,12 +443,12 @@ export default {
@click.prevent="updateConfigShell(scope.$index)" @click.prevent="updateConfigShell(scope.$index)"
>编辑</el-button >编辑</el-button
> >
<!-- <el-button <el-button
type="primary" type="primary"
size="mini" size="mini"
@click.prevent="deleteConfigFile(scope.$index)" @click.prevent="deleteConfigFile(scope.$index)"
>删除</el-button >删除</el-button
> --> >
<el-button <el-button
type="primary" type="primary"
size="mini" size="mini"