wangxy 1 тиждень тому
батько
коміт
785feaab73

+ 8 - 0
src/api/his/packageOrder.js

@@ -99,3 +99,11 @@ export function PackageOrderReport(query) {
     params: query
   })
 }
+
+export function orderReport(query) {
+  return request({
+    url: '/company/statistics/orderReport',
+    method: 'get',
+    params: query
+  })
+}

+ 392 - 0
src/views/his/statistics/orderReport.vue

@@ -0,0 +1,392 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px">
+      <el-form-item label="公司名" prop="companyId">
+        <el-select filterable v-model="queryParams.companyId" placeholder="请选择公司名" @change="companyChange"
+                   clearable size="small">
+          <el-option
+            v-for="item in companys"
+            :key="item.companyId"
+            :label="item.companyName"
+            :value="item.companyId"
+          />
+        </el-select>
+      </el-form-item>
+
+      <el-form-item>
+        <treeselect style="width: 220px" :clearable="false" v-model="queryParams.deptId" :options="deptOptions"
+                    clearable :show-count="true" placeholder="请选择归属部门" @input="currDeptChange"/>
+      </el-form-item>
+      <el-form-item>
+        <el-form-item label="下单时间" prop="createTime">
+          <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd"
+                          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
+                          @change="xdChange"></el-date-picker>
+        </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-form-item>
+    </el-form>
+    <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"-->
+      <!--          v-hasPermi="['his:packageOrder:export']"-->
+      <!--        >导出</el-button>-->
+      <!--      </el-col>-->
+      <!--      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
+    </el-row>
+    <!--    <el-tabs type="card" v-model="actName" @tab-click="handleClickX">-->
+    <!--      <el-tab-pane label="全部订单" name="10"></el-tab-pane>-->
+    <!--      <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>-->
+    <!--    </el-tabs>-->
+    <el-table height="500" v-loading="loading" border :data="tableDataWithTotal">
+      <el-table-column label="销售公司" align="center" prop="companyName" v-if="hasCompanyNameField()" width="120px"/>
+      <el-table-column label="销售部门" align="center" prop="deptName" v-if="hasDeptNameField()"/>
+      <el-table-column label="问诊订单数" align="center" prop="inquiryOrderCount"/>
+      <el-table-column label="问诊订单金额" align="center" prop="inquiryOrderAmount"/>
+      <el-table-column label="积分商品订单数" align="center" prop="integralOrderCount"/>
+      <el-table-column label="积分商品订单金额" align="center" prop="integralOrderAmount"/>
+      <el-table-column label="套餐包订单数" align="center" prop="packageOrderCount"/>
+      <el-table-column label="套餐包定金金额" align="center" prop="packageOrderAmount"/>
+<!--      <el-table-column label="总计" align="center" prop="totals"/>-->
+    </el-table>
+  </div>
+</template>
+
+<script>
+import {
+  listPackageOrder, getPackageOrder, delPackageOrder, addPackageOrder, updatePackageOrder, exportPackageOrder,
+  PackageOrderReport, orderReport
+} from "@/api/his/packageOrder";
+import {getCompanyList} from "@/api/company/company";
+import packageOrderDetails from '../../components/his/packageOrderDetails.vue';
+import {treeselect} from "@/api/company/companyDept";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import {getTask} from "@/api/common";
+
+export default {
+  watch: {
+    'queryParams.deptId': function(newVal, oldVal) {
+      // 避免初始化时的触发
+      if (oldVal !== undefined) {
+        this.handleQuery();
+      }
+    },
+    // 监听deptId
+    'deptId': 'currDeptChange'
+  },
+  name: "PackageOrder",
+  components: {packageOrderDetails, Treeselect},
+  data() {
+    return {
+      totalData: {},
+      companys: [],
+      deptOptions: [],
+      companyId: undefined,
+      deptId: undefined,
+      show: {
+        open: false,
+      },
+      sourceOptions: [],
+      actName: "2",
+      // 遮罩层
+      loading: true,
+      startTime: null,
+      // 导出遮罩层
+      exportLoading: false,
+      // 选中数组
+      ids: [],
+      createTime: null,
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      endTime: null,
+      // 总条数
+      total: 0,
+      // 套餐订单表格数据
+      packageOrderList: [],
+      // 弹出层标题
+      title: "",
+      // 是否显示弹出层
+      open: false,
+      // 是否支付字典
+      isPayOptions: [],
+      // 状态字典
+      statusOptions: [],
+      refundStatusOptions: [],
+      packageSubTypeOptions: [],
+      payTypeOptions: [],
+      deliveryPayStatusOptions: [],
+      deliveryStatusOptions: [],
+      // 查询参数
+      queryParams: {
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        doctorName: null,
+        phone: null,
+        phoneMk: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: null,
+        startTime: null,
+        finishTime: null,
+        sTime: null,
+        eTime: null,
+        stTime: null,
+        endTime: null,
+        endStartTime: null,
+        endEndTime: null,
+        companyUserName: null,
+        companyName: null,
+        deptId: null,
+        source: null,
+      },
+      // 表单参数
+      form: {},
+      // 表单校验
+      rules: {}
+    };
+  },
+  computed: {
+    tableDataWithTotal() {
+      if (this.packageOrderList && this.packageOrderList.length > 0) {
+        // 总是添加一个总计行
+        const totalRow = {
+          companyName: '总计',
+          deptName: '总计',
+          inquiryOrderCount: this.totalData?.inquiryOrderCount || 0,
+          inquiryOrderAmount: this.totalData?.inquiryOrderAmount || 0,
+          integralOrderCount: this.totalData?.integralOrderCount || 0,
+          integralOrderAmount: this.totalData?.integralOrderAmount || 0,
+          packageOrderCount: this.totalData?.packageOrderCount || 0,
+          packageOrderAmount: this.totalData?.packageOrderAmount || 0
+        };
+        return [...this.packageOrderList, totalRow];
+      }
+      return this.packageOrderList;
+    }
+  },
+  created() {
+    getCompanyList().then(response => {
+      this.companys = response.data;
+      if (this.companys != null && this.companys.length > 0) {
+        this.companyId = this.companys[0].companyId;
+        this.getTreeselect();
+      }
+      this.companys.push({companyId: "-1", companyName: "无"})
+    });
+    this.getList();
+    this.totalData = {
+      inquiryOrderCount: 0,
+      inquiryOrderAmount: 0,
+      integralOrderCount: 0,
+      integralOrderAmount: 0,
+      packageOrderCount: 0,
+      packageOrderAmount: 0
+    };
+    this.getDicts("sys_company_or").then(response => {
+      this.isPayOptions = response.data;
+    });
+    this.getDicts("sys_package_order_status").then(response => {
+      this.statusOptions = response.data;
+    });
+    this.getDicts("sys_refund_status").then(response => {
+      this.refundStatusOptions = response.data;
+    });
+    this.getDicts("sys_order_source").then(response => {
+      this.sourceOptions = response.data;
+    });
+    this.getDicts("sys_package_pay_type").then(response => {
+      this.payTypeOptions = response.data;
+    });
+    this.getDicts("sys_store_delivery_pay_status").then(response => {
+      this.deliveryPayStatusOptions = response.data;
+    });
+    this.getDicts("sys_store_order_delivery_status").then(response => {
+      this.deliveryStatusOptions = response.data;
+    });
+    this.getDicts("sys_package_sub_type").then(response => {
+      this.packageSubTypeOptions = response.data;
+    });
+  },
+  methods: {
+    /** 查询套餐订单列表 */
+    getList() {
+      this.loading = true;
+      orderReport(this.queryParams).then(response => {
+        this.packageOrderList = response.data.data;
+        this.totalData = response.data.total || {};
+        this.loading = false;
+        // 延迟强制更新以确保DOM完全渲染
+        setTimeout(() => {
+          this.$forceUpdate();
+        }, 100);
+      });
+    },
+    hasDeptNameField() {
+      return this.packageOrderList &&
+        this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
+    },
+    hasCompanyNameField() {
+      // 当没有任何一项数据包含 deptName 时,才显示公司名列
+      return this.packageOrderList &&
+        !this.packageOrderList.some(item => item.deptName !== undefined && item.deptName !== null && item.deptName !== '');
+    },
+    getSummaries(param) {
+      const { columns } = param;
+      const sums = [];
+      columns.forEach((column, index) => {
+        if (index === 0) {
+          sums[index] = '总计';
+          return;
+        }
+        // 增强数据检查
+        if (this.totalData && Object.keys(this.totalData).length > 0 &&
+          this.totalData[column.property] !== undefined) {
+          sums[index] = this.totalData[column.property];
+          if (column.property.includes('Amount') && typeof sums[index] === 'number') {
+            sums[index] = parseFloat(sums[index]).toFixed(2);
+          }
+        } else {
+          sums[index] = column.property.includes('Amount') ? '0.00' : 0;
+        }
+      });
+      return sums;
+    },
+    // 取消按钮
+    cancel() {
+      this.open = false;
+      this.reset();
+    },
+    // 表单重置
+    reset() {
+      this.form = {
+        orderId: null,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: 0,
+        startTime: null,
+        finishTime: null,
+        createTime: null
+      };
+      this.resetForm("form");
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.resetForm("queryForm");
+      // 清空所有时间相关变量
+      this.createTime = null;
+      this.startTime = null;
+      this.endTime = null;
+
+      // 重置所有查询参数
+      this.queryParams = {
+        pageNum: null,
+        pageSize: null,
+        orderSn: null,
+        userId: null,
+        doctorId: null,
+        doctorName: null,
+        phone: null,
+        phoneMk: null,
+        packageId: null,
+        packageName: null,
+        payMoney: null,
+        isPay: null,
+        days: null,
+        status: null,
+        startTime: null,
+        finishTime: null,
+        sTime: null,
+        eTime: null,
+        stTime: null,
+        endTime: null,
+        endStartTime: null,
+        endEndTime: null,
+        companyUserName: null,
+        companyName: null,
+        companyId: null,
+        deptId: null,
+        source: null,
+      };
+
+      // 立即执行查询
+      this.handleQuery();
+    },
+    xdChange() {
+      if (this.createTime != null) {
+        this.queryParams.stTime = this.createTime[0];
+        this.queryParams.endEndTime = this.createTime[1];
+      } else {
+        this.queryParams.stTime = null;
+        this.queryParams.endEndTime = null;
+      }
+    },
+    endChange() {
+      if (this.endTime != null) {
+        this.queryParams.endStartTime = this.endTime[0];
+        this.queryParams.endEndTime = this.endTime[1];
+      } else {
+        this.queryParams.endStartTime = null;
+        this.queryParams.endEndTime = null;
+      }
+    },
+    /** 查询部门下拉树结构 */
+    getTreeselect() {
+      var that = this;
+      var param = {companyId: this.companyId}
+      treeselect(param).then((response) => {
+        this.deptOptions = response.data;
+        console.log(this.deptOptions)
+        if (response.data != null && response.data.length > 0) {
+          //this.queryParams.deptId=response.data[0].id;
+        }
+      });
+    },
+    companyChange(val) {
+      this.companyId = val;
+      this.queryParams.companyId = val;
+      if (val) {
+        this.getTreeselect();
+      } else {
+        this.deptOptions = [];
+        this.queryParams.deptId = null;
+      }
+      this.getList();
+    },
+    handleDeptChange(val) {
+      this.queryParams.deptId = val;
+      this.handleQuery(); // 选择后立即搜索
+    },
+    currDeptChange(val) {
+      this.queryParams.deptId = val;
+      this.this.handleQuery();
+    },
+  }
+};
+</script>

