reedliuqing_i 5 years ago
parent
commit
b565da4028

+ 2 - 0
package.json

@@ -31,6 +31,7 @@
     "file-saver": "^2.0.2",
     "gantt-elastic": "^1.0.11",
     "gantt-elastic-header": "^0.1.11",
+    "gantt-schedule-timeline-calendar": "^2.6.7",
     "html2canvas": "^1.0.0-rc.3",
     "jodit": "^3.2.58",
     "js-cookie": "2.2.0",
@@ -44,6 +45,7 @@
     "v-jsoneditor": "^1.2.2",
     "vue": "2.6.10",
     "vue-fullcalendar": "^1.0.9",
+    "vue-gantt-schedule-timeline-calendar": "^1.0.32",
     "vue-json-viewer": "^2.2.8",
     "vue-qr": "^2.2.1",
     "vue-router": "3.0.6",

+ 2 - 1
src/api/workbench.js

@@ -12,7 +12,8 @@ export default {
   queryWorkListByTime,
   queryWorkList,
   queryIdleList,
-  queryTeamWorkList
+  queryTeamWorkList,
+  queryTeamIdleList
 }
 
 // 创建个人日程

+ 2 - 9
src/views/workbench/person/calendarFormDialog.vue

@@ -6,6 +6,7 @@
         <div class="module_title__caption">{{ title }}</div>
       </div>
     </template>
+    {{ form }}
     <el-form ref="calendarform" :model="form" :rules="rules" label-position="left" label-width="90px">
       <el-form-item label="日程名称" prop="name">
         <el-input v-model="form.name" />
@@ -69,7 +70,7 @@
 <script>
 import workbenchApi from '@/api/workbench.js'
 import { queryBizTypeList } from '@/api/defectManage'
