Lijy 8 mesiacov pred
rodič
commit
fe32687125

+ 384 - 0
fhKeeper/formulahousekeeper/timesheet/src/components/selectPersonnel.vue

@@ -0,0 +1,384 @@
+<template>
+  <el-select v-model="selectPersonnelValue" filterable @visible-change="toggleSelectPrefix" remote
+    :remote-method="userListRemotemethod" :multiple="multiple" @focus="userFocus" :size="size" collapse-tags
+    @change="updateValue" clearable :ref="`select${timeRef}`" :style="`width: ${width}`" class="custom-select">
+    <template #prefix>
+      <div style="height: 100%;display: flex;align-items: center;">
+        <!-- 单选 -->
+        <template v-if="!multiple">
+          <div v-if="selectPrefixFlg" class="selectSingleChoice" :style="sizeStyle[size]">
+            <template v-if="getSelectedLabel == '请选择'">
+              <span class="pleaseChoose">请选择</span>
+            </template>
+            <template v-else>
+              {{ getSelectedLabel }}
+            </template>
+          </div>
+        </template>
+        <!-- 多选 -->
+        <template v-if="multiple">
+          <div class="selectMultiple" :style="sizeStyle[size]">
+            <template v-if="value.length == 0">
+              <span class="textSpan pleaseChoose">请选择</span>
+            </template>
+            <template v-else>
+              <el-tag closable type="info" :size="size" class="narrow" style="margin: 0;" @close="userTagClose">{{
+                getSelectedLabel
+              }}</el-tag>
+              <el-tag type="info" :size="size" v-if="value.length > 1" class="narrow" style="margin: 0;">+ {{
+                value.length - 1 }}</el-tag>
+            </template>
+          </div>
+        </template>
+        <!-- 占位符 -->
+        <span></span>
+      </div>
+    </template>
+
+    <!-- 主体显示内容 -->
+    <div :ref="`mySelectUser${timeRef}`" class="select-user-class">
+      <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id">
+        <span class="floatLeft">
+          <TranslationOpenDataText type='userName' :openid='item.name'></TranslationOpenDataText>
+        </span>
+        <span class="jonumberUser">{{ item.jobNumber }}</span>
+      </el-option>
+      <!-- 下滚加载提示 -->
+      <div class="itemsLoading" v-if="loadingInProgress">
+        加载中...
+      </div>
+    </div>
+  </el-select>
+</template>
+
+<script>
+export default {
+  name: 'HelloWorld',
+  props: {
+    value: { // 双向数据绑定
+      type: [String, Number, Array],
+      required: true
+    },
+    size: { // 尺寸
+      type: String,
+      default: 'small'
+    },
+    multiple: { // 是否多选
+      type: Boolean,
+      default: () => false
+    },
+    width: { // 宽度
+      type: String,
+      default: '200px'
+    }
+  },
+  data() {
+    return {
+      options: [],
+      selectPersonnelValue: this.value,
+      selectPrefixFlg: true,
+      timeRef: new Date().getTime(),
+      updateTrigger: 0, // 用来强制触发计算属性
+      sizeStyle: {
+        mini: `height: 24px;`,
+        small: `height: 28px`,
+        medium: `height: 32px`,
+      },
+      keyword: '',
+      loadingInProgress: false,
+      userListloading: false,
+      userPageIndex: 1,
+      userPageSize: 50,
+      userTotal: 0,
+      cursor: 1,
+    }
+  },
+  watch: {
+    selectPersonnelValue: {
+      handler() {
+        this.$nextTick(() => {
+          if (this.multiple) {
+            this.getSelectedLabel
+          }
+        });
+      },
+      deep: true,
+      immediate: true
+    }
+  },
+  computed: {
+    getSelectedLabel() {
+      this.updateTrigger;
+
+      if (!this.multiple) {
+        const selectedOption = this.options.find(item => item.id === this.selectPersonnelValue)
+        return selectedOption ? selectedOption.name : '请选择'
+      } else if (this.multiple) {
+        if (this.selectPersonnelValue.length === 0) {
+          return '请选择'
+        }
+        const selectVal = this.selectPersonnelValue[0]
+        const selectedOption = this.options.find(item => item.id === selectVal)
+        return selectedOption ? selectedOption.name : '请选择'
+      }
+
+      return '请选择'
+    }
+  },
+  methods: {
+    userListRemotemethod: _.debounce(function (val) {
+      this.newProjectListPage = 1
+      this.getUserList(val)
+    }, 500),
+    // 随机取名字4-6个字
+    getRandomName() {
+      const firstNames = ['张', '李', '王', '刘', '陈', '杨', '黄', '赵'];
+      const lastNames = ['伟', '芳', '娜', '敏', '军', '洋', '静', '磊'];
+
+      const nameLength = Math.floor(Math.random() * 3) + 4; // 生成4到6之间的随机数
+      let name = '';
+
+      for (let i = 0; i < nameLength; i++) {
+        if (i % 2 === 0) {
+          name += firstNames[Math.floor(Math.random() * firstNames.length)];
+        } else {
+          name += lastNames[Math.floor(Math.random() * lastNames.length)];
+        }
+      }
+
+      return name;
+    },
+    uniqueById(arr) {
+      return arr.reduce((accumulator, current) => {
+        if (!accumulator.some(item => item.id === current.id)) {
+          accumulator.push(current);
+        }
+        return accumulator;
+      }, []);
+    },
+    userTagClose() {
+      this.selectPersonnelValue = this.selectPersonnelValue.splice(0, 1)
+    },
+    userFocus() {
+      console.log('失去焦点了', this.selectPrefixFlg)
+      if (this.selectPrefixFlg) {
+        this.userPageIndex = 1
+        this.getUserList('', false)
+      }
+    },
+    addUserList() {
+      this.loadingInProgress = true
+      this.postData(`/user/getSimpleActiveUserListPage`, {
+        pageIndex: this.userPageIndex,
+        pageSize: this.userPageSize,
+        departmentId: '',
+        keyword: this.keyword,
+        cursor: '',
+        userIds: this.multiple ? this.selectPersonnelValue.join(',') : this.selectPersonnelValue
+      }).then(res => {
+        const { data = [], total = 0 } = res.data
+        this.userTotal = total
+        // this.options = [...new Set([...this.options, ...data].map(JSON.stringify))].map(JSON.parse);
+        // this.options = this.uniqueById([...this.options, ...newData]) 
+        const newData = data.map((item) => {
+          return {
+            ...item,
+            // name: this.getRandomName()
+          }
+        })
+        this.options = this.uniqueById([...this.options, ...newData]) 
+        console.log(this.options.length, '<==== this.options')
+      }).finally(() => {
+        setTimeout(() => {
+          this.loadingInProgress = false
+        }, 500)
+      })
+    },
+    getUserList(keyword = '', flag = true) {
+      this.keyword = keyword
+      this.userListloading = flag
+      this.postData(`/user/getSimpleActiveUserListPage`, {
+        pageIndex: this.userPageIndex,
+        pageSize: this.userPageSize,
+        departmentId: '',
+        keyword,
+        cursor: '',
+        userIds: this.multiple ? this.selectPersonnelValue.join(',') : this.selectPersonnelValue
+      }).then(res => {
+        const { data = [], total = 0 } = res.data
+        this.userTotal = total
+        // this.options = [...new Set(data.map(JSON.stringify))].map(JSON.parse);
+        // this.options = this.uniqueById(data);
+        const dataVal = data.map((item) => {
+          return {
+            ...item,
+            // name: this.getRandomName()
+          }
+        })
+        this.options = this.uniqueById(dataVal);
+      }).finally(() => {
+        this.userListloading = false
+      })
+    },
+    async postData(urls, param) { // 单独封装 post 请求 方法
+      return new Promise((resolve, reject) => {
+        this.http.post(urls, { ...param },
+          res => {
+            if (res.code == 'ok') {
+              resolve(res)
+            } else {
+              this.$message({
+                message: res.msg,
+                type: 'error'
+              })
+              reject(res)
+            }
+            resolve(res)
+          },
+          error => {
+            this.$message({
+              message: error,
+              type: "error"
+            });
+            reject(error)
+          }
+        )
+      });
+    },
+    handleScroll(event) {
+      const container = event.target;
+      const { scrollTop, scrollHeight, clientHeight } = container;
+
+      const totalPage = Math.ceil(this.userTotal / this.userPageSize);
+      if (scrollTop + clientHeight >= scrollHeight - 20 && this.userPageIndex < totalPage && !this.loadingInProgress) {
+        this.loadMoreData()
+      }
+    },
+    loadMoreData() {
+      this.userPageIndex += 1;
+      this.addUserList();
+    },
+    toggleSelectPrefix(value) {
+      this.selectPrefixFlg = !value
+      console.log(this.selectPrefixFlg, '<===== selectPrefixFlg')
+      if (value) {
+        this.$nextTick(() => {
+          this.addScrollListener();
+        });
+      } else {
+        this.removeScrollListener();
+      }
+    },
+    addScrollListener() {
+      const container = this.$refs[`mySelectUser${this.timeRef}`];
+      const scrollbar = container.closest('.el-scrollbar__wrap');
+      if (scrollbar) {
+        this.loadingInProgressHight = scrollbar.clientHeight - 40
+        this.removeScrollListener();
+        const debouncedHandleScroll = _.debounce(this.handleScroll, 200);
+        scrollbar.addEventListener('scroll', debouncedHandleScroll);
+        this.scrollListener = debouncedHandleScroll;
+      }
+    },
+
+    removeScrollListener() {
+      const container = this.$refs[`mySelectUser${this.timeRef}`];
+      const scrollbar = container.closest('.el-scrollbar__wrap');
+      if (scrollbar && this.scrollListener) {
+        scrollbar.removeEventListener('scroll', this.scrollListener);
+        this.scrollListener = null;
+      }
+    },
+    updateValue(value) { // 更新数据
+      if (this.multiple) {
+        this.updateTrigger += 1 // 强行触发计算属性
+      }
+
+      this.$emit('input', value);
+      this.$emit('change', value);
+    },
+  },
+  mounted() {
+    this.$nextTick(() => {
+      this.getUserList()
+    });
+  },
+  beforeDestroy() {
+    this.removeScrollListener();
+  }
+}
+</script>
+
+<style>
+.custom-select input::placeholder {
+  color: transparent !important;
+}
+</style>
+
+<style scoped lang="scss">
+.select-base {
+  position: absolute;
+  width: auto;
+  display: flex;
+  align-items: center;
+  background: #fff;
+  box-sizing: border-box;
+  color: #606266;
+  white-space: nowrap;
+}
+
+.selectSingleChoice {
+  @extend .select-base;
+  left: 26px;
+  transform-origin: left;
+}
+
+.selectMultiple {
+  @extend .select-base;
+  left: 0;
+  z-index: 10;
+  min-width: 40px;
+}
+
+.select-user-class {
+  position: relative;
+
+  .itemsLoading {
+    position: absolute;
+    left: 0;
+    bottom: -2px;
+    width: 100%;
+    text-align: center;
+    padding: 10px;
+    background: #fff;
+    box-shadow: 0px -4px 20px 0px #999;
+    font-size: 12px;
+    color: #999;
+    z-index: 99;
+    box-sizing: border-box;
+  }
+}
+
+.narrow {
+  transform: scale(0.9);
+  transform-origin: left;
+}
+
+.selectMultiple .textSpan {
+  position: relative;
+  left: 26px;
+}
+
+.pleaseChoose {
+  color: #C0C4CC;
+}
+
+.floatLeft {
+  float: left;
+}
+
+.jonumberUser {
+  float: right;
+  color: #8492a6;
+}
+</style>