+ 23 - 13
src/views/his/statistics/packageOrderReport.vue

@@ -45,8 +45,8 @@
     <!--      <el-tab-pane label="全部订单" name="10"></el-tab-pane>-->
     <!--      <el-tab-pane v-for="(item,index) in statusOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>-->
     <!--    </el-tabs>-->
-    <el-table height="500" v-loading="loading" border :data="packageOrderList"
-              v-hasPermi="['his:packageOrder:report']" show-summary :summary-method="getSummaries">
+    <el-table height="500" v-loading="loading" border :data="tableDataWithTotal"
+              v-hasPermi="['his:packageOrder:report']">
       <el-table-column label="销售公司" align="center" prop="companyName" v-if="hasCompanyNameField()" width="120px"/>
       <el-table-column label="销售部门" align="center" prop="deptName" v-if="hasDeptNameField()"/>
       <el-table-column label="总订单数" align="center" prop="orderNum"/>
@@ -154,13 +154,20 @@ export default {
     };
   },
   computed: {
-    totals() {
-      return {
-        orderNum: this.packageOrderList.reduce((sum, item) => sum + (item.orderNum || 0), 0),
-        money: this.packageOrderList.reduce((sum, item) => sum + (item.money || 0), 0),
-        receiptOrder: this.packageOrderList.reduce((sum, item) => sum + (item.receiptOrder || 0), 0),
-        receiptMoney: this.packageOrderList.reduce((sum, item) => sum + (item.receiptMoney || 0), 0)
-      };
+    tableDataWithTotal() {
+      if (this.packageOrderList && this.packageOrderList.length > 0) {
+        // 总是添加一个总计行
+        const totalRow = {
+          companyName: '总计',
+          deptName: '总计',
+          money: this.totalData?.money || 0,
+          orderNum: this.totalData?.orderNum || 0,
+          receiptMoney: this.totalData?.receiptMoney || 0,
+          receiptOrder: this.totalData?.receiptOrder || 0
+        };
+        return [...this.packageOrderList, totalRow];
+      }
+      return this.packageOrderList;
     }
   },
   created() {
@@ -203,12 +210,13 @@ export default {
     getList() {
       this.loading = true;
       PackageOrderReport(this.queryParams).then(response => {
-        this.packageOrderList = response.data;
+        this.packageOrderList = response.data.dataList;
+        this.totalData = response.data.total || {};
         this.loading = false;
-        // 强制触发视图更新
-        this.$nextTick(() => {
+        // 延迟强制更新以确保DOM完全渲染
+        setTimeout(() => {
           this.$forceUpdate();
-        });
+        }, 100);
       });
     },
     hasDeptNameField() {
@@ -289,6 +297,8 @@ export default {
       this.endTime = null;
       this.queryParams.endStartTime = null;
       this.queryParams.endEndTime = null;
+      this.queryParams.companyId = null;
+      this.queryParams.deptId = null;
       this.handleQuery();
     },
     xdChange() {