<template>
|
<div class='ins-record'>
|
<div class="nav-link">
|
<span class="active"><router-link to="">巡查记录</router-link></span>
|
<span><router-link to="/sa_ins_work">安全工作记录</router-link></span>
|
<span><router-link to="/sa_ins_report">安全隐患报告</router-link></span>
|
</div>
|
<v-header
|
title="巡查记录"
|
:bar="bar"
|
search
|
@on-search="onSearch"
|
></v-header>
|
<div class="add">
|
<button
|
class="m_btn bgc_primary"
|
@click="appPath('sa_ins_record_add')"
|
>新增</button>
|
<button class="m_btn bgc_primary" @click="down()">批量下载</button>
|
</div>
|
<div class="tab">
|
<v-tool-table
|
:trs="trs"
|
:tds="tds"
|
first
|
firstWidth="50px"
|
>
|
<template v-slot:first-th>
|
<div>
|
<el-checkbox @change="cheAll" v-model="alls"></el-checkbox>
|
</div>
|
</template>
|
<template v-slot:first-td="item">
|
<div>
|
<el-checkbox @change="change" v-model="item.scope.che"></el-checkbox>
|
</div>
|
</template>
|
<template v-slot:type="{scope}">
|
{{formatPatrol(scope)}}
|
</template>
|
<template v-slot:btnShow="{scope}">
|
<div class="table_flex">
|
<span @click="appPath(`sa_ins_records/${scope.id}`)">查看</span>
|
<span @click="appPath(`sa_ins_work_edit/${scope.id}/record`)">编辑</span>
|
</div>
|
</template>
|
<template v-slot:report="{scope}">
|
<div class="table_flex">
|
<span v-if="scope.dangerOrRecord == '2'" @click="appPath(`sa_ins_works/${scope.serviceId}`)">安全工作记录</span>
|
<span v-if="scope.dangerOrRecord == '1'" @click="appPath(`sa_ins_reports/${scope.serviceId}`)">安全隐患报告</span>
|
</div>
|
</template>
|
</v-tool-table>
|
</div>
|
<div class="page">
|
<v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
|
const queryOptions = [
|
{ label: "防火巡查", value: 1 },
|
{ label: "防汛巡查", value: 2 },
|
{ label: "防疫巡查", value: 3 },
|
];
|
|
export default {
|
props: {},
|
|
components: {},
|
|
data() {
|
return {
|
bar: [
|
{ title: "人员", name: "patrolPerson" },
|
{ title: "巡查类型", name: "patrolType", type: "select",
|
list: queryOptions
|
},
|
{ title: "巡查时间", name: "c", type: "times" },
|
],
|
trs: [
|
{ text: "巡查地址", val: "address" },
|
{ text: "巡查人员", val: "personName" },
|
{ text: "巡查类型", val: "btn" , slot:"type"},
|
{ text: "生成报告", val: "btn", slot: "report" },
|
{ text: "巡查时间", val: "patrolTime" },
|
{ text: "操作", val: "btn" ,slot: "btnShow"},
|
],
|
tds: [],
|
patrolPerson:'',
|
searchTime:'',
|
ids:[], //选中的id集合
|
alls: false, //全选状态
|
paged: { page: 0, total: 0, r: 0, limit: 10 }, //分页
|
patrolAtBegin: "",
|
patrolAtEnd: "",
|
loading:{},
|
};
|
},
|
|
watch: {},
|
|
inject: ["appPath"],
|
|
mounted() {
|
|
},
|
methods: {
|
formatPatrol (scope) {
|
const patrolType = scope.patrolType ? scope.patrolType.split(',') : [];
|
return patrolType.length ? patrolType.map(d => queryOptions.find(m => m.value === +d).label).join(',') : ''
|
},
|
|
/**获取巡查数据
|
* communityId:社区id,patrolAtBegin: 巡查开始时间, patrolAtEnd:巡查结束时间,
|
patrolPerson:巡查人,patrolType: 巡查类型,status: 状态,
|
*/
|
init() {
|
let params = {
|
patrolAtBegin: this.patrolAtBegin,
|
patrolAtEnd: this.patrolAtEnd,
|
patrolPerson: this.patrolPerson,
|
patrolType: this.patrolType,
|
status: "",
|
pageNum: this.paged.page,
|
pageSize: this.paged.limit,
|
selectPerson:1,
|
}
|
|
this.$api.post('patrolRecord/pagePatrolRecord', params, e => {
|
this.paged.total = e.total
|
this.tds = e.records
|
console.log(this.tds)
|
this.tds.map((item,index) => {
|
item.index = index + 1;
|
this.$set(item, 'che', false)
|
|
})
|
})
|
},
|
|
// 监听时间选择范围
|
onSearch(v) {
|
console.log(v)
|
if (v.c && v.c.length && v.c[1]) {
|
v.patrolAtBegin = v.c[0];
|
v.patrolAtEnd = v.c[1];
|
} else {
|
v.patrolAtBegin = "";
|
v.patrolAtEnd = "";
|
}
|
this.patrolAtBegin = v.patrolAtBegin,
|
this.patrolAtEnd = v.patrolAtEnd,
|
this.patrolPerson = v.patrolPerson,
|
this.patrolType = v.patrolType,
|
|
// this.searchTime = demo.copy(v);
|
// delete this.searchTime.c;
|
this.paged.page = 1;
|
this.init();
|
},
|
|
// 分页
|
onPage (v) {
|
if (v.page === this.paged.page && v.page && !v.reset) {
|
return 0;
|
}
|
this.paged.page = v.page;
|
this.paged.limit = v.limit;
|
this.init();
|
},
|
|
//下载模板
|
down(v) {
|
if(!this.ids.length) {
|
demo.toast("请勾选需要下载的内容");
|
return
|
}
|
this.loading = this.$loading({
|
lock: true,
|
text: '下载中,请勿退出系统和关闭网络',
|
spinner: 'el-icon-loading',
|
background: 'rgba(0, 0, 0, 0.7)'
|
});
|
this.$api.post("patrolRecord/export/patrolRecord", this.ids, (e) => {
|
window.location.href = e;
|
this.loading.close();
|
});
|
},
|
cheAll () {
|
//全选
|
this.tds.map(item => {
|
item.che = this.alls
|
})
|
this.change()
|
},
|
|
change () {
|
//单个选择
|
this.ids = []
|
this.tds.map(item => {
|
if (item.che) {
|
this.ids.push(item.id)
|
} else {
|
this.alls = false
|
}
|
})
|
},
|
},
|
|
};
|
</script>
|
<style lang='less' scoped>
|
.ins-record {
|
overflow-y: auto;
|
.add,
|
.tab,
|
.page {
|
margin-bottom: 10px;
|
}
|
.m_btn {
|
min-width: 80px;
|
margin-right: 10px;
|
}
|
}
|
.nav-link {
|
padding: 20px 0 10px 0;
|
span {
|
display:inline-block;
|
width: 150px;
|
height: 30px;
|
border: 1px solid #DCDFE6;
|
text-align: center;
|
line-height: 30px;
|
margin-right: 10px;
|
a {
|
color: #222;
|
}
|
}
|
.active {
|
border: 1px #409EFF solid;
|
a {
|
color: #409EFF;
|
}
|
}
|
}
|
</style>
|