Browse Source

对应字段/通知管理

master
xuhuajiao 1 year ago
parent
commit
eeca6e83a8
  1. 44
      src/api/system/fieldMate.js
  2. 1
      src/api/system/logs.js
  3. 20
      src/api/system/notify.js
  4. 10
      src/api/system/user.js
  5. 34
      src/views/system/fieldCorresManage/index.vue
  6. 26
      src/views/system/notifyManage/data.json
  7. 465
      src/views/system/notifyManage/index.vue
  8. 111
      src/views/system/notifyManage/module/detail.vue
  9. 140
      src/views/system/notifyManage/module/selectObj.vue

44
src/api/system/fieldMate.js

@ -0,0 +1,44 @@
import request from '@/utils/request'
export function FetchInitFieldMateList(params) {
return request({
url: 'api/fieldMate/initFieldMateList',
method: 'get',
params
})
}
export function add(data) {
return request({
url: 'api/fieldMate/editFieldMate',
method: 'post',
data
})
}
export function edit(data) {
return request({
url: 'api/fieldMate/editFieldMate',
method: 'post',
data
})
}
export function del(data) {
return request({
url: 'api/fieldMate/delete',
method: 'delete',
data
})
}
// 查看字段对应详情
export function FetchInitFieldMate(params) {
return request({
url: 'api/fieldMate/initFieldMate',
method: 'get',
params
})
}
export default { add, edit, del, FetchInitFieldMateList, FetchInitFieldMate }

1
src/api/system/logs.js

