570 lines
18 KiB
Vue
570 lines
18 KiB
Vue
<template>
|
|
<div class="container_hui">
|
|
<div class="cards-change">
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
|
|
<el-form-item label="" prop="deptName">
|
|
<el-input
|
|
v-model="queryParams.notificationName"
|
|
placeholder="请输入选择通知名称"
|
|
clearable
|
|
style="width: 240px;"
|
|
@keyup.enter.native="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
<el-form-item label="" prop="notificationType">
|
|
<el-select v-model="queryParams.notificationType" placeholder="请选择通知类型" clearable
|
|
style="width: 240px;">
|
|
<el-option label="到期提醒" value="到期提醒"></el-option>
|
|
<el-option label="库存预警" value="库存预警"></el-option>
|
|
<!-- 添加其他选项 -->
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="" prop="recipientRoles">
|
|
<el-select v-model="queryParams.recipientRoles" placeholder="请选择接收角色" clearable style="width: 240px;">
|
|
<el-option v-for="item in dutyList1" :label="item.dutyName" :value="item.dutyId"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="" prop="templateStatus">
|
|
<el-select v-model="queryParams.templateStatus" placeholder="请选择通知状态" clearable style="width: 240px;">
|
|
<el-option label="启用" value="1"></el-option>
|
|
<el-option label="禁用" value="0"></el-option>
|
|
<!-- 添加其他选项 -->
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item style="float: right;margin-right: 0px">
|
|
<el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
|
|
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
|
|
<el-button
|
|
type="primary"
|
|
@click="handleAdd"
|
|
v-hasPermi="['system:notify:addRecord']"
|
|
>新增通知
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div class="table_box" >
|
|
<el-table :data="tableData" style="width: 100%" border>
|
|
<el-table-column align="center" type="index" label="序号"></el-table-column>
|
|
<el-table-column align="center" prop="notificationName" label="通知名称"></el-table-column>
|
|
<el-table-column align="center" prop="notificationType" label="通知类型"></el-table-column>
|
|
<el-table-column align="center" prop="templateContent" label="通知内容"></el-table-column>
|
|
<el-table-column align="center" prop="recipientRolesName" label="接收角色"></el-table-column>
|
|
<el-table-column align="center" prop="receiveUserNum" label="接收用户">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.receiveUserNum || 0 }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="sendStatus" label="通知状态">
|
|
<template slot-scope="scope">
|
|
<span v-if="scope.row.sendStatus==1">已发送</span>
|
|
<span v-else>未发送</span>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="createName" label="创建人"></el-table-column>
|
|
<el-table-column align="center" prop="createTime" label="创建时间"></el-table-column>
|
|
<el-table-column align="center" prop="createTime" label="发送时间"></el-table-column>
|
|
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
|
<template slot-scope="scope">
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-view"
|
|
@click="edit(scope.row)"
|
|
v-hasPermi="['system:notify:editRecord']"
|
|
>编辑
|
|
</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-edit"
|
|
@click="del(scope.row)"
|
|
v-hasPermi="['system:notify:deleteRecord']"
|
|
>删除
|
|
</el-button>
|
|
<el-button
|
|
size="mini"
|
|
type="text"
|
|
icon="el-icon-edit"
|
|
@click="send(scope.row.id)"
|
|
v-if="scope.row.sendStatus!=1"
|
|
v-hasPermi="['system:notify:send']"
|
|
>发送通知
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
<pagination
|
|
v-show="total>0"
|
|
:total="total"
|
|
:page.sync="queryParams.page"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
/>
|
|
|
|
</div>
|
|
|
|
<el-dialog center :title="title" :close-on-click-modal="false" :visible.sync="open" width="35%" append-to-body>
|
|
<el-form ref="form" :model="form" label-width="80px">
|
|
<!-- 通知名称 -->
|
|
<el-form-item label="通知名称" :required="true">
|
|
<el-input v-model="form.notificationName" placeholder="请输入通知名称"></el-input>
|
|
</el-form-item>
|
|
|
|
<!-- 通知类型 -->
|
|
<el-form-item label="通知类型" :required="true">
|
|
<el-select v-model="form.notificationType" placeholder="请选择通知类型" style="width: 100%;">
|
|
<el-option label="到期提醒" value="到期提醒"></el-option>
|
|
<el-option label="系统升级" value="系统升级"></el-option>
|
|
<!-- 添加其他选项 -->
|
|
<!-- 添加其他选项 -->
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<!-- 通知模板 -->
|
|
<el-form-item label="通知模板" :required="true">
|
|
<el-input type="textarea" v-model="form.templateContent" placeholder="请输入通知内容" :maxlength="200"
|
|
show-word-limit></el-input>
|
|
</el-form-item>
|
|
|
|
<!-- 接收角色 -->
|
|
<el-form-item label="接收角色" :required="true">
|
|
<el-select v-model="form.recipientRoles" multiple placeholder="请选择角色" @change="getUserByRoles"
|
|
style="width: 100%;">
|
|
<el-option v-for="item in dutyList1" :label="item.dutyName" :value="item.dutyId"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="接收用户" :required="true">
|
|
<el-select v-model="form.recipientUser" multiple placeholder="请选择接收用户"
|
|
style="width: 100%;">
|
|
<el-option v-for="item in linshicunshu" :label="item.userName" :value="item.id"></el-option>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<!-- 模板状态 -->
|
|
<el-form-item label="模板状态" :required="true">
|
|
<el-switch v-model="form.templateStatus" active-color="#13ce66" inactive-color="#ff4949"></el-switch>
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
<div style="display: flex; justify-content: center; align-items: center;margin-top: 30px">
|
|
<el-button type="primary" @click="userEnter1">确定</el-button>
|
|
<el-button @click="userCe2">取消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
<el-dialog center :title="title" :close-on-click-modal="false" :visible.sync="open1" width="50%" append-to-body>
|
|
<el-table v-loading="" :data="userList" @selection-change="handleSelectionChange" border>
|
|
<el-table-column type="selection" width="50" align="center"/>
|
|
|
|
<el-table-column label="用户名" align="center" key="accountName" prop="accountName"/>
|
|
<el-table-column label="真实姓名" align="center" key="realName" prop="realName"/>
|
|
<el-table-column label="用户角色" align="center" key="roleName" prop="roleName"/>
|
|
|
|
<el-table-column label="所属机构" align="center" prop="storeName" width="160">
|
|
<template slot-scope="scope">
|
|
<span>{{ scope.row.deptName ? scope.row.deptName : '-' }}</span>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
<div style="display: flex; justify-content: center; align-items: center;margin-top: 30px">
|
|
<el-button type="primary" @click="userEnter">确定</el-button>
|
|
<el-button @click="userCe();open1 = false">取消</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
|
|
|
|
import {deleteAppApi} from "../../../api/sys/app";
|
|
import {listUser1} from "../../../api/system/Site/site";
|
|
import {dutyList, getByRoleIdApi} from "../../../api/duty/duty";
|
|
import {
|
|
deleteSysNotifyApi,
|
|
getSendNotifyApi,
|
|
getSysNotifyInfo,
|
|
getSysNotifyList,
|
|
saveSysNotifyApi,
|
|
updateSysNotifyApi
|
|
} from "../../../api/sys/sysNotify";
|
|
|
|
export default {
|
|
name: "notify-record",
|
|
|
|
data() {
|
|
return {
|
|
tableData: [],
|
|
form: {
|
|
notificationName: '',
|
|
notificationType: '',
|
|
templateContent: '',
|
|
recipientRoles: [],
|
|
templateStatus: true,
|
|
// conditions: [
|
|
// { field: '', operator: '', value: '' }
|
|
// ],
|
|
recipientUser: []
|
|
},
|
|
// dutyList:[],
|
|
dutyList1: [],
|
|
|
|
// 用户表格数据
|
|
userList: null,
|
|
|
|
// 是否显示弹出层
|
|
open: false,
|
|
open1: false,
|
|
title: "",
|
|
total: 0,
|
|
// 查询参数
|
|
queryParams: {
|
|
page: 1,
|
|
pageSize: 10,
|
|
deptName: '',
|
|
legalRepresentativeContact: '',
|
|
appStatus: '',
|
|
},
|
|
// 查询参数
|
|
queryParamsUser: {
|
|
page: 1,
|
|
pageSize: 10000
|
|
|
|
},
|
|
linshicunshu: [],
|
|
|
|
getroleStaff: [],
|
|
};
|
|
},
|
|
created() {
|
|
this.getList()
|
|
this.getDutyList()
|
|
},
|
|
methods: {
|
|
getList() {
|
|
getSysNotifyList(this.queryParams).then(res => {
|
|
this.tableData = res.data.records;
|
|
this.total = res.data.total
|
|
})
|
|
},
|
|
|
|
submitForm(formName) {
|
|
this.$refs[formName].validate(valid => {
|
|
if (valid) {
|
|
// 表单验证通过,可以提交数据
|
|
// 示例:调用 API 提交数据
|
|
this.submitDeviceInfo();
|
|
} else {
|
|
// 表单验证失败,不执行任何操作
|
|
return false;
|
|
}
|
|
});
|
|
},
|
|
// 发送通知
|
|
send(data) {
|
|
this.$confirm('是否发送本条通知信息', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
getSendNotifyApi({id: data}).then(res => {
|
|
if (res.data == true) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '发送成功!'
|
|
});
|
|
this.getList()
|
|
} else {
|
|
this.$message.error("发送失败")
|
|
}
|
|
})
|
|
|
|
}).catch(() => {
|
|
this.$message({
|
|
type: 'info',
|
|
message: '已取消发送'
|
|
});
|
|
});
|
|
},
|
|
|
|
getUserByRoles() {
|
|
if (this.form.recipientRoles.length === 0) {
|
|
this.form.recipientRoles = []
|
|
this.getroleStaff = []
|
|
return
|
|
}
|
|
console.log("123", this.form.recipientRoles)
|
|
// this.form.recipientUser = []
|
|
let ids = this.form.recipientRoles.join(',')
|
|
getByRoleIdApi({roleIds: ids}).then(res => {
|
|
const getUsertList = res.data;
|
|
console.log(getUsertList,335)
|
|
// recipientUser
|
|
// this.form.recipientUser = []
|
|
getUsertList.forEach(item => {
|
|
this.form.recipientUser.push(item.acctId)
|
|
// this.form.recipientUser.push({
|
|
// id: item.acctId,
|
|
// staffId:item.staffId,
|
|
// userName: item.realName,
|
|
// })
|
|
this.getroleStaff.push({
|
|
id: item.acctId,
|
|
userName: item.accountName,
|
|
})
|
|
|
|
})
|
|
})
|
|
// this.getroleStaff();
|
|
this.cenDis();
|
|
},
|
|
// 去重
|
|
cenDis() {
|
|
// this.form.recipientUser
|
|
|
|
const uniqueMap = new Map();
|
|
this.form.recipientUser = this.form.recipientUser.filter((item) => {
|
|
const stringifiedItem = JSON.stringify(item);
|
|
return uniqueMap.has(stringifiedItem) ? false : uniqueMap.set(stringifiedItem, true);
|
|
});
|
|
},
|
|
|
|
// 数组合并
|
|
getroleStaff() {
|
|
// this.getroleStaff
|
|
this.form.recipientUser.push(...this.getroleStaff)
|
|
// this.form.recipientUser = this.form.recipientUser.concat(e)
|
|
console.log("this.form.recipientUser", this.form.recipientUser)
|
|
},
|
|
|
|
handleQuery() {
|
|
this.getList()
|
|
},
|
|
resetQuery() {
|
|
this.queryParams = {
|
|
page: 1,
|
|
pageSize: 10,
|
|
deviceName: '',
|
|
}
|
|
this.getList()
|
|
},
|
|
handleAdd(e) {
|
|
this.clean()
|
|
this.open = true;
|
|
this.getDutyList()
|
|
|
|
this.title = "新增通知"
|
|
this.onlyGetUser()
|
|
},
|
|
userEnter1() {
|
|
// 在这里调用接口提交设备信息数据
|
|
console.log('提交设备信息数据:', this.form);
|
|
this.form.receiveUserNum = this.form.recipientUser.length
|
|
this.form.recipientUser = JSON.stringify(this.form.recipientUser)
|
|
this.form.recipientRoles = JSON.stringify(this.form.recipientRoles)
|
|
if (this.form.id) {
|
|
updateSysNotifyApi(this.form).then(res => {
|
|
if (res.code === 200) {
|
|
this.getList()
|
|
this.open = false
|
|
this.$message.success("修改成功")
|
|
}
|
|
})
|
|
} else {
|
|
saveSysNotifyApi(this.form).then(res => {
|
|
if (res.code === 200) {
|
|
this.getList()
|
|
this.open = false
|
|
this.$message.success("添加成功")
|
|
}
|
|
})
|
|
}
|
|
},
|
|
userCe2() {
|
|
this.open = false;
|
|
|
|
},
|
|
edit(e) {
|
|
this.clean()
|
|
// this.open = true;
|
|
// this.title = "编辑通知"
|
|
// this.form = e
|
|
// this.form.recipientUser = JSON.parse(this.form.recipientUser)
|
|
// this.form.recipientRoles = JSON.parse(this.form.recipientRoles)
|
|
// this.getDutyList()
|
|
this.onlyGetUser()
|
|
getSysNotifyInfo(e.id).then(res => {
|
|
this.open = true;
|
|
this.title = "编辑通知"
|
|
this.form = res.data
|
|
if (this.form.recipientUser) {
|
|
this.form.recipientUser = JSON.parse(this.form.recipientUser)
|
|
} else {
|
|
this.form.recipientUser = []
|
|
}
|
|
this.form.recipientRoles = JSON.parse(this.form.recipientRoles)
|
|
this.getDutyList()
|
|
})
|
|
|
|
},
|
|
del(e) {
|
|
|
|
this.$confirm('是否删除本条数据,删除后无法恢复!', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
deleteSysNotifyApi(e.id).then(res => {
|
|
if (res.code == 200) {
|
|
this.$message({
|
|
type: 'success',
|
|
message: '删除成功!'
|
|
});
|
|
this.getList()
|
|
}
|
|
})
|
|
|
|
}).catch(() => {
|
|
this.$message({
|
|
type: 'info',
|
|
message: '已取消删除'
|
|
});
|
|
});
|
|
},
|
|
handleSelectionChange(val) {
|
|
console.log("valval", val)
|
|
this.linshicunshu = [],
|
|
// this.form.recipientUser = []
|
|
|
|
|
|
val.forEach(item => {
|
|
this.linshicunshu.push({
|
|
id: item.acctId,
|
|
staffId: item.staffId,
|
|
userName: item.realName ? item.realName : '--'
|
|
})
|
|
})
|
|
|
|
console.log("val2", this.linshicunshu)
|
|
|
|
},
|
|
onlyGetUser() {
|
|
this.linshicunshu = []
|
|
listUser1(this.queryParamsUser).then(response => {
|
|
this.userList = response.data.records
|
|
console.log(this.userList,507)
|
|
this.userList.forEach(item => {
|
|
this.linshicunshu.push({
|
|
id: item.acctId,
|
|
staffId: item.staffId,
|
|
userName: item.realName ? item.realName : '--'
|
|
})
|
|
})
|
|
}
|
|
);
|
|
},
|
|
clickUser(id) {
|
|
this.form.recipientUser = this.form.recipientUser.filter(item => item.id !== id);
|
|
},
|
|
clickAdd() {
|
|
this.linshicunshu = []
|
|
this.open1 = true;
|
|
this.onlyGetUser()
|
|
},
|
|
userEnter() {
|
|
this.open1 = false
|
|
console.log("this.linshicunshu", this.linshicunshu)
|
|
// this.form.recipientUser = [],
|
|
this.form.recipientUser.push(...this.linshicunshu)
|
|
this.cenDis()
|
|
// this.form.recipientUser.push(...this.getroleStaff)
|
|
console.log(this.form.recipientUser)
|
|
},
|
|
|
|
toggleSelection(rows) {
|
|
if (rows) {
|
|
rows.forEach(row => {
|
|
this.$refs.multipleTable.toggleRowSelection(row);
|
|
});
|
|
} else {
|
|
this.$refs.multipleTable.clearSelection();
|
|
}
|
|
},
|
|
|
|
|
|
userCe() {
|
|
console.log("4444444444444444")
|
|
this.open1 = false
|
|
// open1
|
|
this.linshicunshu = []
|
|
},
|
|
getDutyList() {
|
|
// this.loading = true;
|
|
let queryParams1 = {
|
|
page: 1,
|
|
pageSize: 10000
|
|
}
|
|
dutyList(queryParams1).then(res => {
|
|
this.dutyList1 = res.data.records;
|
|
// this.total1 = res.data.total;
|
|
// this.loading = false;
|
|
})
|
|
},
|
|
clean() {
|
|
this.deviceInfo = {
|
|
id: null, // 自增id
|
|
orgName: '', // 机构名称
|
|
unifiedSocialCreditCode: '', // 统一社会信用代码
|
|
appId: '', // 小程序appID
|
|
appKey: '', // 密钥
|
|
legalRepresentativeName: '', // 法人姓名
|
|
legalRepresentativeWeChat: '', // 法人微信
|
|
legalRepresentativeContact: '', // 法人联系方式
|
|
appStatus: false, // 小程序状态
|
|
createByName: '',
|
|
}
|
|
this.form = {
|
|
notificationName: '',
|
|
notificationType: '',
|
|
templateContent: '',
|
|
recipientRoles: [],
|
|
templateStatus: true,
|
|
// conditions: [
|
|
// { field: '', operator: '', value: '' }
|
|
// ],
|
|
recipientUser: []
|
|
}
|
|
},
|
|
}
|
|
};
|
|
</script>
|
|
<style lang="scss" scoped>
|
|
.common-dialog.el-upload--picture-card {
|
|
width: 60px;
|
|
height: 50px;
|
|
line-height: 60px;
|
|
}
|
|
.container_hui{
|
|
background: #fff;
|
|
margin: 10px;
|
|
margin-bottom: 0px;
|
|
border-radius: 8px;
|
|
box-sizing: border-box;
|
|
padding: 15px;
|
|
|
|
}
|
|
.cards-change{
|
|
//height: 81vh;
|
|
}
|
|
.table_box{
|
|
height: 72vh;
|
|
overflow: auto;
|
|
scrollbar-width: none;
|
|
}
|
|
</style>
|
|
|