You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
8.7 KiB
354 lines
8.7 KiB
<template> |
|
<basic-container> |
|
<avue-crud |
|
:option="option" |
|
:table-loading="loading" |
|
:data="data" |
|
v-model="form" |
|
v-model:page="page" |
|
ref="crud" |
|
@row-del="rowDel" |
|
@row-update="rowUpdate" |
|
@search-change="searchChange" |
|
@search-reset="searchReset" |
|
@selection-change="selectionChange" |
|
@current-change="currentChange" |
|
@size-change="sizeChange" |
|
@refresh-change="refreshChange" |
|
@on-load="onLoad" |
|
> |
|
<template #menu-left> |
|
<el-button type="primary" @click="handleAdd">新增 </el-button> |
|
<el-button type="danger" icon="el-icon-delete" @click="handleDelete">删除 </el-button> |
|
</template> |
|
<template #menu-right> |
|
<el-button type="primary" icon="el-icon-printer" @click="handlePrint">打印 </el-button> |
|
<el-button type="primary" @click="handleImport">导入 </el-button> |
|
</template> |
|
</avue-crud> |
|
<!-- 导入 --> |
|
<basic-import |
|
v-if="isShowImport" |
|
title="导入" |
|
:isShow="isShowImport" |
|
templateUrl="/blade-desk/bsSafeInspectionPoint/downloadExcelTemplate" |
|
templateName="安全巡检点配置导入模板.xlsx" |
|
importUrl="/blade-desk/bsSafeInspectionPoint/importExcel" |
|
@closeDialog="closeImportDialog" |
|
></basic-import> |
|
<!-- 新增弹窗 --> |
|
<addInspectDailog |
|
v-if="showDialog" |
|
:showDialog="showDialog" |
|
:moldAddMore="moldAddMore" |
|
@closeDialog="closeDialog" |
|
:title="title" |
|
></addInspectDailog> |
|
</basic-container> |
|
</template> |
|
|
|
<script> |
|
import basicImport from '@/components/basic-import/main.vue'; |
|
import { getList, add, remove, update } from '@/api/safetyManagement/safetyInspectionPoint.js'; |
|
import addInspectDailog from './addInspectDailog.vue' |
|
|
|
export default { |
|
components: { |
|
basicImport, |
|
addInspectDailog |
|
}, |
|
data() { |
|
return { |
|
isShowImport: false, |
|
page: { |
|
pageSize: 10, |
|
currentPage: 1, |
|
total: 0, |
|
}, |
|
data: [], |
|
selectionList: [], |
|
query: {}, |
|
option: { |
|
height: 'auto', |
|
calcHeight: 32, |
|
tip: false, |
|
simplePage: true, |
|
searchShow: true, |
|
searchMenuSpan: 6, |
|
searchIcon: true, |
|
searchIndex: 3, |
|
tree: false, |
|
border: true, |
|
index: true, |
|
selection: true, |
|
viewBtn: false, |
|
delBtn: true, |
|
editBtn: true, |
|
editBtnText: '修改', |
|
addBtn: false, |
|
addBtnIcon: false, |
|
viewBtnIcon: ' ', |
|
delBtnIcon: ' ', |
|
editBtnIcon: ' ', |
|
labelWidth: 120, |
|
menuWidth: 150, |
|
dialogWidth: 600, |
|
dialogClickModal: false, |
|
searchEnter: true, |
|
excelBtn: false, |
|
filterBtn: true, |
|
searchShowBtn: false, |
|
columnSort: true, |
|
excelBtn: true, |
|
columnSort: true, |
|
index: false, |
|
showOverflowTooltip: true, |
|
searchLabelPosition: 'left', |
|
searchGutter: 24, |
|
searchSpan: 6, |
|
menuAlign: 'left', |
|
gridBtn: false, |
|
searchMenuPosition: 'right', |
|
align: 'center', |
|
column: [ |
|
{ |
|
label: '巡检点编号', |
|
prop: 'insNum', |
|
sortable: true, |
|
filter: true, |
|
span: 24, |
|
search: true, |
|
searchLabelWidth: 90, |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入巡检点编号', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
{ |
|
label: '巡检点位置', |
|
prop: 'insSite', |
|
sortable: true, |
|
filter: true, |
|
span: 24, |
|
search: true, |
|
searchLabelWidth: 90, |
|
rules: [ |
|
{ |
|
required: true, |
|
message: '请输入巡检点位置', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
// { |
|
// label: '巡检点类型', |
|
// prop: 'insSpotType', |
|
// sortable: true, |
|
// filter: true, |
|
// span: 24, |
|
// search: true, |
|
// searchLabelWidth: 90, |
|
// rules: [ |
|
// { |
|
// required: false, |
|
// message: '请输入巡检点位置', |
|
// trigger: 'blur', |
|
// }, |
|
// ], |
|
// }, |
|
{ |
|
label: '上次检验日期', |
|
prop: 'lastInsCycle', |
|
sortable: true, |
|
filter: true, |
|
span: 24, |
|
search: false, |
|
display: false, |
|
searchLabelWidth: 100, |
|
}, |
|
{ |
|
label: '备注', |
|
prop: 'memo', |
|
sortable: true, |
|
filter: true, |
|
span: 24, |
|
search: false, |
|
type: 'textarea', |
|
searchLabelWidth: 90, |
|
rows: 3, |
|
rules: [ |
|
{ |
|
required: false, |
|
message: '请输入备注', |
|
trigger: 'blur', |
|
}, |
|
], |
|
}, |
|
], |
|
}, |
|
title: '新增', |
|
showDialog: false, |
|
moldAddMore: false, |
|
}; |
|
}, |
|
computed: { |
|
ids() { |
|
let ids = []; |
|
this.selectionList.forEach(ele => { |
|
ids.push(ele.id); |
|
}); |
|
return ids.join(','); |
|
}, |
|
}, |
|
methods: { |
|
// 点击导入按钮 |
|
handleImport() { |
|
this.isShowImport = true |
|
}, |
|
// 保存 |
|
rowSave(row, done, loading) { |
|
add(row).then( |
|
res => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
done(); |
|
}, |
|
error => { |
|
window.console.log(error); |
|
loading(); |
|
} |
|
); |
|
}, |
|
handlePrint() { |
|
// 打印当前页面 |
|
window.print(); |
|
}, |
|
//删除 |
|
handleDelete() { |
|
if (this.selectionList.length === 0) { |
|
this.$message.warning('请选择至少一条数据'); |
|
return; |
|
} |
|
this.$confirm('确定将选择数据删除?', { |
|
confirmButtonText: '确定', |
|
cancelButtonText: '取消', |
|
type: 'warning', |
|
}) |
|
.then(() => { |
|
return remove(this.ids); |
|
}) |
|
.then(() => { |
|
// 刷新表格数据并重载 |
|
this.data = []; |
|
this.parentId = 0; |
|
this.$refs.crud.refreshTable(); |
|
this.$refs.crud.toggleSelection(); |
|
// 表格数据重载 |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
}); |
|
}, |
|
rowDel(row) { |
|
this.$confirm('确定将选择数据删除?', { |
|
confirmButtonText: '确定', |
|
cancelButtonText: '取消', |
|
type: 'warning', |
|
}) |
|
.then(() => { |
|
return remove(row.id); |
|
}) |
|
.then(() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
}); |
|
}, |
|
//更新 |
|
rowUpdate(row, index, done, loading) { |
|
update(row).then( |
|
() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: 'success', |
|
message: '操作成功!', |
|
}); |
|
done(); |
|
}, |
|
error => { |
|
window.console.log(error); |
|
loading(); |
|
} |
|
); |
|
}, |
|
//选择行 |
|
selectionChange(list) { |
|
this.selectionList = list; |
|
}, |
|
// 搜索重置 |
|
searchReset() { |
|
this.query = {} |
|
this.onLoad(this.page) |
|
}, |
|
selectionClear() { |
|
this.selectionList = []; |
|
this.$refs.table.clearSelection(); |
|
}, |
|
// 加载页面数据 |
|
onLoad(page, params = {}) { |
|
this.loading = true; |
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)) |
|
.then(res => { |
|
const data = res.data.data; |
|
this.page.total = data.total; |
|
this.data = data.records; |
|
this.loading = false; |
|
}) |
|
.catch(() => { |
|
this.loading = false; |
|
}); |
|
}, |
|
//刷新 |
|
refreshChange() { |
|
this.onLoad(this.page, this.query); |
|
}, |
|
//搜索 |
|
searchChange(params, done) { |
|
this.query = params; |
|
this.page.currentPage = 1; |
|
this.onLoad(this.page, params) |
|
done() |
|
|
|
}, |
|
// 关闭弹窗 |
|
closeDialog() { |
|
this.showDialog = false; |
|
this.onLoad(this.page); |
|
}, |
|
// 关闭导入弹窗 |
|
closeImportDialog() { |
|
this.isShowImport = false; |
|
this.onLoad(this.page); |
|
}, |
|
// 新增 |
|
handleAdd() { |
|
this.title = '新增'; |
|
// this.tableData = []; |
|
this.showDialog = true; |
|
this.moldAddMore = true; |
|
}, |
|
}, |
|
}; |
|
</script> |
|
|
|
<style></style>
|
|
|