浏览代码

使用了day.js第三方包,卡片评论功能初步完成

Lljy-ai 4 年之前
父节点
当前提交
9db9fe76e9

+ 11 - 9
fhKeeper/formulahousekeeper/timesheet/config/index.js

@@ -1,14 +1,16 @@
 var path = require('path')
 
-var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
-for (var i in ifaces) {
-    for (var j in ifaces[i]) {
-        var val = ifaces[i][j]
-        if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
-            ip = val.address
-        }
-    }
-}
+var ip = '192.168.2.2'
+
+// var os = require('os'), ip = '', ifaces = os.networkInterfaces() // 获取本机ip
+// for (var i in ifaces) {
+//     for (var j in ifaces[i]) {
+//         var val = ifaces[i][j]
+//         if (val.family === 'IPv4' && val.address !== '127.0.0.1') {
+//             ip = val.address
+//         }
+//     }
+// }
 
 module.exports = {
   build: {

文件差异内容过多而无法显示
+ 342 - 203
fhKeeper/formulahousekeeper/timesheet/package-lock.json


+ 3 - 1
fhKeeper/formulahousekeeper/timesheet/package.json

@@ -12,6 +12,7 @@
   "dependencies": {
     "@tinymce/tinymce-vue": "^4.0.0",
     "axios": "^0.15.3",
+    "dayjs": "^1.10.4",
     "echarts": "^3.8.5",
     "element-ui": "^2.13.0",
     "font-awesome": "^4.7.0",
@@ -21,6 +22,7 @@
     "vue": "^2.6.10",
     "vue-clipboard2": "^0.3.0",
     "vue-pdf": "^4.2.0",
+    "vue-quill-editor": "^3.0.6",
     "vue-router": "^2.3.0",
     "vuedraggable": "^2.24.3",
     "vuex": "^2.0.0-rc.6"
@@ -50,7 +52,7 @@
     "http-proxy-middleware": "^0.17.3",
     "json-loader": "^0.5.4",
     "mockjs": "^1.0.1-beta3",
-    "node-sass": "^4.5.0",
+    "node-sass": "^4.14.1",
     "opn": "^4.0.2",
     "optimize-css-assets-webpack-plugin": "^1.3.0",
     "ora": "^1.0.0",

+ 19 - 0
fhKeeper/formulahousekeeper/timesheet/src/day.js

@@ -0,0 +1,19 @@
+import dayjs from 'dayjs'
+
+// 加载中文语言包
+import 'dayjs/locale/zh-cn'
+
+import relativeTime from 'dayjs/plugin/relativeTime'
+
+// 配置使用处理相对时间的插件
+dayjs.extend(relativeTime)
+
+// 配置使用中文语言包
+dayjs.locale('zh-cn')
+
+console.log(dayjs().format('YYYY-MM-DD'));
+
+// 全局过滤器:处理相对时间
+Vue.filter('relativeTime', value => {
+  return dayjs().to(dayjs(value))
+})

+ 10 - 1
fhKeeper/formulahousekeeper/timesheet/src/main.js

@@ -18,12 +18,21 @@ import http from './http'
 import port from './port'
 import $ from 'jquery'
 
+// 导入富文本编辑器
+import VueQuillEditor from 'vue-quill-editor'
+// 导入富文本编辑器的对应的样式
+import 'quill/dist/quill.core.css'
+import 'quill/dist/quill.snow.css'
+import 'quill/dist/quill.bubble.css'
+
+import './day.js' // 加载 dayjs 初始化配置
+
 Vue.prototype.http = http
 Vue.prototype.port = port
 Vue.prototype.echarts = echarts
 
 import VueClipboard from 'vue-clipboard2'
-Vue.use(VueClipboard)
+Vue.use(VueClipboard, VueQuillEditor)
 // collapse 展开折叠
 import CollapseTransition from 'element-ui/lib/transitions/collapse-transition';
 Vue.component(CollapseTransition.name, CollapseTransition)

+ 239 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/project/projectInside.vue

@@ -212,8 +212,12 @@
             <el-tab-pane label="数据统计" name="summary"><Summary ref="summary"></Summary></el-tab-pane>
             
         </el-tabs>
+        <!-- 发布评论弹出层 -->
+
+        <!-- /发布评论弹出层 -->
+
         <!--新增任务界面-->
-        <el-dialog :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="800px">
+        <el-dialog class="jm" :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="800px">
             <el-form ref="form1" :model="addForm" :rules="taskRules" label-width="100px">
                 <!--子任务需要选择任务列表 -->
                 <el-form-item label="任务列表" prop="stages" v-if="addForm.parentTid != null">
@@ -248,10 +252,13 @@
                         <el-option v-for="item in importanceList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                     </el-select>
                 </el-form-item>
+                <!-- 富文本 -->
                 <el-form-item label="详细描述" >
                     <!-- <Editor id="tinymce" v-model="tinymceHtml" :init="editorInit"></Editor> -->
-                    <el-input type="textarea" v-model="addForm.taskDesc" :rows="3"></el-input>
+                    <!-- <el-input type="textarea" v-model="addForm.taskDesc" :rows="3"></el-input> -->
+                    <quill-edito v-model="addForm.taskDesc"></quill-edito>
                 </el-form-item>
+                <!-- 富文本 -->
                 <div v-if="addForm.id != null">
                     <el-divider ></el-divider>
                     <p ><i class="iconfont firerock-icontree" style="color:#20A0ff;margin-left:10px;">子任务</i>
@@ -294,6 +301,45 @@
                 <!-- <el-link @click="backToParentTask"><i class="el-icon-arrow-left single_line">返回父级任务</i> | {{addForm.parentTname}}</el-link> -->
                 <el-page-header  @back="backToParentTask" title="返回父任务" :content="addForm.parentTname"></el-page-header>
             </div>
+            <!-- 评论 -->
+            <div class="remark">
+                <div class="player">
+                    <p>评论</p>
+                    <div class="bj">
+                        <el-image style="width: 50px; height: 50px" :src="url" :fit="fit"></el-image>
+                    </div>
+                </div>
+                <div class="subject">
+                    <div class="sub-all">所有动态</div>
+                    <div class="sub-details" ref="main">
+                        <ul class="infinite-list" v-infinite-scroll="load" style="overflow:auto" ref="contRoll">
+                            <li v-for="i in count" class="infinite-list-item counli" :key="i">
+                                <p><i class="el-icon-s-fold"></i> <em>屈经理完成了依赖任务</em><span>4月20日</span></p>
+                            </li>
+                            <li class="carts" v-for="item in commentList" :key="item.id">
+                                <el-image style="width: 30px; height: 30px" :src="url" :fit="fit"></el-image>
+                                <div>
+                                    <p>{{item.userName}}</p>
+                                    <em>{{item.content}}</em>
+                                </div>
+                                <span>{{item.createTime | relativeTime}}</span>
+                            </li>
+                        </ul>
+                    </div>
+                </div>
+                <div class="issue">
+                    <!-- <el-input type="textarea" class="textareays" label-width="100%" label-height="140px"></el-input> -->
+                    <el-input
+                    class="issue-input"
+                    type="textarea"
+                    placeholder="请输入内容"
+                    :autosize="{ minRows: 5, maxRows: 6}"
+                    v-model.trim="textarea2">
+                    </el-input>
+                    <el-button class="issue-button" type="primary" @click="release()">发布</el-button>
+                </div>
+            </div>
+            <!-- 评论 -->
         </el-dialog>
         <!-- 子任务列表 -->
         <el-dialog title="查看子任务" v-if="subTaskVisible" :visible.sync="subTaskVisible" :close-on-click-modal="false" customClass="customWidth" width="800px">
@@ -496,9 +542,19 @@ toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor backc
                 sleectId: null,
                 sleectProjectId: null,
                 sidebarIndex: null, // 侧边栏索引
+                url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
+                count: 0,
+                textarea2: '',
+                taskId: null,
+                commentList: []
             };
         },
         methods: {
+             load () {
+                 if(this.count >= 6) return
+                this.count += 2
+            },
+
             // 侧边栏的点击事件
             retract() {
                 if (this.$refs.box.className == 'el-icon-arrow-left') {
@@ -822,12 +878,74 @@ toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor backc
                             });
                         });
             },
