mirror of
https://gitee.com/xiongmao1988/rax-medical.git
synced 2025-08-24 13:04:57 +08:00
日志和消息模块
This commit is contained in:
parent
ec8e203e67
commit
c05e694e38
|
@ -2,6 +2,7 @@ import request, {CommonHeaderEnum} from "@/utils/request";
|
|||
|
||||
const getMonthlyLogCountUrl = '/admin/log/getMonthlyLogCount'
|
||||
const getPageUrl = "/admin/log/page";
|
||||
const logUrl = "/admin/log";
|
||||
|
||||
export function getMonthlyLogCount(startTime: string, endTime: string) {
|
||||
return new Promise(resolve => {
|
||||
|
@ -21,12 +22,31 @@ export function getMonthlyLogCount(startTime: string, endTime: string) {
|
|||
})
|
||||
}
|
||||
|
||||
export function getPage(current: number, size: number) {
|
||||
export function getPage(current: number, size: number, condition: {timeInterval: string, logType: string}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.get(getPageUrl + `?current=${current}&size=${size}`).then((res: any) => {
|
||||
request.get(getPageUrl, {
|
||||
params: {
|
||||
current,
|
||||
size,
|
||||
timeInterval: condition?.timeInterval,
|
||||
logType: condition?.logType
|
||||
}
|
||||
}).then((res: any) => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
reject(err);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteByIds(ids: string[]) {
|
||||
return new Promise(resolve => {
|
||||
request.delete(logUrl, {
|
||||
data: ids
|
||||
}).then(res => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
resolve(err);
|
||||
})
|
||||
})
|
||||
}
|
|
@ -2,6 +2,8 @@ import request from "@/utils/request";
|
|||
|
||||
const saveUrl = "/admin/sysMessage/save";
|
||||
const pageUrl = "/admin/sysMessage/page";
|
||||
const updateUrl = "/admin/sysMessage/update";
|
||||
const deleteUrl = "/admin/sysMessage/delete";
|
||||
|
||||
export function save(message: any, organization?: [], permissions?: []) {
|
||||
return new Promise(resolve => {
|
||||
|
@ -13,6 +15,26 @@ export function save(message: any, organization?: [], permissions?: []) {
|
|||
})
|
||||
}
|
||||
|
||||
export function update(message: any) {
|
||||
return new Promise(resolve => {
|
||||
request.postForm(updateUrl, message).then(res => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
resolve(err);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteByIds(ids: string[]) {
|
||||
return new Promise(resolve => {
|
||||
request.postForm(deleteUrl, {ids: ids.join(",")}).then(res => {
|
||||
resolve(res.data);
|
||||
}).catch(err => {
|
||||
resolve(err);
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function page(current: number, size: number, condition?: { category: string, message: string }) {
|
||||
return new Promise(resolve => {
|
||||
request.postForm(pageUrl, {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
export enum LogTypeEnum {
|
||||
NORMAL = '0',
|
||||
ADD = "1",
|
||||
DELETE = "2",
|
||||
MODIFY = "3",
|
||||
EXCEPTION = '4',
|
||||
}
|
|
@ -35,7 +35,7 @@ export const getMessageType = () => {
|
|||
export const getLogType = () => {
|
||||
const type = []
|
||||
type.push({ label: '正常', value: '0' })
|
||||
type.push({ label: '异常', value: '9' })
|
||||
type.push({ label: '异常', value: '4' })
|
||||
type.push({ label: '添加', value: '1' })
|
||||
type.push({ label: '删除', value: '2' })
|
||||
type.push({ label: '编辑', value: '3' })
|
||||
|
|
|
@ -20,7 +20,6 @@ export const tableRemoveRow = (params: any, callback: (res: boolean) => void) =>
|
|||
draggable: true
|
||||
}
|
||||
).then(() => {
|
||||
ElMessage.success('删除成功!')
|
||||
callback(true)
|
||||
}).catch(() => {
|
||||
callback(false)
|
||||
|
@ -36,7 +35,6 @@ export const tableRemoveRow = (params: any, callback: (res: boolean) => void) =>
|
|||
draggable: true
|
||||
}
|
||||
).then(() => {
|
||||
ElMessage.success('删除成功!')
|
||||
callback(true)
|
||||
}).catch(() => {
|
||||
callback(false)
|
||||
|
|
|
@ -5,20 +5,45 @@
|
|||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
|
||||
import {onMounted, ref} from 'vue'
|
||||
import * as echarts from 'echarts'
|
||||
import { dateFormater, getDays } from '@/utils/date-util'
|
||||
import {dateFormater, getDays, getEndOfMonth} from '@/utils/date-util'
|
||||
import * as logManageApi from '@/api/log-manage'
|
||||
|
||||
const chartDom = ref()
|
||||
|
||||
onMounted(() => {
|
||||
getData(new Date())
|
||||
const month = dateFormater('yyyy-MM');
|
||||
const startTime = month + '-01'
|
||||
const endTime = month + '-' + getEndOfMonth(new Date().getFullYear(), new Date().getMonth() + 1);
|
||||
getMonthlyLogCount(startTime, endTime);
|
||||
})
|
||||
|
||||
// 大于当前时间返回 true
|
||||
function calcTime(time: any) {
|
||||
return Boolean(new Date().getTime() < new Date(time).getTime())
|
||||
function getMonthlyLogCount(startTime: string, endTime: string) {
|
||||
logManageApi.getMonthlyLogCount(startTime, endTime).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
|
||||
formatMonthLog(res.data, startTime);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formatMonthLog(params: any, startTime: string) {
|
||||
const dateNum: number = getEndOfMonth(new Date(startTime).getFullYear(), new Date(startTime).getMonth() + 1);
|
||||
const dataMap: any = {};
|
||||
params.forEach((item: any) => {
|
||||
dataMap[item.date] = item.count;
|
||||
})
|
||||
const xData = []
|
||||
const data = []
|
||||
for (let i = 0; i < dateNum; i++) {
|
||||
const dateTemp = getDays(new Date(startTime), i);
|
||||
xData.unshift(dateTemp);
|
||||
data.unshift(dataMap[dateFormater("yyyy-MM-dd", dateTemp)] ? dataMap[dateFormater("yyyy-MM-dd", dateTemp)] : 0);
|
||||
initChart({xData, data});
|
||||
}
|
||||
}
|
||||
|
||||
function initChart(chartData: any) {
|
||||
const chart = echarts.init(chartDom.value as HTMLElement);
|
||||
chart.clear();
|
||||
|
@ -27,7 +52,7 @@ function initChart(chartData: any) {
|
|||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
return dateFormater('yyyy-MM-dd', params[0].axisValue) + '<br>登录记录:' + params[0].value + '条'
|
||||
return dateFormater('yyyy-MM-dd', params[0].axisValue) + '<br>记录:' + params[0].value + '条'
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
|
@ -45,7 +70,11 @@ function initChart(chartData: any) {
|
|||
nameTextStyle: {color: '#909399'},
|
||||
axisLine: {show: true, lineStyle: {color: '#006080', width: 2}},
|
||||
axisTick: {show: false},
|
||||
axisLabel: { show: true, interval: chartData.xData.length - 2, formatter: (value: any) => dateFormater('MM-dd', value) },
|
||||
axisLabel: {
|
||||
show: true,
|
||||
interval: chartData.xData.length - 2,
|
||||
formatter: (value: any) => dateFormater('MM-dd', value)
|
||||
},
|
||||
splitLine: {show: true, lineStyle: {color: 'rgba(0, 96, 128, .05)', width: 1, type: 'solid'}},
|
||||
data: chartData.xData,
|
||||
},
|
||||
|
@ -90,17 +119,6 @@ function initChart(chartData: any) {
|
|||
chart.resize();
|
||||
});
|
||||
}
|
||||
|
||||
const getData = (date: Date) => {
|
||||
|
||||
const xData = []
|
||||
const data = []
|
||||
for (let i = 0; i < 30; i++) {
|
||||
xData.unshift(getDays(date, -1))
|
||||
data.unshift(Math.ceil(Math.random() * 10))
|
||||
}
|
||||
initChart({ xData, data })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
@ -111,6 +129,7 @@ const getData = (date: Date) => {
|
|||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.chart-dom {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
|
|
@ -49,7 +49,7 @@ import {getMessageType} from '@/static-data/core'
|
|||
import * as hospitalApi from "@/api/hospital";
|
||||
import * as sysMessageApi from "@/api/sys-message";
|
||||
|
||||
const emit = defineEmits(['close'])
|
||||
const emit = defineEmits(['close', 'save'])
|
||||
const props = defineProps({
|
||||
type: String
|
||||
})
|
||||
|
@ -112,16 +112,27 @@ function resetData() {
|
|||
const saveData = () => {
|
||||
formRef.value.validate((valid: any, fields: any) => {
|
||||
if (valid) {
|
||||
if (props.type == "add") {
|
||||
sysMessageApi.save(formData.value).then((res: any) => {
|
||||
if (res.code == 0 && res.data) {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success('保存成功!')
|
||||
close()
|
||||
emit('save');
|
||||
} else {
|
||||
ElMessage.error(res.msg ? res.msg : "保存失败");
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// console.log('error submit!', fields)
|
||||
sysMessageApi.update(formData.value).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success("保存成功");
|
||||
close()
|
||||
emit('save');
|
||||
} else {
|
||||
ElMessage.error(res.msg ? res.msg : "保存失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="search-cell">
|
||||
<span class="label">类型</span>
|
||||
<el-select v-model="queryParams.type" placeholder="请选择类型">
|
||||
<el-option v-for="item in getLogType()" :key="item.value" :label="item.label" :value="item.value"/>
|
||||
<el-option v-for="item in Object.keys(logType)" :key="item" :label="logType[item]" :value="item"/>
|
||||
</el-select>
|
||||
</div>
|
||||
<div class="search-cell">
|
||||
|
@ -16,12 +16,12 @@
|
|||
<el-date-picker v-model="queryParams.time" type="datetimerange" range-separator="-" start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"/>
|
||||
</div>
|
||||
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
|
||||
<el-button icon="Refresh" @click="queryParams = {}">重置</el-button>
|
||||
<el-button type="primary" icon="Search" @click="search">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetSearch">重置</el-button>
|
||||
</div>
|
||||
<div class="button-part" style="justify-content: space-between;">
|
||||
<el-button icon="Delete" @click="removeData()">删除</el-button>
|
||||
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="queryData({})"
|
||||
<TableAbility @searchBtn="isSearch = !isSearch" @refreshBtn="init"
|
||||
@downloadBtn="exportData('日志数据', tableData)"></TableAbility>
|
||||
</div>
|
||||
<div class="table-part">
|
||||
|
@ -29,14 +29,16 @@
|
|||
@row-click="tableRowClick">
|
||||
<el-table-column type="selection" width="55"/>
|
||||
<el-table-column type="index" label="#" width="55" align="center"/>
|
||||
<el-table-column property="type" label="类型" width="120" align="center"/>
|
||||
<el-table-column property="title" label="标题" width="120" align="center"/>
|
||||
<el-table-column property="ip" label="IP地址" width="120" align="center"/>
|
||||
<el-table-column property="requestMethod" label="请求方式" width="120" align="center"/>
|
||||
<el-table-column label="请求时间" width="220" align="center">
|
||||
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.requestTime) }}</template>
|
||||
<el-table-column property="logType" label="类型" width="120" align="center">
|
||||
<template #default="scope">{{ logType[scope.row.logType] }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="operator" label="操作人" width="120" align="center"/>
|
||||
<el-table-column property="title" label="标题" width="120" align="center"/>
|
||||
<el-table-column property="remoteAddr" label="IP地址" width="120" align="center"/>
|
||||
<el-table-column property="method" label="请求方式" width="120" align="center"/>
|
||||
<el-table-column label="请求时间" width="220" align="center">
|
||||
<template #default="scope">{{ scope.row.createTime }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="createBy" label="操作人" width="120" align="center"/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
<span @click.stop>
|
||||
|
@ -48,7 +50,7 @@
|
|||
</el-table>
|
||||
</div>
|
||||
<div class="pagination-part">
|
||||
<CommonPagination :total="100" @paginationChange="paginationChange"/>
|
||||
<CommonPagination :total="total" @paginationChange="paginationChange"/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="40%">
|
||||
|
@ -57,20 +59,22 @@
|
|||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {useRouter, useRoute} from 'vue-router'
|
||||
import {onMounted, ref} from 'vue'
|
||||
import LoginChart from './chart/login-chart.vue'
|
||||
import CommonPagination from '@/components/common-pagination.vue'
|
||||
import LogForm from './form/log-form.vue'
|
||||
import {tableRemoveRow, exportData} from '@/utils/table-util'
|
||||
import {getLogType} from '@/static-data/core'
|
||||
import {dateFormater, getEndOfMonth} from '@/utils/date-util'
|
||||
import {exportData, tableRemoveRow} from '@/utils/table-util'
|
||||
import {dateFormater} from '@/utils/date-util'
|
||||
import * as logManageApi from '@/api/log-manage'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const logType: any = {
|
||||
"0": '正常',
|
||||
"1": '添加',
|
||||
"2": '删除',
|
||||
"3": '修改',
|
||||
"4": '异常'
|
||||
}
|
||||
const tableRef = ref()
|
||||
const logFormRef = ref()
|
||||
const isSearch = ref(true)
|
||||
|
@ -79,25 +83,41 @@ const isFormDialog = ref(false)
|
|||
const formDialogTitle = ref('')
|
||||
const queryParams = ref({} as any)
|
||||
const tableData = ref([] as any)
|
||||
let current = 0;
|
||||
let size = 10;
|
||||
const total = ref(0);
|
||||
|
||||
queryData({type: '正常'})
|
||||
onMounted(() => {
|
||||
init();
|
||||
})
|
||||
|
||||
function queryData(e: any) {
|
||||
loading.value = true
|
||||
tableData.value = []
|
||||
setTimeout(() => {
|
||||
while (tableData.value.length < 10) {
|
||||
tableData.value.push({
|
||||
type: e.type || '正常',
|
||||
title: e.title || '测试',
|
||||
ip: '127.0.0.1',
|
||||
requestMethod: 'post',
|
||||
requestTime: new Date(),
|
||||
operator: 'admin'
|
||||
function init() {
|
||||
loading.value = true;
|
||||
getList();
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
function getList() {
|
||||
logManageApi.getPage(current, size, {
|
||||
timeInterval: queryParams.value.timeStr,
|
||||
logType: queryParams.value.type
|
||||
}).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
total.value = res.data.total
|
||||
tableData.value = res.data.records
|
||||
}
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
}, 200);
|
||||
|
||||
function search() {
|
||||
queryParams.value.timeStr = [dateFormater("yyyy-MM-dd", queryParams.value.time[0]),
|
||||
dateFormater("yyyy-MM-dd", queryParams.value.time[1])]
|
||||
init();
|
||||
}
|
||||
|
||||
function resetSearch() {
|
||||
queryParams.value = {};
|
||||
init();
|
||||
}
|
||||
|
||||
const viewData = (e: any) => {
|
||||
|
@ -109,30 +129,34 @@ const viewData = (e: any) => {
|
|||
}, 0)
|
||||
}
|
||||
const removeData = (e?: any) => {
|
||||
const selectRow = e || tableRef.value.getSelectionRows()
|
||||
const selectRow = e ? [e] : tableRef.value.getSelectionRows()
|
||||
tableRemoveRow({data: selectRow}, (res: boolean) => {
|
||||
if (res) {
|
||||
// console.log('调用删除', selectRow)
|
||||
const ids: string[] = [];
|
||||
selectRow.forEach((row: any) => {
|
||||
ids.push(row.id);
|
||||
})
|
||||
logManageApi.deleteByIds(ids).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success("删除成功");
|
||||
init();
|
||||
} else {
|
||||
ElMessage.error(res.msg ? res.msg : "删除失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const tableRowClick = (row: any) => {
|
||||
tableRef.value.toggleRowSelection(row)
|
||||
}
|
||||
const paginationChange = (page: number, size: number) => {
|
||||
|
||||
const paginationChange = (page: number, s: number) => {
|
||||
current = page
|
||||
size = s
|
||||
getList()
|
||||
}
|
||||
|
||||
function getMonthlyLogCount(startTime: string, endTime: string) {
|
||||
logManageApi.getMonthlyLogCount(startTime, endTime);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const month = dateFormater('yyyy-MM');
|
||||
const startTime = month + '-01'
|
||||
const endTime = month + '-' + getEndOfMonth(new Date().getFullYear(), new Date().getMonth() + 1);
|
||||
getMonthlyLogCount(startTime, endTime);
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
<span class="label">消息内容</span>
|
||||
<el-input v-model="queryParams.content" placeholder="请输入消息内容"></el-input>
|
||||
</div>
|
||||
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
|
||||
<el-button type="primary" icon="Search" @click="search">查询</el-button>
|
||||
<!-- <el-button icon="Refresh" @click="queryParams = {}">重置</el-button> -->
|
||||
</div>
|
||||
<div class="button-part" style="justify-content: space-between;">
|
||||
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
|
||||
<TableAbility :isDownload="false" @searchBtn="isSearch = !isSearch" @refreshBtn="queryData({})"></TableAbility>
|
||||
<TableAbility :isDownload="false" @searchBtn="isSearch = !isSearch" @refreshBtn="init"></TableAbility>
|
||||
</div>
|
||||
<div class="table-part">
|
||||
<el-table ref="tableRef" v-loading="loading" :data="tableData" height="100%" border show-overflow-tooltip>
|
||||
<el-table-column property="type" label="消息类型" width="120" align="center"/>
|
||||
<el-table-column property="content" label="消息内容" width="120" align="center"/>
|
||||
<el-table-column property="creator" label="创建人" width="120" align="center"/>
|
||||
<el-table-column property="category" label="消息类型" width="120" align="center"/>
|
||||
<el-table-column property="message" label="消息内容" width="120" align="center"/>
|
||||
<el-table-column property="creatorName" label="创建人" width="120" align="center"/>
|
||||
<el-table-column label="创建时间" width="220" align="center">
|
||||
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.creatTime) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column property="editor" label="修改人" width="120" align="center"/>
|
||||
<el-table-column property="updaterName" label="修改人" width="120" align="center"/>
|
||||
<el-table-column label="修改时间" width="220" align="center">
|
||||
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.editTime) }}</template>
|
||||
</el-table-column>
|
||||
|
@ -42,12 +42,12 @@
|
|||
</el-table>
|
||||
</div>
|
||||
<div class="pagination-part">
|
||||
<CommonPagination :total="100" @paginationChange="paginationChange"/>
|
||||
<CommonPagination :total="total" @paginationChange="paginationChange"/>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="40%">
|
||||
<MessageForm ref="messageFormRef" :type="formDialogTitle === '新增消息' ? 'add' : 'edit'"
|
||||
@close="isFormDialog = false"/>
|
||||
@close="isFormDialog = false" @save="init"></MessageForm>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
|
@ -60,6 +60,7 @@ import {tableRemoveRow} from '@/utils/table-util'
|
|||
import {getMessageType} from '@/static-data/core'
|
||||
import {dateFormater} from '@/utils/date-util'
|
||||
import * as sysMessageApi from "@/api/sys-message";
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
@ -80,14 +81,19 @@ onMounted(() => {
|
|||
})
|
||||
|
||||
const init = () => {
|
||||
loading.value = true
|
||||
total.value = 0;
|
||||
current = 0;
|
||||
tableData.value = [];
|
||||
getMessageList();
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const getMessageList = () => {
|
||||
sysMessageApi.page(current, size).then((res: any) => {
|
||||
sysMessageApi.page(current, size, {
|
||||
category: queryParams.value.type,
|
||||
message: queryParams.value.content
|
||||
}).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
total.value = res.data.total
|
||||
tableData.value = res.data.records
|
||||
|
@ -95,29 +101,8 @@ const getMessageList = () => {
|
|||
})
|
||||
}
|
||||
|
||||
queryData({type: '公告', content: '测试测试测试'})
|
||||
|
||||
function queryData(e: any) {
|
||||
loading.value = true
|
||||
tableData.value = []
|
||||
setTimeout(() => {
|
||||
while (tableData.value.length < 10) {
|
||||
tableData.value.push({
|
||||
type: e.type || '公告',
|
||||
content: e.content || '测试测试测试',
|
||||
creator: 'admin',
|
||||
creatTime: new Date(),
|
||||
editor: 'admin',
|
||||
editTime: new Date(),
|
||||
hospital: '',
|
||||
showDept: '',
|
||||
permissions: '',
|
||||
link: '',
|
||||
isHot: true,
|
||||
})
|
||||
}
|
||||
loading.value = false
|
||||
}, 200);
|
||||
const search = () => {
|
||||
init()
|
||||
}
|
||||
|
||||
const addData = () => {
|
||||
|
@ -138,10 +123,21 @@ const editData = (e: any) => {
|
|||
}
|
||||
|
||||
const removeData = (e?: any) => {
|
||||
const selectRow = e || tableRef.value.getSelectionRows()
|
||||
const selectRow = [e] || tableRef.value.getSelectionRows()
|
||||
tableRemoveRow({data: selectRow}, (res: boolean) => {
|
||||
if (res) {
|
||||
// console.log('调用删除', selectRow)
|
||||
const ids: any = [];
|
||||
selectRow.forEach((row: any) => {
|
||||
ids.push(row.id);
|
||||
})
|
||||
sysMessageApi.deleteByIds(ids).then((res: any) => {
|
||||
if (res.code == 0) {
|
||||
ElMessage.success("删除成功");
|
||||
init();
|
||||
} else {
|
||||
ElMessage.error(res.msg ? res.msg : "删除失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user