From 8182715ad404d1f985fd289d176d893c663f772e Mon Sep 17 00:00:00 2001
From: mg <maokecheng@163.com>
Date: 星期一, 24 十月 2022 18:14:38 +0800
Subject: [PATCH] 联调消息分页查询条件,添加消息编辑页面。

---
 src/views/operate/message/myIndex/update/index.vue |  364 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 310 insertions(+), 54 deletions(-)

diff --git a/src/views/operate/message/myIndex/update/index.vue b/src/views/operate/message/myIndex/update/index.vue
index 76bddbc..2c25012 100644
--- a/src/views/operate/message/myIndex/update/index.vue
+++ b/src/views/operate/message/myIndex/update/index.vue
@@ -4,109 +4,331 @@
             <div class="mainContent">
                 <el-form ref="user" label-width="140px" autoComplete="on" :model="role" :rules="createRoleRules"
                     label-position="right">
-                    <!-- 鏍忕洰鍚嶇О -->
-                    <el-form-item class="optionItem" label="鏍忕洰鍚嶇О:" prop="name">
-                        <el-input v-model="role.name" placeholder="璇峰~鍐欐爮鐩悕绉�"></el-input>
+                    <!-- 娑堟伅鏍忕洰 -->
+                    <el-form-item 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-option>
+                                </el-select>
+                            </div>
+                            <span class="message-add" @click='dialogCreate = true'> 娣诲姞鏍忕洰</span>
+                        </div>
                     </el-form-item>
-                    <!-- 瑙掕壊鎻忚堪 -->
-                    <el-form-item class="optionItem" label="瑙掕壊鎻忚堪:" prop="description">
-                        <el-input type="textarea" :rows="5" maxlength="300" show-word-limit v-model="role.description"
-                            placeholder="璇疯緭鍏ユ弿杩板唴瀹�200瀛椾互鍐�"></el-input>
+                    <!-- 娑堟伅鏍囬 -->
+                    <el-form-item class="optionItems" label="娑堟伅鏍囬:" prop="head">
+                        <div class="message-item__left">
+                            <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-option :value="role.targetTo">
+                                    <el-tree ref="tree" :data="departList" :props="defaultProps" show-checkbox
+                                        @check="handleCheck" default-expand-all node-key="id">
+                                    </el-tree>
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </el-form-item>
+                    <!-- 娑堟伅鍐呭 -->
+                    <el-form-item class="optionItem" label="娑堟伅鍐呭:" prop="body">
+                        <MyEditor ref="edit" @getMyBody="getMyBody"></MyEditor>
+                        <!-- <el-input type="textarea" v-model="role.description" placeholder="璇疯緭鍏ユ弿杩板唴瀹�200瀛椾互鍐�"></el-input> -->
+                    </el-form-item>
+                    <!-- 鎻愰啋鏂瑰紡 -->
+                    <el-form-item class="optionItem" label="鎻愰啋鏂瑰紡:" prop="channelCode">
+                        <el-radio-group v-model="role.channelCode">
+                            <el-radio label="01">绔欏唴淇�</el-radio>
+                            <el-radio label="02">閭欢</el-radio>
+                            <el-radio label="03">鐭俊</el-radio>
+                        </el-radio-group>
+                        <span class="message-tip">(鐭俊鍙敤鏁�: 1000鏉�)</span>
                     </el-form-item>
                     <el-form-item>
                         <div class="optionBtn">
-                            <el-button class="btn cancel" @click.native.prevent="handleCancel">鍙栨秷</el-button>
-                            <el-button type="primary" class="btn submit" @click.native.prevent="handleUser">纭畾
+                            <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>
+                            <el-button type="primary" @click.native.prevent="handleView" class="btn submit">棰勮
+                            </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>
+                    <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>
             </div>
         </main>
     </div>
 </template>
 <script>