+            // 点击卡片事件
             editTask(task) {
+                console.log(task);
                 // this.addForm = JSON.parse(JSON.stringify(task));
                 this.addFormVisible = true;
                 this.addLoading = false;
                 this.title = "编辑任务";
                 this.getTaskDetail(task.id);
+                this.gain(task); // 获取评论列表
+            },
+            // 获取评论列表
+            gain (task) {
+                // this.http.get('/task-comment/getList', {params: {task: task.id}}),
+                // this.http.get('/task-comment/getList', task.id),
+                // this.http.get('/task-comment/getList', {task: task.id}),
+                this.taskId = task.id
+                this.http.post('/task-comment/getList', {taskId: task.id},
+                res => {
+                    if (res.code == "ok") {
+                        this.commentList = res.data
+                        // this.commentList.reverse()
+                    } else {
+                        this.$message({
+                        message: res.msg,
+                        type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                });
+            },
+            // 点击发布
+            release() {
+                if(this.textarea2.length <= 0) return this.$message({message: "请输入内容", type: "error"})
+                // console.log(this.taskId);
+                this.http.post('/task-comment/add', {taskId: this.taskId, userId: this.user.id, content: this.textarea2},
+                res => {
+                    if(res.code == "ok"){
+                        this.commentList.push(res.data)
+                        // this.commentList.reverse()
+                        this.textarea2 = ""
+                        this.contRoll() // 滚动到底部
+                        // this.gain(this.taskId)
+
+                    } else {
+                        this.$message({
+                        message: res.msg,
+                        type: "error"
+                        });
+                    }
+                },
+                error => {
+                    this.$message({
+                        message: error,
+                        type: "error"
+                    });
+                })
+            },
+            // 滚动到底部
+            contRoll(){
+                console.log("滚动到底部");
+                this.$nextTick(() => {
+                    this.$refs.main.scrollTop = this.$refs.contRoll.scrollHeight;
+                })
             },
             getTaskDetail(id) {
                 this.http.post('/task/getTask',{id: id},
@@ -1566,4 +1684,123 @@ toolbar: 'bold italic underline strikethrough | fontsizeselect | forecolor backc
     padding-left: 10px;
     padding-right: 5px;
 }
+
+/* 评论部分 */
+.remark {
+    width: 500px;
+    height: 100%;
+    background: #fff;
+    position: absolute;
+    top: 0;
+    right: -500px;
+    border-left: 3px solid #dddddd;
+}
+.jm {
+    margin-left: -500px;
+}
+
+.bj {
+    float: left;
+    width: 90%;
+    overflow: hidden;
+    height: 50px;
+    white-space: nowrap;
+    text-overflow: ellipsis;
+}
+.player {
+    height: 15%;
+    box-sizing: border-box;
+    padding-left: 15px;
+    border-bottom: 1px solid #dddddd;
+}
+.player p {
+    margin: 0;
+    padding: 2% 0;
+    font-size: 18px;
+} 
+.player .el-image {
+    border-radius: 50%;
+    margin-right: 10px;
+}
+.subject {
+    height: 60%;
+    box-sizing: border-box;
+}
+.sub-all {
+    font-size: 20px;
+    padding: 15px 0 15px 15px;
+}
+.sub-details {
+    width: 100%;
+    height: 87%;
+    padding-right: 15px;
+    box-sizing: border-box;
+    overflow: hidden;
+    overflow-y: scroll
+}
+.sub-details li {
+    list-style:none
+} 
+
+</style>
+<style lang="scss" scoped>
+.counli {
+    em {
+        font-style: normal;
+        display: inline-block;
+        margin-left: 9%;
+    }
+    span {
+        float: right;
+    }
+}
+.carts {
+    position: relative;
+    .el-image{
+        border-radius: 50%;
+        float: left;
+        width: 20%;
+    }
+    div {
+        text-align: left;
+        p {
+            text-align: left;
+            margin-left: 10px;
+            margin-left: 13%;
+        }
+        em {
+            display: block;
+            font-style: normal;
+            margin-left: 13%;
+        }
+    }
+    span {
+        font-size: 10px;
+        float: right;
+        margin-top: -40px;
+    }
+}
+.issue {
+    height: 20%;
+    position: relative;
+    .textareays {
+        background: #000;
+        height: 140px;
+        border: 0;
+        .el-textarea__inner {
+            height: 85%;
+        }
+    }
+    .issue-button {
+        // position: fixd;
+        // bottom: 0px;
+        float: right;
+    }
+}
+.issue-input {
+        // height: 140px;
+       /deep/ .el-textarea__inner {
+            border: 0;
+        }
+    }
 </style>