| | |
| | | </el-form-item> |
| | | <!-- 消息内容 --> |
| | | <el-form-item class="optionItem" label="消息内容:" prop="body"> |
| | | <MyEditor ref="edit" @getMyBody="getMyBody" :mybody='role.body'></MyEditor> |
| | | <!-- <el-input type="textarea" v-model="role.description" placeholder="请输入描述内容200字以内"></el-input> --> |
| | | <MyEditor ref="edit" @getMyBody="getMyBody"></MyEditor> |
| | | </el-form-item> |
| | | <!-- 提醒方式 --> |
| | | <el-form-item class="optionItem" label="提醒方式:" prop="channelCode"> |
| | |
| | | import MyEditor from '@/components/edit' |
| | | import MyColumnAdd from '@/views/operate/message/mycontrol/createUser' |
| | | import MyColView from '../messageView' |
| | | import { sendMessage, updateMessage } from "@/api/operate/messageManagement"; |
| | | |
| | | export default { |
| | | components: { MyEditor, MyColumnAdd,MyColView }, |
| | | props: ['type', 'myDataRow'], |
| | | data() { |
| | | const validateNickname = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(new Error("请填写消息栏目")); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validatePass = (rule, value, callback) => { |
| | | if (!value) { |
| | | callback(); |
| | | } else { |
| | | callback(); |
| | | } |
| | | }; |
| | | const validateTruename = (rule, value, callback) => { |
| | | if (value.length !== 0) { |
| | | callback(); |
| | | } else { |
| | | callback(new Error('请选择接收对象')); |
| | | } |
| | | }; |
| | | return { |
| | | role: { |
| | | messageType: '', |
| | |
| | | }, |
| | | createRoleRules: { |
| | | messageType: [ |
| | | { required: true, trigger: "blur", validator: validateNickname }, |
| | | { required: true, trigger: ['blur', 'change'], message: '请输入消息栏目' }, |
| | | ], |
| | | head: [ |
| | | { required: false, trigger: "blur", validator: validatePass }, |
| | | { required: false, trigger: "blur" }, |
| | | ], |
| | | targetTo: [ |
| | | { required: false, trigger: "blur", validator: validateTruename }, |
| | | { required: false, trigger: "blur" }, |
| | | ], |
| | | }, |
| | | colList: [], |
| | |
| | | dialogView: false, |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'departName', |
| | | // disabled: function (data, node) { |
| | | // if (data.createTime) { |
| | | // return !data.leaf |
| | | // } |
| | | // } |
| | | label: 'departName' |
| | | }, |
| | | checkedList: [], |
| | | tempNameArr:[], |
| | | info:{}, |
| | | sendUser:"" |
| | | sendUser: '' |
| | | } |
| | | }, |
| | | created() { |
| | | this.setColumnList(); |
| | | this.setDepartList(); |
| | | this.getColumnList(); |
| | | this.getDepartList(); |
| | | this.getLoginUserInfo(); |
| | | if (this.type === 'update' && this.myDataRow) { |
| | | this.role = this.myDataRow; |
| | | console.log(this.role); |
| | | } |
| | | }, |
| | | methods: { |
| | | // 关闭弹窗 |
| | |
| | | done(); |
| | | }) |
| | | }, |
| | | // 设置栏目 |
| | | async setColumnList() { |
| | | this.colList = await this.getColumnList(); |
| | | }, |
| | | |
| | | // 获取栏目 |
| | | async getColumnList() { |
| | | let arr; |
| | | await this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/message_column/getAllColumn' |
| | | }) |
| | | .then(res => { |
| | | console.log(res); |
| | | arr = res.data; |
| | | this.colList = res.data; |
| | | }) |
| | | return arr; |
| | | }, |
| | | // 关闭弹窗 |
| | | closeDialog({ flag, index }) { |
| | | this.dialogCreate = flag; |
| | | if (index === 1) { |
| | | // 重新设置栏目 |
| | | this.setColumnList(); |
| | | this.getColumnList(); |
| | | } |
| | | }, |
| | | |
| | | // 获取部门树 |
| | | async getDepartList() { |
| | | let arr |
| | | await this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/depart/tree' |
| | | }) |
| | | .then(res => { |
| | | arr = res.data |
| | | res.data.forEach(item => { |
| | | this.departList.push(this.setChildren(item)); |
| | | }); |
| | | }) |
| | | return arr; |
| | | }, |
| | | // 设置部门树 |
| | | async setDepartList() { |
| | | this.departList = await this.filterDepartList(); |
| | | }, |
| | | // 处理部门树 |
| | | async filterDepartList() { |
| | | let arr = await this.getDepartList(); |
| | | const { setChildren } = this; |
| | | // console.log(setChildren); |
| | | arr.forEach(item => { |
| | | setChildren(item); |
| | | }) |
| | | return arr; |
| | | }, |
| | | |
| | | // 递归children |
| | | setChildren(obj) { |
| | | if (obj.children !== null) { |
| | |
| | | }) |
| | | } |
| | | } |
| | | return obj; |
| | | }, |
| | | |
| | | // 选中id |
| | | handleCheck(data, node) { |
| | | let arr = [],nameArr = [] |
| | | console.log(node.checkedNodes) |
| | | node.checkedNodes.forEach(item => { |
| | | if(!item.hasOwnProperty('departType')){ |
| | | arr.push(item.id) |
| | | nameArr.push(item.departName) |
| | | this.checkedList.push(item.id) |
| | | this.tempNameArr.push(item.departName) |
| | | } |
| | | }) |
| | | this.checkedList = arr |
| | | this.tempNameArr = nameArr |
| | | console.log(this.tempNameArr) |
| | | this.role.targetTo = arr.length + '人' |
| | | this.role.targetTo = this.checkedList.length + '人' |
| | | }, |
| | | |
| | | // 新建/保存消息(1:新建,0保存消息) |
| | | handleSubmit(mystatus) { |
| | | console.log(mystatus); |
| | | if(mystatus===0){ |
| | | this.updateMessage(mystatus); |
| | | }else{ |
| | | this.newsMessage(mystatus); |
| | | } |
| | | }, |
| | | //修改消息 |
| | | updateMessage(mystatus){ |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { role, checkedList } = this; |
| | | console.log(checkedList); |
| | | this.$axios({ |
| | | method: 'post', |
| | | url: `sccg/message/update/${this.role.id}`, |
| | | data: { |
| | | body: role.body, |
| | | channelCode: `${role.channelCode}`, |
| | | head: role.head, |
| | | messageType: role.messageType, |
| | | const { body, head, messageType, targetFrom, channelCode } = this.role; |
| | | const params = { |
| | | body, |
| | | head, |
| | | messageType, |
| | | channelCode: `${channelCode}`, |
| | | sendTime: new Date(), |
| | | targetTo: checkedList.join(','), |
| | | targetFrom: `${role.targetFrom}`, |
| | | targetTo: this.checkedList.join(','), |
| | | targetFrom: `${targetFrom}`, |
| | | status: mystatus, |
| | | } |
| | | if (this.type === 'create') { |
| | | sendMessage(params) |
| | | .then(() => { |
| | | this.$emit('closeMyDialog'); |
| | | this.$message({ type: 'success', message: '操作成功' }); |
| | | }) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: mystatus === 1 ? '发布成功' : '保存成功', |
| | | }) |
| | | this.$emit('closeMyDialog', { flag: false, index: 1 }); |
| | | } |
| | | }) |
| | | .catch(err => this.$message({ type: 'error', message: err })); |
| | | } else { |
| | | return false; |
| | | updateMessage(params) |
| | | .then(() => { |
| | | this.$emit('closeMyDialog'); |
| | | this.$message({ type: 'success', message: '操作成功' }); |
| | | }) |
| | | .catch(err => this.$message({ type: 'error', message: err })); |
| | | } |
| | | } else { |
| | | this.$message.error({ type: 'warning', message: '请检查必填项' }); |
| | | } |
| | | }) |
| | | }, |
| | | //发布消息 |
| | | newsMessage(mystatus){ |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { role, checkedList } = this; |
| | | console.log(checkedList); |
| | | this.$axios({ |
| | | method: 'post', |
| | | url: 'sccg/message/sendMessage', |
| | | data: { |
| | | id:role.id, |
| | | body: role.body, |
| | | channelCode: `${role.channelCode}`, |
| | | head: role.head, |
| | | messageType: role.messageType, |
| | | sendTime: new Date(), |
| | | targetTo: checkedList.join(','), |
| | | targetFrom: `${role.targetFrom}`, |
| | | status: mystatus, |
| | | } |
| | | }) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | this.$message({ |
| | | type: 'success', |
| | | message: mystatus === 1 ? '发布成功' : '保存成功', |
| | | }) |
| | | this.$emit('closeMyDialog', { flag: false, index: 1 }); |
| | | } |
| | | }) |
| | | } else { |
| | | return false; |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 获得消息体 |
| | | getMyBody(obj) { |
| | | console.log(obj); |
| | | this.role.body = obj; |
| | | }, |
| | | |
| | | // 重置表单 |
| | | handleReset() { |
| | | this.$refs.edit.editor.txt.clear(); |
| | | // this.$refs.edit.wangEditor.txt.html('<p><br></p>') |
| | | this.setDepartList(); |
| | | this.$refs.user.resetFields(); |
| | | }, |
| | | |
| | | // 获取当前登录用户信息 |
| | | getLoginUserInfo() { |
| | | const name = sessionStorage.getItem('name'); |
| | |
| | | this.sendUser = res.data.username |
| | | }) |
| | | }, |
| | | |
| | | // 消息预览 |
| | | handleView() { |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { role,getColText,tempNameArr,sendUser } = this |
| | | const { body, head, channelCode } = this.role; |
| | | this.dialogView = true; |
| | | let info = {} |
| | | // 获得栏目消息 |
| | | info.channelCode = role.channelCode === '01'? '站内信': role.channelCode === '02' ? '邮件':'短信' |
| | | info.messageType = getColText(role.messageType) |
| | | info.body = role.body |
| | | info.head = role.head |
| | | info.targetTo = tempNameArr |
| | | info.targetFrom = sendUser |
| | | this.info = info |
| | | this.info = { |
| | | body, |
| | | head, |
| | | channelCode: channelCode === '01'? '站内信': channelCode === '02' ? '邮件':'短信', |
| | | messageType: this.getColText(this.role.messageType), |
| | | targetTo: this.tempNameArr, |
| | | targetFrom: this.sendUser |
| | | } |
| | | } else { |
| | | return false |
| | | this.$message({ type: 'warning', message: '请检查必填项' }); |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 获得栏目消息 |
| | | getColText(id){ |
| | | console.log(id) |
| | | const {colList} = this |
| | | let str = '' |
| | | colList.forEach(item=>{ |
| | | this.colList.forEach(item=>{ |
| | | item.id === id ? str = item.columnName : '' |
| | | }) |
| | | return str |
| | | return str; |
| | | } |
| | | }, |
| | | props: ['closeMyDialog','myDataRow'] |
| | | } |
| | | </script> |
| | | <style lang="scss" scoped> |
| | |
| | | text-align: left; |
| | | padding: 0 55px; |
| | | background-color: #09152f; |
| | | padding-bottom: 50px; |
| | | |
| | | .mainContent { |
| | | display: flex; |