-import dayjs from 'dayjs'
+// import dayjs from 'dayjs'
 
 export default {
   props: {
@@ -122,14 +123,6 @@ export default {
       if (newVal) {
         if (this.title === '编辑日程') {
           this.form = JSON.parse(JSON.stringify(this.data))
-          this.form.startTime = dayjs(this.form.startTime).toDate()
-          this.form.endTime = dayjs(this.form.endTime).toDate()
-          this.form.time = [this.form.startTime, this.form.endTime]
-          if (this.form.bizId !== null) {
-            this.form.isJoin = 1
-          } else {
-            this.form.isJoin = 0
-          }
         } else {
           this.form = {
             time: [this.data.start, this.data.end],

+ 25 - 6
src/views/workbench/person/index.vue

@@ -91,14 +91,14 @@
                   />
                 </el-select>
                 <el-checkbox
-                  v-model="selfScheduleForm.origin[0]"
+                  v-model="selfScheduleForm.myOrigin[0]"
                   style="margin: 0 20px"
                   :true-label="1"
                   :false-label="0"
                   @change="queryWorkList()"
                 >任务排期</el-checkbox>
                 <el-checkbox
-                  v-model="selfScheduleForm.origin[1]"
+                  v-model="selfScheduleForm.myOrigin[1]"
                   :true-label="1"
                   :false-label="0"
                   @change="queryWorkList()"
@@ -153,7 +153,7 @@
                 {{ scope.row.startTime + ' ~ ' + scope.row.endTime }}
               </template>
             </el-table-column>
-            <el-table-column label="使用/工作日/全部" align="center" min-width="30">
+            <el-table-column prop="needDays" label="使用/工作日/全部" align="center" min-width="30">
               <template v-slot="scope">
                 {{ scope.row.needDays + '/' + scope.row.legalDays + '/' + scope.row.allDays }}
               </template>
@@ -237,6 +237,7 @@ export default {
       selfScheduleListTotal: 10,
       selfScheduleForm: {
         status: 0,
+        myOrigin: [1, 1],
         origin: [0, 1],
         syncTeam: 1,
         curIndex: 1,
@@ -277,7 +278,16 @@ export default {
       // this.createSelfScheduleDialog.visible = true
     },
     openUpdateSelfScheduleDialog(val) {
-      this.updateSelfScheduleDialog.data = val
+      const form = JSON.parse(JSON.stringify(val))
+      form.startTime = dayjs(form.startTime).toDate()
+      form.endTime = dayjs(form.endTime).toDate()
+      form.time = [form.startTime, form.endTime]
+      if (form.bizId !== null) {
+        form.isJoin = 1
+      } else {
+        form.isJoin = 0
+      }
+      this.updateSelfScheduleDialog.data = form
       this.updateSelfScheduleDialog.visible = true
     },
     openDeleteSelfScheduleDialog(val) {
@@ -302,8 +312,10 @@ export default {
     queryIdleList() {
       workbenchApi
         .queryIdleList({
-          startTime: dayjs(this.timeSelectVal[0]).format('YYYY.MM.DD'),
-          endTime: dayjs(this.timeSelectVal[1]).format('YYYY.MM.DD'),
+          timeInfo: {
+            startTime: dayjs(this.timeSelectVal[0]).format('YYYY.MM.DD'),
+            endTime: dayjs(this.timeSelectVal[1]).format('YYYY.MM.DD')
+          },
           curIndex: this.selfScheduleForm.curIndex,
           pageSize: this.selfScheduleForm.pageSize
         })
@@ -314,6 +326,13 @@ export default {
     },
     // 获取个人工作日程列表
     queryWorkList() {
+      if (this.selfScheduleForm.myOrigin[0] && this.selfScheduleForm.myOrigin[1]) {
+        this.selfScheduleForm.origin = [0, 1]
+      } else if (this.selfScheduleForm.myOrigin[0]) {
+        this.selfScheduleForm.origin = [0]
+      } else if (this.selfScheduleForm.myOrigin[1]) {
+        this.selfScheduleForm.origin = [1]
+      }
       workbenchApi.queryWorkList(this.selfScheduleForm).then(res => {
         if (res.code === 200) {
           this.selfScheduleBusyTableData = res.data.list

+ 194 - 53
src/views/workbench/team/index.vue

@@ -4,9 +4,9 @@
       <div>
         <div style="display: inline-block">团队</div>
         <el-select
-          v-model="searchForm.team"
+          v-model="searchForm.teamId"
           style="margin-left: 20px"
-          @change="query()"
+          @change="queryTeamWorkList()"
         >
           <el-option
             v-for="item in searchEnum.teams"
@@ -17,9 +17,9 @@
         </el-select>
         <div style="display: inline-block;margin-left: 20px">业务线</div>
         <el-select
-          v-model="searchForm.businessline"
+          v-model="searchForm.bizId"
           style="margin-left: 20px"
-          @change="query()"
+          @change="queryTeamWorkList()"
         >
           <el-option
             v-for="item in searchEnum.businesslines"
@@ -41,28 +41,40 @@
         <div class="module_title__sign" />
         <div class="module_title__caption">团队日程</div>
       </div>
-      <el-row>
+      <el-row style="margin-bottom: 20px" class="gantt-view-header">
         <el-col :span="12">
-          <el-radio-group v-model="radio1" size="small">
+          <el-radio-group v-model="radio1" size="small" @change="radioChange">
             <el-radio-button label="忙碌" />
             <el-radio-button label="空闲" />
           </el-radio-group>
+          <div v-if="radio1 === '空闲'" style="display: inline-block">
+            <div style="display: inline-block;margin-left: 20px">选择时间:</div>
+            <el-date-picker
+              v-model="timeSelectVal"
+              type="daterange"
+              range-separator="-"
+              start-placeholder="开始日期"
+              end-placeholder="结束日期"
+              :picker-options="pickerOptions"
+              :clearable="false"
+              @change="queryTeamIdleList()"
+            />
+          </div>
         </el-col>
-        <el-col :span="12" style="text-align: right">
-          <el-radio-group v-model="radio2" size="small">
-            <el-radio-button label="今天" />
-          </el-radio-group>
-          <el-radio-group v-model="radio3" size="small" style="margin-left: 20px">
+        <el-col v-if="radio1 === '空闲'" :span="12" style="text-align: right">
+          <div style="display: inline-block" @click="radio2 = ''">
+            <el-radio-group v-model="radio2" size="small" @change="radioChange">
+              <el-radio-button label="今天" />
+            </el-radio-group>
+          </div>
+          <el-radio-group v-model="radio3" size="small" style="margin-left: 20px" @change="radioChange">
             <el-radio-button label="日" />
             <el-radio-button label="周" />
             <el-radio-button label="月" />
           </el-radio-group>
         </el-col>
       </el-row>
-      <gantt-elastic :tasks="tasks" :options="options">
-        <gantt-elastic-header slot="header" />
-        <gantt-elastic-footer slot="footer" />
-      </gantt-elastic>
+      <gantt-elastic :tasks="tasks" :options="options" />
     </el-main>
   </el-container>
 </template>
@@ -71,20 +83,30 @@
 import workbenchApi from '@/api/workbench.js'
 import { queryBizTypeList } from '@/api/defectManage'
 import GanttElastic from 'gantt-elastic'
-import Header from 'gantt-elastic-header'
+// import Header from 'gantt-elastic-header'
+import dayjs from 'dayjs'
 
 export default {
   components: {
-    ganttElasticHeader: Header, // or Header
-    ganttElastic: GanttElastic,
-    ganttElasticFooter: { template: `<span>your footer</span>` }
+    ganttElastic: GanttElastic
   },
   data() {
     return {
+      timeSelectVal: [new Date(), dayjs(new Date()).add(29, 'day')],
+      pickerOptions: {
+        disabledDate(time) {
+          return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
+        }
+      },
       tasks: [], // 甘特图任务
       options: {
+        locale: {
+          name: 'zh_cn',
+          weekdays: ['周天', '周一', '周二', '周三', '周四', '周五', '周六'],
+          months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
+        },
         maxRows: 100,
-        maxHeight: 300,
+        maxHeight: 460,
         title: {
           label: 'Your project title as html (link or whatever...)',
           html: false
@@ -94,7 +116,7 @@ export default {
         },
         calendar: {
           hour: {
-            display: false
+            display: true
           }
         },
         chart: {
@@ -112,47 +134,69 @@ export default {
           columns: [
             {
               id: 1,
-              label: 'ID',
-              value: 'id',
-              width: 40
+              label: '团队成员',
+              value: 'user',
+              width: 80,
+              style: {
+                'task-list-header-label': {
+                  'text-align': 'center',
+                  width: '100%'
+                },
+                'task-list-item-value-container': {
+                  'font-weight': '500'
+                }
+              }
             },
             {
               id: 2,
-              label: 'Description',
+              label: '任务名称',
               value: 'label',
-              width: 200,
+              width: 180,
               expander: true,
-              html: true,
-              events: {
-                click({ data, column }) {
-                  alert('description clicked!\n' + data.label)
+              style: {
+                'task-list-header-label': {
+                  'text-align': 'center',
+                  width: '100%'
                 }
               }
             },
             {
               id: 3,
-              label: 'Assigned to',
-              value: 'user',
-              width: 130,
-              html: true
-            },
-            {
-              id: 3,
-              label: 'Start',
+              label: '开始时间',
               value: task => dayjs(task.start).format('YYYY-MM-DD'),
-              width: 78
+              width: 90,
+              style: {
+                'task-list-header-label': {
+                  'text-align': 'center',
+                  width: '100%'
+                },
+                'task-list-item-value-container': {
+                  'text-align': 'center',
+                  width: '100%'
+                }
+              }
             },
             {
               id: 4,
-              label: 'Type',
-              value: 'type',
-              width: 68
+              label: '结束时间',
+              value: task => dayjs(task.start + task.duration).format('YYYY-MM-DD'),
+              width: 90,
+              style: {
+                'task-list-header-label': {
+                  'text-align': 'center',
+                  width: '100%'
+                },
+                'task-list-item-value-container': {
+                  'text-align': 'center',
+                  width: '100%'
+                }
+              }
             },
             {
               id: 5,
-              label: '%',
-              value: 'progress',
-              width: 35,
+              label: '使用/工作日/全部',
+              value: 'needLegalAllDays',
+              width: 130,
               style: {
                 'task-list-header-label': {
                   'text-align': 'center',
@@ -167,27 +211,46 @@ export default {
           ]
         }
       }, // 甘特图配置
+      ganttHeaderStyle: {
+      },
       radio1: '忙碌',
       radio2: '今天',
+      radio2TF: true,
       radio3: '日',
       searchForm: {
-        team: 0,
-        businessline: 0
+        teamId: null,
+        bizId: null
+      },
+      idleSearchForm: {
+        startTime: null,
+        endTime: null
       },
       searchEnum: {
         teams: [],
         businesslines: []
       },
-      username: localStorage.getItem('username')
+      username: localStorage.getItem('username'),
+      teamWorkList: []
     }
   },
   mounted() {
     this.queryTeamInfoList(this.username)
     this.queryBizTypeList()
+    this.queryTeamWorkList()
   },
   methods: {
-    query() {
-
+    radioChange(val) {
+      if (val === '忙碌') {
+        this.queryTeamWorkList()
+      } else {
+        this.queryTeamIdleList()
+      }
+      if (val === '今天') {
+        if (this.radio2TF) {
+          this.radio2 = ''
+        }
+        this.radio2TF = !this.radio2TF
+      }
     },
     queryTeamInfoList(username) {
       const data = { memberIDAP: username, curIndex: 1, pageSize: 9999 }
@@ -195,7 +258,7 @@ export default {
         if (res.data) {
           this.searchEnum.teams = res.data.list
           this.searchEnum.teams.unshift({
-            teamId: 0,
+            teamId: null,
             teamName: '全部'
           })
         }
@@ -206,18 +269,96 @@ export default {
         if (res.data) {
           this.searchEnum.businesslines = res.data.list
           this.searchEnum.businesslines.unshift({
-            id: 0,
+            id: null,
             bizName: '全部'
           })
         }
       })
+    },
+    queryTeamWorkList() {
+      workbenchApi.queryTeamWorkList(this.searchForm)
+        .then(res => {
+          if (res.data) {
+            this.createTasks(res, '忙碌')
+          }
+        })
+    },
+    queryTeamIdleList() {
+      this.idleSearchForm.startTime = dayjs(this.timeSelectVal[0]).format('YYYY.MM.DD')
+      this.idleSearchForm.endTime = dayjs(this.timeSelectVal[1]).format('YYYY.MM.DD')
+      workbenchApi.queryTeamIdleList({
+        timeInfo: this.idleSearchForm,
+        teamWorkQueryInfo: this.searchForm
+      }).then(res => {
+        if (res.data) {
+          this.createTasks(res, '空闲')
+        }
+      })
+    },
+    createTasks(res, mode) {
+      this.tasks = []
+      let count = 0
+      for (const i in res.data) {
+        let label = ''
+        if (mode === '忙碌') {
+          label = res.data[i].workNum.taskWorkNum + '个任务、' + res.data[i].workNum.selfWorkNum + '个日程'
+        } else {
+          label = res.data[i].workNum.taskWorkNum + '个空闲时段'
+        }
+        const parentItem = {
+          id: count++,
+          label: label,
+          user: res.data[i].userInfo.ldapName,
+          collapsed: true,
+          needLegalAllDays: res.data[i].workNum.needDays + '/' + res.data[i].workNum.legalDays + '/' + res.data[i].workNum.allDays,
+          start: dayjs(res.data[i].workNum.startTime).toDate().getTime(),
+          duration: dayjs(res.data[i].workNum.endTime).toDate().getTime() - dayjs(res.data[i].workNum.startTime).toDate().getTime(),
+          type: 'task'
+        }
+        this.tasks.push(parentItem)
+        for (const j in res.data[i].workData) {
+          const item = {
+            id: count++,
+            parentId: parentItem.id,
+            label: res.data[i].workData[j].name,
+            user: parentItem.user,
+            needLegalAllDays: res.data[i].workData[j].needDays + '/' + res.data[i].workData[j].legalDays + '/' + res.data[i].workData[j].allDays,
+            start: dayjs(res.data[i].workData[j].startTime).toDate().getTime(),
+            duration: dayjs(res.data[i].workData[j].endTime).toDate().getTime() - dayjs(res.data[i].workData[j].startTime).toDate().getTime(),
+            type: 'task'
+          }
+          this.tasks.push(item)
+        }
+      }
     }
-
   }
 
 }
 </script>
 
+<style>
+/* .gantt-elastic__task-list-header-label {
+  font-size: 16px !important;
+  font-weight: 500;
+}
+.gantt-elastic__task-list-item-value {
+  font-size: 14px!important;
+} */
+.gantt-view-header .el-date-editor {
+  padding-top: 0;
+  padding-bottom: 0;
+  height: 35px;
+  width: 240px;
+}
+.gantt-view-header .el-date-editor input {
+  height: 32px;
+  width: 90px;
+}
+.gantt-view-header .el-date-editor .el-range__close-icon {
+  display: none;
+}
+</style>
+
 // 布局
 <style scoped>
 .workbench_team {