Browse Source

每月研发工时分配表联调

ljb 9 months ago
parent
commit
52ed7f8e8b

+ 1 - 1
src/api/yfCostManage/yfCostStatistics/yfWorkHoursAllocationList.js

@@ -2,7 +2,7 @@ import request from '@/router/axios';
 
 export const getList = (current, size, params) => {
   return request({
-    url: '/api/kd-scientific/page',
+    url: '/api/kd-scientific/xm/technician/hours/myyfgsfpb',
     method: 'get',
     params: {
       ...params,

+ 1 - 1
src/option/yfCostManage/yfCostStatistics/yfWorkHoursAllocationList.js

@@ -7,7 +7,7 @@ export default {
   border: true,
   index: true,
   addBtn: false,
-  selection: true,
+  selection: false,
   searchLabelWidth: 140,
   labelWidth: 100,
   menuWidth: 180,

+ 0 - 1
src/views/tech-person/cy-person-sum-list.vue

@@ -124,7 +124,6 @@ export default window.$crudCommon({
         });
       });
     });
-    console.log(newList)
     data.records = newList;
     return data;
   }

+ 0 - 2
src/views/yf-cost-manage/basic-data-setting/working-hours-records.vue

@@ -196,8 +196,6 @@ export default window.$crudCommon({
         }
       });
 
