yxh
2 天以前 484b1f3e41a561e438ce4cdbec0e09958c932767
src/views/project/statistics/performanceStaristics/index.vue
@@ -1,29 +1,13 @@
<!--  -->
<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="70px"
    >
      <el-row :gutter="8">
        <el-col :span="6">
          <el-form-item label="业务人员" prop="pauserno">
            <el-input
              v-model="queryParams.pauserno"
              placeholder="请输入姓名"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="6">
    <el-form class="opo-query-form" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="70px">
      <el-row :gutter="4">
        <!-- <el-col :span="6">
          <el-form-item align="left" label="业务组" prop="padeptno">
            <el-select
              v-model="queryParams.padeptno"
              placeholder="请选择案例状态"
              placeholder="请选择部门、业务组"
            >
              <el-option
                v-for="item in deptList"
@@ -33,97 +17,72 @@
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="绩效类型">
            <el-select
              v-model="queryParams.pabonustype"
              placeholder="请选择案例状态"
            >
              <el-option
                v-for="item in reportlist"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="8">
        <el-col :span="12">
        </el-col> -->
        <el-col :span="8">
          <el-form-item label="统计日期">
            <el-date-picker
              style="width: 100%"
              v-model="selecttime"
              type="monthrange"
              range-separator="至"
              start-placeholder="开始月份"
              end-placeholder="结束月份"
              value-format="yyyy-MM-dd"
              @change="getTimeList"
            >
            <el-date-picker style="width: 100%" v-model="selecttime" type="monthrange" range-separator="至"
              start-placeholder="开始月份" end-placeholder="结束月份" value-format="yyyy-MM-dd" @change="getTimeList">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="绩效人员" prop="pauserno">
            <el-input v-model="queryParams.pausername" placeholder="请输入姓名" clearable size="small"
              @keyup.enter.native="handleQuery" />
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!--<el-table v-loading="loading" border :data="donatebaseinfoList">     -->
    <el-table
      v-loading="loading"
      :data="jxidata"
      ref="table"
      border
      max-height="700"
      highlight-current-row
      :summary-method="getSummaries"
      show-summary
    >
      <el-table-column label="序号" align="center" prop="id" width="100">
      </el-table-column>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" :loading="exportLoading"
          @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
      <el-table-column label="统计月份" align="center" prop="bonusmonth" />
    <el-tabs v-model="activeTab">
      <el-tab-pane label="按业务组" name="dept">
        <el-table v-loading="loading" :data="deptData" ref="deptTable" border max-height="700"
          highlight-current-row :summary-method="getDeptSummaries" show-summary>
          <el-table-column label="序号" align="center" prop="id" width="80" />
          <el-table-column label="业务组" align="center" prop="deptname" />
          <el-table-column label="绩效金额" align="center" prop="amount" :formatter="amountFormatter" />
          <el-table-column label="月度绩效" align="center" prop="mamount" :formatter="amountFormatter" />
          <el-table-column label="季度绩效" align="center" prop="samount" :formatter="amountFormatter" />
          <el-table-column label="年度绩效" align="center" prop="yamount" :formatter="amountFormatter" />
        </el-table>
      </el-tab-pane>
      <el-table-column label="业务组" align="center" prop="deptName">
      </el-table-column>
      <el-table-column label="专职人员" align="center" prop="beneficiaryname" />
      <el-tab-pane label="按人员" name="person">
        <el-table v-loading="loading" :data="jxidata" ref="personTable" border max-height="700"
          highlight-current-row :summary-method="getSummaries" show-summary>
          <el-table-column label="序号" align="center" prop="id" width="80" />
          <el-table-column label="业务组" align="center" prop="deptName" />
          <el-table-column label="绩效人员/医院" align="center" prop="beneficiaryname" />
          <el-table-column label="绩效金额" align="center" prop="amount" :formatter="amountFormatter" />
          <el-table-column label="月度绩效" align="center" prop="mamount" :formatter="amountFormatter" />
          <el-table-column label="季度绩效" align="center" prop="samount" :formatter="amountFormatter" />
          <el-table-column label="年度绩效" align="center" prop="yamount" :formatter="amountFormatter" />
          <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-edit">明细</el-button>
            </template>
          </el-table-column> -->
        </el-table>
      </el-tab-pane>
    </el-tabs>
      <el-table-column label="金额" align="center" prop="amount" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
      >
        <template slot-scope="scope">
          <!--           v-if="scope.row.recordstate==2"
 -->
          <el-button size="mini" type="text" icon="el-icon-edit"
            >明细</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div style="margin: 10px;text-align: right;">
      <div>
        共 <span style="color:#1890FF ;">{{ total }}</span> 条数据
        共 <span style="color:#1890FF ;">{{ tableTotal }}</span> 条数据
      </div>
    </div>
