Pārlūkot izejas kodu

2022.10.11 移动端编辑任务

ggooalice 2 gadi atpakaļ
vecāks
revīzija
2534bf0130

+ 11 - 11
fhKeeper/formulahousekeeper/octopus/config/index.js

@@ -1,18 +1,18 @@
 var path = require('path')
 
 //  var ip = '127.0.0.1'
-// var ip = '192.168.2.13'
-// var ip = '47.100.37.243' 
+var ip = '192.168.2.4'
+// var ip = '47.101.180.183' 
 
-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 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: {

+ 12 - 12
fhKeeper/formulahousekeeper/timesheet/config/index.js

@@ -1,20 +1,20 @@
 var path = require('path')
 
 //  var ip = '127.0.0.1'
-// var ip = '47.101.180.183' 
+var ip = '47.101.180.183'
 // var ip = '192.168.10.6'
-// var ip = '192.168.2.39'
-
-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.6'
 
+// 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
+//         }
+//     }
+// }
+// 1196735749
 module.exports = {
   build: {
     env: require('./prod.env'),

+ 8 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/router/index.js

@@ -82,6 +82,14 @@ const router = new Router({
         },
         component: () => import("@/views/project/projectInside")
     },
+    {
+        path: "/editask",
+        name: "editask",
+        meta: {
+            title: "编辑任务"
+        },
+        component: () => import("@/views/task/editask")
+    },
     {
         path: "/search", 
         meta: {

+ 5 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/views/project/index.vue

@@ -47,7 +47,7 @@
                     <van-swipe-cell v-for="(item,index) in list" :key="index">
                         <van-cell :border="false" :title="item.projectName" :value="item.projectCode"/>
                         <template slot="right" v-if="projectManagement || item.creatorId == user.id">
-                            <van-button square type="primary" text="查看" :to="{name:'projectInside',params:{project:JSON.stringify(item)}}"/>
+                            <van-button square type="primary" text="查看" @click="toProjectInside(item)"/>
                             <van-button square type="info" text="编辑" @click="openDialog(index)"/>
                             <van-button square type="danger" text="删除" @click="delPro(index)"/>
                         </template>
@@ -162,6 +162,10 @@
         created() {
         },
         methods: {
+            toProjectInside(item){
+                sessionStorage.setItem('projectId',JSON.stringify(item.id))
+                this.$router.push("/projectInside");
+            },
             popoverSelect(action){
                 if(this.popoverType == action.type){
                     return

+ 57 - 7
fhKeeper/formulahousekeeper/timesheet_h5/src/views/project/projectInside.vue

@@ -2,7 +2,7 @@
     <div>
         <van-nav-bar title="项目详情" left-text="返回" @click-left="back" fixed left-arrow />
         <div class="content">
-            <van-cell><div style="width:100%;text-align:center;font-size:120%">{{project.projectName}}</div></van-cell>
+            <van-cell><div style="width:100%;text-align:center;font-size:120%">{{projectDetail.projectName ? projectDetail.projectName : '-'}}</div></van-cell>
             <van-tabs v-model="active" @change="activeChange">
                 <!-- 任务看板 -->
                 <van-tab title="任务看板">
@@ -30,6 +30,9 @@
                             </template>
                         </van-picker>
                     </van-popup>
+                    <van-cell value-class="addtaskvalue">
+                        <van-button plain type="info" class="addtaskbutton" @click="toEditask(null)">新建任务</van-button>
+                    </van-cell>
                     <div class="taskList">
                         <van-cell v-for="item in inside.taskList" :key="item.id">
                             <div style="line-height:0.8rem">任务名称:{{item.name}}</div>
@@ -37,6 +40,9 @@
                                 <span v-if="item.startDate && item.endDate">{{(item.startDate ? item.startDate : ' - ') + '\u3000至\u3000' + (item.endDate ? item.endDate : ' - ')}}</span>
                                 <span v-else></span>
                             </div>
+                            <div class="task_button">
+                                <van-button size="small" type="info" @click="toEditask(item.id)">编辑</van-button>
+                            </div>
                         </van-cell>
                     </div>
                 </van-tab>
@@ -130,7 +136,7 @@
                     <van-cell>
                         <van-row>
                             <van-col span="7">合同编号:</van-col>
-                            <van-col span="17">{{projectDetail.projectSeparate.contractCode}}</van-col>
+                            <van-col span="17">{{projectDetail.projectSeparate.contractCode ? projectDetail.projectSeparate.contractCode : '-'}}</van-col>
                         </van-row>
                     </van-cell>
                     <van-cell>
@@ -221,8 +227,8 @@ export default {
     data() {
         return {
             user: JSON.parse(localStorage.userInfo),
-            project: JSON.parse(this.$route.params.project),
-            projectDetail: {},
+            projectId: JSON.parse(sessionStorage.projectId),
+            projectDetail: null,
             
             active: 0,
             inside:{    // 任务看板
@@ -247,6 +253,7 @@ export default {
     },
     mounted() {
         // console.log('project',this.project);
+        
         this.getProjectDetail()
         this.getLevelList()
         this.getTaskGroupList()
@@ -274,9 +281,34 @@ export default {
             this.inside.taskList = value.taskList
         },
 
+        // 新建/编辑任务
+        toEditask(taskid){
+            let item
+            if(taskid == null){
+                item = {
+                    addNew: true,
+                    id: null,
+                    groupId: this.inside.taskGroup.active.id,
+                    stagesId: this.inside.stages.active.id
+                }
+            }else{
+                item = {
+                    addNew: false,
+                    id: taskid,
+                    groupId: null,
+                    stagesId: null
+                }
+            }
+            sessionStorage.setItem('taskId',JSON.stringify(item))
+            this.$router.push("/editask");
+        },
+        
+        
+
+
         getTaskGroupList(){     // 任务分组列表
             this.$axios.post("/task-group/list", {
-                projectId:this.project.id
+                projectId:this.projectId
             }).then(res => {
                 if(res.code == "ok") {
                     this.inside.taskGroup.list = res.data
@@ -290,7 +322,7 @@ export default {
         getStagesList(){        // 任务列表
             this.$axios.post("/stages/list", {
                 groupId: this.inside.taskGroup.active.id,
-                projectId: this.project.id,
+                projectId: this.projectId,
                 order: 'seq',
                 isDesc: false
             }).then(res => {
@@ -306,7 +338,7 @@ export default {
 
         // 项目概览
         getProjectDetail(){
-            this.$axios.post("/project/detail", {id: this.project.id})
+            this.$axios.post("/project/detail", {id: this.projectId})
             .then(res => {
                 if(res.code == "ok") {
                     this.projectDetail = res.data
@@ -316,7 +348,11 @@ export default {
             }).catch(err=> {this.$toast.clear();console.log(err)});
         },
         levelToText(lev){
+            console.log('levelToText',lev,this.info.levelList,this.info.levelList.filter(item => item.id == lev));
             if(this.user.timeType.projectLevelState == 1){
+                if(this.info.levelList.filter(item => item.id == lev).length == 0){
+                    return this.info.levelText[lev]
+                }
                 return this.info.levelList.filter(item => item.id == lev)[0].projectLevelName
             }else{
                 return this.info.levelText[lev]
@@ -340,5 +376,19 @@ export default {
 .content{
     margin-top: 46px;
     overflow: auto;
+    .addtaskvalue{
+        text-align: center;
+        .addtaskbutton{
+            width: 70%;
+            height: 30px;
+        }
+    }
+    .task_button{
+        padding-top: .09rem;
+        text-align: right;
+        button{
+            margin-left: .2667rem;
+        }
+    }
 }
 </style>

+ 340 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/editask.vue

@@ -0,0 +1,340 @@
+<template>
+    <div>
+        <van-nav-bar :title="title" left-text="返回" @click-left="back" fixed left-arrow />
+        <div class="content">
+            <van-form>
+                <!-- 类型 -->
+                <van-field v-model="taskform.taskType" label="类型" @click="taskType.show = true" readonly clickable>
+                    <template #input><span>{{taskType.list[taskform.taskType]}}</span></template>
+                </van-field>
+                <van-popup v-model="taskType.show" position="bottom" v-if="canEdit">
+                    <van-picker
+                    show-toolbar
+                    :columns="taskType.list"
+                    @confirm="tasktypeChange"
+                    @cancel="taskType.show = false;$forceUpdate();"/>
+                </van-popup>
+                <!-- 任务内容 -->
+                <van-field v-model="taskform.name" label="任务内容" placeholder="请输入任务内容" :rules="[{ required: true, message: '请输入任务内容' }]" type="textarea" :disabled="!canEdit"></van-field>
+                <!-- 开始时间 -->
+                <van-field v-if="taskform.type != 1" v-model="taskform.startDate" label="开始时间" placeholder="请选择开始时间" @click="startDateShow = true" readonly clickable></van-field>
+                <van-popup v-model="startDateShow" position="bottom" v-if="canEdit">
+                    <van-datetime-picker
+                    type="date"
+                    title="选择开始时间"
+                    @confirm="startDateChange"
+                    @cancel="startDateShow = false;$forceUpdate();"
+                    :min-date="new Date(2010,0,1)"
+                    :max-date="taskform.endDate ? new Date(taskform.endDate) : new Date(2030,11,31)"/>
+                </van-popup>
+                <!-- 截止时间 -->
+                <van-field v-model="taskform.endDate" label="截止时间" placeholder="请选择截止时间" @click="endDateShow = true" readonly clickable></van-field>
+                <van-popup v-model="endDateShow" position="bottom" v-if="canEdit">
+                    <van-datetime-picker
+                    type="date"
+                    title="选择截止时间"
+                    @confirm="endDateChange"
+                    @cancel="endDateShow = false;$forceUpdate();"
+                    :min-date="taskform.startDate ? new Date(taskform.startDate) : new Date(2010,0,1)"
+                    :max-date="new Date(2030,11,31)"/>
+                </van-popup>
+                <!-- 完成时间 -->
+                <van-field v-if="taskform.type == 1" v-model="taskform.finishDate" label="完成时间" placeholder="请选择完成时间" @click="finishDateShow = true" readonly clickable></van-field>
+                <van-popup v-model="finishDateShow" position="bottom" v-if="canEdit">
+                    <van-datetime-picker
+                    type="date"
+                    title="选择完成时间"
+                    @confirm="finishDateChange"
+                    @cancel="finishDateShow = false;$forceUpdate();"
+                    :min-date="new Date(2010,0,1)"
+                    :max-date="new Date(2030,11,31)"/>
+                </van-popup>
+                <!-- 执行人 -->
+                <div style="border: 0.5px solid #87c3ff;margin:0.2rem;position:relative" v-for="item,index in taskform.executorList" :key="index">
+                    <van-field v-model="item.executorName" :label="'执行人' + (index + 1)" placeholder="请选择执行人" @click="executorChange(item,index)" readonly clickable></van-field>
+                    <van-field label="计划工时">
+                        <template #input>
+                            <van-stepper v-model="item.planHours" :disabled="!canEdit"/><span>{{'\u3000h'}}</span>
+                        </template>
+                    </van-field>
+                    <van-icon v-if="index != 0" class="delete_executor" name="delete-o" @click.stop="deleteExecutor(index)" />
+                </div>
+                <van-popup v-model="executor.show" position="bottom" v-if="canEdit">
+                    <van-search v-model="executor.searchText" placeholder="输入员工姓名搜索" @search="onSearch" v-if="user.userNameNeedTranslate != '1'"></van-search>
+                    <div style="minHeight:300px;">
+                        <van-radio-group v-model="executor.item">
+                            <van-radio v-for="uitem in executor.searchList" :key="uitem.id" :name="uitem" style="padding:10px">
+                                <span>{{uitem.name}}</span>
+                            </van-radio>
+                        </van-radio-group>
+                    <van-button style="width:100%;position: -webkit-sticky;position: sticky;bottom: 0;" @click="searchExecutor()">确定</van-button>
+                    </div>
+                </van-popup>
+                <!-- 添加执行人 -->
+                <div class="add_executor" @click="addExecutor" v-if="canEdit">添加执行人</div>
+                <!-- 优先级 -->
+                <van-field v-model="taskform.taskLevel" label="优先级" @click="taskLevel.show = true" readonly clickable>
+                    <template #input><span>{{taskLevel.list[taskform.taskLevel]}}</span></template>
+                </van-field>
+                <van-popup v-model="taskLevel.show" position="bottom" v-if="canEdit">
+                    <van-picker
+                    show-toolbar
+                    :columns="taskLevel.list"
+                    @confirm="taskLevelChange"
+                    @cancel="taskLevel.show = false;$forceUpdate();"/>
+                </van-popup>
+
+            </van-form>
+            <div class="form_btn" style="position:fixed; bottom:0px;width:100%;">
+                <div style="padding-bottom:10px;">
+                    <van-button square block type="info" @click="submitTask" native-type="submit" style="width:100%;float:left;" :disabled="!canEdit">
+                        <div v-if="canEdit">保存</div>
+                        <div v-else>暂无权限编辑</div>
+                    </van-button>
+                </div>
+            </div>
+                    
+        </div>
+    </div>
+</template>
+
+<script>
+export default {
+    data() {
+        return {
+            title: '编辑任务',
+            user: JSON.parse(localStorage.userInfo),
+            taskId: JSON.parse(sessionStorage.taskId),
+            canEdit: true,
+            taskform:{      // 表单
+                taskType: 0,
+                name: '',
+                startDate: null,
+                endDate: null,
+                finishDate: null,
+                taskLevel: 0,
+                executorList: [{executorName: '',executorId: '',planHours: 8}],
+
+            },
+            taskType:{
+                show: false,
+                list: ['任务','里程碑','风险']
+            },
+            startDateShow: false,
+            endDateShow: false,
+            finishDateShow: false,
+            taskLevel:{
+                show: false,
+                list: ['一般','重要','紧急']
+            },
+            executor:{
+                show: false,
+                item: {id:null,name:''},
+                index: 0,
+                list: [],
+                searchList: [],
+                searchText: ''
+            }
+
+        }
+    },
+    mounted() {
+        if(!this.taskId.addNew){
+            this.title = '编辑任务'
+            this.getTask()
+        }else{
+            this.title = '新建任务'
+            this.taskform = {
+                projectId: JSON.parse(sessionStorage.projectId),
+                groupId: this.taskId.groupId,
+                stagesId: this.taskId.stagesId,
+                taskType: 0,
+                name: '',
+                startDate: null,
+                endDate: null,
+                finishDate: null,
+                taskLevel: 0,
+                executorList: [{executorName: '',executorId: '',planHours: this.user.timeType.allday}]
+            }
+        }
+        this.getUsersList()
+        console.log('mounted',this.taskId,null);
+    },
+    methods: {
+        back() {
+            history.back();
+        },
+        formatDate(date) {
+            let mon = date.getMonth() + 1
+            return `${date.getFullYear()}-${mon<10?'0'+mon:mon}-${date.getDate()<10?'0'+date.getDate():date.getDate()}`;
+        },
+
+
+        tasktypeChange(value,key){      // 类型
+            this.taskform.taskType = key
+            this.taskType.show = false
+        },
+        startDateChange(date){          // 开始时间
+            this.taskform.startDate = this.formatDate(date)
+            this.startDateShow = false
+        },
+        endDateChange(date){            // 截止时间
+            this.taskform.endDate = this.formatDate(date)
+            this.endDateShow = false
+        },
+        finishDateChange(date){         // 完成时间
+            this.taskform.finishDate = this.formatDate(date)
+            this.finishDateShow = false
+        },
+        
+        executorChange(item,index){           // 选择执行人
+            this.executor.show = true
+            this.executor.index = index
+            this.executor.searchList.forEach(u=>{if (u.id == item.executorId) {
+                this.executor.item = u
+            }})
+        },
+        deleteExecutor(index){
+            console.log('deleteExecutor');
+            this.taskform.executorList.splice(index,1)
+            this.$forceUpdate();
+        },
+        addExecutor(){
+            console.log('addExecutor');
+            this.taskform.executorList.push({
+                executorName: '',
+                executorId: '',
+                planHours: this.user.timeType.allday
+            })
+            this.$forceUpdate();
+        },
+        onSearch(val) {
+            console.log(val);
+            this.executor.searchList = [];
+            this.executor.list.forEach(u=>{if (u.name.startsWith(val)) {
+                this.executor.searchList.push(u);
+            }})
+        },
+        searchExecutor(){
+            this.taskform.executorList[this.executor.index].executorId = this.executor.item.id
+            this.taskform.executorList[this.executor.index].executorName = this.executor.item.name
+            this.executor.show = false
+            console.log('searchExecutor',this.executor.item,this.executor.item.name);
+        },
+
+        taskLevelChange(value,key){     // 优先级
+            this.taskform.taskLevel = key
+            this.taskLevel.show = false
+        },
+
+        submitTask(){
+            console.log('submitTask');
+            
+            // 执行人查重
+            let arr = this.taskform.executorList
+            let json={};
+            for(let i in arr){
+                if(!json[arr[i].executorId]){
+                    json[arr[i].executorId]=1;
+                }else{
+                    this.$toast.fail("执行人存在重复");
+                    return
+                }
+            }
+
+            // 去除未选择执行人的执行人列表
+            this.taskform.executorList = this.taskform.executorList.filter(item => item.executorId)
+            this.taskform.executorListStr = JSON.stringify(this.taskform.executorList)
+            
+            delete this.taskform.executorList
+            delete this.taskform.subTaskList;
+            delete this.taskform.refTaskList;
+            delete this.taskform.progress;
+            this.$axios.post("/task/save", this.taskform)
+            .then(res => {
+                if(res.code == "ok") {
+                    this.$toast.success('保存成功');
+                    this.back()
+                } else {
+                    this.$toast.fail('保存失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
+
+        },
+
+        getTask(){
+            this.$axios.post("/task/getTask", {
+                id: this.taskId.id
+            }).then(res => {
+                if(res.code == "ok") {
+                    this.taskform = res.data
+                    this.taskform.createDate = null;
+                    this.taskform.indate = null;
+                    let projectManagement = false
+
+                    // 判断编辑权限
+                    for(let i in this.user.functionList){
+                        if(this.user.functionList[i].name == '查看全部项目'){
+                            projectManagement = true
+                        }
+                    }
+                    if(this.user.id == res.data.createrId || this.user.id == res.data.projectInchargerId || this.user.id == res.data.groupInchargerId || projectManagement || this.title == '新建任务'){
+                        this.canEdit = true
+                    }else{
+                        this.canEdit = false
+                    }
+
+
+                    // (
+                    //     (
+                    //         (addForm.executorListFront == null || addForm.executorListFront.length<10) 
+                    //         && (
+                    //             addForm.id == null|| user.id == addForm.createrId || currentProject.inchargerId == user.id || permissions.projectManagement
+                    //         )
+                    //     ) 
+                    //     || groupResponsibleId == user.id
+                    // )
+
+
+
+                    // this.canEdit = false
+                } else {
+                    this.$toast.fail('获取失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
+        },
+        getUsersList(){
+            this.$axios.post("/user/getSimpleActiveUserList", {})
+            .then(res => {
+                if(res.code == "ok") {
+                    this.executor.list = res.data
+                    this.executor.searchList = res.data
+                } else {
+                    this.$toast.fail('获取失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
+        }
+    },
+}
+</script>
+
+<style lang="less" scoped>
+.content{
+    margin-top: 46px;
+    overflow: auto;
+    .add_executor{
+        font-size:13px;
+        color:#1989fa;
+        padding-left:0.42667rem;
+        padding-bottom:.2rem;
+        width:100px
+    }
+    .delete_executor{
+        position: absolute;
+        top: 3px;
+        right: 3px;
+        font-size: 22px;
+        color: #c03131;
+    }
+}
+</style>

+ 36 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/views/task/index.vue

@@ -49,7 +49,7 @@
                 <van-icon v-if="select_date.length != 0" name="close" style="line-height:0.64rem;position:relative;left:5px;" @click.stop="dateClear"/>
             </template>
         </van-cell>
-        <van-calendar v-model="select_date_show" type="range" @confirm="dateChange" />
+        <van-calendar v-model="select_date_show" type="range" @confirm="dateChange" :min-date="new Date(2010,0,1)" :max-date="new Date(2030,11,31)" />
     </van-sticky>
 
         <div class="taskList" v-if="taskList.length != 0">
@@ -60,6 +60,12 @@
                     <span v-if="item.startDate && item.endDate">{{(item.startDate ? item.startDate : ' - ') + '\u3000至\u3000' + (item.endDate ? item.endDate : ' - ')}}</span>
                     <span v-else></span>
                 </div>
+                <div class="task_button">
+                    <van-button size="small" type="info" @click="toEditask(item.id)">编辑</van-button>
+                    <van-button size="small" type="primary" @click="taskStatus(item.id,0)" v-if="select_state == '进行中'">完成</van-button>
+                    <van-button size="small" color="#e6a23c" @click="taskStatus(item.id,1)" v-else>重启</van-button>
+
+                </div>
             </van-cell>
         </div>
         <div v-else style="text-align:center;font-size:16px;font-weight:500;color:#999;width:100%;margin-top:16px">暂无数据</div>
@@ -99,6 +105,28 @@ export default {
         back() {
             history.back();
         },
+        toEditask(taskid){    // 跳转编辑任务
+            sessionStorage.setItem('taskId',JSON.stringify({
+                addNew: false,
+                id: taskid,
+                groupId: null,
+                stagesId: null
+            }))
+            this.$router.push("/editask");
+        },
+        taskStatus(taskid,status){          // 改变任务状态
+            this.$axios.post("/task/finish", {
+                id: taskid,
+                taskStatus: status
+            }).then(res => {
+                if(res.code == "ok") {
+                    this.$toast.success('操作成功');
+                    this.getList()
+                } else {
+                    this.$toast.fail('获取失败');
+                }
+            }).catch(err=> {this.$toast.clear();console.log(err)});
+        },
         formatDate(date) {
             let mon = date.getMonth() + 1
             return `${date.getFullYear()}-${mon<10?'0'+mon:mon}-${date.getDate()<10?'0'+date.getDate():date.getDate()}`;
@@ -173,6 +201,13 @@ export default {
 .content{
     margin-top: 46px;
     // overflow: auto;
+    .task_button{
+        padding-top: .09rem;
+        text-align: right;
+        button{
+            margin-left: .2667rem;
+        }
+    }
 }
 // .dateSelectCell{
 //     height: 1.2rem;