This commit is contained in:
liang.chao 2025-11-26 13:40:28 +08:00
parent 90fd9a61e3
commit 0d9cf0e0b4
2 changed files with 244 additions and 1 deletions

View File

@ -19,7 +19,10 @@ export function updateKyFilesIndexAPI(data) {
} }
// 删除数据类型 // 删除数据类型
export function delKyFilesIndexAPI(data) { export function delKyFilesIndexAPI(id) {
let data = {
id: id
};
return request({ return request({
url: '/blade-system/FileIndex/del', url: '/blade-system/FileIndex/del',
method: 'POST', method: 'POST',

View File

@ -0,0 +1,240 @@
<template>
<basic-container>
<avue-crud
:option="option"
:table-loading="loading"
:data="data"
v-model:page="page"
:permission="permissionList"
:before-open="beforeOpen"
v-model="form"
ref="crud"
@row-update="rowUpdate"
@row-save="rowSave"
@row-del="rowDel"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
>
</avue-crud>
</basic-container>
</template>
<script>
import {
addKyFilesIndexAPI,
updateKyFilesIndexAPI,
delKyFilesIndexAPI,
getKyFilesIndexAPI,
} from '@/api/archivesManagement/fileIndex';
import { mapGetters } from 'vuex';
import website from '@/config/website';
export default {
data() {
return {
form: {},
query: {},
loading: true,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
option: {
height: 'auto',
calcHeight: 32,
tip: false,
searchShow: true,
searchMenuSpan: 6,
border: true,
index: true,
viewBtn: false,
selection: false,
addBtn:true,
dialogClickModal: false,
column: [
{
label: '文件名称',
prop: 'fileName',
search: true,
},
{
label: '文件内容',
prop: 'fileContent',
},
{
label: '文件目录',
prop: 'filePath',
},
{
label: '保存日期',
prop: 'saveDate',
},
],
},
data: [],
};
},
computed: {
...mapGetters(['permission']),
permissionList() {
return {
addBtn: this.validData(this.permission.post_add, false),
viewBtn: this.validData(this.permission.post_view, false),
delBtn: this.validData(this.permission.post_delete, false),
editBtn: this.validData(this.permission.post_edit, false),
};
},
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
},
methods: {
rowSave(row, done, loading) {
//
const submitData = {
fileContent: row.fileContent,
fileName: row.fileName,
filePath: row.filePath,
saveDate: row.saveDate,
};
addKyFilesIndexAPI(submitData).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
console.error('新增失败:', error);
loading(); // loading
}
);
},
rowUpdate(row, index, done, loading) {
//
const submitData = {
id: row.id,
fileContent: row.fileContent,
fileName: row.fileName,
filePath: row.filePath,
saveDate: row.saveDate
};
updateKyFilesIndexAPI(submitData).then(
() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
console.log(error);
loading(); //
}
);
},
rowDel(row) {
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return delKyFilesIndexAPI(row.id);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
});
},
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.warning('请选择至少一条数据');
return;
}
this.$confirm('确定将选择数据删除?', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
return delKyFilesIndexAPI(this.ids);
})
.then(() => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
this.$refs.crud.toggleSelection();
});
},
beforeOpen(done, type, row) {
done(); // done()
},
searchReset() {
this.query = {};
this.onLoad(this.page);
},
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
selectionChange(list) {
this.selectionList = list;
},
selectionClear() {
this.selectionList = [];
this.$refs.crud.toggleSelection();
},
currentChange(currentPage) {
this.page.currentPage = currentPage;
},
sizeChange(pageSize) {
this.page.pageSize = pageSize;
},
refreshChange() {
this.onLoad(this.page, this.query);
},
onLoad(page, params = {}) {
this.loading = true;
let data = {
...params,
pageNum:page.currentPage,
pageSize:page.pageSize
};
getKyFilesIndexAPI(data).then(res => {
const data = res.data;
this.page.total = data.total;
this.data = data.rows;
this.loading = false;
this.selectionClear();
});
},
},
};
</script>
<style></style>