factory_web/src/views/am/area.vue

477 lines
14 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<el-container>
<el-container>
<el-aside width="50%">
<el-container>
<el-header>
<div class="left-panel">
<el-button
type="primary"
icon="el-icon-plus"
v-auth="area.create"
@click="handleForm('add')"
></el-button>
</div>
<div class="right-panel">
<div class="right-panel-search">
<el-input
v-model="search.keyword"
placeholder="姓名/手机号"
clearable
@click="upsearch"
></el-input>
<el-button
type="primary"
icon="el-icon-search"
@click="upsearch"
></el-button>
</div>
</div>
</el-header>
<el-main class="nopadding">
<scTable
ref="table"
:apiObj="apiObj"
row-key="id"
stripe
@resetQuery="resetQuery"
@row-click="rowClick"
>
<el-table-column
label="序号"
type="index"
fixed="left"
width="50"
></el-table-column>
<el-table-column
label="区域编号"
fixed="left"
prop="number"
min-width="100"
></el-table-column>
<el-table-column
label="区域名称"
prop="name"
min-width="150"
fixed="left"
></el-table-column>
<el-table-column label="区域类型" min-width="100">
<template #default="scope">{{
cates[scope.row.cate]
}}</template>
</el-table-column>
<el-table-column
label="区域负责人"
prop="manager_name"
min-width="100"
></el-table-column>
<el-table-column label="风险等级" min-width="100">
<template #default="scope">{{
levels[scope.row.level]
}}</template>
</el-table-column>
<el-table-column label="访客人员" min-width="100">
<template #default="scope">
<span v-if="scope.row.visitor_yes">允许进入</span>
<span v-else>禁止进入</span>
</template>
</el-table-column>
<el-table-column label="相关方人员" min-width="100">
<template #default="scope">
<span v-if="scope.row.remployee_yes">允许进入</span>
<span v-else>禁止进入</span>
</template>
</el-table-column>
<el-table-column label="全部员工" min-width="100">
<template #default="scope">
<span v-if="scope.row.employee_yes">允许进入</span>
<span v-else>审批进入</span>
</template>
</el-table-column>
<el-table-column
label="最小人员数"
prop="count_people_min"
min-width="90"
></el-table-column>
<el-table-column
label="最大人员数"
prop="count_people_max"
min-width="90"
></el-table-column>
<el-table-column
label="当前人数"
prop="count_people"
min-width="90"
></el-table-column>
<el-table-column
label="所属部门"
prop="create_time"
min-width="180"
></el-table-column>
<el-table-column
label="创建时间"
prop="create_time"
width="160"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="160"
>
<template #default="scope">
<el-button-group>
<el-button
text
type="primary"
size="small"
v-auth="area.bind_rail"
@click="handleRail(scope.row)"
>围栏</el-button
>
<el-button
text
type="warning"
size="small"
v-auth="area.update"
@click="handleForm('edit', scope.row)"
>编辑</el-button
>
<el-popconfirm
title="确定删除吗?"
@confirm="handleDel(scope.row, scope.$index)"
>
<template #reference>
<el-button text type="danger" size="small" v-auth="area.delete"
>删除</el-button
>
</template>
</el-popconfirm>
</el-button-group>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
</el-aside>
<el-container>
<el-header>
<div class="left-panel">
<el-button
type="primary"
icon="el-icon-plus"
v-auth="access.create"
@click="handleFormaccess('add')"
></el-button>
</div>
<div class="right-panel">
<div class="right-panel-search">
<el-input
v-model="search.keyword"
placeholder="姓名/手机号"
clearable
@click="upsearch"
></el-input>
<el-button
type="primary"
icon="el-icon-search"
@click="upsearch"
></el-button>
</div>
</div>
</el-header>
<el-main class="nopadding">
<scTable
ref="accesstable"
:data="apiaccessObj"
row-key="id"
stripe
@resetQuery="resetQuery"
>
<el-table-column
label="序号"
type="index"
fixed="left"
width="50"
></el-table-column>
<el-table-column label="准入类型" fixed="left" min-width="100">
<template #default="scope">
<span v-if="scope.row.type == 10">准入</span>
<span v-else>禁入</span>
</template>
</el-table-column>
<el-table-column
label="对象类型"
fixed="left"
prop="obj_cate"
min-width="100"
>
<template #default="scope">{{
cate_[scope.row.obj_cate]
}}</template></el-table-column
>
<el-table-column
label="最短停留时间(分)"
prop="stay_minute_min"
min-width="180"
></el-table-column>
<el-table-column
label="最长停留时间(分)"
prop="stay_minute_max"
width="160"
></el-table-column>
<el-table-column
label="关联区域"
prop="area"
width="160"
></el-table-column>
<el-table-column
label="关联岗位"
prop="post_name"
width="160"
></el-table-column>
<el-table-column
label="关联部门"
prop="dept_name"
width="160"
></el-table-column>
<el-table-column
label="关联人员"
prop="employee_name"
width="160"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="160"
>
<template #default="scope">
<el-button-group>
<el-popconfirm
title="确定删除吗?"
@confirm="handleDelaccess(scope.row, scope.$index)"
>
<template #reference>
<el-button text type="danger" size="small" v-auth="access.delete"
>删除</el-button
>
</template>
</el-popconfirm>
</el-button-group>
</template>
</el-table-column>
</scTable>
</el-main>
</el-container>
</el-container>
</el-container>
<!--区域添加编辑-->
<save-dialog
v-if="dialog.save"
ref="saveDialog"
@success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
<!--围栏-->
<save-rail-dialog
v-if="dialog.saveRail"
ref="saveRailDialog"
:areaId="areaId"
:areaName="areaName"
@success="handleSaveSuccess"
@closed="dialog.saveRail = false"
></save-rail-dialog>
<!--出入权限添加编辑-->
<save-access-dialog
v-if="dialog.saveAccesss"
ref="saveAccessDialog"
@success="handleSaveSuccessAccess"
@closed="dialog.saveAccesss = false"
></save-access-dialog>
</template>
<script>
import saveDialog from "./area_form.vue";
import saveRailDialog from "./area_rail_form.vue";
import saveAccessDialog from "./access_form.vue";
export default {
name: "amArea",
components: {
saveDialog,
saveRailDialog,
saveAccessDialog,
},
data() {
return {
dialog: {
save: false,
saveRail: false,
saveAccesss: false,
permission: false,
},
apiObj: this.$API.am.area.list,
query: {},
selection: [],
search: {
keyword: null,
},
levels: {
10: "低风险",
20: "一般风险",
30: "较大风险",
40: "重大风险",
},
cates: {
10: "生活区域",
20: "一般区域",
30: "重点区域",
},
apiaccessObj: [],
areaId: null,
areaName: "",
cate_: { post: "岗位", org: "单位", people: "人员" },
};
},
mounted() {
this.getAccessList();
},
methods: {
//添加/编辑区域
handleForm(type, row) {
this.dialog.save = true;
this.$nextTick(() => {
if (type === "add") {
this.$refs.saveDialog.open(type);
} else {
this.$refs.saveDialog.open(type).setData(row);
}
});
},
//出入权限添加,编辑
handleFormaccess(type, row) {
this.dialog.saveAccesss = true;
this.$nextTick(() => {
if (type === "add") {
this.$refs.saveAccessDialog.open(type);
} else {
this.$refs.saveAccessDialog.open(type).setData(row);
}
});
},
//点击区域显示进入权限
rowClick(row) {
this.$API.am.access.list.req({ area: row.id, page: 0 }).then((res) => {
this.apiaccessObj = res;
});
this.area = row.id;
},
//围栏,添加
handleRail(row) {
this.areaId = row.id;
this.areaName = row.name;
this.dialog.saveRail = true;
},
//删除区域
async handleDel(row) {
await this.$API.am.area.delete.req(row.id).then((res) => {
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("删除成功");
}
});
},
//出入权限列表
getAccessList() {
this.$API.am.access.list.req({ page: 0 }).then((res) => {
this.apiaccessObj = res;
});
},
//批量删除区域
async batch_del() {
this.$confirm(
`确定删除选中的 ${this.selection.length} 项吗?如果删除项中含有子集将会被一并删除`,
"提示",
{
type: "warning",
}
)
.then(() => {
const loading = this.$loading();
let params = { pk: { pks: this.selection } };
this.$API.am.area.deletes.req(params).then((res) => {
loading.close();
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("删除成功");
}
});
})
.catch(() => {});
},
//表格选择后回调事件
selectionChange(selection) {
this.selection = selection;
},
//表格内开关
changeSwitch(val, row) {
row.status = row.status == "1" ? "0" : "1";
row.$switch_status = true;
setTimeout(() => {
delete row.$switch_status;
row.status = val;
this.$message.success("操作成功");
}, 500);
},
//搜索
upsearch() {},
//根据ID获取树结构
filterTree(id) {
var target = null;
function filter(tree) {
tree.forEach((item) => {
if (item.id == id) {
target = item;
}
if (item.children) {
filter(item.children);
}
});
}
filter(this.$refs.table.tableData);
return target;
},
//本地更新数据
handleSaveSuccess(data, mode) {
if (mode == "add") {
this.$refs.table.refresh();
} else if (mode == "edit") {
this.$refs.table.refresh();
}
},
//本地更新数据
handleSaveSuccessAccess(data, mode) {
if (mode == "add") {
this.$refs.accesstable.refresh();
} else if (mode == "edit") {
this.$refs.accesstable.refresh();
}
},
resetQuery() {
this.query = {};
},
},
};
</script>