hfxc226 3 years ago
parent
commit
f347dce6e8
2 changed files with 85 additions and 3 deletions
  1. 18 0
      src/api/report/check-job.js
  2. 67 3
      src/views/dashboard/CheckJobReportWeek.vue

+ 18 - 0
src/api/report/check-job.js

@@ -66,3 +66,21 @@ export function exportWeekReport (parameter) {
     responseType: 'blob'
   })
 }
+
+/**
+ * add func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function saveWorkHour (parameter) {
+  return axios({
+    url: '/report/check/jobs',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}

+ 67 - 3
src/views/dashboard/CheckJobReportWeek.vue

@@ -42,9 +42,21 @@
                     :columns="columns"
                     tableLayout="auto"
                     :scroll="{x: 1, y: BaseTool.Constant.scrollY }"
-                    rowKey="month">
+                    rowKey="week">
+                    <template slot="useHours" slot-scope="text, record">
+                      <div class="editable-cell-input-wrapper">
+                        <a-input :value="text" :id="record.week + ',useHours'" @change="$event => onUseHoursChange($event, record.week, 'useHours')" />
+                      </div>
+                    </template>
+                    <template slot="usePeople" slot-scope="text, record">
+                      <div class="editable-cell-input-wrapper">
+                        <a-input :value="text" :id="record.year + record.week + ',useHours'" @change="$event => onUsePeopleChange($event, record.week, 'usePeople')" />
+                      </div>
+                    </template>
                     <span slot="action" slot-scope="record">
                       <template>
+                        <a @click="handleAdd(record)">提交数据</a>
+                        <a-divider type="vertical" />
                         <a @click="handleView(record)">查看明细</a>
                       </template>
                     </span>
@@ -62,10 +74,11 @@
 </template>
 
 <script>
-import { getWeekReport, exportWeekReport } from '@/api/report/check-job'
+import { getWeekReport, exportWeekReport, saveWorkHour } from '@/api/report/check-job'
 import { Chart } from '@antv/g2'
 import PrintInCheckJobReportWeek from '@/views/dashboard/modules/PrintInCheckJobReportWeek'
 import DetailCheckJobReport from '@/views/dashboard/modules/DetailCheckJobReport'
+import { addSbType } from '@/api/sb/type'
 
 export default {
   name: 'Analysis',
@@ -89,16 +102,33 @@ export default {
       chartsData: [],
       // 表头
       columns: [
+        {
+          title: '年',
+          width: 180,
+          dataIndex: 'year'
+        },
         {
           title: '周',
           width: 180,
           dataIndex: 'week'
         },
         {
-          title: '保养标准工时',
+          title: '标准工时',
           width: 120,
           dataIndex: 'totalHours'
         },
+        {
+          title: '可用工时',
+          width: 120,
+          dataIndex: 'useHours',
+          scopedSlots: { customRender: 'useHours' }
+        },
+        {
+          title: '可用人数',
+          width: 120,
+          dataIndex: 'usePeople',
+          scopedSlots: { customRender: 'usePeople' }
+        },
         {
           title: '操作',
           key: 'action',
@@ -187,8 +217,42 @@ export default {
       const modal = this.$refs.detailModal
       modal.base(record)
     },
+    handleAdd (record) {
+      saveWorkHour(record)
+        .then((res) => {
+          this.$message.info(res.data)
+        }).catch(() => {
+          this.confirmLoading = false
+        })
+    },
     handleOk () {
       this.visible = true
+    },
+    onUseHoursChange (e, week, attr) {
+      const value = e.target.value
+      console.log(value)
+      if (value !== 0 && !value) {
+        return
+      }
+      const data = [...this.chartsData]
+      const target = data.find(item => item.week === week)
+      if (target) {
+        target[attr] = value
+        this.chartsData = data
+      }
+    },
+    onUsePeopleChange (e, week, attr) {
+      const value = e.target.value
+      console.log(value)
+      if (value !== 0 && !value) {
+        return
+      }
+      const data = [...this.chartsData]
+      const target = data.find(item => item.week === week)
+      if (target) {
+        target[attr] = value
+        this.chartsData = data
+      }
     }
   }
 }