中航光电热表web
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.
 
 
 
 

386 lines
9.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-save="rowSave"
@row-update="rowUpdate"
@search-change="searchChange"
@search-reset="searchReset"
@selection-change="selectionChange"
@current-change="currentChange"
@size-change="sizeChange"
@refresh-change="refreshChange"
@on-load="onLoad"
@sort-change="sortChange"
:permission="permissionList"
>
<template #menu-left>
<el-button type="primary" v-if="permission.equipmentInspectionPoint_add" @click="handleAdd">
新增
</el-button>
<el-button
type="danger"
v-if="permission.equipmentInspectionPoint_del"
@click="handleDelete"
>
删除
</el-button>
</template>
<template #menu-right>
<el-button
type="primary"
v-if="permission.equipmentInspectionPoint_import"
@click="handleImport"
>导入
</el-button>
</template>
</avue-crud>
<!-- 导入 -->
<basic-import
v-if="isShowImport"
title="导入"
:isShow="isShowImport"
templateUrl="/blade-desk/bsEpciuInspectionPoint/downloadExcelTemplate"
templateName="环保巡检点配置表模板.xls"
importUrl="/blade-desk/bsEpciuInspectionPoint/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/equipmentInspectionPoint';
import addInspectDailog from './addInspectDailog.vue';
import { mapGetters } from 'vuex';
export default {
components: {
basicImport,
addInspectDailog,
},
data() {
return {
isShowImport: false,
page: {
pageSize: 10,
currentPage: 1,
total: 0,
},
selectionList: [],
data: [],
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: false,
addBtn: false,
editBtn: true,
editBtnText: '修改',
addBtnIcon: ' ',
viewBtnIcon: ' ',
delBtnIcon: ' ',
editBtnIcon: ' ',
labelWidth: 120,
menuWidth: 80,
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: 'center',
gridBtn: false,
searchMenuPosition: 'right',
align: 'center',
column: [
{
label: '巡检点编号',
prop: 'insNum',
sortable: 'custom',
filter: true,
span: 24,
search: true,
searchLabelWidth: 90,
rules: [
{
required: true,
message: '请输入巡检点编号',
trigger: 'blur',
},
],
},
{
label: '巡检点位置',
prop: 'insSite',
sortable: 'custom',
filter: true,
span: 24,
search: true,
searchLabelWidth: 90,
rules: [
{
required: true,
message: '请输入巡检点位置',
trigger: 'blur',
},
],
},
{
label: '巡检点类型',
prop: 'insType',
sortable: 'custom',
filter: true,
span: 24,
search: true,
searchLabelWidth: 90,
type: 'select',
width: 110,
dicData: [
{ label: '废水巡检点', value: '1' },
{ label: '废气巡检点', value: '2' },
],
rules: [
{
required: true,
message: '请输入巡检点位置',
trigger: 'blur',
},
],
},
{
label: '巡检周期(h)',
prop: 'insCycle',
sortable: 'custom',
filter: true,
span: 24,
search: false,
searchLabelWidth: 90,
type: 'number',
width: 110,
rules: [
{
required: true,
message: '请输入巡检周期(h)',
trigger: 'blur',
},
],
},
{
label: '上次检验日期',
prop: 'lastInsCycle',
sortable: 'custom',
filter: true,
span: 24,
search: false,
display: false,
searchLabelWidth: 100,
width: 150,
},
{
label: '备注',
prop: 'memo',
sortable: 'custom',
filter: true,
span: 24,
search: false,
type: 'textarea',
searchLabelWidth: 90,
rows: 3,
rules: [
{
required: false,
message: '请输入备注',
trigger: 'blur',
},
],
},
],
},
title: '新增',
showDialog: false,
moldAddMore: false,
query: {},
};
},
computed: {
ids() {
let ids = [];
this.selectionList.forEach(ele => {
ids.push(ele.id);
});
return ids.join(',');
},
...mapGetters(['permission']),
permissionList() {
return {
editBtn: this.validData(this.permission.equipmentInspectionPoint_edit, false),
delBtn: this.validData(this.permission.equipmentInspectionPoint_del, false),
};
},
},
methods: {
// 点击导入按钮
handleImport() {
this.isShowImport = true;
},
// 关闭导入弹窗
closeImportDialog() {
this.isShowImport = false;
this.onLoad(this.page);
},
// 保存
rowSave(row, done, loading) {
add(row).then(
res => {
this.onLoad(this.page);
this.$message({
type: 'success',
message: '操作成功!',
});
done();
},
error => {
window.console.log(error);
loading();
}
);
},
//删除
handleDelete() {
if (this.selectionList.length === 0) {
this.$message.error('请选择至少一条数据');
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: '操作成功!',
});
});
},
//更新
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();
},
sortChange({ prop, order }) {
this.query.descs = undefined;
this.query.ascs = undefined;
let orderByFieldKey = order === 'descending' ? 'descs' : 'ascs';
this.query[orderByFieldKey] = !prop
? undefined
: prop.replace(/([a-z])([A-Z0-9])/g, '$1_$2').toUpperCase();
// // 重新加载数据
this.onLoad(this.page, this.query);
},
// 加载页面数据
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
this.data = res.data.data.records;
this.loading = false;
this.page.total = res.data.data.total;
});
},
//刷新
refreshChange() {
this.onLoad(this.page, this.query);
},
//搜索
searchChange(params, done) {
this.query = params;
this.page.currentPage = 1;
this.onLoad(this.page, params);
done();
},
// 关闭弹窗
closeDialog(isRefresh = false) {
this.showDialog = false;
if (isRefresh) {
this.onLoad(this.page);
}
},
// 新增
handleAdd() {
this.title = '新增';
// this.tableData = [];
this.showDialog = true;
this.moldAddMore = true;
},
},
};
</script>
<style></style>