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.
473 lines
13 KiB
473 lines
13 KiB
<template> |
|
<basic-container> |
|
<avue-crud :option="option" |
|
:table-loading="loading" |
|
:data="data" |
|
:page="page" |
|
:permission="permissionList" |
|
:before-open="beforeOpen" |
|
:search.sync="search" |
|
:header-cell-class-name="headerClass" |
|
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" |
|
@on-load="onLoad"> |
|
<template slot="menuLeft"> |
|
<el-button type="danger" |
|
size="small" |
|
icon="el-icon-delete" |
|
plain |
|
v-if="permission.inspectionroute_delete" |
|
@click="handleDelete">批量删除 |
|
</el-button> |
|
</template> |
|
<template slot="menuRight"> |
|
<el-button type="primary" |
|
size="small" |
|
v-if="permission.inspectionroute_add" |
|
plain |
|
@click="handleDetailAdd">新增 |
|
</el-button> |
|
<el-button type="primary" |
|
size="small" |
|
plain |
|
@click="handleTakeEffect">生效 |
|
</el-button> |
|
<el-button type="primary" |
|
size="small" |
|
plain |
|
@click="handleLapse">失效 |
|
</el-button> |
|
<el-button type="primary" |
|
size="small" |
|
plain |
|
@click="handleExport">导出 |
|
</el-button> |
|
</template> |
|
<template #menu="{row,index,size}"> |
|
<el-button v-if="permission.inspectionroute_view" @click="handleDetailSearch(row,index)" type="text">查看</el-button> |
|
<el-button v-if="permission.inspectionroute_delete" @click="rowDel(row)" type="text">删除</el-button> |
|
</template> |
|
</avue-crud> |
|
<el-dialog title="失效" |
|
append-to-body |
|
:visible.sync="cancelBox" |
|
width="555px"> |
|
<avue-form :option="cancelOption" v-model="cancelForm" ref="cancelForm"> |
|
</avue-form> |
|
<div class="container"> |
|
<span> |
|
<el-button type="primary" |
|
size="small" |
|
plain |
|
@click="handleDetailCancel">失效 |
|
</el-button> |
|
</span> |
|
</div> |
|
</el-dialog> |
|
</basic-container> |
|
</template> |
|
|
|
<script> |
|
import {getList, getDetail, add, update, remove, takeEffect, lapse} from "@/api/inspection/inspectionobject"; |
|
import {mapGetters} from "vuex"; |
|
import {getToken} from "@/util/auth"; |
|
import expUtil from "@/util/exportUtil"; |
|
|
|
export default { |
|
data() { |
|
return { |
|
form: {}, |
|
search:{}, |
|
query: {}, |
|
loading: true, |
|
cancelBox: false, |
|
page: { |
|
pageSize: 10, |
|
currentPage: 1, |
|
total: 0 |
|
}, |
|
selectionList: [], |
|
option: { |
|
height: 'auto', |
|
calcHeight: 210, |
|
searchShow: true, |
|
searchMenuSpan: 6, |
|
tip: false, |
|
border: true, |
|
index: false, |
|
viewBtn: true, |
|
selection: true, |
|
column: [ |
|
{ |
|
label: "对象编号", |
|
prop: "objectNo", |
|
span:4.5, |
|
rules: [{ |
|
required: true, |
|
message: "请输入对象编号", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "对象名称", |
|
prop: "objectName", |
|
search:true, |
|
type: "select", |
|
span: 4.5, |
|
dicUrl: "/api/daf-system/dict/dictionary?code=obj_name", |
|
props: { |
|
label: "dictValue", |
|
value: "dictKey" |
|
}, |
|
rules: [{ |
|
required: true, |
|
message: "请输入对象名称", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "场站", |
|
prop: "station", |
|
search:true, |
|
type: "select", |
|
span: 4.5, |
|
dicUrl: "/api/daf-system/dict/dictionary?code=station", |
|
props: { |
|
label: "dictValue", |
|
value: "dictKey" |
|
}, |
|
rules: [{ |
|
required: true, |
|
message: "请输入场站", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "对象类型", |
|
prop: "objectType", |
|
rules: [{ |
|
required: true, |
|
message: "请输入对象类型", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "对象区域", |
|
prop: "objectArea", |
|
search:true, |
|
span:4.5, |
|
rules: [{ |
|
required: true, |
|
message: "请输入对象区域", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "对象状态", |
|
prop: "istatus", |
|
search:true, |
|
type: "select", |
|
span:4.5, |
|
rules: [{ |
|
required: true, |
|
message: "请输入对象状态", |
|
trigger: "blur" |
|
}], |
|
dicUrl: "/api/daf-system/dict/dictionary?code=istatus", |
|
props: { |
|
label: "dictValue", |
|
value: "dictKey" |
|
} |
|
}, |
|
{ |
|
label: "KKS编号", |
|
prop: "kksNo", |
|
search:true, |
|
rules: [{ |
|
required: true, |
|
message: "请输入KKS编号", |
|
trigger: "blur" |
|
}] |
|
}, |
|
{ |
|
label: "取消原因", |
|
prop: "cancelReason", |
|
rules: [{ |
|
required: true, |
|
message: "请输入取消原因", |
|
trigger: "blur" |
|
}] |
|
}, |
|
] |
|
}, |
|
cancelForm: {}, |
|
cancelOption: { |
|
height: 'auto', |
|
calcHeight: 210, |
|
emptyBtn:false, |
|
submitBtn:false, |
|
tip: false, |
|
border: true, |
|
index: false, |
|
selection: true, |
|
column: [ |
|
{ |
|
label: "取消原因", |
|
type: "textarea", |
|
prop: "cancelReason", |
|
span: 24 |
|
}, |
|
] |
|
}, |
|
data: [] |
|
}; |
|
}, |
|
computed: { |
|
...mapGetters(["permission"]), |
|
permissionList() { |
|
// this.option.column = this.option.column.filter(v => { |
|
// return this.permission['inspectionroute_col_' + v.prop] |
|
// }) |
|
return { |
|
addBtn: false, |
|
viewBtn: false, |
|
delBtn: false, |
|
editBtn: false |
|
}; |
|
}, |
|
ids() { |
|
let ids = []; |
|
this.selectionList.forEach(ele => { |
|
ids.push(ele.id); |
|
}); |
|
return ids.join(","); |
|
} |
|
}, |
|
methods: { |
|
rowSave(row, done, loading) { |
|
add(row).then(() => { |
|
done(); |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
}, error => { |
|
window.console.log(error); |
|
loading(); |
|
}); |
|
}, |
|
rowUpdate(row, index, done, loading) { |
|
update(row).then(() => { |
|
done(); |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
}, error => { |
|
window.console.log(error); |
|
loading(); |
|
}); |
|
}, |
|
rowDel(row) { |
|
this.$confirm("确定将选择数据删除?", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}) |
|
.then(() => { |
|
return remove(row.id); |
|
}) |
|
.then(() => { |
|
const cancelReason = this.findObject(this.cancelOption.column, "cancelReason"); |
|
cancelReason.value = ' '; |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
}); |
|
}, |
|
handleDetailAdd() { |
|
this.$router.push({ |
|
path: "/inspection/inspectionobjectDetail", |
|
query: { |
|
frameMode:"add" |
|
}, |
|
}); |
|
}, |
|
handleDetailSearch(row) { |
|
debugger |
|
this.$router.push({ |
|
path: "/inspection/inspectionobjectDetail", |
|
query: { |
|
frameMode:"view", |
|
id: row.id |
|
}, |
|
}); |
|
}, |
|
handleDelete() { |
|
if (this.selectionList.length === 0) { |
|
this.$message.warning("请选择至少一条数据"); |
|
return; |
|
} |
|
this.$confirm("确定将选择数据删除?", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}) |
|
.then(() => { |
|
return remove(this.ids); |
|
}) |
|
.then(() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
this.$refs.crud.toggleSelection(); |
|
}); |
|
}, |
|
handleTakeEffect() { |
|
if (this.selectionList.length === 0) { |
|
this.$message.warning("请选择至少一条数据"); |
|
return; |
|
} |
|
this.$confirm("是否将选择数据改为生效状态?", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}) |
|
.then(() => { |
|
return takeEffect(this.ids); |
|
}) |
|
.then(() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
this.$refs.crud.toggleSelection(); |
|
}); |
|
}, |
|
handleCancel() { |
|
if (this.selectionList.length === 0) { |
|
this.$message.warning("请选择至少一条数据"); |
|
return; |
|
} |
|
this.$confirm("是否将选择数据取消?", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}) |
|
.then(() => { |
|
return takeEffect(this.ids); |
|
}) |
|
.then(() => { |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
this.$refs.crud.toggleSelection(); |
|
}); |
|
}, |
|
handleLapse() { |
|
if (this.selectionList.length === 0) { |
|
this.$message.warning("请选择至少一条数据"); |
|
return; |
|
} |
|
this.cancelBox = true; |
|
}, |
|
handleDetailCancel() { |
|
this.$confirm("是否将选择数据改为失效状态?", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}) |
|
.then(() => { |
|
return lapse(this.ids, this.cancelForm.cancelReason); |
|
}) |
|
.then(() => { |
|
this.cancelForm.cancelReason = ''; |
|
this.cancelBox = false; |
|
this.onLoad(this.page); |
|
this.$message({ |
|
type: "success", |
|
message: "操作成功!" |
|
}); |
|
this.$refs.crud.toggleSelection() |
|
}); |
|
}, |
|
handleExport() { |
|
this.$confirm("是否导出数据?", "提示", { |
|
confirmButtonText: "确定", |
|
cancelButtonText: "取消", |
|
type: "warning" |
|
}).then(() => { |
|
expUtil.excelExport(`/api/inspection/inspectionobject/export?daf-auth=${getToken()}`, this.search, ['stations', "istatus", "objectName"]); |
|
}); |
|
}, |
|
beforeOpen(done, type) { |
|
if (["edit", "view"].includes(type)) { |
|
getDetail(this.form.id).then(res => { |
|
this.form = res.data.data; |
|
}); |
|
} |
|
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; |
|
}, |
|
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; |
|
this.selectionClear(); |
|
}); |
|
}, |
|
headerClass() { |
|
return 'header-class' |
|
} |
|
} |
|
}; |
|
</script> |
|
|
|
<style> |
|
.header-class{ |
|
background-color: #3366cc !important; |
|
color: #FFFFFF !important; |
|
} |
|
</style>
|
|
|