+ 192 - 0
fhKeeper/formulahousekeeper/timesheet/src/components/selectProject.vue

@@ -0,0 +1,192 @@
+<template>
+  <el-select v-model="selectedValue" size="mini" filterable remote @change="updateValue"
+    :remote-method="projectListRemotemethod" :loading="newProjectListLoading" @visible-change="visibleChangeProjrct" @focus="peojectFocus">
+    <div ref="mySelectProject" class="select-project-class">
+      <el-option v-for="item in newProjectList" :key="item.id" :label="item.projectName + '\u3000' + item.projectCode"
+        :value="item.id">
+        <span style="float: left; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
+        <span style="float: right;margin-left: 20px">{{ item.projectName }}</span>
+      </el-option>
+      <div class="itemsLoading" v-if="loadingInProgress">
+        加载中...
+      </div>
+    </div>
+  </el-select>
+</template>
+
+<script>
+export default {
+  name: 'selectProject',
+  props: {
+    value: {
+      type: [String, Number],
+      required: true
+    }
+  },
+  data() {
+    return {
+      newProjectListLoading: false,
+      newProjectList: [],
+      selectedValue: this.value,
+      newProjectListPage: 1,
+      newProjectListSize: 20,
+      newProjectListTotal: 0,
+      loadingInProgress: false,
+      loadingInProgressHight: 0,
+      refRollVal: null,
+      scrollListener: null,
+      infoString: ''
+    }
+  },
+  watch: {
+    value(newValue) {
+      this.selectedValue = newValue;
+    },
+    selectedValue(newValue) {
+      this.$emit('input', newValue);
+    }
+  },
+  methods: {
+    projectListRemotemethod: _.debounce(function (val) {
+      this.newProjectListPage = 1
+      this.getNewProjectList(val)
+    }, 300),
+    peojectFocus() {
+      this.newProjectListPage = 1
+      this.getNewProjectList()
+    },
+    getNewProjectList(infoString = '') {
+      this.infoString = infoString
+      this.newProjectListLoading = true
+      this.postData(`/project/getProjectListByPage`, {
+        pageIndex: this.newProjectListPage,
+        pageSize: this.newProjectListSize,
+        id: this.curProjectId,
+        forReport: 0,
+        infoString,
+      }).then((res) => {
+        this.newProjectList = res.data.data
+        this.newProjectListTotal = res.data.total
+      }).finally(() => {
+        this.newProjectListLoading = false
+      })
+    },
+    addNewProjectList() {
+      this.loadingInProgress = true
+      this.postData(`/project/getProjectListByPage`, {
+        pageIndex: this.newProjectListPage,
+        pageSize: this.newProjectListSize,
+        id: this.curProjectId,
+        forReport: 0,
+        infoString: this.infoString,
+      }).then((res) => {
+        this.newProjectList = [...this.newProjectList, ...res.data.data]
+      }).finally(() => {
+        setTimeout(() => {
+          this.loadingInProgress = false
+        }, 500)
+      })
+    },
+    handleScroll(event) {
+      const container = event.target;
+      const { scrollTop, scrollHeight, clientHeight } = container;
+
+      const totalPage = Math.ceil(this.newProjectListTotal / this.newProjectListSize);
+      if (scrollTop + clientHeight >= scrollHeight - 20 && this.newProjectListPage < totalPage && !this.loadingInProgress) {
+        this.loadMoreData()
+      }
+    },
+    loadMoreData() {
+      this.newProjectListPage += 1;
+      this.addNewProjectList();
+    },
+    visibleChangeProjrct(flag) {
+      if (flag) {
+        this.$nextTick(() => {
+          this.addScrollListener();
+        });
+      } else {
+        this.removeScrollListener();
+      }
+    },
+    addScrollListener() {
+      const container = this.$refs.mySelectProject;
+      const scrollbar = container.closest('.el-scrollbar__wrap');
+      if (scrollbar) {
+        this.loadingInProgressHight = scrollbar.clientHeight - 40
+        this.removeScrollListener();
+        const debouncedHandleScroll = _.debounce(this.handleScroll, 200);
+        scrollbar.addEventListener('scroll', debouncedHandleScroll);
+        this.scrollListener = debouncedHandleScroll;
+      }
+    },
+
+    removeScrollListener() {
+      const container = this.$refs.mySelectProject;
+      const scrollbar = container.closest('.el-scrollbar__wrap');
+      if (scrollbar && this.scrollListener) {
+        scrollbar.removeEventListener('scroll', this.scrollListener);
+        this.scrollListener = null;
+      }
+    },
+    async postData(urls, param) {
+      return new Promise((resolve, reject) => {
+        this.http.post(urls, { ...param },
+          res => {
+            if (res.code == 'ok') {
+              resolve(res)
+            } else {
+              this.$message({
+                message: res.msg,
+                type: 'error'
+              })
+              reject(res)
+            }
+            resolve(res)
+          },
+          error => {
+            this.$message({
+              message: error,
+              type: "error"
+            });
+            reject(error)
+          }
+        )
+      });
+    },
+    updateValue(value) {
+      this.$emit('input', value);
+      this.$emit('change', value);
+    }
+  },
+  created() {
+
+  },
+  mounted() {
+    this.getNewProjectList()
+  },
+  beforeDestroy() {
+    this.removeScrollListener();
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+  .select-project-class {
+    position: relative;
+    .itemsLoading {
+      position: absolute;
+      left: 0;
+      bottom: -2px;
+      width: 100%;
+      text-align: center;
+      padding: 10px;
+      background: #fff;
+      box-shadow: 0px -4px 20px 0px #999;
+      font-size: 12px;
+      color: #999;
+      z-index: 99;
+      box-sizing: border-box;
+    }
+  }
+</style>

+ 3 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/project/info.vue

@@ -79,7 +79,7 @@
                     <div v-if="user.companyId == '936'">
                         <el-row :gutter="10" >
                             <el-col :span="5" ><span class="gray_label">{{ $t('contractno') }}:</span></el-col><el-col :span="7" ></el-col>
-                            <el-col :span="18" ><span>{{project.projectSeparate.contractCode}}</span></el-col>
+                            <el-col :span="18" ><span>{{project.projectSeparate && project.projectSeparate.contractCode}}</span></el-col>
                         </el-row>
                         <el-row :gutter="10">
                             <el-col :span="5" ><span class="gray_label">{{ $t('warrantystartime') }}:</span></el-col><el-col :span="7" >
@@ -811,7 +811,8 @@
                 mileStoneList:[],
                 reverse:false,
                 project:{
-                    auditorList: []
+                    auditorList: [],
+                    projectSeparate: {}
                 },
                 addFolderDialog: false,
                 upLoading:false,

+ 12 - 3
fhKeeper/formulahousekeeper/timesheet/src/views/project/list.vue

@@ -131,7 +131,9 @@
                         </el-option>
                     </el-select> 
 
-                    <selectCat v-if="user.userNameNeedTranslate == 1" :filterable="true" :size="'mini'" :subject="users" :subjectId="inchagerId" :distinction="'1'" :clearable="true" @selectCal="selectCal"></selectCat>
+                    <selectCat v-if="user.userNameNeedTranslate == 1 && attemptFields != '223'" :filterable="true" :size="'mini'" :subject="users" :subjectId="inchagerId" :distinction="'1'" :clearable="true" @selectCal="selectCal"></selectCat>
+
+                    <selectPersonnel v-model="inchagerId" clearable @change="manageSelect" size="small" v-if="user.userNameNeedTranslate == 1 && attemptFields == '223'"></selectPersonnel>
 
                 </el-form-item>
                 <el-form-item>
@@ -144,8 +146,10 @@
                         </el-option>
                     </el-select>
 
-                    <selectCat v-if="user.userNameNeedTranslate == 1" :filterable="true" :size="'mini'" :subject="users" :subjectId="participationId" :distinction="'2'" :clearable="true" @selectCal="selectCal"></selectCat>
+                    <selectCat v-if="user.userNameNeedTranslate == 1 && attemptFields != '223' " :filterable="true" :size="'mini'" :subject="users" :subjectId="participationId" :distinction="'2'" :clearable="true" @selectCal="selectCal"></selectCat>
 
+                    
+                    <selectPersonnel v-model="participationId" clearable @change="participationSelect" size="small" v-if="user.userNameNeedTranslate == 1 && attemptFields == '223'"></selectPersonnel>
                 </el-form-item>
                 <!-- 部门筛选 -->
                 <el-form-item v-if="user.timeType.projectWithDept">
@@ -1781,16 +1785,21 @@ a {
     import vueCascader from "@/components/cascader.vue"
     import vueCascadeSelection from "@/components/cascadeSelection.vue"
     import DepartmentSelectionPersonnel from "@/components/departmentSelectionPersonnel.vue"
+
+    // 尝试字段
+    import selectPersonnel from "@/components/selectPersonnel.vue"
     export default {
         components:{
             projectgantt,
             selectCat,
             vueCascader,
             vueCascadeSelection,
-            DepartmentSelectionPersonnel
+            DepartmentSelectionPersonnel,
+            selectPersonnel
         },
         data() {
             return {
+                attemptFields: localStorage.getItem('attemptFields'),
                 importTaskDialog: false,
                 manDaySetting:{},
                 projectManDaySettingDialog: false,

+ 86 - 26
fhKeeper/formulahousekeeper/timesheet/src/views/project/projectInside.vue

@@ -6,12 +6,14 @@
             <el-tab-pane :label="$t('maincontent')" name="project" @click="null" disabled=true>
                 <template slot="label">
                     <i type="default" size="mini"  class="el-icon-arrow-left" @click="toList" style="margin-left:10px;cursor:pointer;"></i>
-                    <el-select v-model="curProjectId"  size="mini" class="projectCls" @change="onProjectChange" filterable>
+                    <!-- <el-select v-model="curProjectId"  size="mini" class="projectCls" @change="onProjectChange" filterable>
                         <el-option v-for="item in projectList"  :key="item.id" :label="item.projectName + '\u3000' + item.projectCode" :value="item.id">
                             <span style="float: left; color: #8492a6; font-size: 13px;">{{ item.projectCode }}</span>
                             <span style="float: right;margin-left: 20px">{{ item.projectName }}</span>
                         </el-option>
-                    </el-select>
+                    </el-select> -->
+                    
+                    <select-project v-model="curProjectId" class="projectCls" @change="onProjectChange"></select-project>
                     
                     <el-dropdown trigger="click" style="margin-right:30px;color:#262626;cursor:pointer;" v-if="projectCreatorId == user.id || projectInchargerId == user.id || permissions.projectManagement || isManageDept">
                         <i class="iconfont firerock-iconcaidan" ></i>
@@ -345,12 +347,23 @@
                     </el-main>
                 </el-container>
             </el-tab-pane>
-            <el-tab-pane :label="$t('fileCenter')" name="files"><FileCenter ref="fileCenter"></FileCenter></el-tab-pane>
-            <el-tab-pane :label="$t('overviewoftheproject')" name="info"><ProjectInfo ref="projectInfo" @basecost-change="changeBase"></ProjectInfo></el-tab-pane>
-            <el-tab-pane :label="$t('datastatistics')" name="summary"><Summary ref="summary"></Summary></el-tab-pane>
-            <el-tab-pane :label="$t('costmanagement')" name="costbaseline" v-if="permissions.projectBaseline"><CostBaseline ref="costbaseline"></CostBaseline></el-tab-pane>
+            
+            <el-tab-pane :label="$t('fileCenter')" name="files">
+                <FileCenter ref="fileCenter" v-if="activeName == 'files'"></FileCenter>
+            </el-tab-pane>
+            <el-tab-pane :label="$t('overviewoftheproject')" name="info">
+                <ProjectInfo ref="projectInfo" v-if="activeName == 'info'" @basecost-change="changeBase"></ProjectInfo>
+            </el-tab-pane>
+            <el-tab-pane :label="$t('datastatistics')" name="summary">
+                <Summary ref="summary" v-if="activeName == 'summary'" ></Summary>
+            </el-tab-pane>
+            <el-tab-pane :label="$t('costmanagement')" name="costbaseline" v-if="permissions.projectBaseline">
+                <CostBaseline ref="costbaseline" v-if="activeName == 'costbaseline'"></CostBaseline>
+            </el-tab-pane>
             <!--去掉挣值分析模块-->
-            <!-- <el-tab-pane :label="$t('valueanalysis')" name="earning" v-if="user.id == currentProject.creator || user.id == currentProject.incharger_id ||permissions.projectBaseline"><Earning ref="earning"></Earning></el-tab-pane> -->
+            <!-- <el-tab-pane :label="$t('valueanalysis')" name="earning" v-if="user.id == currentProject.creator || user.id == currentProject.incharger_id ||permissions.projectBaseline">
+                <Earning ref="earning"></Earning>
+            </el-tab-pane> -->
         </el-tabs>
 
 
@@ -1285,6 +1298,7 @@
     import CostBaseline from './CostBaseline.vue'
 
     import taskComponent from "@/components/taskComponent.vue"
+    import selectProject from "../../components/selectProject.vue";
     
     // import editor from '@tinymce/tinymce-vue'
     // 富文本样式
@@ -1310,7 +1324,8 @@
             Earning,
             quillEditor, // 富文本
             selectCat,
-            taskComponent
+            taskComponent,
+            selectProject
         },
         
         data() {
@@ -1534,7 +1549,7 @@
                 nowManDay:0,
                 nowEstimatedWorkTime:0,
 
-                modGroupManDayKey: 1
+                modGroupManDayKey: 1,
             };
             
         },
@@ -2550,12 +2565,35 @@
             handleClick(tab, event) {
                 let pathModel = tab.name;
                 this.$router.push('/'+pathModel+'/'+this.curProjectId);
-                if(tab.name == 'costbaseline'){
-                    this.$refs.costbaseline.refreshPage();
-                }
-                if(tab.name == 'info') {
-                    this.$refs.projectInfo.getMileStoneList()
-                }
+                setTimeout(() => {
+                    if(tab.name == 'costbaseline'){
+                        this.$refs.costbaseline.refreshPage();
+                    }
+                    if(tab.name == 'info') {
+                        this.$refs.projectInfo.getMileStoneList()
+                    }
+
+                    const name = tab.name || '';
+                    const refreshActions = {
+                        files: () => this.$refs.fileCenter.refreshPage(),
+                        info: () => {
+                            this.$refs.projectInfo.refreshPage();
+                            if(this.user.companyId === '936') {
+                                this.$refs.projectInfo.getKeyNodes();
+                            }
+                        },
+                        summary: () => this.$refs.summary.refreshPage(),
+                        costbaseline: () => {
+                            if(this.permissions.projectBaseline) {
+                                this.$refs.costbaseline.refreshPage();
+                            }
+                        }
+                    };
+
+                    if(name in refreshActions) {
+                        refreshActions[name]();
+                    }
+                }, 500)
             },
             showSubTaskList(task) {
                 this.subTaskVisible = true;
@@ -3192,6 +3230,7 @@
             },
             //本地搜索组
             startSearchGroup() {
+                console.log(this.curProjectId, '<===== this.curProjectId')
                 if (this.groupSearch != null || this.groupSearch.length > 0) {
                     this.groupList = this.allGroupData.filter(g=>g.name.indexOf(this.groupSearch) >= 0);
                 } else {
@@ -3552,21 +3591,44 @@
 
             //切换项目
             onProjectChange() {
+                console.log('<===== 开始切换项目')
                 let path = this.$route.path;
                 path = path.substring(0,path.lastIndexOf('/'))+'/'+this.curProjectId;
                 this.$router.push(path);
                 this.getTaskGroups();
                 this.getDetail()
-                this.$refs.fileCenter.refreshPage();
-                this.$refs.projectInfo.refreshPage();
-                this.$refs.summary.refreshPage();
-                if(this.permissions.projectBaseline) {
-                    this.$refs.costbaseline.refreshPage();
-                }
-                // this.$refs.earning.refreshPage();
-                if(this.user.companyId == '936') {
-                    this.$refs.projectInfo.getKeyNodes()
+
+                console.log(this.pathModel, '<==== 看看数据')
+                const name = this.pathModel || '';
+                const refreshActions = {
+                    files: () => this.$refs.fileCenter.refreshPage(),
+                    info: () => {
+                        this.$refs.projectInfo.refreshPage();
+                        if(this.user.companyId === '936') {
+                            this.$refs.projectInfo.getKeyNodes();
+                        }
+                    },
+                    summary: () => this.$refs.summary.refreshPage(),
+                    costbaseline: () => {
+                        if(this.permissions.projectBaseline) {
+                            this.$refs.costbaseline.refreshPage();
+                        }
+                    }
+                };
+
+                if(name in refreshActions) {
+                    refreshActions[name]();
                 }
+
+                // this.$refs.fileCenter.refreshPage();
+                // this.$refs.projectInfo.refreshPage();
+                // this.$refs.summary.refreshPage();
+                // if(this.permissions.projectBaseline) {
+                //     this.$refs.costbaseline.refreshPage();
+                // }
+                // if(this.user.companyId == '936') {
+                //     this.$refs.projectInfo.getKeyNodes()
+                // }
             },
             //获取我的项目列表
             getMyProjectList() {
@@ -3575,8 +3637,6 @@
                 res => {
                     if (res.code == "ok") {
                         this.projectList = res.data;
-                        console.log('getprojectlist',res.data);
-
                     } else {
                         this.$message({
                         message: res.msg,

+ 58 - 32
fhKeeper/formulahousekeeper/timesheet/src/views/project/summary.vue

@@ -30,7 +30,7 @@
                             <el-row :gutter="10">
                                 <el-col :span="6" style="text-align:center;">
                                     <p style="color:#666;font-size:12px;">{{ $t('dai-ren-ling') }}</p>
-                                    <p style="font-size:28px;color:#orange;font-weight:bold;">{{ taskSum.unassignCount }}</p>
+                                    <p style="font-size:28px;color:orange;font-weight:bold;">{{ taskSum.unassignCount }}</p>
                                 </el-col>
                                 <el-col :span="6" style="text-align:center;">
                                     <p style="color:#666;font-size:12px;">{{ $t('duetoday') }}</p>
@@ -187,9 +187,9 @@ export default {
     data() {
         return {
             compareChart: null,
-            costChart: null,
-            stagesChart: null,
-            executorChart: null,
+            costChart: null, // 耗时最多任务实例
+            stagesChart: null, // 按任务列表统计实例
+            executorChart: null, 
             pVisible: false,
             taskSum: {},
             users: [],
@@ -213,6 +213,8 @@ export default {
             dataPagingSize: 10,
             dataPagingTotal: 0,
             dataPagingData: [],
+            
+            taskListEcharts: {},
         };
     },
     methods: {
@@ -263,8 +265,8 @@ export default {
                     console.log(list[i], list[i].name)
                     taskNames.push(list[i].name.length > 12 ? list[i].name.substring(0, 12) + '..' : list[i].name);
                 }
-                var myChart = echarts.init(document.getElementById("taskTimeComparePanel"));
-                _this.compareChart = myChart;
+                // var myChart = echarts.init(document.getElementById("taskTimeComparePanel"));
+                _this.compareChart = echarts.init(document.getElementById("taskTimeComparePanel"));
                 var option = {
                     // 全局调色盘。
                     color: ["#409EFF", "#71C671"],
@@ -332,9 +334,9 @@ export default {
                     }]
                 };
                 
-                myChart.setOption(option, { notMerge: true });
+                _this.compareChart.setOption(option, { notMerge: true });
                 this.$nextTick(() => {
-                    myChart.resize(); // 在DOM更新后,调用resize方法更新图表大小
+                    _this.compareChart.resize(); // 在DOM更新后,调用resize方法更新图表大小
                 });
                 this.departmentOptionLoading = false
             }, 1000);
@@ -458,8 +460,8 @@ export default {
                                 "fullName": list[i].name,
                             });
                         }
-                        var myChart = echarts.init(document.getElementById("costPanel"));
-                        _this.costChart = myChart;
+                        // var myChart = echarts.init(document.getElementById("costPanel"));
+                        _this.costChart = echarts.init(document.getElementById("costPanel"));
                         var option = {
                             title: {
                                 show: list.length == 0,
@@ -515,7 +517,7 @@ export default {
                                 data: yList,
                             }]
                         };
-                        myChart.setOption(option, { notMerge: true });
+                        _this.costChart.setOption(option, { notMerge: true });
                     } else {
                         this.$message({
                             message: res.msg,
@@ -536,9 +538,9 @@ export default {
                 res => {
                     if (res.code == "ok") {
                         var list = res.data;
-                        var myChart = echarts.init(document.getElementById("stagesPanel"));
-                        _this.stagesChart = myChart;
-                        myChart.setOption({
+                        // var myChart = echarts.init(document.getElementById("stagesPanel"));
+                        _this.stagesChart = echarts.init(document.getElementById("stagesPanel"));
+                        _this.stagesChart.setOption({
                             title: {
                                 show: list.length == 0,
                                 textStyle: {
@@ -664,8 +666,8 @@ export default {
                     "id": list[i].executorId
                 });
             }
-            var myChart = echarts.init(document.getElementById("executorPanel"));
-            _this.executorChart = myChart;
+            // var myChart = echarts.init(document.getElementById("executorPanel"));
+            _this.executorChart = echarts.init(document.getElementById("executorPanel"));;
             var option = {
                 color: ["#409EFF", "#71C671"],
                 title: {
@@ -734,7 +736,7 @@ export default {
                     data: yList,
                 }]
             };
-            myChart.setOption(option, { notMerge: true });
+            _this.executorChart.setOption(option, { notMerge: true });
         },
         getProjectTaskSum() {
             this.http.post('/project/taskSum', {
@@ -764,6 +766,20 @@ export default {
             this.getTopCostTask();
             this.getStagesPanel();
             this.getTaskTimeCompare();
+        },
+        resizeCharts() {
+            if (this.executorChart != null) {
+                this.executorChart.resize();
+            }
+            if (this.stagesChart != null) {
+                this.stagesChart.resize();
+            }
+            if (this.costChart != null) {
+                this.costChart.resize();
+            }
+            if (this.compareChart != null) {
+                this.compareChart.resize();
+            }
         }
     },
     created() {
@@ -776,27 +792,37 @@ export default {
     },
     mounted() {
         this.curProjectId = parseInt(this.$route.params.id);
-        var _this = this;
-        window.addEventListener("resize", function () {
-            if (_this.executorChart != null) {
-                _this.executorChart.resize();
-            }
-            if (_this.stagesChart != null) {
-                _this.stagesChart.resize();
-            }
-            if (_this.costChart != null) {
-                _this.costChart.resize();
-            }
-            if (_this.compareChart != null) {
-                _this.compareChart.resize();
-            }
-        });
+        window.addEventListener("resize", this.resizeCharts);
         this.getProjectTaskSum();
         this.getExecutorPanel();
         this.getStagesPanel();
         this.getTopCostTask();
         this.getTaskTimeCompare();
         this.getDepartment()
+    },
+    beforeDestroy() {
+        console.log('开始执行销毁')
+        window.removeEventListener("resize", this.resizeCharts);
+        console.log(this.executorChart, '<==== this.executorChart')
+        console.log(this.stagesChart, '<==== this.stagesChart')
+        console.log(this.costChart, '<==== this.costChart')
+        console.log(this.compareChart, '<==== this.compareChart')
+        if (this.executorChart != null) {
+            this.executorChart.dispose();
+            this.executorChart = null
+        }
+        if (this.stagesChart != null) {
+            this.stagesChart.dispose();
+            this.stagesChart = null
+        }
+        if (this.costChart != null) {
+            this.costChart.dispose();
+            this.costChart = null
+        }
+        if (this.compareChart != null) {
+            this.compareChart.dispose();
+            this.costChart = null
+        }
     }
 };
 </script>