-      console.log(dailyAttendances)
-
       // 获取最新修改过的数据
       let updatedMonthData = [];
       dailyAttendances.forEach(item => {

+ 67 - 43
src/views/yf-cost-manage/yf-cost-statistics/person-cost-statistics/yf-work-hours-allocation-list.vue

@@ -5,9 +5,7 @@
       v-on="onEvent"
       v-model="form"
       :page.sync="page"
-      :before-open="handleBeforeOpen"
       :header-cell-style="headerCellStyle" 
-      :span-method="spanMethod"
     >
       <template slot="menuLeft">
         <el-button
@@ -25,7 +23,35 @@
           <year-month-select v-model="params.yearAndMonth" :showAllYear="false"></year-month-select>
         </div>
       </template>
-      
+
+      <template slot="gslb" slot-scope="{ row }">
+        <div v-if="row.dailyHoursList.length" class="custom-cell">
+          <div class="custom-cell-line">研发工时</div>
+          <div class="custom-cell-line">非研发工时</div>
+        </div>
+      </template>
+
+      <template v-for="col of allMonthCols" :slot="col" slot-scope="{ row }">
+        <div v-if="row.dailyHoursList.length" class="custom-cell" :key="col">
+          <div class="custom-cell-line">{{ row.dailyHoursList[0] ? row.dailyHoursList[0][col] : '' }}</div>
+          <div class="custom-cell-line">{{ row.dailyHoursList[1] ? row.dailyHoursList[1][col] : '' }}</div>
+        </div>
+      </template>
+
+      <template slot="hoursTotal" slot-scope="{ row }">
+        <div v-if="row.dailyHoursList.length" class="custom-cell">
+          <div class="custom-cell-line">{{ row.workHoursTotal }}</div>
+          <div class="custom-cell-line">{{ row.unworkHoursTotal }}</div>
+        </div>
+      </template>
+
+      <template slot="hoursRate" slot-scope="{ row }">
+        <div v-if="row.dailyHoursList.length" class="custom-cell">
+          <div class="custom-cell-line">{{ row.workHoursRate }}</div>
+          <div class="custom-cell-line">{{ row.unworkHoursRate }}</div>
+        </div>
+      </template>
+
     </avue-crud>
 
     <WideTablePrinter
@@ -62,6 +88,8 @@ export default window.$crudCommon({
 
       wideTableColumns: [],
       printTitle: "",
+
+      allMonthCols: [],
     };
   },
   watch: {
@@ -79,33 +107,12 @@ export default window.$crudCommon({
     this.option.column = deepClone(this.defaultColumns);
   },
   methods: {
-    loadData() {},
-    spanMethod({ row, column, rowIndex, columnIndex }) {
-      let fields = ["xm", "number", "idCard", "personnelType"];
-      let cellValue = row[column.property];
-      if (cellValue && fields.includes(column.property)) {
-        let prevRow = this.data[rowIndex - 1];
-        let nextRow = this.data[rowIndex + 1];
-        if (prevRow && prevRow[column.property] === cellValue) {
-          return { rowspan: 0, colspan: 0 };
-        } else {
-          let countRowspan = 1;
-          while (nextRow && nextRow[column.property] === cellValue) {
-            nextRow = this.data[++countRowspan + rowIndex];
-          }
-          if (countRowspan > 1) {
-            row.hbFlag = true;
-            return { rowspan: countRowspan, colspan: 1 };
-          }
-        }
-      }
-    },
     refreshTableCol(yearAndMonth) {
       let yearMonth = moment(yearAndMonth).format("YYYY-MM").split("-");
       const monthDays = getMonthDatesWithMarkers(Number(yearMonth[0]), Number(yearMonth[1]));
 
       let newColumns = deepClone(this.defaultColumns);
-
+      this.allMonthCols = [];
       monthDays.forEach((item) => {
         let col = {
           prop: moment(item.dateString).format('yyyyMMDD'),
@@ -124,16 +131,17 @@ export default window.$crudCommon({
           col.labelClassName = 'red';
         }
         newColumns.push(col);
+        this.allMonthCols.push(moment(item.dateString).format('yyyyMMDD'));
       });
       newColumns.push({
-        prop: "hj",
+        prop: "hoursTotal",
         label: "合计",
-        width: 60,
+        width: 50,
         align: 'center',
         showOverflowTooltip: true,
         display: false,
       }, {
-        prop: "gsfpl",
+        prop: "hoursRate",
         label: "工时分配率",
         width: 60,
         align: 'center',
@@ -141,10 +149,10 @@ export default window.$crudCommon({
         display: false,
       });
 
-      this.option.column = newColumns;
+      this.option.column = [...newColumns];
     },
     handleExport() {
-      exportBlob(`/api/kd-scientific/attendance/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
+      exportBlob(`/api/kd-scientific/xm/technician/hours/myyfgsfpb/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
         downloadXls(res.data, `${this.params.yearAndMonth}研发工时分配表.xlsx`);
       });
     },
@@ -170,21 +178,37 @@ export default window.$crudCommon({
   // 模块路径
   name: 'yfCostManage/yfCostStatistics/yfWorkHoursAllocationList',
   res: ({ data }) => {
-    let newList = [];
-    data.records.forEach((item) => {
-      let objData = {
-        ...item,
-        id: item.unicode,
-        monthlyHours: (item.monthlyHours || 0).toFixed(1),
-        monthlyDays: (item.monthlyDays || 0).toFixed(1)
-      };
-      item.dailyAttendances.forEach(hourItem => {
-        objData[hourItem.workDate] = (hourItem.workHours || 0).toFixed(1);
-      });
-      newList.push(objData);
+    data.records = data.records.map(item => {
+      if (item.dailyHoursList && item.dailyHoursList.length) {
+        let newDailyHoursList = [
+          {gslb: '研发工时', hoursTotal: item.workHoursTotal, hoursRate: (item.workHoursRate * 100).toFixed(2)},
+          {gslb: '非研发工时', hourTotal: item.unworkHoursTotal, hoursRate: (item.unworkHoursRate * 100).toFixed(2)}
+        ];
+        item.dailyHoursList.forEach(hourItem => {
+          newDailyHoursList[0][hourItem.workDate] = hourItem.workHours;
+          newDailyHoursList[1][hourItem.workDate] = hourItem.unworkHours;
+        });
+
+        item.dailyHoursList = newDailyHoursList;
+        item.workHoursRate = (item.workHoursRate * 100).toFixed(2);
+        item.unworkHoursRate = (item.unworkHoursRate * 100).toFixed(2);
+      }
+      return item;
     });
-    data.records = newList;
     return data;
   },
 });
 </script>
+
+<style lang="scss" scoped>
+.custom-cell {
+  margin: 0 -10px;
+  &-line {
+    border-bottom: 1px solid #EBEEF5;
+    line-height: 24px;
+    &:last-child {
+      border-bottom: 0;
+    }
+  }
+}
+</style>