@ -11,7 +11,6 @@ export function warnRemark(data) {
}
// ------通知管理-------
// 获取表格
export function getNoticeList(params) {
return request({
url: 'api/notice/initNotice',

20
src/api/system/notify.js

@ -0,0 +1,20 @@
import request from '@/utils/request'
export function getNoticeList(params) {
return request({
url: 'api/notice/initNotice',
method: 'get',
params
})
}
// 发布
export function add(data) {
return request({
url: 'api/notice/create',
method: 'post',
data
})
}
export default { add, getNoticeList }

10
src/api/system/user.js

@ -2,6 +2,14 @@ import request from '@/utils/request'
import { encrypt } from '@/utils/rsaEncrypt'
import { getToken } from '@/utils/auth'
export function FetchInitUserList(params) {
return request({
url: 'api/users/initUserList',
method: 'get',
params
})
}
export function add(data) {
return request({
url: 'api/users/editUser',
@ -80,5 +88,5 @@ export function FetchEditUserState(data) {
})
}
export default { add, edit, del, resetpassword, FetchEditUserState }
export default { add, edit, del, resetpassword, FetchEditUserState, FetchInitUserList }

34
src/views/system/fieldCorresManage/index.vue

@ -4,17 +4,17 @@
<div class="head-container">
<div class="head-search">
<!-- 搜索 -->
<el-input v-model="query.blurry" clearable size="small" placeholder="输入规则名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<el-input v-model="query.ruleName" clearable size="small" placeholder="输入规则名称搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<!-- @input="changePid" -->
<treeselect
v-model="query.source"
v-model="query.documentId"
:options="sourceOptions"
:load-options="loadSource"
style="width: 320px;"
placeholder="请选择源分类(文件库分类)"
/>
<treeselect
v-model="query.target"
v-model="query.categoryId"
:options="targetOptions"
:load-options="loadSource"
style="width: 320px;"
@ -91,7 +91,7 @@
</template>
<script>
import crudMenu from '@/api/system/menu'
import crudFieldMate from '@/api/system/fieldMate'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
@ -108,8 +108,8 @@ export default {
cruds() {
return CRUD({
title: '对应关系',
url: 'api/menus',
crudMethod: { },
url: 'api/fieldMate/initFieldMateList',
crudMethod: { ...crudFieldMate },
optShow: {
add: true,
edit: false,
@ -155,17 +155,17 @@ export default {
},
loadSource({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
crudMenu.getMenusTree(parentNode.id).then(res => {
parentNode.children = res.map(function(obj) {
if (!obj.leaf) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 100)
})
// crudMenu.getMenusTree(parentNode.id).then(res => {
// parentNode.children = res.map(function(obj) {
// if (!obj.leaf) {
// obj.children = null
// }
// return obj
// })
// setTimeout(() => {
// callback()
// }, 100)
// })
}
}
}

26
src/views/system/notifyManage/data.json

@ -1,26 +0,0 @@
[
{
"id": 1,
"label": "全宗部门选择",
"children": [
{
"id": 2,
"label": "全宗A",
"children": [
{
"id": 4,
"label": "部门A1"
},
{
"id": 5,
"label": "部门A2"
}
]
},
{
"id": 3,
"label": "全宗B"
}
]
}
]

465
src/views/system/notifyManage/index.vue

@ -3,70 +3,70 @@
<div class="head-container">
<div class="head-search">
<!-- 搜索 -->
<el-input v-model="query.blurry" clearable size="small" placeholder="输入关键字搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<date-range-picker v-model="query.createTime" class="date-item" />
<el-input v-model="query.search" clearable size="small" placeholder="输入关键字搜索" prefix-icon="el-icon-search" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<date-range-picker v-model="blurryTime" class="date-item" />
<rrOperation />
</div>
<el-button size="mini" @click="handleSend"><i class="iconfont icon-fabu" />发布</el-button>
<!-- <el-button icon="el-icon-edit" size="mini" :disabled="!(selections.length === 1)" @click="handleEdit">修改</el-button>
<el-button icon="el-icon-delete" size="mini" :disabled="!selections.length" @click="handleDel">删除</el-button> -->
<crudOperation>
<template v-slot:left>
<el-button size="mini" @click="crud.toAdd">
<i class="iconfont icon-fabu" />
发布
</el-button>
</template>
</crudOperation>
</div>
<div class="container-wrap">
<span class="right-top-line" />
<span class="left-bottom-line" />
<!--表格渲染-->
<!-- height="calc(100vh - 294px)"
@row-click="clickRowHandler"
@selection-change="selectionChangeHandler" -->
<el-table
ref="table"
v-loading="isLoading"
:default-sort="{prop: 'create_time', order: 'descending'}"
:data="tableData"
v-loading="crud.loading"
:data="crud.data"
style="width: 100%;"
@row-dblclick="handleDbClick"
>
<!-- <el-table-column type="selection" width="55" align="center" /> -->
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="noticeType" label="消息类型" align="center" min-width="150">
<!-- <span v-if="scope.row.noticeType===1">系统消息</span> -->
<span>系统消息</span>
</el-table-column>
<el-table-column prop="title" :show-overflow-tooltip="true" label="标题" min-width="150" align="center" />
<el-table-column prop="noticeContent" :show-overflow-tooltip="true" label="内容" align="center" />
<el-table-column prop="pushTo" :show-overflow-tooltip="true" label="发送对象" align="center">
<el-table-column prop="noticeType" label="消息类型" align="center" min-width="100">
<template slot-scope="scope">
<span v-if="typeof(scope.row.pushTo)==='string'">{{ scope.row.pushTo }}</span>
<div v-if="!(typeof(scope.row.pushTo)==='string')" class="tag-hidden">
<!-- <el-tag v-for="(item,i) in scope.row.pushTo" :key="i" style="margin-left:3px;color: #fff">{{ item }}</el-tag> -->
{{ scope.row.pushTo.join(',') }}
</div>
<span v-if="scope.row.noticeType===0">系统消息</span>
</template>
</el-table-column>
<el-table-column prop="update_by" label="创建人" align="center" min-width="100" />
<el-table-column prop="create_time" :sortable="true" label="创建时间" align="center" min-width="180">
<el-table-column prop="noticeTitle" :show-overflow-tooltip="true" label="标题" min-width="150" align="center" />
<el-table-column prop="noticeContext" :show-overflow-tooltip="true" label="内容" align="center" min-width="200" />
<el-table-column :show-overflow-tooltip="true" label="发送对象" align="center" min-width="200">
<template v-if="scope.row.noticeDevices.length !== 0" slot-scope="scope">
{{ scope.row.noticeDevices.join(',') }}
<!-- <div class="tag-hidden">
<el-tag v-for="(item,i) in scope.row.noticeDevices" :key="i" style="margin-left:3px; color: #fff">{{ item }}</el-tag>
</div> -->
</template>
<template v-if="scope.row.noticeUsers.length !== 0" slot-scope="scope">
<!-- <div class="tag-hidden">
<el-tag v-for="(item,i) in scope.row.noticeUsers" :key="i" style="margin-left:3px; color: #fff">{{ item }}</el-tag>
</div> -->
{{ scope.row.noticeUsers.join(',') }}
</template>
</el-table-column>
<el-table-column prop="create_by" label="创建人" align="center" min-width="100" />
<el-table-column prop="create_time" label="创建时间" align="center" min-width="180">
<template slot-scope="scope">
<div>{{ scope.row.create_time | parseTime }}</div>
</template>
</el-table-column>
</el-table>
<el-pagination
:page-size.sync="page.size"
:total="page.total"
:current-page.sync="page.page"
style="margin-top: 8px;"
layout="total, prev, pager, next, sizes"
@size-change="sizeChangeHandler($event)"
@current-change="pageChangeHandler"
/>
<!--分页组件-->
<pagination />
</div>
<!-- 发布 -->
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="sendVisible" title="发布通知" @close="handleClose">
<el-dialog append-to-body :close-on-click-modal="false" :modal-append-to-body="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" title="发布通知">
<span class="dialog-right-top" />
<span class="dialog-left-bottom" />
<div class="setting-dialog">
<el-form ref="formDom" :rules="rules" :model="sendForm" size="small" label-width="100px">
<el-form-item label="消息类型" prop="msgType" class="down-select">
<el-input v-model="sendForm.msgType" disabled />
<el-form ref="form" :rules="rules" :model="form" size="small" label-width="100px">
<el-form-item label="消息类型" prop="noticeType" class="down-select">
<el-input v-model="form.noticeTypeName" disabled />
<!-- <el-select v-model="noticeType" placeholder="请选择">
<el-option
v-for="item in msgTypeOptions"
@ -77,375 +77,124 @@
/>
</el-select> -->
</el-form-item>
<el-form-item label="标题" prop="title">
<el-input v-model="sendForm.title" placeholder="请输入" style="width: 580px;" />
<el-form-item label="标题" prop="noticeTitle">
<el-input v-model="form.noticeTitle" placeholder="请输入" style="width: 580px;" />
</el-form-item>
<el-form-item label="内容" prop="notification">
<el-input v-model="sendForm.notification" placeholder="请输入" type="textarea" rows="3" style="width: 580px;" />
<el-form-item label="内容" prop="noticeContext">
<el-input v-model="form.noticeContext" placeholder="请输入" type="textarea" rows="3" style="width: 580px;" />
</el-form-item>
<el-form-item label="发送对象" prop="pushObj">
<el-input v-model="sendForm.pushObj" placeholder="点击下方按钮选择对象" type="textarea" rows="6" style="width: 580px;" />
<el-form-item label="发送对象" prop="userId">
<div class="send-obj">
<span v-if="pushObjItem.length === 0">点击下方按钮选择对象</span>
<el-tag
v-for="tag in pushObjItem"
v-else
:key="tag.userId"
:disable-transitions="false"
>
{{ tag.username }}
</el-tag>
</div>
</el-form-item>
<span class="select-btn iconfont icon-shezhi" @click="openSelectObj" />
<!-- <el-form-item label="发送对象" prop="">
<el-radio-group v-model="pushObj" @change="pushObjChange">
<el-radio label="用户">用户</el-radio>
<el-radio label="设备">设备</el-radio>
</el-radio-group>
</el-form-item> -->
<!-- <el-form-item label="发送对象" prop="paramName">
<el-select ref="selectBox" v-model="selectOptions" class="select" multiple :collapse-tags="showTags" clearable placeholder="请选择" style="width:588px" @change="changeSelect">
<el-option v-for="item in sendObjOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item> -->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="sendVisible = false">取消</el-button>
<el-button v-loading="btnloading" type="primary" @click="handleSave">保存</el-button>
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">保存</el-button>
</div>
</div>
</el-dialog>
<SelectObj ref="selectObj" />
<SelectObj ref="selectObj" @selectObjItem="handleSelectObjItem" />
<Detail ref="archiveDetailDom" />
</div>
</template>
<script>
import crudNotify from '@/api/system/notify'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import crudOperation from '@crud/CRUD.operation'
import rrOperation from '@crud/RR.operation'
import DateRangePicker from '@/components/DateRangePicker'
import pagination from '@crud/Pagination'
import SelectObj from './module/selectObj'
// noticeDel
import { noticeCreate, getAllDev, getAllUser, getNoticeList } from '@/api/system/logs'
import Detail from './module/detail'
const defaultForm = {}
const defaultForm = { id: null, noticeTypeName: '系统消息', noticeType: null, noticeTitle: null, noticeContext: null, userId: [], deviceInfoId: [] }
export default {
name: 'NotifyManage',
components: { rrOperation, DateRangePicker, SelectObj },
components: { crudOperation, rrOperation, DateRangePicker, pagination, SelectObj, Detail },
cruds() {
return CRUD({ title: '通知', url: 'api/notice/initNotice', crudMethod: { }})
return CRUD({ title: '通知', url: 'api/notice/initNotice', crudMethod: { ...crudNotify }, sort: [], optShow: {
add: false,
edit: false,
del: false,
download: false,
group: false
}})
},
mixins: [presenter(), header(), form(defaultForm), crud()],
inject: ['reload'],
data() {
return {
isLoading: false,
tableData: [],
selections: [],
blurryTime: null,
sendVisible: false,
sendForm: {
msgType: '系统消息',
title: null,
notification: ''
},
pushObj: '用户',
checked: '',
noticeType: 1,
tableData: [],
pushObjItem: [],
msgTypeOptions: [
{ value: 1, label: '系统通知' }
// { value: 2, label: '', disabled: true },
// { value: 3, label: '', disabled: true },
// { value: 4, label: '', disabled: true }
],
userOptions: [],
devOptions: [],
selectOptions: [],
oldSelect: null,
showTags: true,
rules: {
title: [
noticeTitle: [
{ required: true, message: '标题不可为空', trigger: 'blur' }
],
notification: [
noticeContext: [
{ required: true, message: '内容不可为空', trigger: 'blur' }
],
pushObj: [
userId: [
{ required: true, message: '发送对象不可为空', trigger: 'blur' }
]
},
allUser: null,
allDev: null,
page: {
total: 0,
size: 10,
page: 1
},
btnloading: false,
isEdit: null
}
},
computed: {
sendObjOptions() {
if (this.pushObj === '用户') {
return this.userOptions
} else {
return this.devOptions
}
}
},
async created() {
await this.getUser()
await this.getDev()
this.getTableData()
},
methods: {
openSelectObj() {
this.$refs.selectObj.sendObjVisible = true
},
getParams() {
const params = {
page: null,
size: null,
sort: 'createTime,desc'
}
params.page = this.page.page - 1
params.size = this.page.size
return params
},
getTableData() {
this.isLoading = true
getNoticeList(this.getParams()).then(res => { //
console.log(res, 'res')
const table = res.content
this.page.total = res.totalElements
table.forEach(item => {
item.pushTo = null
item.pushVal = null
if (item.pushType === 2) { //
item.pushVal = item.noticeDevices.map(i => { return i.deviceInfoId })
item.pushTo = item.noticeDevices.map(i => {
let dev = null
this.devOptions.forEach(val => {
if (val.value === i.deviceInfoId) {
dev = val.label
}
})
return dev
})
} else if (item.pushType === 1) { //
item.pushVal = item.noticeUsers.map(i => { return i.userId })
item.pushTo = item.noticeUsers.map(i => {
let user = null
this.userOptions.forEach(val => {
if (val.value === i.userId) {
user = val.label
}
})
return user
})
}
//
const arrTo = []
const arrVal = []
item.pushTo.forEach(i => {
if (arrTo.indexOf(i) === -1 && i !== null) {
arrTo.push(i)
}
})
item.pushVal.forEach(i => {
if (arrVal.indexOf(i) === -1 && i !== null) {
arrVal.push(i)
}
})
item.pushVal = arrVal
if (item.pushType === 1) { //
item.pushTo = arrVal.length === this.userOptions.length - 1 ? '全部用户' : arrTo
[CRUD.HOOK.beforeRefresh]() {
if (this.blurryTime) {
this.crud.query.startTime = this.blurryTime[0]
this.crud.query.endTime = this.blurryTime[1]
} else {
item.pushTo = arrVal.length === this.devOptions.length - 1 ? '全部设备' : arrTo
this.crud.query.startTime = null
this.crud.query.endTime = null
}
})
this.tableData = table
this.isLoading = false
})
},
//
async getUser() {
await getAllUser().then(res => {
const arr0 = [{ value: 0, label: '全部用户' }]
const arr = res.map(item => {
const val = item.id
const lab = item.dept.name + '-' + item.username
const obj = {
value: val,
label: lab
}
return obj
})
this.userOptions = arr0.concat(arr)
})
},
//
async getDev() {
await getAllDev().then(res => {
const arr0 = [{ value: 0, label: '全部设备' }]
const arr = res.map(item => {
const val = item.id
const lab = item.deviceName
const obj = {
value: val,
label: lab
}
return obj
})
this.devOptions = arr0.concat(arr)
})
},
//
sizeChangeHandler(e) {
this.loading = true
this.page.size = e
this.page.page = 1
this.getTableData()
this.loading = false
},
//
pageChangeHandler(e) {
this.loading = true
this.page.page = e
this.getTableData()
this.loading = false
},
// clickRowHandler(row) {
// // this.$refs.table.clearSelection()
// this.$refs.table.toggleRowSelection(row) //
// },
// selectionChangeHandler(val) {
// this.selections = val
// console.log(val)
// },
//
handleSend() {
this.defaultSelAll()
this.isEdit = false
this.sendVisible = true
openSelectObj() {
this.$refs.selectObj.sendObjVisible = true
this.$refs.selectObj.getFondsDatas()
},
//
// handleEdit() {
// this.isEdit = true
// this.sendForm.notification = this.selections[0].noticeContent
// const temp = this.selections[0].pushVal
// if (this.selections[0].pushType === 1) {
// this.pushObj = ''
// this.selectOptions = temp.length === this.userOptions.length - 1 ? [0, ...temp] : temp
// } else {
// this.pushObj = ''
// this.selectOptions = temp.length === this.devOptions.length - 1 ? [0, ...temp] : temp
// }
// this.sendVisible = true
// },
//
handleSave() {
this.$refs.formDom.validate((valid) => {
if (valid) {
this.noticeSend(this.getPushParams())
handleSelectObjItem(objType, selectItemAll) {
this.pushObjItem = selectItemAll
if (objType === 0) {
this.form.userId = selectItemAll.map(item => item.userId)
this.form.deviceInfoId = []
} else {
return false
this.form.userId = []
}
})
},
getPushParams() { //
const params = {}
params.noticeType = this.noticeType
params.noticeContent = this.sendForm.notification
//* ************** */
if (this.pushObj === '用户') { //
params.pushType = 1
params.userId = this.selectOptions.filter(item => item !== 0)
} else { //
params.pushType = 2
params.deviceInfoId = this.selectOptions.filter(item => item !== 0)
}
if (this.isEdit) {
params.id = this.selections[0].id
}
console.log(params, '参数')
return params
//
[CRUD.HOOK.afterValidateCU](crud) {
console.log(crud.form)
crud.form.noticeType = 0
delete crud.form.noticeTypeName
return true
},
//
noticeSend(params) {
noticeCreate(params).then(res => {
if (res === 'SUCCESS') {
this.btnloading = false
this.sendVisible = false
// this.getTableData()
this.reload()
this.$message({
message: '发布成功',
type: 'success'
handleDbClick(row) {
this.$nextTick(() => {
this.$refs.archiveDetailDom.detailVisible = true
this.$refs.archiveDetailDom.rowData = row
})
this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate()
} else {
this.btnloading = false
this.$message.error('发布失败')
}
})
},
handleClose() {
this.$refs.formDom.resetFields()
this.$refs.formDom.clearValidate()
this.sendForm.notification = ''
this.pushObj = '用户'
this.noticeType = 1
},
//
// handleDel() {
// this.delVisible = true
// },
// //
// handleDelConfirm() {
// const params = this.selections.map(item => { return item.id })
// noticeDel(params).then(res => {
// if (res === 'SUCCESS') {
// // this.getTableData()
// this.delVisible = false
// this.reload()
// this.$message({
// message: '',
// type: 'success'
// })
// } else {
// this.$message.error('')
// }
// })
// },
//
handelChange(val) {
if (val.length === this.sendObjOptions.length) {
this.checked = true
} else {
this.checked = false
}
},
//
defaultSelAll() {
this.selectOptions = this.sendObjOptions.map(item => { return item.value })
this.oldSelect = this.selectOptions
this.showTags = true
},
changeSelect(val) {
if (val[val.length - 1] === 0) { //
this.defaultSelAll()
this.$refs.selectBox.$el.querySelector('.el-input__inner').style.height = '34px'
} else {
const arr1 = this.oldSelect.filter(item => item !== 0)
const arr2 = val.filter(item => item !== 0)
if (arr1.length === arr2.length) { //
this.selectOptions = []
} else if (arr1.length < arr2.length && arr2.length === this.sendObjOptions.length - 1) {
this.defaultSelAll() //
this.$refs.selectBox.$el.querySelector('.el-input__inner').style.height = '34px'
} else {
this.selectOptions = this.selectOptions.filter(item => item !== 0) //
this.showTags = false
}
this.oldSelect = this.selectOptions
}
},
pushObjChange(val) {
if (val) {
this.defaultSelAll()
this.showTags = true
}
}
}
}
@ -463,5 +212,11 @@ export default {
text-align: center;
cursor: pointer;
}
.send-obj{
width: 580px;
height: 180px;
padding: 0 10px;
border-radius: 3px 3px 3px 3px;
border: 1px solid #E6E8ED;
}
</style>

111
src/views/system/notifyManage/module/detail.vue

@ -0,0 +1,111 @@
<template>
<!-- 选择发送对象 -->
<el-dialog append-to-body :close-on-click-modal="false" :visible.sync="detailVisible" title="通知详情" @close="handleClose">
<span class="dialog-right-top" />
<span class="dialog-left-bottom" />
<div class="setting-dialog">
<span class="message-type-title type-title1">系统通知</span>
<div class="notify-item">
<p>标题{{ rowData.noticeTitle }}</p>
</div>
<div class="notify-item">
<span class="notify-title">内容</span>
<div class="notify-cont">
{{ rowData.noticeContext }}
</div>
</div>
<div class="notify-item">
<span class="notify-title">发送对象</span>
<div class="notify-cont">
<p v-if="rowData.noticeDevices.length !== 0">{{ rowData.noticeDevices.join('') }}</p>
<p v-if="rowData.noticeUsers.length !== 0">{{ rowData.noticeUsers.join('') }}</p>
</div>
</div>
<div class="notify-create">
<span>创建人{{ rowData.create_by }}</span>
<span>创建时间{{ rowData.create_time | parseTime }}</span>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="detailVisible=false">确定</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
data() {
return {
detailVisible: false,
rowData: {}
}
},
watch: {
},
created() {
},
mounted() {
},
methods: {
handleClose() {
this.detailVisible = false
}
}
}
</script>
<style lang='scss' scoped>
::v-deep .el-dialog .el-dialog__body{
padding: 20px 0;
}
.dialog-footer, .el-message-box__btns{
margin-top: 20px;
}
.message-type-title{
display: block;
padding-left: 33px;
height: 33px;
line-height: 33px;
margin-bottom: 15px;
&.type-title1{
background: url('~@/assets/images/icon/xttz.png') no-repeat left center;
background-size: 23px 23px;
}
&.type-title2{
background: url('~@/assets/images/icon/lcdd.png') no-repeat left center;
background-size: 23px 23px;
}
&.type-title3{
background: url('~@/assets/images/icon/lcwc.png') no-repeat left center;
background-size: 23px 23px;
}
&.type-title4{
background: url('~@/assets/images/icon/fqdq.png') no-repeat left center;
background-size: 23px 23px;
}
}
.notify-item{
margin-bottom: 10px;
color: #0C0E1E;
.notify-title{
line-height: 30px;
}
.notify-cont{
padding: 10px;
height: 120px;
overflow: hidden;
overflow-y: scroll;
border-radius: 3px;
color: #545B65;
border: 1px solid #E6E8ED;
}
}
.notify-create{
display: flex;
justify-content: space-between;
padding: 10px 10px 0 10px;
font-size: 12px;
color: #A6ADB6;
}
</style>

140
src/views/system/notifyManage/module/selectObj.vue

@ -14,40 +14,50 @@
</el-form>
<div class="obj-tree-select">
<div class="obj-tree">
<el-tree :data="treeList" :props="defaultProps" @node-click="handleNodeClick" />
<el-tree ref="tree" :data="fondsDatas" :props="defaultProps" :expand-on-click-node="false" :default-expanded-keys="defaultExpandedKeys" node-key="id" highlight-current @node-click="handleNodeClick">
<template slot-scope="{ node, data }">
<div :class="{'top-level': data.id === 0}">
<span>
{{ data.fondsName }}
<span>{{ data.deptsName }}</span>
</span>
</div>
</template>
</el-tree>
</div>
<div class="obj-list">
<p class="obj-title">用户列表<i class="el-icon-circle-plus-outline" /></p>
<el-checkbox-group v-model="checkList">
<el-checkbox label="用户列表" />
<el-checkbox label="张三" />
<el-checkbox label="李思思" />
</el-checkbox-group>
<!-- <i class="el-icon-circle-plus-outline" /> -->
<p class="obj-title">用户列表</p>
<div v-for="user in userListWithCheck" :key="user.userId">
<el-checkbox v-model="user.checked" @change="handleChange(user)">{{ user.username }}</el-checkbox>
</div>
</div>
<div class="obj-selected">
<p class="obj-title">已选中<i class="iconfont icon-shanchu" /></p>
<p class="obj-title">已选中<i class="iconfont icon-shanchu" @click="clearSelectAll" /></p>
<div class="selected-list">
<el-tag
v-for="tag in dynamicTags"
:key="tag"
v-for="tag in selectedItems"
:key="tag.userId"
closable
:disable-transitions="false"
@close="handleDelt(tag)"
>
{{ tag }}
{{ tag.username }}
</el-tag>
</div>
</div>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary">保存</el-button>
<el-button type="primary" @click="handleSaveSelectObj">保存</el-button>
</div>
</div>
</el-dialog>
</template>
<script>
import dataJson from '../data.json'
import { FetchFondsAll } from '@/api/system/fonds'
import { FetchInitUserList } from '@/api/system/user'
import Vue from 'vue'
export default {
props: {
selectedCategory: {
@ -59,17 +69,17 @@ export default {
},
data() {
return {
fondsDatas: [],
defaultExpandedKeys: [],
defaultProps: { children: 'children', label: 'fondsName' },
sendObjVisible: false,
selectObjForm: {
sendObj: 0
},
treeList: [],
checkList: ['用户列表'],
dynamicTags: ['张三', '李思思'],
defaultProps: {
children: 'children',
label: 'label'
},
userList: [],
selectedItems: [],
userListWithCheck: [], //
rulesObj: {
sendObj: [
{ required: true, message: '请选择发送对象', trigger: 'change' }
@ -78,20 +88,102 @@ export default {
}
},
watch: {
selectedItems: {
handler(val) {
this.updateCheckedState()
},
deep: true
},
userListWithCheck: {
handler(val) {
this.updateCheckedState()
},
deep: true
}
},
created() {
this.treeList = dataJson
},
mounted() {
},
methods: {
getFondsDatas() {
const parent = {}
parent.id = 0
parent.fondsName = '全宗选择'
FetchFondsAll().then(res => {
res.forEach(item => {
item.children = item.depts
})
parent.children = res
this.fondsDatas.push(parent)
this.$nextTick(() => {
Vue.set(this.defaultExpandedKeys, 0, this.fondsDatas[0].children[0].children[0].id)
this.$refs.tree.setCurrentKey(this.fondsDatas[0].children[0].children[0].id)
this.handleNodeClick(this.fondsDatas[0].children[0].children[0])
})
})
},
//
handleNodeClick(data) {
console.log(data)
let params = {}
if (data.pid === 0) {
params = {
'deptsId': null,
'deptsName': null
}
} else {
params = {
'deptsId': data.id,
'deptsName': data.deptsName
}
}
this.getUserList(params)
},
resetCheckedState() {
//
this.userListWithCheck = this.userList.map(user => {
return { ...user, checked: false }
})
},
updateCheckedState() {
this.userListWithCheck.forEach(user => {
user.checked = this.selectedItems.some(selectedUser => selectedUser.userId === user.userId)
})
},
getUserList(params) {
FetchInitUserList(params).then(res => {
const newArr = res.content.map(item => {
const json = {}
json.userId = item.userId
json.username = item.username
return json
})
this.userList = newArr
this.resetCheckedState()
})
},
handleChange(user) {
if (user.checked) {
this.selectedItems.push(user)
} else {
const index = this.selectedItems.findIndex(selectedUser => selectedUser.userId === user.userId)
if (index > -1) {
this.selectedItems.splice(index, 1)
}
}
},
handleClose() {
this.sendObjVisible = false
},
handleDelt(tag) {
this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1)
this.selectedItems.splice(this.selectedItems.indexOf(tag), 1)
},
clearSelectAll() {
this.selectedItems = []
},
handleSaveSelectObj() {
this.$emit('selectObjItem', this.selectObjForm.sendObj, this.selectedItems)
this.sendObjVisible = false
}
}
}

Loading…
Cancel
Save