| | |
| | | <div class="createUser"> |
| | | <main> |
| | | <div class="mainContent"> |
| | | <el-form ref="user" label-width="140px" autoComplete="on" :model="role" :rules="createRoleRules" |
| | | label-position="right"> |
| | | <el-form |
| | | ref="user" |
| | | label-width="140px" |
| | | autoComplete="on" |
| | | :model="role" |
| | | :rules="createRoleRules" |
| | | label-position="right" |
| | | > |
| | | <!-- 提醒方式 --> |
| | | <el-form-item class="optionItem" label="提醒方式:" prop="channelCode"> |
| | | <el-radio-group v-model="role.channelCode"> |
| | |
| | | <span class="message-tip">(短信可用数: 1000条)</span> |
| | | </el-form-item> |
| | | <!-- 消息栏目 --> |
| | | <el-form-item v-if="role.channelCode === '01'" class="optionItem" label="消息栏目:" prop="messageType"> |
| | | <el-form-item |
| | | v-if="role.channelCode === '01'" |
| | | class="optionItem" |
| | | label="消息栏目:" |
| | | prop="messageType" |
| | | > |
| | | <div class="message-item"> |
| | | <div class="message-item__left"> |
| | | <el-select v-model="role.messageType" placeholder="请选择消息栏目"> |
| | | <el-option v-for="item in colList" :key="item.id" :label="item.columnName" |
| | | :value="item.id"> |
| | | <el-select |
| | | v-model="role.messageType" |
| | | placeholder="请选择消息栏目" |
| | | > |
| | | <el-option |
| | | v-for="item in colList" |
| | | :key="item.id" |
| | | :label="item.columnName" |
| | | :value="item.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | </div> |
| | | <span class="message-add" @click='dialogCreate = true'> 添加栏目</span> |
| | | <span class="message-add" @click="dialogCreate = true"> |
| | | 添加栏目</span |
| | | > |
| | | </div> |
| | | </el-form-item> |
| | | <!-- 消息标题 --> |
| | | <el-form-item class="optionItems" label="消息标题:" prop="head"> |
| | | <div class="message-item__left"> |
| | | <el-input v-model="role.head" placeholder="请选择消息标题"></el-input> |
| | | <el-input |
| | | v-model="role.head" |
| | | placeholder="请选择消息标题" |
| | | ></el-input> |
| | | </div> |
| | | </el-form-item> |
| | | <!-- 接收对象 --> |
| | | <el-form-item class="optionItem" label="接收对象:" prop="targetTo"> |
| | | <div class="message-item__left"> |
| | | <el-select v-model="role.targetTo" placeholder="请选择接收对象" > |
| | | <el-select v-model="role.targetTo" placeholder="请选择接收对象"> |
| | | <el-option :value="role.targetTo"> |
| | | <el-tree ref="tree" :data="departList" :props="defaultProps" show-checkbox |
| | | @check="handleCheck" default-expand-all node-key="id"> |
| | | <el-tree |
| | | ref="tree" |
| | | :data="departList" |
| | | :props="defaultProps" |
| | | show-checkbox |
| | | @check="handleCheck" |
| | | default-expand-all |
| | | node-key="id" |
| | | > |
| | | </el-tree> |
| | | </el-option> |
| | | </el-select> |
| | |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <div class="optionBtn"> |
| | | <el-button type="primary" @click.native.prevent="handleSubmit(0)" class="btn save">保存 |
| | | <el-button |
| | | type="primary" |
| | | @click.native.prevent="handleSubmit(0)" |
| | | class="btn save" |
| | | >保存 |
| | | </el-button> |
| | | <el-button type="primary" @click.native.prevent="handleSubmit(1)" class="btn submit">发布 |
| | | <el-button |
| | | type="primary" |
| | | @click.native.prevent="handleSubmit(1)" |
| | | class="btn submit" |
| | | >发布 |
| | | </el-button> |
| | | <el-button type="primary" @click.native.prevent="handleView" class="btn submit">预览 |
| | | <el-button |
| | | type="primary" |
| | | @click.native.prevent="handleView" |
| | | class="btn submit" |
| | | >预览 |
| | | </el-button> |
| | | <el-button class="btn cancel" @click.native.prevent="handleReset">重置</el-button> |
| | | <el-button class="btn cancel" @click.native.prevent="handleReset" |
| | | >重置</el-button |
| | | > |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <!-- 新增栏目 --> |
| | | <el-dialog title="添加栏目" :visible.sync="dialogCreate" v-if="dialogCreate" width="60%" |
| | | :before-close="handleConfirmClose" append-to-body> |
| | | <el-dialog |
| | | title="添加栏目" |
| | | :visible.sync="dialogCreate" |
| | | v-if="dialogCreate" |
| | | width="60%" |
| | | :before-close="handleConfirmClose" |
| | | append-to-body |
| | | > |
| | | <MyColumnAdd @closeDialog="closeDialog"></MyColumnAdd> |
| | | </el-dialog> |
| | | <!-- 预览消息 --> |
| | | <el-dialog title="消息预览" :visible.sync="dialogView" v-if="dialogView" width="60%" |
| | | :before-close="handleConfirmClose" append-to-body> |
| | | <MyColView :info="info" @closeDialog="closeDialog"></MyColView> |
| | | <el-dialog |
| | | title="消息预览" |
| | | :visible.sync="dialogView" |
| | | v-if="dialogView" |
| | | width="60%" |
| | | :before-close="handleConfirmClose" |
| | | append-to-body |
| | | > |
| | | <MyColView :info="info" @closeDialog="closeDialog"></MyColView> |
| | | </el-dialog> |
| | | </div> |
| | | </main> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import MyEditor from '@/components/edit' |
| | | import MyColumnAdd from '@/views/operate/message/mycontrol/createUser' |
| | | import MyColView from '../messageView' |
| | | 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'], |
| | | props: ["type", "myDataRow"], |
| | | data() { |
| | | return { |
| | | role: { |
| | | messageType: '', |
| | | head: '', |
| | | targetTo: '', |
| | | messageType: "", |
| | | head: "", |
| | | targetTo: "", |
| | | targetFrom: null, |
| | | body: '', |
| | | channelCode: '01', |
| | | body: "", |
| | | channelCode: "01", |
| | | }, |
| | | createRoleRules: { |
| | | messageType: [ |
| | | { required: true, trigger: ['blur', 'change'], message: '请输入消息栏目' }, |
| | | { |
| | | required: true, |
| | | trigger: ["blur", "change"], |
| | | message: "请输入消息栏目", |
| | | }, |
| | | ], |
| | | head: [ |
| | | { required: true, trigger: "blur", message: '请选择消息标题'} |
| | | ], |
| | | head: [{ required: true, trigger: "blur", message: "请选择消息标题" }], |
| | | targetTo: [ |
| | | { required: true, trigger: "blur", message: '请选择接受对象' }, |
| | | { required: true, trigger: "blur", message: "请选择接受对象" }, |
| | | ], |
| | | body: [ |
| | | { required: true, trigger: ['blue','change'], message: '请输入消息内容' } |
| | | ] |
| | | { |
| | | required: true, |
| | | trigger: ["blue", "change"], |
| | | message: "请输入消息内容", |
| | | }, |
| | | ], |
| | | }, |
| | | colList: [], |
| | | departList: [], |
| | |
| | | dialogCreate: false, |
| | | dialogView: false, |
| | | defaultProps: { |
| | | children: 'children', |
| | | label: 'departName' |
| | | children: "children", |
| | | label: "departName", |
| | | }, |
| | | checkedList: [], |
| | | tempNameArr: [], |
| | | info: {}, |
| | | sendUser: '' |
| | | } |
| | | sendUser: "", |
| | | }; |
| | | }, |
| | | created() { |
| | | this.getColumnList(); |
| | | this.getDepartList(); |
| | | this.getLoginUserInfo(); |
| | | if (this.type === 'update' && this.myDataRow) { |
| | | if (this.type === "update" && this.myDataRow) { |
| | | this.role = this.myDataRow; |
| | | } |
| | | }, |
| | | methods: { |
| | | // 关闭弹窗 |
| | | handleConfirmClose(done) { |
| | | this.$confirm('确认关闭?') |
| | | .then(_ => { |
| | | done(); |
| | | }) |
| | | this.$confirm("确认关闭?").then((_) => { |
| | | done(); |
| | | }); |
| | | }, |
| | | |
| | | // 获取栏目 |
| | | async getColumnList() { |
| | | await this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/message_column/getAllColumn' |
| | | }) |
| | | .then(res => { |
| | | this.colList = res.data; |
| | | }) |
| | | method: "get", |
| | | url: "sccg/message_column/getAllColumn", |
| | | }).then((res) => { |
| | | this.colList = res.data; |
| | | }); |
| | | }, |
| | | // 关闭弹窗 |
| | | closeDialog({ flag, index }) { |
| | |
| | | // 获取部门树 |
| | | async getDepartList() { |
| | | await this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/depart/tree' |
| | | }) |
| | | .then(res => { |
| | | res.data.forEach(item => { |
| | | this.departList.push(this.setChildren(item)); |
| | | }); |
| | | }) |
| | | method: "get", |
| | | url: "sccg/depart/tree", |
| | | }).then((res) => { |
| | | res.data.forEach((item) => { |
| | | this.departList.push(this.setChildren(item)); |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | // 递归children |
| | | setChildren(obj) { |
| | | if (obj.children !== null) { |
| | | if (obj.children.length !== 0) { |
| | | obj.children.forEach(item => { |
| | | obj.children.forEach((item) => { |
| | | return this.setChildren(item); |
| | | }) |
| | | }); |
| | | } |
| | | } else { |
| | | if (obj.userInfoDTOS.length !== 0) { |
| | | obj.children = []; |
| | | obj.userInfoDTOS.forEach(item => { |
| | | obj.children.push({ id: item.userId, departName: item.username }) |
| | | }) |
| | | obj.userInfoDTOS.forEach((item) => { |
| | | obj.children.push({ id: item.userId, departName: item.username }); |
| | | }); |
| | | } |
| | | } |
| | | return obj; |
| | |
| | | |
| | | // 选中id |
| | | handleCheck(data, node) { |
| | | node.checkedNodes.forEach(item => { |
| | | if(!item.hasOwnProperty('departType')){ |
| | | this.checkedList.push(item.id) |
| | | this.tempNameArr.push(item.departName) |
| | | node.checkedNodes.forEach((item) => { |
| | | if (!item.hasOwnProperty("departType")) { |
| | | this.checkedList.push(item.id); |
| | | this.tempNameArr.push(item.departName); |
| | | } |
| | | }) |
| | | this.role.targetTo = this.checkedList.length + '人' |
| | | }); |
| | | this.role.targetTo = this.checkedList.length + "人"; |
| | | }, |
| | | |
| | | // 新建/保存消息(1:新建,0保存消息) |
| | | handleSubmit(mystatus) { |
| | | this.$refs.user.validate((valid) => { |
| | | if (valid) { |
| | | const { body, head, messageType, targetFrom, channelCode } = this.role; |
| | | const { body, head, messageType, targetFrom, channelCode } = |
| | | this.role; |
| | | const params = { |
| | | body, |
| | | head, |
| | | messageType, |
| | | channelCode: `${channelCode}`, |
| | | sendTime: new Date(), |
| | | targetTo: this.checkedList.join(','), |
| | | targetTo: this.checkedList.join(","), |
| | | targetFrom: `${targetFrom}`, |
| | | status: mystatus, |
| | | } |
| | | if (this.type === 'create') { |
| | | }; |
| | | if (this.type === "create") { |
| | | sendMessage(params) |
| | | .then(() => { |
| | | this.$emit('closeMyDialog'); |
| | | this.$message({ type: 'success', message: '操作成功' }); |
| | | .then(() => { |
| | | this.$emit("closeMyDialog"); |
| | | this.$message({ type: "success", message: "操作成功" }); |
| | | }) |
| | | .catch((err) => |
| | | this.$message({ |
| | | type: "error", |
| | | message: err.data || err.message, |
| | | }) |
| | | .catch(err => this.$message({ type: 'error', message: err })); |
| | | ); |
| | | } else { |
| | | updateMessage(params) |
| | | .then(() => { |
| | | this.$emit('closeMyDialog'); |
| | | this.$message({ type: 'success', message: '操作成功' }); |
| | | .then(() => { |
| | | this.$emit("closeMyDialog"); |
| | | this.$message({ type: "success", message: "操作成功" }); |
| | | }) |
| | | .catch((err) => |
| | | this.$message({ |
| | | type: "error", |
| | | message: err.data || err.message, |
| | | }) |
| | | .catch(err => this.$message({ type: 'error', message: err })); |
| | | ); |
| | | } |
| | | } else { |
| | | this.$message.error({ type: 'warning', message: '请检查必填项' }); |
| | | this.$message.error({ type: "warning", message: "请检查必填项" }); |
| | | } |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | // 获得消息体 |
| | |
| | | |
| | | // 获取当前登录用户信息 |
| | | getLoginUserInfo() { |
| | | const name = sessionStorage.getItem('name'); |
| | | const name = sessionStorage.getItem("name"); |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: 'sccg/admin/info?name=' + name, |
| | | }) |
| | | .then(res => { |
| | | this.role.targetFrom = res.data.userId |
| | | this.sendUser = res.data.username |
| | | }) |
| | | method: "get", |
| | | url: "sccg/admin/info?name=" + name, |
| | | }).then((res) => { |
| | | this.role.targetFrom = res.data.userId; |
| | | this.sendUser = res.data.username; |
| | | }); |
| | | }, |
| | | |
| | | // 消息预览 |
| | |
| | | this.info = { |
| | | body, |
| | | head, |
| | | channelCode: channelCode === '01'? '站内信': channelCode === '02' ? '邮件':'短信', |
| | | channelCode: |
| | | channelCode === "01" |
| | | ? "站内信" |
| | | : channelCode === "02" |
| | | ? "邮件" |
| | | : "短信", |
| | | messageType: this.getColText(this.role.messageType), |
| | | targetTo: this.tempNameArr, |
| | | targetFrom: this.sendUser |
| | | } |
| | | targetFrom: this.sendUser, |
| | | }; |
| | | } else { |
| | | this.$message({ type: 'warning', message: '请检查必填项' }); |
| | | this.$message({ type: "warning", message: "请检查必填项" }); |
| | | } |
| | | }) |
| | | }); |
| | | }, |
| | | |
| | | // 获得栏目消息 |
| | | getColText(id){ |
| | | let str = '' |
| | | this.colList.forEach(item=>{ |
| | | item.id === id ? str = item.columnName : '' |
| | | }) |
| | | getColText(id) { |
| | | let str = ""; |
| | | this.colList.forEach((item) => { |
| | | item.id === id ? (str = item.columnName) : ""; |
| | | }); |
| | | return str; |
| | | } |
| | | }, |
| | | }, |
| | | } |
| | | }; |
| | | </script> |
| | | <style lang="scss" scoped> |
| | | .createUser { |
| | |
| | | padding: 12px 50px; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |