601 lines
17 KiB
Vue
601 lines
17 KiB
Vue
<template>
|
|
<div class="fullHeight">
|
|
<div class="searchBox whiteBlock">
|
|
<el-button
|
|
v-permission="{
|
|
key: 'add',
|
|
menuPath: '/project/labor/attendanceRules',
|
|
}"
|
|
size="medium"
|
|
type="primary"
|
|
@click="addBefore"
|
|
>{{ $t("message.workType.add") }}</el-button
|
|
>
|
|
<div class="search-box">
|
|
<div>
|
|
<span>是否开始监测</span>
|
|
</div>
|
|
<el-radio-group v-model="radioVal" @change="changeSelect">
|
|
<el-radio :label="1">是</el-radio>
|
|
<el-radio :label="0">否</el-radio>
|
|
</el-radio-group>
|
|
</div>
|
|
<div class="search-box">
|
|
<div>
|
|
<span>报警推送时间</span>
|
|
</div>
|
|
<el-date-picker
|
|
v-model="alarmTime"
|
|
style="width: 210px"
|
|
type="date"
|
|
value-format="yyyy-MM-dd"
|
|
:placeholder="$t('message.laborMange.pleaseSelectADate')"
|
|
@change="changeSelect"
|
|
></el-date-picker>
|
|
</div>
|
|
</div>
|
|
<div class="table_wrap whiteBlock">
|
|
<vue-scroll>
|
|
<el-table class="tables" :data="rulesList">
|
|
<el-table-column
|
|
prop="type"
|
|
label="安全履职规则类型"
|
|
></el-table-column>
|
|
<el-table-column prop="dayNum" label="连续未履职(天数)">
|
|
<template v-slot="{ row }">
|
|
<el-input
|
|
v-if="row.isEdit"
|
|
v-model="row.dayNum"
|
|
placeholder="请输入内容"
|
|
style="width: 200px"
|
|
></el-input>
|
|
<span v-else>{{ row.dayNum }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column width="300" label="操作" align="center">
|
|
<div class="operation-style" slot-scope="scope">
|
|
<el-button
|
|
v-if="scope.row.isEdit"
|
|
size="small"
|
|
type="primary"
|
|
@click="saveForm(scope.$index)"
|
|
style="margin-right: 5px"
|
|
>保存</el-button
|
|
>
|
|
<el-button
|
|
v-else
|
|
size="small"
|
|
type="primary"
|
|
@click="editForm(scope.$index)"
|
|
>编辑</el-button
|
|
>
|
|
<el-button
|
|
size="small"
|
|
type="danger"
|
|
@click="deleteItem(scope.row)"
|
|
style="margin-right: 10px"
|
|
>删除</el-button
|
|
>
|
|
<div @click="pushConfigOpen(scope.row)" class="operationText">
|
|
<img
|
|
src="@/assets/images/icon-setting.png"
|
|
width="15px"
|
|
height="15px"
|
|
/>
|
|
<span>推送配置</span>
|
|
</div>
|
|
</div>
|
|
</el-table-column>
|
|
</el-table>
|
|
<el-pagination
|
|
class="pagerBox"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
:current-page="pageInfo.pageNo"
|
|
:page-sizes="$store.state.PAGESIZRS"
|
|
:page-size="pageInfo.pageSize"
|
|
layout="total, sizes, prev, pager, next"
|
|
:total="Number(pageInfo.total)"
|
|
background
|
|
></el-pagination>
|
|
</vue-scroll>
|
|
</div>
|
|
<el-dialog
|
|
:modal-append-to-body="false"
|
|
title="添加安全履职规则"
|
|
:visible.sync="dialogVisible"
|
|
width="667px"
|
|
>
|
|
<div class="dialog_content">
|
|
<el-form
|
|
:rules="rules"
|
|
:model="workerInfo"
|
|
ref="form"
|
|
label-width="150px"
|
|
size="medium"
|
|
class="dialogFormBox"
|
|
>
|
|
<el-form-item prop="type" label="安全履职规则类型">
|
|
<el-input
|
|
v-model="workerInfo.type"
|
|
:placeholder="$t('message.workType.placeholder')"
|
|
></el-input>
|
|
</el-form-item>
|
|
<el-form-item prop="dayNum" label="连续未履职(天数)">
|
|
<el-input
|
|
v-model="workerInfo.dayNum"
|
|
:placeholder="$t('message.workType.placeholder')"
|
|
></el-input>
|
|
</el-form-item>
|
|
<div class="dialog-footer">
|
|
<el-button
|
|
class="cancleBtn"
|
|
@click="closeBtn"
|
|
icon="el-icon-circle-close"
|
|
size="medium"
|
|
>{{ $t("message.personnelPosition.cancel") }}
|
|
</el-button>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-circle-check"
|
|
@click="Submit"
|
|
size="medium"
|
|
>{{ $t("message.personnelPosition.determine") }}
|
|
</el-button>
|
|
</div>
|
|
</el-form>
|
|
</div>
|
|
</el-dialog>
|
|
|
|
<!-- 推送配置 -->
|
|
<el-dialog
|
|
:modal-append-to-body="false"
|
|
title="配置报警推送人"
|
|
:visible.sync="pushConfigDialog"
|
|
width="1000px"
|
|
>
|
|
<div class="dialog_content">
|
|
<el-button type="primary" size="medium" @click="addTableData"
|
|
>新增</el-button
|
|
>
|
|
<div class="dialog-table">
|
|
<el-table class="tables" :data="dialogPushList">
|
|
<el-table-column prop="name" label="企业名称">
|
|
<template v-slot="{ row,$index }">
|
|
<el-select
|
|
v-model="row.enterpriseId"
|
|
placeholder="请选择"
|
|
v-if="row.isEdit"
|
|
@change="e => enterpriseChange(e,$index)"
|
|
>
|
|
<el-option
|
|
:label="item.enterpriseName"
|
|
:value="item.enterpriseId"
|
|
v-for="(item, index) in enterpriseList"
|
|
:key="index"
|
|
></el-option>
|
|
</el-select>
|
|
<span v-else>{{ row.enterpriseName }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="userId" label="报警推送人">
|
|
<template v-slot="{ row }">
|
|
<el-select
|
|
v-model="row.userId"
|
|
placeholder="请选择"
|
|
multiple
|
|
v-if="row.isEdit"
|
|
>
|
|
<el-option
|
|
:label="item.realName"
|
|
:value="item.userId"
|
|
v-for="(item, index) in personList"
|
|
:key="index"
|
|
></el-option>
|
|
</el-select>
|
|
<span v-else>{{ row.userName }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column width="300" label="操作" align="center">
|
|
<div class="operation-style" slot-scope="scope">
|
|
<el-button
|
|
v-if="scope.row.isEdit"
|
|
size="small"
|
|
type="primary"
|
|
@click="saveDialogForm(scope.row, scope.$index)"
|
|
style="margin-right: 5px"
|
|
>保存</el-button
|
|
>
|
|
<el-button
|
|
v-else
|
|
size="small"
|
|
type="primary"
|
|
@click="editDialogForm(scope.$index)"
|
|
>编辑</el-button
|
|
>
|
|
<el-button
|
|
size="small"
|
|
type="danger"
|
|
@click="deleteDialogItem(scope.row)"
|
|
style="margin-right: 10px"
|
|
>删除</el-button
|
|
>
|
|
</div>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<!-- <div class="dialog-footer">
|
|
<el-button
|
|
class="cancleBtn"
|
|
icon="el-icon-circle-close"
|
|
size="medium"
|
|
@click="pushConfigDialog = false"
|
|
>{{ $t("message.safeMangeCheck.dialog.cancel") }}</el-button
|
|
>
|
|
<el-button
|
|
type="primary"
|
|
icon="el-icon-circle-check"
|
|
size="medium"
|
|
@click="pushConfigDialog = false"
|
|
>{{ $t("message.safeMangeCheck.dialog.confirm") }}</el-button
|
|
>
|
|
</div> -->
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import {
|
|
SafeWatchConfigPageApi,
|
|
SafeWatchConfigAddApi,
|
|
SafeWatchConfigEditApi,
|
|
SafeWatchConfigDeleteApi,
|
|
SafeWatchManagerListApi,
|
|
SafeWatchManagerAddApi,
|
|
SafeWatchManagerEditApi,
|
|
SafeWatchManagerDeleteApi,
|
|
getEnterpriseInfoList,
|
|
getProjectChilderSystemUserListApi,
|
|
} from "@/assets/js/api/laborPerson";
|
|
import {
|
|
getProjectDetail,
|
|
editProjectInfo,
|
|
editClearData,
|
|
} from "@/assets/js/api/baseInfo";
|
|
export default {
|
|
data() {
|
|
return {
|
|
pageInfo: {
|
|
total: 0,
|
|
pageNo: 1,
|
|
pageSize: 10,
|
|
},
|
|
dialogPushList: [],
|
|
pushConfigDialog: false,
|
|
radioVal: 0,
|
|
alarmTime: "",
|
|
title: "",
|
|
dialogVisible: false,
|
|
rulesList: [],
|
|
enterpriseList: [],
|
|
personList: [],
|
|
workerInfo: {
|
|
type: "",
|
|
dayNum: "",
|
|
},
|
|
rules: {
|
|
type: [
|
|
{
|
|
required: true,
|
|
message: this.$t("message.workType.placeholder"),
|
|
trigger: "change",
|
|
},
|
|
],
|
|
dayNum: [
|
|
{
|
|
required: true,
|
|
message: this.$t("message.workType.placeholder"),
|
|
trigger: "change",
|
|
},
|
|
],
|
|
},
|
|
rowObj: {},
|
|
};
|
|
},
|
|
mounted() {
|
|
this.getDataList();
|
|
this.getProjectDetailFn();
|
|
},
|
|
methods: {
|
|
enterpriseChange(e,index) {
|
|
this.getPersonListFn(e);
|
|
this.dialogPushList[index].userId = [];
|
|
},
|
|
// 获取企业列表
|
|
getEnterpriseListFn() {
|
|
let that = this;
|
|
let reqeustData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
};
|
|
getEnterpriseInfoList(reqeustData).then((res) => {
|
|
that.enterpriseList = res.result;
|
|
});
|
|
},
|
|
// 获取人员列表
|
|
getPersonListFn(enterpriseId) {
|
|
let that = this;
|
|
let reqeustData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
enterpriseId,
|
|
};
|
|
getProjectChilderSystemUserListApi(reqeustData).then((res) => {
|
|
that.personList = res.result;
|
|
});
|
|
},
|
|
//查看条数
|
|
handleSizeChange(val) {
|
|
this.pageInfo.pageSize = val;
|
|
this.getDataList();
|
|
},
|
|
//查看页
|
|
handleCurrentChange(val) {
|
|
this.pageInfo.pageNo = val;
|
|
this.getDataList();
|
|
},
|
|
// 添加表格数据
|
|
addTableData() {
|
|
this.dialogPushList.push({ enterpriseId: "", userId: [], isEdit: true });
|
|
},
|
|
// 推送配置
|
|
pushConfigOpen(row) {
|
|
this.pushConfigDialog = true;
|
|
this.rowObj = row;
|
|
this.getDialogDataList();
|
|
this.getEnterpriseListFn();
|
|
},
|
|
// 删除弹窗数据
|
|
deleteDialogItem(obj) {
|
|
this.$confirm("请确认是否删除?", "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning",
|
|
})
|
|
.then(() => {
|
|
SafeWatchManagerDeleteApi({ id: obj.id }).then((res) => {
|
|
if (res.success) {
|
|
this.getDialogDataList();
|
|
this.$message({
|
|
type: "success",
|
|
message: "删除成功!",
|
|
});
|
|
} else {
|
|
this.$message({
|
|
type: "error",
|
|
message: res.message,
|
|
});
|
|
}
|
|
});
|
|
})
|
|
.catch(() => {
|
|
this.$message({
|
|
type: "info",
|
|
message: "已取消删除",
|
|
});
|
|
});
|
|
},
|
|
// 切换弹窗保存
|
|
saveDialogForm(obj, index) {
|
|
let requestData = {
|
|
...obj,
|
|
watchConfigId: this.rowObj.id,
|
|
};
|
|
if (requestData.userId) {
|
|
requestData.userId = requestData.userId.join(",");
|
|
}
|
|
if (obj.id) {
|
|
SafeWatchManagerEditApi(requestData).then((result) => {
|
|
this.$message.success(result.message);
|
|
this.dialogPushList[index].isEdit = false;
|
|
this.getDialogDataList();
|
|
});
|
|
} else {
|
|
SafeWatchManagerAddApi(requestData).then((result) => {
|
|
this.$message.success(result.message);
|
|
this.dialogPushList[index].isEdit = false;
|
|
this.getDialogDataList();
|
|
});
|
|
}
|
|
},
|
|
// 切换弹窗编辑
|
|
editDialogForm(index) {
|
|
console.log(this.dialogPushList[index])
|
|
this.getPersonListFn(this.dialogPushList[index].enterpriseId);
|
|
if (this.dialogPushList[index].userId) {
|
|
this.dialogPushList[index].userId =
|
|
this.dialogPushList[index].userId.split(",");
|
|
}
|
|
this.dialogPushList[index].isEdit = true;
|
|
},
|
|
// 删除
|
|
deleteItem(obj) {
|
|
this.$confirm("请确认是否删除?", "提示", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning",
|
|
})
|
|
.then(() => {
|
|
SafeWatchConfigDeleteApi({ id: obj.id }).then((res) => {
|
|
if (res.success) {
|
|
this.getDataList();
|
|
this.$message({
|
|
type: "success",
|
|
message: "删除成功!",
|
|
});
|
|
} else {
|
|
this.$message({
|
|
type: "error",
|
|
message: res.message,
|
|
});
|
|
}
|
|
});
|
|
})
|
|
.catch(() => {
|
|
this.$message({
|
|
type: "info",
|
|
message: "已取消删除",
|
|
});
|
|
});
|
|
},
|
|
// 切换保存
|
|
saveForm(index) {
|
|
let requestData = {
|
|
...this.rulesList[index],
|
|
};
|
|
SafeWatchConfigEditApi(requestData).then((result) => {
|
|
this.$message.success(result.message);
|
|
this.rulesList[index].isEdit = false;
|
|
this.getDataList();
|
|
});
|
|
},
|
|
// 切换编辑
|
|
editForm(index) {
|
|
this.rulesList[index].isEdit = true;
|
|
console.log(this.rulesList);
|
|
},
|
|
// 切换清零配置
|
|
changeSelect() {
|
|
let reqeustData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
enableWorkerSafeWatch: this.radioVal,
|
|
workerSafeWatchTime: this.alarmTime
|
|
};
|
|
editProjectInfo(reqeustData).then((res) => {
|
|
if (res.success) {
|
|
this.$message.success("操作成功");
|
|
}
|
|
});
|
|
},
|
|
// 查询是否清零配置
|
|
getProjectDetailFn() {
|
|
let reqeustData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
};
|
|
getProjectDetail(reqeustData).then((res) => {
|
|
if (res && res.result) {
|
|
this.radioVal = res.result.enableWorkerAttendanceZero;
|
|
}
|
|
});
|
|
},
|
|
getDialogDataList() {
|
|
let that = this;
|
|
let requestData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
};
|
|
// if (this.timeRange && this.timeRange.length > 0) {
|
|
// requestData.alarmTime_begin = this.timeRange[0];
|
|
// requestData.alarmTime_end = this.timeRange[1];
|
|
// }
|
|
SafeWatchManagerListApi(requestData).then((res) => {
|
|
that.dialogPushList = [];
|
|
res.result.map(item => {
|
|
that.dialogPushList.push({...item,isEdit: false})
|
|
})
|
|
});
|
|
},
|
|
getDataList() {
|
|
let that = this;
|
|
let requestData = {
|
|
projectSn: this.$store.state.projectSn,
|
|
pageNo: this.pageInfo.pageNo,
|
|
pageSize: this.pageInfo.pageSize,
|
|
};
|
|
// if (this.timeRange && this.timeRange.length > 0) {
|
|
// requestData.alarmTime_begin = this.timeRange[0];
|
|
// requestData.alarmTime_end = this.timeRange[1];
|
|
// }
|
|
SafeWatchConfigPageApi(requestData).then((res) => {
|
|
let responseData = [...res.result.records];
|
|
that.rulesList = [];
|
|
responseData.map(item => {
|
|
that.rulesList.push({...item,isEdit: false})
|
|
})
|
|
that.pageInfo.total = res.result.total;
|
|
});
|
|
},
|
|
addBefore() {
|
|
this.title = "新增考勤规则";
|
|
this.dialogVisible = true;
|
|
(this.workerInfo = {
|
|
type: "",
|
|
dayNum: "",
|
|
}),
|
|
this.$nextTick(() => {
|
|
this.$refs.form.clearValidate();
|
|
});
|
|
},
|
|
editBefore(worker) {
|
|
this.title = "编辑考勤规则";
|
|
this.dialogVisible = true;
|
|
this.$nextTick(() => {
|
|
this.$refs.form.clearValidate();
|
|
});
|
|
// console.log('编辑前的内容', worker)
|
|
this.workerInfo = JSON.parse(JSON.stringify(worker));
|
|
},
|
|
deleteBefore(worker) {},
|
|
closeBtn() {
|
|
this.dialogVisible = false;
|
|
this.workerInfo = {};
|
|
},
|
|
Submit() {
|
|
this.$refs.form.validate((valid) => {
|
|
this.workerInfo.projectSn = this.$store.state.projectSn;
|
|
if (valid) {
|
|
SafeWatchConfigAddApi(this.workerInfo).then((result) => {
|
|
this.$message.success(result.message);
|
|
|
|
this.dialogVisible = false;
|
|
this.getDataList();
|
|
});
|
|
} else {
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
<style lang="less" scoped>
|
|
::v-deep .el-input__inner {
|
|
line-height: 1px !important;
|
|
}
|
|
.flex() {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.search-box {
|
|
.flex();
|
|
margin-left: 30px;
|
|
> div {
|
|
.flex();
|
|
margin-right: 10px;
|
|
> span {
|
|
margin-right: 2px;
|
|
font-size: 14px;
|
|
}
|
|
.question-icon {
|
|
border: 1px solid #676c7c;
|
|
border-radius: 50%;
|
|
width: 10px;
|
|
height: 10px;
|
|
text-align: center;
|
|
line-height: 10px;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
/deep/.el-radio-group {
|
|
margin-top: 2px;
|
|
}
|
|
}
|
|
</style>
|