@@ -140,7 +99,9 @@
  listsfeistatistics,
  listbxiaostatistics,
  listjixstatistics,
  listanlstatistics
  listanlstatistics,
  exportPerformanceStatistics,
  exportPerformanceDeptStatistics
} from "@/api/project/statistics";
import { listUser } from "@/api/project/organization";
@@ -170,11 +131,6 @@
      selecttime: "",
      reportervalue: "",
      reportlist: [
        { label: "月度", value: 1 },
        { label: "季度", value: 2 },
        { label: "年度", value: 3 }
      ],
      //省市区
      //默认值设置,可为空
      searchAddress: {
@@ -212,7 +168,7 @@
        shi: "",
        qu: ""
      },
      deptList:[],
      deptList: [],
      // 遮罩层
      loading: false,
      // 导出遮罩层
@@ -231,6 +187,10 @@
      donatebaseinfoList: [],
      // 捐献基础表格数据
      jxidata: [],
      // 当前页签:dept=按业务组,person=按人员
      activeTab: "dept",
      // 按业务组聚合数据
      deptData: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
@@ -239,10 +199,9 @@
      daterangeReporttime: [],
      // 查询参数
      queryParams: {
        pabonustype:'',
        pabegtime: null,
        paendtime: null,
        pauserno: null,
        pausername: "",
        padeptno: null,
      },
@@ -264,9 +223,13 @@
    };
  },
  //监听属性 类似于data概念
  computed: {},
  activated() {},
  mounted() {},
  computed: {
    tableTotal() {
      return this.activeTab === "dept" ? this.deptData.length : this.jxidata.length;
    }
  },
  activated() { },
  mounted() { },
  //监控data中的数据变化
  watch: {},
@@ -277,48 +240,14 @@
        this.queryParams.pabegtime = this.selecttime[0];
        this.queryParams.paendtime = this.selecttime[1];
        // if (this.queryParams.paendtime == this.queryParams.pabegtime) {
        let num = Number(this.queryParams.paendtime.slice(5, 7));
        if (num < 9) {
          let mon = Number(this.queryParams.paendtime.slice(6, 7));
          this.queryParams.paendtime =
            this.queryParams.paendtime.slice(0, 5) +
            "0" +
            (mon + 1) +
            "-" +
            "01" +
            " " +
            "00" +
            ":" +
            "00" +
            ":" +
            "00";
        }
        // this.queryParams.paendtime=this.queryParams.paendtime.slice(0,5)年
        else if (num >= 10) {
          this.queryParams.paendtime =
            this.queryParams.paendtime.slice(0, 5) +
            (num + 1) +
            "-" +
            "01" +
            " " +
            "00" +
            ":" +
            "00" +
            ":" +
            "00";
        } else {
          this.queryParams.paendtime =
            this.queryParams.paendtime.slice(0, 5) +
            "10" +
            "-" +
            "01" +
            " " +
            "00" +
            ":" +
            "00" +
            ":" +
            "00";
        }
        // 结束时间取"所选结束月的次月 1 号",以包含整个结束月。
        // 原实现把月份 +1 后直接拼字符串,12 月会得到 13 月(2026-13-01),
        // MySQL 报 Incorrect datetime value,存储过程直接 500。
        this.queryParams.paendtime = this.$moment(this.queryParams.paendtime)
          .startOf("month")
          .add(1, "month")
          .format("YYYY-MM")
          .concat("-01 00:00:00");
        this.queryParams.pabegtime =
          this.queryParams.pabegtime + " " + "00" + ":" + "00" + ":" + "00";
        // }
