yusheng пре 1 година
родитељ
комит
80ad9eb03c

+ 13 - 0
src/api/project-manage/index.js

@@ -299,3 +299,16 @@ export async function getProjectAndCategoryLevelTree(id) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 项目行事历 树
+ * @id id
+ */
+export async function getProjectCalender(data) {
+  const res = await request.post(`/pro/projects/getProjectCalender`,data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+

+ 3 - 0
src/styles/index.scss

@@ -24,3 +24,6 @@ table th .is-required::before {
 .switch {
   padding-bottom: 20px;
 }
+.gantt_tooltip{
+  z-index: 9999 !important;
+}

+ 24 - 15
src/views/BOMmanage/ProjectDetailDialog.vue

@@ -275,7 +275,11 @@
                 :min-size="1"
                 :resizable="true"
                 :responsive="true"
-                :width="activeName=='任务'||activeName=='计划'?'450px':'100%'"
+                :width="
+                  activeName == '任务' || activeName == '计划'
+                    ? '450px'
+                    : '100%'
+                "
                 :right-style="{ overflow: 'hidden' }"
                 :allow-collapse="false"
               >
@@ -331,7 +335,6 @@
                           @handlePlanTableNodeClick="handlePlanTableNodeClick"
                           v-if="refreshPlan"
                         ></planManageList>
-
                       </div>
                     </el-tab-pane>
                     <el-tab-pane
@@ -449,7 +452,7 @@
                       name="项目看板"
                       class="el-tab-pane-tree"
                     >
-                    <project-statistics></project-statistics>
+                      <project-statistics></project-statistics>
                     </el-tab-pane>
                     <el-tab-pane
                       label="项目审核流程"
@@ -466,9 +469,10 @@
                       label="项目行事历"
                       name="项目行事历"
                       class="el-tab-pane-tree"
-                      style="overflow: scroll; padding-bottom: 30px"
                     >
-                      <projectCalendar></projectCalendar>
+                      <projectCalendar
+                        ref="projectCalendarRef"
+                      ></projectCalendar>
                     </el-tab-pane>
                   </el-tabs>
                 </div>
@@ -692,7 +696,8 @@
       planManageList,
       projectCalendar,
       projectInfoTable,
-      addOrEditStageDialog,projectStatistics
+      addOrEditStageDialog,
+      projectStatistics
     },
     data() {
       return {
@@ -943,9 +948,10 @@
         this.rowData = row;
         this.visible = true;
         if (this.rowData.id) {
-          this.$nextTick(()=>{
-            this.$refs.treeList.getTreeData('',this.rowData.id)
-          })
+          this.$nextTick(() => {
+            this.$refs.treeList.getTreeData('', this.rowData.id);
+            this.$refs.projectCalendarRef.init(row.id);
+          });
           this.initData();
           this.dialogType = this.rowData.type;
         }
@@ -1283,13 +1289,16 @@
         } catch (error) {}
         this.treeLoading = false;
       },
-      async handleNodeClick1(data){
-        if(data.type=="projectType"){
-          this.rowData=this.dialogForm = await projectsGetByIdDetailsAPI(data.id);
-        this.getTreeData()
+      async handleNodeClick1(data) {
+        if (data.type == 'projectType') {
+          this.rowData = this.dialogForm = await projectsGetByIdDetailsAPI(
+            data.id
+          );
+          this.getTreeData();
+          this.$nextTick(() => {
+            this.$refs.projectCalendarRef.init(data.id);
+          });
         }
-       
-
       },
       getIconClass(node, data) {
         switch (data.type) {

+ 8 - 3
src/views/project-manage/planManage/components/addDialog.vue

@@ -86,13 +86,16 @@ export default {
 
     async submit(type = '') {
       let form = await this.$refs.planForm.validForm();
-      form.planStageList = await this.$refs.planInfoTable.getTableValidate() || [];
+      // return
+      // form.planStageList = await this.$refs.planInfoTable.getTableValidate() || [];
       form.realStartDate = null
       form.realEndDate = null
-      for (const item of form.planStageList) {
+      for (const item of form.datasource) {
         item.responsibleUserList = await this.getResponsibleUserList(item.responsibleUserIds)
       }
-      form.responsibleUserList = await this.getResponsibleUserList(form.responsibleUserIds)
+      // form.responsibleUserList = await this.getResponsibleUserList(form.responsibleUserIds)
+      console.log(form,'form')
+
       const API = this.dialogType === 'add' ? projectsPlanSaveAPI : projectsPlanUpdateAPI;
       const id = await API(form)
       if (type === 'sub') {
@@ -104,6 +107,8 @@ export default {
       this.$emit('reload');
     },
     async getResponsibleUserList(list = []) {
+      console.log(list)
+      console.log(this.allUserList)
       return list.map(
         i => {
           return {

+ 2 - 2
src/views/project-manage/planManage/index.vue

@@ -18,7 +18,7 @@
       >
         <!-- 表头工具栏 -->
         <template v-slot:toolbar>
-          <el-button
+          <!-- <el-button
             size="small"
             type="primary"
             icon="el-icon-plus"
@@ -26,7 +26,7 @@
             @click="openEdit2('', 'add')"
           >
             新建2
-          </el-button>
+          </el-button> -->
           <el-button
             size="small"
             type="primary"

+ 286 - 257
src/views/project-manage/project-calendar/index.vue

@@ -7,19 +7,23 @@
       <div class="box-container-top-search">
         <el-form :inline="true" :model="form">
           <el-form-item label="时间">
-            <el-select v-model="form.dateType" style="width: 120px;margin-right: 10px" placeholder="时间类型">
+            <el-select
+              v-model="form.dateType"
+              style="width: 120px; margin-right: 10px"
+              placeholder="时间类型"
+            >
               <el-option label="月度" value="month"></el-option>
               <el-option label="年度" value="year"></el-option>
               <el-option label="时间范围" value="daterange"></el-option>
             </el-select>
 
-
             <el-date-picker
               v-model="form.dateRange"
               :type="form.dateType"
               range-separator="至"
               start-placeholder="开始日期"
-              end-placeholder="结束日期">
+              end-placeholder="结束日期"
+            >
             </el-date-picker>
           </el-form-item>
           <el-form-item>
@@ -28,25 +32,13 @@
         </el-form>
       </div>
       <div class="box-container-top-cell">
-        <!-- <el-card class="card-cell middle-cell">
-          <el-calendar >
-            <template
-              v-slot:dateCell="{date, data}">
-              <p @click="aaa(date,data)" class="dateCellText" :class="data.isSelected ? 'is-selected' : ''">
-                {{ data.day.split('-').slice(2).join(',') }}
-              </p>
-            </template>
-          </el-calendar>
-        </el-card> -->
         <el-card class="card-cell middle-cell">
-          <gantt ref="gantt"  v-show="showGantt" :ganttTasks="tableData"></gantt>
+          <gantt ref="gantt" v-show="showGantt" :ganttTasks="tableData"></gantt>
         </el-card>
       </div>
-
     </div>
-    <div class="box-container-footer">
+    <!-- <div class="box-container-footer">
       <el-card class="card-cell middle-cell">
-        <!-- 数据表格 -->
         <ele-pro-table
           ref="table"
           row-key="id"
@@ -58,308 +50,345 @@
           :toolbar="false"
           :need-page="false"
           :default-expand-all="true"
-          :tree-props="{children: 'projectList'}"
-          :indent="15"
+          :tree-props="{ children: 'projectList' }"
+          :initLoad=""
+          init
         >
           <template v-slot:code="{ row }">
-            <el-button type="text" @click="openDetail(row)">{{ row.code }}</el-button>
+            <el-button type="text" @click="openDetail(row)">{{
+              row.code
+            }}</el-button>
           </template>
           <template v-slot:isOverTime="{ row }">
-            <el-tag v-if="row.isOverTime==0" type="success">正常</el-tag>
+            <el-tag v-if="row.isOverTime == 0" type="success">正常</el-tag>
             <el-tag v-else type="danger">超时</el-tag>
           </template>
           <template v-slot:projectName="{ row }">
-            <el-tag v-if="row.relationType==0" type="success">{{ row.projectName }}</el-tag>
+            <el-tag v-if="row.relationType == 0" type="success">{{
+              row.projectName
+            }}</el-tag>
             <span v-else>{{ row.projectName }}</span>
           </template>
           <template v-slot:projectStageName="{ row }">
-            <el-tag v-if="row.relationType==1" type="success">{{ row.projectStageName }}</el-tag>
+            <el-tag v-if="row.relationType == 1" type="success">{{
+              row.projectStageName
+            }}</el-tag>
             <span v-else>{{ row.projectStageName }}</span>
           </template>
           <template v-slot:targetPlanName="{ row }">
-            <el-tag v-if="row.relationType==2" type="success">{{ row.targetPlanName }}</el-tag>
+            <el-tag v-if="row.relationType == 2" type="success">{{
+              row.targetPlanName
+            }}</el-tag>
             <span v-else>{{ row.targetPlanName }}</span>
           </template>
           <template v-slot:planStageName="{ row }">
-            <el-tag v-if="row.relationType==3" type="success">{{ row.planStageName }}</el-tag>
+            <el-tag v-if="row.relationType == 3" type="success">{{
+              row.planStageName
+            }}</el-tag>
             <span v-else>{{ row.planStageName }}</span>
           </template>
           <template v-slot:taskName="{ row }">
-            <el-tag v-if="row.relationType==4" type="success">{{ row.taskName }}</el-tag>
+            <el-tag v-if="row.relationType == 4" type="success">{{
+              row.taskName
+            }}</el-tag>
             <span v-else>{{ row.taskName }}</span>
           </template>
 
           <template v-slot:type="{ row }">
-            <!--            {{ getDictV('task_type', row.type) }}-->
           </template>
         </ele-pro-table>
       </el-card>
-
-
-    </div>
+    </div> -->
   </div>
 </template>
 <script>
-import Gantt from "@/views/project-manage/project-initiation/components/project-gantt.vue";
-import dayjs from "dayjs";
-import {projectsPageAPI} from "@/api/project-manage";
-
-export default {
-  name: "index",
-  components: {Gantt},
-  data() {
-    return {
-      showGantt: false,
-      form: {
-        dateType:'daterange',
-        dateRange:'',
-      },
-      tableData: []
-    };
-  },
-  computed: {
-    columns() {
-      return [
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true,
-        },
-        {
-          prop: 'name',
-          label: '任务名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 300
-        },
-        {
-          prop: 'responsibleUserName',
-          label: '执行人',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 170,
-          // formatter: (_row, _column, cellValue) => {
-          //   return !_row.responsibleUserList.length ? '' : _row.responsibleUserList.map(i => i.userName).join(',');
-          // }
-        },
-        {
-          prop: 'cost',
-          label: '费用(元)',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 150
+  import Gantt from '@/views/project-manage/project-initiation/components/project-gantt.vue';
+  import dayjs from 'dayjs';
+  import { projectsPageAPI, getProjectCalender } from '@/api/project-manage';
+
+  export default {
+    name: 'index',
+    components: { Gantt },
+
+    data() {
+      return {
+        showGantt: false,
+        form: {
+          dateType: 'daterange',
+          dateRange: ''
         },
-        {
-          prop: 'planStartDate',
-          label: '计划开始日期',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 190
-        },
-        {
-          prop: 'planEndDate',
-          label: '计划完成日期',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 200
-        },
-        {
-          prop: 'realStartTime',
-          label: '实际开始日期',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 200
-        },
-        {
-          prop: 'realEndTime',
-          label: '实际完成日期',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 200
-        },
-        {
-          prop: 'isOverTime',
-          label: '是否超时',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 140,
-          slot: 'isOverTime'
-        },
-
-      ]
-    },
-  },
-  methods: {
-    aaa(date,data){
-      console.log(date,data);
+        tableData: [],
+        projectId: ''
+      };
     },
-    /* 表格数据源 */
-    async datasource({page, limit, where, parent}) {
-      // await this.getDictList('task_type')
-      const data = await projectsPageAPI({
-        pageNum: page,
-        size: 10,
-        parentId: parent?.id ?? '0',
-        ...where
-      });
-      this.showGantt = true
-      this.tableData = data.list.map(item => {
-        let obj = {
-          ...item,
-          parentId:item.id
-        }
-        return {
-          ...item,
-          level: 1,
-          text: item.name, // 名称-gantt必填字段
-          start_date:dayjs(item.planStartDate||new Date()).format('YYYY-MM-DD'), // 开始时间-gantt必填字段
-          duration: 10, //工作时长-gantt必填字段
-          executor: item.responsibleUserName
-        }
 
-      });
-      return data
-    },
-    /* 刷新表格 */
-    reload() {
-      this.$refs.table.reload({...this.form, size: 1, pageNum: 10});
+    computed: {
+      columns() {
+        return [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'name',
+            label: '任务名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 300
+          },
+          {
+            prop: 'responsibleUserName',
+            label: '执行人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 170
+            // formatter: (_row, _column, cellValue) => {
+            //   return !_row.responsibleUserList.length ? '' : _row.responsibleUserList.map(i => i.userName).join(',');
+            // }
+          },
+          {
+            prop: 'cost',
+            label: '费用(元)',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 150
+          },
+          {
+            prop: 'planStartDate',
+            label: '计划开始日期',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 190
+          },
+          {
+            prop: 'planEndDate',
+            label: '计划完成日期',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+          {
+            prop: 'realStartTime',
+            label: '实际开始日期',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+          {
+            prop: 'realEndTime',
+            label: '实际完成日期',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 200
+          },
+          {
+            prop: 'isOverTime',
+            label: '是否超时',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 140,
+            slot: 'isOverTime'
+          }
+        ];
+      }
     },
-  }
-}
-</script>
-
-
-<style scoped lang="scss">
-.box-container {
-  padding: 10px;
-  display: flex;
-  flex-direction: column;
-  justify-content: space-between;
-  height: calc(100vh - 116px);
-  width: calc(100%);
+    methods: {
+      /* 表格数据源 */
+      init(projectId) {
+        this.projectId = projectId;
+        this.reload();
+      },
 
-  .box-container-header {
-    background: #32b952;
-    margin-bottom: 10px;
-    flex: 1;
-    border-radius: 5px;
-    display: flex;
-    align-items: center;
-    justify-content: center;
+      /* 刷新表格 */
+      async reload() {
+        let startTime = '',
+          endTime = '';
+
+        // daterange
+        // year
+        // month
+        console.log(this.form.dateRange, 'form.dateRange');
+        if (this.form.dateRange) {
+          if (this.form.dateType == 'daterange') {
+            startTime = dayjs(this.form.dateRange[0]).format('YYYY-MM-DD');
+            endTime = dayjs(this.form.dateRange[1]).format('YYYY-MM-DD');
+          }
+          if (this.form.dateType == 'month') {
+            startTime = dayjs(this.form.dateRange).format('YYYY-MM-DD');
+            endTime = dayjs(this.form.dateRange).format('YYYY-MM-31')
+            console.log(startTime,'startTime')
+          }
+          if (this.form.dateType == 'year') {
+            startTime = dayjs(this.form.dateRange).format('YYYY-01-01');
+            endTime = dayjs(this.form.dateRange).format('YYYY-12-31')
+            console.log(startTime,'startTime')
+          }
+        }
 
-    span {
-      color: #ffffff;
-      font-size: 18px;
+        // startTime
+        // endTime
+        let relationAll = await getProjectCalender({
+          parentId: this.projectId,
+          startTime,
+          endTime
+        });
+        this.showGantt = true;
+        this.tableData = relationAll.data.map((item, index) => {
+          let duration = 10;
+          if (item.planStartDate && item.planEndDate) {
+            duration =
+              (new Date(item.planEndDate).getTime() -
+                new Date(item.planStartDate).getTime()) /
+              1000 /
+              60 /
+              60 /
+              24;
+            console.log(duration, 'duration');
+          }
+          return {
+            ...item,
+            open: true,
+            level: 1,
+            text: item.name, // 名称-gantt必填字段
+            start_date: dayjs(item.planStartDate || new Date()).format(
+              'YYYY-MM-DD'
+            ), // 开始时间-gantt必填字段
+            duration: duration, //工作时长-gantt必填字段
+            executor: item.name,
+            parent: item.parentId
+          };
+        });
+      }
     }
-    padding: 5px 0;
-  }
+  };
+</script>
 
-  .box-container-top {
+<style scoped lang="scss">
+  .box-container {
+    padding: 10px;
     display: flex;
     flex-direction: column;
-    flex: 0 0 55%;
-    width: 100%;
-    min-height: 280px;
-
-    .box-container-top-search {
-      width: 100%;
-      height: 50px;
-      margin-bottom: 8px;
-      background: #ffffff;
-      padding-left: 10px;
+    justify-content: space-between;
+    height: calc(100vh - 116px);
+    width: calc(100%);
+
+    .box-container-header {
+      background: #32b952;
+      margin-bottom: 10px;
+      border-radius: 5px;
       display: flex;
       align-items: center;
-      border-radius: 4px;
-      box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.15);
-    }
-    .box-container-top-cell {
-      justify-content: space-between;
-      display: flex;
-      flex: 1;
-      width: 100%;
-      .middle-cell {
-        flex: 1;
+      justify-content: center;
+      height: 40px;
 
+      span {
+        color: #ffffff;
+        font-size: 18px;
       }
+      padding: 5px 0;
+    }
 
-      // .middle-cell:nth-child(1) {
-      //   flex: 0 0 20%;
-      // }
+    .box-container-top {
+      display: flex;
+      flex-direction: column;
+      height: calc(100% - 40px);
 
-      // .middle-cell:nth-child(2) {
-      //   flex: 0 0 79%;
+      width: 100%;
 
+      .box-container-top-search {
+        width: 100%;
+        height: 50px;
+        margin-bottom: 8px;
+        background: #ffffff;
+        padding-left: 10px;
+        display: flex;
+        align-items: center;
+        border-radius: 4px;
+        box-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.15);
+      }
+      .box-container-top-cell {
+        justify-content: space-between;
+        display: flex;
+        height: calc(100% - 160px);
+
+        width: 100%;
+        .middle-cell {
+          flex: 1;
+        }
 
-      // }
+        // .middle-cell:nth-child(1) {
+        //   flex: 0 0 20%;
+        // }
 
+        // .middle-cell:nth-child(2) {
+        //   flex: 0 0 79%;
 
+        // }
+      }
     }
-  }
-
-
-  .box-container-footer {
-    margin-top: 10px;
-    display: flex;
-    width: 100%;
-    flex: 0 0 40%;
-    min-height: 280px;
-    min-width: 200px;
-  }
 
-  ::v-deep .el-calendar-day {
-    box-sizing: border-box;
-    padding: 5px;
-    min-height: 20px;
-    max-height: 40px;
-    border: none;
-  }
+    .box-container-footer {
+      margin-top: 10px;
+      display: flex;
+      width: 100%;
+      flex: 0 0 40%;
+      min-height: 280px;
+      min-width: 200px;
+    }
 
-  ::v-deep .el-card__body {
-    width: 100%;
-    height: 100%;
-  }
+    ::v-deep .el-calendar-day {
+      box-sizing: border-box;
+      padding: 5px;
+      min-height: 20px;
+      max-height: 40px;
+      border: none;
+    }
 
-  ::v-deep .el-calendar__body {
-    padding: 8px 20px 0;
+    ::v-deep .el-card__body {
+      width: 100%;
+      height: 100%;
+    }
 
-    table {
-      border: none;
+    ::v-deep .el-calendar__body {
+      padding: 8px 20px 0;
 
-      td {
+      table {
         border: none;
-      }
 
-      thead {
-        background: #f2f2f2 !important;
+        td {
+          border: none;
+        }
 
-        th {
-          padding: 10px 0;
+        thead {
+          background: #f2f2f2 !important;
+
+          th {
+            padding: 10px 0;
+          }
         }
       }
     }
 
-  }
-
-  .el-card + .el-card {
-    margin-top: 0;
-  }
-
-  ::v-deep .el-calendar-day {
-    display: flex;
-    justify-content: center;
-    align-items: center;
-  }
-  ::v-deep .el-calendar__header{
-    padding: 12px 2px;
-  }
-  ::v-deep .el-form-item{
-    margin-bottom: 0 !important;
-  }
-  .dateCellText {
+    .el-card + .el-card {
+      margin-top: 0;
+    }
 
+    ::v-deep .el-calendar-day {
+      display: flex;
+      justify-content: center;
+      align-items: center;
+    }
+    ::v-deep .el-calendar__header {
+      padding: 12px 2px;
+    }
+    ::v-deep .el-form-item {
+      margin-bottom: 0 !important;
+    }
+    .dateCellText {
+    }
   }
-}
 </style>

+ 286 - 258
src/views/project-manage/project-initiation/components/project-gantt.vue

@@ -4,287 +4,315 @@
   </div>
 </template>
 <script>
-import {Gantt} from './gantt';
-import "dhtmlx-gantt/codebase/dhtmlxgantt.css"
-import {proStatusEnum} from "@/enum/dict";
-import {deepClone} from "@/utils";
-let gantt = new Gantt();
-let i = 0
-export default {
-  name: 'gantt',
-  props: {
-    ganttTasks: {
-      type: Array,
-      default: () => {
-        return []
+  import { Gantt } from './gantt';
+  import 'dhtmlx-gantt/codebase/dhtmlxgantt.css';
+  import { proStatusEnum } from '@/enum/dict';
+  import { deepClone } from '@/utils';
+  let gantt = new Gantt();
+  let i = 0;
+  export default {
+    name: 'gantt',
+    props: {
+      ganttTasks: {
+        type: Array,
+        default: () => {
+          return [];
+        }
       }
     },
-  },
-  watch: {
-    ganttTasks: {
-      handler(val) {
-        this.initData()
-      },
-      deep: true
-    }
-  },
-  data() {
-    return {
-      ganttData: []
-    }
-  },
-  created() {
-    console.log(gantt);
-  },
-  mounted() {
-    this.initGantt() // gantt初始化配置
-    this.initData() // 数据format以及gantt reload
-  },
-
-  methods: {
-    initGantt() {
+    watch: {
+      ganttTasks: {
+        handler(val) {
+          this.initData();
+        },
+        deep: true
+      }
+    },
+    data() {
+      return {
+        ganttData: []
+      };
+    },
+    created() {
+      console.log(gantt);
+    },
+    mounted() {
+      this.initGantt(); // gantt初始化配置
+      this.initData(); // 数据format以及gantt reload
+    },
 
-      let _this = this
-      // 在初始化前设置配置项
-      // gantt只读
-      //设置图表区域的日期坐标最大值 var date = new Date(dateString.replace(/-/,"/"))
-      //  gantt.config.start_date = new Date("2020-04-08".replace(/-/,"/")) ;
-      //gantt.config.end_date = new Date("2020-04-18".replace(/-/,"/")) ; //结束时间需要+1天
-      gantt.config.readonly = true;
-      gantt.config.select_task = false;
-      gantt.config.autofit = false;
-      gantt.config.xml_date = "%Y/%m/%d";
-      // //设置x轴日期
-      // gantt.config.scale_unit = 'day'
-      // gantt.config.step = 1
-      // gantt.config.date_scale = '星期' + '%D'
-      gantt.config.columns = [
-        {
-          name: "name", width: 160, label: "名称", align: "left", tree: true,
-          template: function (obj) {
-            // 通过 template 回调可以指定返回内容值
-            return `
+    methods: {
+      initGantt() {
+        let _this = this;
+        // 在初始化前设置配置项
+        // gantt只读
+        //设置图表区域的日期坐标最大值 var date = new Date(dateString.replace(/-/,"/"))
+        //  gantt.config.start_date = new Date("2020-04-08".replace(/-/,"/")) ;
+        //gantt.config.end_date = new Date("2020-04-18".replace(/-/,"/")) ; //结束时间需要+1天
+        gantt.config.readonly = true;
+        gantt.config.select_task = false;
+        gantt.config.autofit = false;
+        gantt.config.xml_date = '%Y/%m/%d';
+        // //设置x轴日期
+        // gantt.config.scale_unit = 'day'
+        // gantt.config.step = 1
+        // gantt.config.date_scale = '星期' + '%D'
+        gantt.config.columns = [
+          {
+            name: 'name',
+            width: 160,
+            label: '名称',
+            align: 'left',
+            tree: true,
+            template: function (obj) {
+              // 通过 template 回调可以指定返回内容值
+              return `
                 <div class="gantt-span-${obj.level}" style="width:130px;text-overflow:ellipsis;overflow: hidden;">${obj.name}</div>
               `;
+            }
           },
-        },
- 
-      ];
-      let daysStyle = function (date) {
-        let todayDate = new Date().setHours(0, 0, 0, 0)
-        let paramsDate = new Date(date).setHours(0, 0, 0, 0)
-        if (todayDate === paramsDate) {
-          return "today";
-        }
-        if (date.getDay() === 0 || date.getDay() === 6) {
-          return "weekend";
-        }
-        return "";
-      };
-      gantt.config.scales = [
-        // {unit: "month", step: 1, format: "%Y/%M"},
-        {unit: "day", format: "%d", css:daysStyle},
-        {unit:"day",  step:1, date:"星期"+"%D" },
-      ];
-      //这里在时间轴表格内的cell上添加class
-      gantt.templates.timeline_cell_class = function (item, date) {
-        if (date.getDay() == 0 || date.getDay() == 6) {
-          return "weekend"
-        }
-      };
-      // 条形图里的文字
-      gantt.templates.task_text = function (start, end, task) {
-        return `<span style='text-align:left;'>执行人:${task.executor}</span>`;
-      };
-// 条形图自定义class
-      gantt.templates.task_class = function (start, end, task) {
-        return `task-${task.level}`
-      };
-      gantt.config.scale_height = 60;
-      gantt.config.task_height = 24;
-      gantt.config.row_height = 25;
-      gantt.config.min_column_width = 50;
-      gantt.config.show_task_cells = false
-      gantt.plugins({
-        marker: true,
-      });
-      let today = new Date();
-      gantt.addMarker({
-        start_date: today,
-        css: 'today',
-        text: '',
-      });
-      gantt.plugins({
-        tooltip: true
-      });
-// 自定义tooltip内容
-      gantt.templates.tooltip_text = function (start, end, task) {
-        const t = gantt;
-        return `<div style="font-size:14px;padding: 0 10px;width:250px;line-height:20px;white-space:normal;">
+          {
+            name: 'start_date',
+            width: 150,
+            label: '开始时间',
+            align: 'center'
+          },
+          {
+            name: 'planEndDate',
+            width: 150,
+            label: '结束时间',
+            align: 'center'
+          },
+          {
+            name: 'duration',
+            width: 80,
+            label: '工时(天)',
+            align: 'center'
+          }
+        ];
+        let daysStyle = function (date) {
+          let todayDate = new Date().setHours(0, 0, 0, 0);
+          let paramsDate = new Date(date).setHours(0, 0, 0, 0);
+          if (todayDate === paramsDate) {
+            return 'today';
+          }
+          if (date.getDay() === 0 || date.getDay() === 6) {
+            return 'weekend';
+          }
+          return '';
+        };
+        gantt.config.scales = [
+          // {unit: "month", step: 1, format: "%Y/%M"},
+          { unit: 'day', format: '%d', css: daysStyle },
+          { unit: 'day', step: 1, date: '星期' + '%D' }
+        ];
+        //这里在时间轴表格内的cell上添加class
+        gantt.templates.timeline_cell_class = function (item, date) {
+          if (date.getDay() == 0 || date.getDay() == 6) {
+            return 'weekend';
+          }
+        };
+        // 条形图里的文字
+        gantt.templates.task_text = function (start, end, task) {
+          return `<div style='text-align:left;'>&nbsp;&nbsp;&nbsp;名称:${task.executor}</div>`;
+        };
+        // 条形图自定义class
+        gantt.templates.task_class = function (start, end, task) {
+          return `task-${task.level}`;
+        };
+        gantt.config.scale_height = 60;
+        gantt.config.task_height = 24;
+        gantt.config.row_height = 25;
+        gantt.config.min_column_width = 50;
+        gantt.config.show_task_cells = false;
+        gantt.plugins({
+          marker: true
+        });
+        let today = new Date();
+        gantt.addMarker({
+          start_date: today,
+          css: 'today',
+          text: ''
+        });
+        gantt.plugins({
+          tooltip: true
+        });
+        // 自定义tooltip内容
+        gantt.templates.tooltip_text = function (start, end, task) {
+    //       <p style="margin: 4px 0;">当前进度:${
+    //   task.level == 5
+    //     ? proStatusEnum[task.status]?.label
+    //     : task.progress * 100 + '%'
+    // }</p>
+		// <p style="margin: 4px 0;">标准工时:${task.standardTime}</p>
+		// <p style="margin: 4px 0;">实际工时:${task.actualTime}</p>
+          const t = gantt;
+          return `<div style="font-size:14px;padding: 0 10px;width:250px;line-height:20px;white-space:normal;">
 		<p style="font-weight:bold;margin: 8px 0;">名称:${task.text}</p>
-		<p style="margin: 4px 0;">当前进度:${task.level == 5 ? proStatusEnum[task.status]?.label : task.progress * 100 + '%'}</p>
-		<p style="margin: 4px 0;">标准工时:${task.standardTime}</p>
-		<p style="margin: 4px 0;">实际工时:${task.actualTime}</p>
+
 		<p style="margin: 4px 0;">状态:${proStatusEnum[task.status]?.label}</p>
 	</div>`;
-      }
-      gantt.attachEvent("onTaskClick", function(id,e){
-        let box = document.querySelector('.gantt_tooltip');
-        if (box) {
-          box.parentNode.removeChild(box);
-        }
-        let classList = e.target.className.split(' ')
-        // 这里自定义了展开/收起树形的点击事件
-        if (classList.includes('gantt_open')) {
-          gantt.open(id); // 展开
-          return true
-        }
-        if (classList.includes('gantt_close')) {
-          gantt.close(id); // 收起
-          return true
-        }
-        // 这里是其他的点击事件
-        let task = _this.ganttData.find(item => {return item.id == id})
-        if (task.taskType === 'stage') {
-          // toDo()
-          return true
-        }
-      });
-      gantt.i18n.setLocale("cn");
-      // 初始化gantt
-      gantt.init(this.$refs.gantt);
-      // 绑定数据
-      gantt.parse({
-        data: [], // 时间轴上横条的数据
-        link: [] // 连接线的数据
-      });
-    },
-    reload() {
-      console.log('重新渲染',this.ganttData);
-      gantt.clearAll();// 从甘特图中删除所有任务和其他元素(包括标记)
-      this.ganttData = deepClone(this.ganttData)
-      gantt.parse({
-        data: this.ganttData,
-        link: []
-      }); // 数据解析
-      gantt.render(); // 呈现整个甘特图
-    },
-    getGanttData() {
-      // toDo
-      // formatGanttData()
+        };
+        gantt.attachEvent('onTaskClick', function (id, e) {
+          let box = document.querySelector('.gantt_tooltip');
+          if (box) {
+            box.parentNode.removeChild(box);
+          }
+          let classList = e.target.className.split(' ');
+          // 这里自定义了展开/收起树形的点击事件
+          if (classList.includes('gantt_open')) {
+            gantt.open(id); // 展开
+            return true;
+          }
+          if (classList.includes('gantt_close')) {
+            gantt.close(id); // 收起
+            return true;
+          }
+          // 这里是其他的点击事件
+          let task = _this.ganttData.find((item) => {
+            return item.id == id;
+          });
+          if (task.taskType === 'stage') {
+            // toDo()
+            return true;
+          }
+        });
+        gantt.i18n.setLocale('cn');
+        // 初始化gantt
+        gantt.init(this.$refs.gantt);
+        // 绑定数据
+        gantt.parse({
+          data: [], // 时间轴上横条的数据
+          link: [] // 连接线的数据
+        });
+      },
+      reload() {
+        console.log('重新渲染', this.ganttData);
+        gantt.clearAll(); // 从甘特图中删除所有任务和其他元素(包括标记)
+        this.ganttData = deepClone(this.ganttData);
+        gantt.parse({
+          data: this.ganttData,
+          link: []
+        }); // 数据解析
+        gantt.render(); // 呈现整个甘特图
+      },
+      getGanttData() {
+        // toDo
+        // formatGanttData()
 
-      this.ganttData = this.ganttTasks
-      this.reload()
-    },
-    initData() {
-      this.ganttData = this.ganttTasks.map((current, ind, arry) => {
-        let newObj = {}
-        if (current.level) { //存在type字段 说明非一级菜单,判断阶段的具体类型 设置不同颜色
-          if (current.level == 1) { //项目
-            newObj = Object.assign({}, current, {'color': '#fcca02'})
-          } else if (current.level == 2) { //项目阶段
-            newObj = Object.assign({}, current, {'color': '#fec0dc'})
-          } else if (current.level == 3) { //计划
-            newObj = Object.assign({}, current, {'color': '#62ddd4'})
-          } else if (current.level == 4) {//计划节点
-            newObj = Object.assign({}, current, {'color': '#d1a6ff'})
-          } else if (current.level == 5) {//任务
-            newObj = Object.assign({}, current, {'color': '#0e85fa'})
+        this.ganttData = this.ganttTasks;
+        this.reload();
+      },
+      initData() {
+        this.ganttData = this.ganttTasks.map((current, ind, arry) => {
+          let newObj = {};
+          if (current.level) {
+            //存在type字段 说明非一级菜单,判断阶段的具体类型 设置不同颜色
+            if (current.level == 1) {
+              //项目
+              newObj = Object.assign({}, current, { color: '#fcca02' });
+            } else if (current.level == 2) {
+              //项目阶段
+              newObj = Object.assign({}, current, { color: '#fec0dc' });
+            } else if (current.level == 3) {
+              //计划
+              newObj = Object.assign({}, current, { color: '#62ddd4' });
+            } else if (current.level == 4) {
+              //计划节点
+              newObj = Object.assign({}, current, { color: '#d1a6ff' });
+            } else if (current.level == 5) {
+              //任务
+              newObj = Object.assign({}, current, { color: '#0e85fa' });
+            }
+          } else {
+            //默认色
+            newObj = Object.assign({}, current, { color: '#5b0b83' });
           }
-        } else { //默认色
-          newObj = Object.assign({}, current, {'color': '#5b0b83'})
-        }
 
-        return newObj
-      })
-      console.log(this.ganttData);
-      this.reload()
+          return newObj;
+        });
+        console.log(this.ganttData);
+        this.reload();
+      }
     },
-
-
-  },
-  activated() {
-    console.log(gantt,i++);
-    gantt.render(); // 呈现整个甘特图
-  }
-}
+    activated() {
+      console.log(gantt, i++);
+      gantt.render(); // 呈现整个甘特图
+    }
+  };
 </script>
 <style lang="less" scoped>
-/*@import "dhtmlx-gantt/codebase/dhtmlxgantt.css"*/
-.gantt-box {
-  width: calc(100%);
-
-  height: calc(100%);
-}
-.gantt-container {
-  width: calc(100%);
-
-  height: calc(100%);
-}
-
+  /*@import "dhtmlx-gantt/codebase/dhtmlxgantt.css"*/
+  .gantt-box {
+    width: calc(100%);
 
+    height: calc(100%);
+  }
+  .gantt-container {
+    width: calc(100%);
 
+    height: calc(100%);
+  }
 
-/* 周末高亮 */
-/deep/ .weekend {
-  background: #F8F8F8;
-  color: #676767 !important;
-  // height: 47px!important;
-}
+  /* 周末高亮 */
+  /deep/ .weekend {
+    background: #f8f8f8;
+    color: #676767 !important;
+    // height: 47px!important;
+  }
 
-/* 今日高亮 */
-/deep/ .gantt_task_scale {
-  .gantt_scale_line > .gantt_scale_cell {
-    color: #333333;
+  /* 今日高亮 */
+  /deep/ .gantt_task_scale {
+    .gantt_scale_line > .gantt_scale_cell {
+      color: #333333;
 
-    &.today {
-      background: #72b9ff;
-      color: #FFFFFF;
+      &.today {
+        background: #72b9ff;
+        color: #ffffff;
+      }
     }
   }
-}
-/* 去掉文件夹图标 */
-/deep/ .gantt_tree_icon {
-  &.gantt_folder_closed, &.gantt_file, &.gantt_folder_open {
-    display:none
+  /* 去掉文件夹图标 */
+  /deep/ .gantt_tree_icon {
+    &.gantt_folder_closed,
+    &.gantt_file,
+    &.gantt_folder_open {
+      display: none;
+    }
   }
-}
-/* 把展开收起图标替换成element-ui的icon */
-/* 这里没有找到在js中配置图标的方法,为省事,使用css */
-/* 扒了element-ui的icon样式表 */
-/deep/ .gantt_tree_icon.gantt_open {
-  background-image: none;
-  font-family: element-icons!important;
-  speak: none;
-  font-style: normal;
-  font-weight: 400;
-  font-variant: normal;
-  text-transform: none;
-  vertical-align: baseline;
-  display: inline-block;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  &::before {
-    content: "\e6df";
+  /* 把展开收起图标替换成element-ui的icon */
+  /* 这里没有找到在js中配置图标的方法,为省事,使用css */
+  /* 扒了element-ui的icon样式表 */
+  /deep/ .gantt_tree_icon.gantt_open {
+    background-image: none;
+    font-family: element-icons !important;
+    speak: none;
+    font-style: normal;
+    font-weight: 400;
+    font-variant: normal;
+    text-transform: none;
+    vertical-align: baseline;
+    display: inline-block;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+    &::before {
+      content: '\e6df';
+    }
   }
-}
-/deep/ .gantt_tree_icon.gantt_close {
-  background-image: none;
-  font-family: element-icons!important;
-  speak: none;
-  font-style: normal;
-  font-weight: 400;
-  font-variant: normal;
-  text-transform: none;
-  vertical-align: baseline;
-  display: inline-block;
-  -webkit-font-smoothing: antialiased;
-  -moz-osx-font-smoothing: grayscale;
-  &::before {
-    content: "\e6e1";
+  /deep/ .gantt_tree_icon.gantt_close {
+    background-image: none;
+    font-family: element-icons !important;
+    speak: none;
+    font-style: normal;
+    font-weight: 400;
+    font-variant: normal;
+    text-transform: none;
+    vertical-align: baseline;
+    display: inline-block;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+    &::before {
+      content: '\e6e1';
+    }
   }
-}
-
-
 </style>
-

+ 1 - 19
src/views/project-manage/project-initiation/components/projectInfoTable.vue

@@ -22,19 +22,6 @@
         tool-class="ele-toolbar-form"
         cache-key="eomContactPageTable"
       >
-<!--        &lt;!&ndash; 表头工具栏 &ndash;&gt;-->
-<!--        <template v-slot:toolbar>-->
-<!--          <el-button-->
-<!--            v-if="dialogType!=='view'"-->
-<!--            size="small"-->
-<!--            type="primary"-->
-<!--            icon="el-icon-plus"-->
-<!--            class="ele-btn-icon"-->
-<!--            @click="handleAddInfo">-->
-<!--            新增项目阶段-->
-<!--          </el-button>-->
-<!--        </template>-->
-
         <template v-slot:action="{row,$index}">
           <el-popconfirm
             class="ele-action"
@@ -103,12 +90,7 @@
                 :value="item.id">
               </el-option>
             </el-select>
-            <!--            <personSelect-->
-            <!--              :disabled="dialogType=='view'"-->
-            <!--              :ref="'directorRef'+$index"-->
-            <!--              v-model="row.responsibleUserIds"-->
-            <!--              :init="false"-->
-            <!--              @selfChange="(val, info)=>personChange(val,info,$index)"/>-->
+        
           </el-form-item>
         </template>
         <template v-slot:responsibleDeptId="{row,$index}" v-if="dialogType!=='view'">

+ 10 - 5
src/views/project-manage/project-initiation/index.vue

@@ -540,8 +540,8 @@
       console.log(111);
     },
     watch: {
-      $route(){
-        this.reload&&this.reload()
+      $route() {
+        this.reload && this.reload();
       }
     },
     methods: {
@@ -584,12 +584,16 @@
         await this.getDictList('pro_projects_type');
         await this.getDictList('pro_projects_budget_unit');
         // /project-manage/myProject
-        const api=this.$route.path=='/project-manage'?projectsPageAPI:getMyProjectsPage
+        const api =
+          this.$route.path == '/project-manage'
+            ? projectsPageAPI
+            : getMyProjectsPage;
         return api({
           pageNum: page,
           size: limit,
           parentId: parent?.id ?? '0',
-          ...where
+          ...where,
+          type: this.treeId
         });
       },
       onDone(row) {
@@ -601,7 +605,8 @@
         this.$refs.table.reRenderTable();
       },
       handleNodeClick(data, node) {
-        this.reload({ type: data.id });
+        this.treeId = data.id;
+        this.reload();
       },
       /* 显示编辑 */
       openEdit(row = {}, type) {

+ 6 - 1
src/views/project-manage/task-manage/index.vue

@@ -412,6 +412,11 @@ export default {
   },
   async created() {
   },
+  watch: {
+      $route() {
+        this.reload && this.reload();
+      }
+    },
   methods: {
     getDictV(code, val) {
       if (!this.dictList[code]) return '';
@@ -430,7 +435,7 @@ export default {
     /* 表格数据源 */
     async datasource({page, limit, where, parent}) {
       await this.getDictList('task_type')
-      const api=this.$route.path=='/task/taskList'?projectsTaskPageAPI:myProjectsTaskPageAPI
+      const api=this.$route.path=='/task/myTaskList'?myProjectsTaskPageAPI:projectsTaskPageAPI
       return api({
         pageNum: page,
         size: limit,