+import MyEditor from '@/components/edit'
+import MyColumnAdd from '@/views/operate/message/mycontrol/createUser'
+import MyColView from '../messageView'
 export default {
+    components: { MyEditor, MyColumnAdd,MyColView },
     data() {
         const validateNickname = (rule, value, callback) => {
             if (!value) {
-                callback(new Error("璇峰~鍐欐爮鐩悕绉�"));
+                callback(new Error("璇峰~鍐欐秷鎭爮鐩�"));
+            } else {
+                callback();
+            }
+        };
+        const validatePass = (rule, value, callback) => {
+            if (!value) {
+                callback();
             } else {
                 callback();
             }
         };
         const validateTruename = (rule, value, callback) => {
-            if (value) {
+            if (value.length !== 0) {
                 callback();
             } else {
-                // const rep = /^[\u4E00-\u9FA5]{2,4}$/;
-                // if (!rep.test(value)) {
-                //     callback("璇疯緭鍏ユ纭殑鐢ㄦ埛濮撳悕");
-                // }
-                callback();
+                callback(new Error('璇烽�夋嫨鎺ユ敹瀵硅薄'));
             }
         };
         return {
             role: {
-                name: '',
-                description: '',
+                messageType: '',
+                head: '',
+                targetTo: '',
+                targetFrom: null,
+                body: '',
+                channelCode: '01',
             },
             createRoleRules: {
-                name: [
+                messageType: [
                     { required: true, trigger: "blur", validator: validateNickname },
                 ],
-                description: [
+                head: [
+                    { required: false, trigger: "blur", validator: validatePass },
+                ],
+                targetTo: [
                     { required: false, trigger: "blur", validator: validateTruename },
                 ],
             },
+            colList: [],
+            departList: [],
             typeList: [],
+            dialogCreate: false,
+            dialogView: false,
+            defaultProps: {
+                children: 'children',
+                label: 'departName',
+                // disabled: function (data, node) {
+                //     if (data.createTime) {
+                //         return !data.leaf
+                //     }
+                // }
+            },
+            checkedList: [],
+            tempNameArr:[],
+            info:{},
+            sendUser:""
         }
     },
     created() {
+        this.setColumnList();
+        this.setDepartList();
+        this.getLoginUserInfo();
     },
     methods: {
-        handleUser() {
-            this.$refs['user'].validate((valid) => {
-                console.log(valid);
+        // 鍏抽棴寮圭獥
+        handleConfirmClose(done) {
+            this.$confirm('纭鍏抽棴?')
+                .then(_ => {
+                    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;
+                })
+            return arr;
+        },
+        // 鍏抽棴寮圭獥
+        closeDialog({ flag, index }) {
+            this.dialogCreate = flag;
+            if (index === 1) {
+                // 閲嶆柊璁剧疆鏍忕洰
+                this.setColumnList();
+            }
+        },
+        // 鑾峰彇閮ㄩ棬鏍�
+        async getDepartList() {
+            let arr
+            await this.$axios({
+                method: 'get',
+                url: 'sccg/depart/tree'
+            })
+                .then(res => {
+                    arr = res.data
+                })
+            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) {
+                if (obj.children.length !== 0) {
+                    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 })
+                    })
+                }
+            }
+        },
+        // 閫変腑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 = arr
+            this.tempNameArr = nameArr
+            console.log(this.tempNameArr)
+            this.role.targetTo = arr.length + '浜�'
+        },
+        // 鏂板缓/淇濆瓨娑堟伅(1:鏂板缓,0淇濆瓨娑堟伅)
+        handleSubmit(mystatus) {
+            this.$refs.user.validate((valid) => {
                 if (valid) {
-                    const { role } = this;
-                    console.log(role);
+                    const { role, checkedList } = this;
+                    console.log(checkedList);
                     this.$axios({
                         method: 'post',
-                        url: 'sccg/message_column/addColumn',
+                        url: 'sccg/message/sendMessage',
                         data: {
-                            columnName: role.name,
-                            createUser: 3,
-                            description: role.description,
-                            isShow: 0,
+                            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:'娣诲姞鎴愬姛'
-                            })
-                            this.$emit('closeDialog',{flag:false,index:1});
-                        }else{
-                            this.$message({
-                                type:'error',
-                                message:res.message
-                            })
-                        }
-                    })
+                        .then(res => {
+                            if (res.code === 200) {
+                                this.$message({
+                                    type: 'success',
+                                    message: mystatus === 1 ? '鍙戦�佹垚鍔�' : '淇濆瓨鎴愬姛',
+                                })
+                                this.$emit('closeMyDialog', { flag: false, index: 1 });
+                            }
+                        })
                 } else {
                     return false;
                 }
             })
         },
-        // 鍏抽棴寮圭獥
-        handleCancel(){
-            this.$emit('closeDialog',{flag:false,index:0});
+        // 鑾峰緱娑堟伅浣�
+        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.$axios({
+                method: 'get',
+                url: 'sccg/admin/info?name=' + name,
+            })
+                .then(res => {
+                    this.role.targetFrom = res.data.userId
+                    this.sendUser = res.data.username
+                })
+        },
+        // 娑堟伅棰勮
+        handleView() {
+            this.$refs.user.validate((valid) => {
+                if (valid) {
+                    const { role,getColText,tempNameArr,sendUser } = this
+                    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
+                } else {
+                    return false
+                }
+            })
+        },
+        // 鑾峰緱鏍忕洰娑堟伅
+        getColText(id){
+            console.log(id)
+            const {colList} = this
+            let str = ''
+            colList.forEach(item=>{
+                item.id === id ? str = item.columnName : '' 
+            })
+            return str
         }
     },
-    props: ['closeDialog']
+    props: ['closeMyDialog']
 }
 </script>
 <style lang="scss" scoped>
@@ -124,23 +346,57 @@
             display: flex;
             justify-content: center;
             padding-top: 50px;
-
+            &:deep(.el-dialog__title) {
+                color: #4b9bb7;
+            }
             &::v-deep .el-form-item__label {
                 color: #4b9bb7;
             }
 
             &::v-deep .el-input__inner {
+                width: 400px;
                 background-color: #09152f;
                 border: 1px solid #17324c;
+            }
+
+            .message-item__left {
+                width: 400px;
+            }
+
+            .message-add {
+                &:hover {
+                    cursor: pointer;
+                }
+            }
+
+            .el-form-item__content :deep(.el-select) {
+                width: 400px;
+            }
+
+            :deep(.el-input) {
+                width: 400px;
+            }
+
+            .message-item {
+                display: flex;
+
+                span {
+                    margin-left: 20px;
+                    color: #4b9bb7;
+                }
+            }
+
+            .message-tip {
+                margin-left: 20px;
+            }
+
+            :deep(.el-input--suffix) {
+                width: 400px;
             }
 
             &::v-deep .el-textarea__inner {
                 background-color: #09152f;
                 border: 1px solid #17324c;
-            }
-
-            :deep(.el-input__count) {
-                background-color: #09152f;
             }
 
             .el-form-item__content {

--
Gitblit v1.8.0