@@ -330,7 +259,7 @@
    resetArr(Arr) {
      var hash = {};
      Arr = Arr.reduce(function(arr, current) {
      Arr = Arr.reduce(function (arr, current) {
        hash[current.reporterno]
          ? ""
          : (hash[current.reporterno] = true && arr.push(current));
@@ -339,15 +268,73 @@
      return Arr;
    },
    /** 组装查询参数:未选择统计日期时查全部 */
    buildQueryParams() {
      const query = { ...this.queryParams };
      if (!query.pabegtime || !query.paendtime) {
        // 新 SP 默认取近 6 个月,而绩效 jxrq 数据集中在 2023-08~2024-01,默认会查不到
        query.pabegtime = "2000-01-01 00:00:00";
        query.paendtime = "2999-12-31 23:59:59";
      }
      return query;
    },
    /** 查询捐献基础列表 */
    getList() {
      listjixstatistics(this.queryParams).then(res => {
      listjixstatistics(this.buildQueryParams()).then(res => {
        this.jxidata = res.rows;
        this.jxidata.forEach(($obj, $index) => {
          $obj.id = $index + 1;
        });
        this.total=res.total;
        this.total = res.total;
        this.buildDeptData();
      });
    },
    /** 按业务组聚合:绩效金额/月度/季度/年度分别求和 */
    buildDeptData() {
      const map = new Map();
      this.jxidata.forEach(row => {
        const key = row.deptId || row.deptName || "未分组";
        if (!map.has(key)) {
          map.set(key, {
            deptname: row.deptName || "未分组",
            amount: 0,
            mamount: 0,
            samount: 0,
            yamount: 0
          });
        }
        const item = map.get(key);
        item.amount += Number(row.amount) || 0;
        item.mamount += Number(row.mamount) || 0;
        item.samount += Number(row.samount) || 0;
        item.yamount += Number(row.yamount) || 0;
      });
      this.deptData = Array.from(map.values()).map((item, index) => {
        item.id = index + 1;
        return item;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.buildQueryParams();
      const exportApi =
        this.activeTab === "dept"
          ? exportPerformanceDeptStatistics
          : exportPerformanceStatistics;
      this.$modal
        .confirm("是否确认导出当前列表的绩效统计数据?")
        .then(() => {
          this.exportLoading = true;
          return exportApi(queryParams);
        })
        .then(response => {
          this.$download.name(response.msg);
          this.exportLoading = false;
        })
        .catch(() => {
          this.exportLoading = false;
        });
    },
    listDept() {
      listDept({}).then(response => {
@@ -372,10 +359,9 @@
      this.queryParams = {
        pabonustype:'',
        pabegtime: null,
        paendtime: null,
        pauserno: null,
        pausername: "",
        padeptno: null
      };
      this.selecttime = [];
@@ -390,10 +376,24 @@
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 金额显示:保留两位小数,0.00 不显示 */
    formatAmount(value) {
      if (value === null || value === undefined || value === "") {
        return "";
      }
      const num = Number(value);
      if (!Number.isFinite(num) || num === 0) {
        return "";
      }
      return num.toFixed(2);
    },
    amountFormatter(row, column, cellValue) {
      return this.formatAmount(cellValue);
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      var columnnames = ["applymonth", "deptmentName", "username",'deptName'];
      var columnnames = ["deptName", "beneficiaryname"];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
@@ -406,7 +406,7 @@
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
          const total = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
@@ -414,12 +414,33 @@
              return prev;
            }
          }, 0);
          sums[index] = sums[index].toFixed(2); // 保留2位小数,解决小数合计列;
          // 合计保留 2 位小数;0.00 不显示
          sums[index] = total === 0 ? "" : Number(total).toFixed(2);
        } else {
          sums[index] = "";
        }
      });
      return sums;
    },
    /** 按业务组表格合计 */
    getDeptSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = "合计";
          return;
        }
        if (column.property === "deptname") {
          return;
        }
        const total = data.reduce(
          (prev, item) => prev + (Number(item[column.property]) || 0),
          0
        );
        sums[index] = total === 0 ? "" : Number(total).toFixed(2);
      });
      return sums;
    }
  },