瀏覽代碼

益寿缘总后台的处方管理增加开方时长筛选

cgp 4 天之前
父節點
當前提交
630f4606aa

+ 6 - 6
src/views/his/duration/index.vue

@@ -133,8 +133,8 @@ export default {
         hospitalId: null,
         deptId: null,
         doctorName: '',
-        startTime: null,
-        endTime: null,
+        startOperateTime: null,
+        endOperateTime: null,
         sort: 'asc' // 默认升序
       },
 
@@ -182,11 +182,11 @@ export default {
 
         // 处理时间范围
         if (this.dateRange && this.dateRange.length === 2) {
-          params.startTime = this.dateRange[0]
-          params.endTime = this.dateRange[1]
+          params.startOperateTime = this.dateRange[0]
+          params.endOperateTime = this.dateRange[1]
         } else {
-          params.startTime = null
-          params.endTime = null
+          params.startOperateTime = null
+          params.endOperateTime = null
         }
 
         const res = await getDurationList(params)

+ 1 - 0
src/views/his/statistics/appOrderCountStats.vue

@@ -109,6 +109,7 @@ export default {
     getCompanyList().then(response => {
       this.companys = response.data || [];
     });
+    this.search();
   },
   methods: {
     // 根据 companyId 加载员工

+ 61 - 55
src/views/his/statistics/hisOrderCountStats.vue

@@ -3,22 +3,31 @@
     <div class="app-content">
       <div class="title">互联网医院订单统计</div>
       <el-form class="search-form" :inline="true">
-        <el-form-item>
-          <treeselect
-            :clearable="false"
-            v-model="companyId"
-            :options="deptOptions"
-            :show-count="true"
-            placeholder="请选择归属部门"
-          />
+        <el-form-item label="公司名称" prop="companyId">
+          <el-select
+            style="width: 220px"
+            filterable
+            v-model="queryParams.companyId"
+            placeholder="请选择公司名"
+            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>
+        <el-form-item label="员工" prop="companyUserId">
           <el-select
             filterable
-            v-model="companyUserId"
+            v-model="queryParams.companyUserId"
             placeholder="请选择员工"
             clearable
             size="small"
+            :disabled="!queryParams.companyId"
           >
             <el-option
               v-for="item in users"
@@ -62,68 +71,65 @@
 
 <script>
 import { getHisOrderCountStats } from "@/api/company/statistics";
-import { getUserListByDeptId } from "@/api/company/companyUser";
-import { treeselect } from "@/api/company/companyDept";
-import Treeselect from "@riophae/vue-treeselect";
-import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { getUserList } from "@/api/company/companyUser"; // 使用 getUserList(companyId)
+import { getCompanyList } from "@/api/company/company";
 
 export default {
   name: "HisOrderCountStats",
-  components: { Treeselect },
-  watch: {
-    // 监听 companyId 变化,自动重载员工列表
-    companyId: {
-      handler(newVal) {
-        if (newVal != null) {
-          this.companyUserId = null; // 清空已选员工
-          this.getUserListByDeptId();
-        } else {
-          this.users = [];
-          this.companyUserId = null;
-        }
-      },
-      immediate: false
-    }
-  },
   data() {
     return {
-      companyId: null,        // 销售公司(部门)ID
-      companyUserId: null,    // 销售人员(员工)ID
-      users: [],              // 员工列表
-      deptOptions: [],        // 部门树形数据
-      dateRange: [],          // 日期范围
-      tableData: []           // 表格数据
+      // 仅保留必要查询参数
+      queryParams: {
+        companyId: null,
+        companyUserId: null
+      },
+      companys: [],   // 公司列表
+      users: [],      // 员工列表
+      dateRange: [],  // 日期范围
+      tableData: []   // 表格数据
     };
   },
+  watch: {
+    // 公司变化时,重新加载员工
+    'queryParams.companyId'(newVal) {
+      if (newVal) {
+        this.queryParams.companyUserId = null;
+        this.loadUsers();
+      } else {
+        this.users = [];
+        this.queryParams.companyUserId = null;
+      }
+    }
+  },
   created() {
-    this.loadDeptTree();
+    // 初始化公司下拉列表
+    getCompanyList().then(response => {
+      this.companys = response.data || [];
+    });
+    this.search();
   },
   methods: {
-    // 加载部门树
-    loadDeptTree() {
-      treeselect().then(response => {
-        this.deptOptions = response.data;
-        if (response.data && response.data.length > 0) {
-          // 默认选中第一个部门
-          this.companyId = response.data[0].id;
-          // 触发 watch 自动加载员工(无需手动调用)
-        }
-      });
-    },
+    // 根据 companyId 加载员工
+    loadUsers() {
+      const companyId = this.queryParams.companyId;
+      if (!companyId) return;
 
-    // 根据 companyId 获取员工列表
-    getUserListByDeptId() {
-      if (!this.companyId) return;
-      getUserListByDeptId({ deptId: this.companyId }).then(response => {
-        this.users = response.data || [];
+      getUserList(companyId).then(res => {
+        if (res.code === 200) {
+          this.users = Array.isArray(res.data) ? res.data : [];
+        } else {
+          this.users = [];
+        }
+      }).catch(() => {
+        this.users = [];
       });
     },
 
     // 搜索统计
     search() {
       const params = {
-        companyId: this.companyId,
-        companyUserId: this.companyUserId,
+        companyId: this.queryParams.companyId,
+        companyUserId: this.queryParams.companyUserId,
         startTime: this.dateRange?.[0] || undefined,
         endTime: this.dateRange?.[1] ? this.dateRange[1] + " 23:59:59" : undefined
       };

+ 109 - 2
src/views/his/storeOrder/order2.vue

@@ -87,6 +87,34 @@
         <el-form-item label="审核时间" prop="auditTime">
             <el-date-picker v-model="auditTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
         </el-form-item>
+
+      <!-- 开方耗时区间筛选 -->
+      <el-form-item label="开方耗时" prop="operateTimeRange">
+        <el-input-number
+          v-model="operateTime.minVal"
+          :min="0"
+          size="small"
+          placeholder="最小值"
+          style="width: 100px"
+        />
+        <el-select v-model="operateTime.minUnit" size="small" style="width: 70px; margin: 0 8px">
+          <el-option label="秒" value="sec" />
+          <el-option label="分" value="min" />
+        </el-select>
+        ~
+        <el-input-number
+          v-model="operateTime.maxVal"
+          :min="0"
+          size="small"
+          placeholder="最大值"
+          style="width: 100px; margin-left: 8px"
+        />
+        <el-select v-model="operateTime.maxUnit" size="small" style="width: 70px; margin: 0 8px">
+          <el-option label="秒" value="sec" />
+          <el-option label="分" value="min" />
+        </el-select>
+      </el-form-item>
+
       <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>
@@ -150,6 +178,15 @@
             </template>
       </el-table-column>
       <el-table-column label="审核时间" align="center" prop="auditTime" width="180" />
+      <el-table-column
+        prop="operate_second"
+        label="操作时长"
+        min-width="140"
+      >
+        <template slot-scope="{ row }">
+          {{ formatSeconds(row.operateSecond) }}
+        </template>
+      </el-table-column>
       <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="100px">
         <template slot-scope="scope">
@@ -191,6 +228,13 @@ export default {
   components: { prescribeDetails },
   data() {
     return {
+      operateTime: {
+        minVal: null,
+        minUnit: 'sec', // 默认单位:秒
+        maxVal: null,
+        maxUnit: 'sec'
+      },
+      dateRange: null,
       companyList:[],
       createTime:null,
       pjtUrl: process.env.VUE_APP_BASE_API+"/",
@@ -256,7 +300,9 @@ export default {
         auditETime:null,
         doctorName:null,
         orderStatus:null,
-        appId:null
+        appId:null,
+        minOperateSeconds: null,
+        maxOperateSeconds: null,
       },
        actName:"10",
       // 表单参数
@@ -320,7 +366,20 @@ export default {
     /** 查询处方列表 */
     getList() {
       this.loading = true;
-      listPrescribe(this.queryParams).then(response => {
+
+      // 构造请求参数(避免直接修改 queryParams)
+      const params = { ...this.queryParams };
+
+      // 处理开方时间
+      if (this.dateRange?.length === 2) {
+        params.startOperateTime = this.dateRange[0];
+        params.endOperateTime = this.dateRange[1];
+      } else {
+        delete params.startOperateTime;
+        delete params.endOperateTime;
+      }
+
+      listPrescribe(params).then(response => {
         this.prescribeList = response.rows;
         this.total = response.total;
         this.loading = false;
@@ -387,6 +446,21 @@ export default {
     /** 搜索按钮操作 */
     handleQuery() {
       this.queryParams.pageNum = 1;
+      const toSeconds = (val, unit) => {
+        if (val == null || val === '') return null;
+        return unit === 'min' ? val * 60 : val;
+      };
+      const minSec = toSeconds(this.operateTime.minVal, this.operateTime.minUnit);
+      const maxSec = toSeconds(this.operateTime.maxVal, this.operateTime.maxUnit);
+
+      //核心校验:如果两个值都存在,max 不能小于 min
+      if (minSec != null && maxSec != null && minSec > maxSec) {
+        this.$message.warning('开方耗时:最大值不能小于最小值!');
+        return; // 阻止查询
+      }
+      this.queryParams.minOperateSeconds = toSeconds(this.operateTime.minVal, this.operateTime.minUnit);
+      this.queryParams.maxOperateSeconds = toSeconds(this.operateTime.maxVal, this.operateTime.maxUnit);
+
       this.getList();
     },
     /** 重置按钮操作 */
@@ -396,8 +470,15 @@ export default {
       this.queryParams.sTime=null;
       this.queryParams.eTime=null;
       this.auditTime=null;
+      this.dateRange = null;
       this.queryParams.auditSTime=null;
       this.queryParams.auditETime=null;
+      this.operateTime = {
+        minVal: null,
+        minUnit: 'sec',
+        maxVal: null,
+        maxUnit: 'sec'
+      };
       this.handleQuery();
     },
     // 多选框选中数据
@@ -513,6 +594,32 @@ export default {
 			},10000);
 		  }
         }).catch(() => {});
+    },
+    // 表格排序变化(点击表头排序)
+    handleSortChange({ prop, order }) {
+      if (order === 'ascending') {
+        this.queryParams.sortField = prop;
+        this.queryParams.sortOrder = 'asc';
+      } else if (order === 'descending') {
+        this.queryParams.sortField = prop;
+        this.queryParams.sortOrder = 'desc';
+      } else {
+        // 取消排序
+        delete this.queryParams.sortField;
+        delete this.queryParams.sortOrder;
+      }
+      this.handleQuery(); // 重新查询
+    },
+    // 秒数转“X分Y秒”
+    formatSeconds(seconds) {
+      if (seconds == null || seconds === '') return '0秒'
+      const sec = Math.floor(Number(seconds))
+      const min = Math.floor(sec / 60)
+      const remainingSec = sec % 60
+      if (min > 0) {
+        return `${min}分${remainingSec}秒`
+      }
+      return `${remainingSec}秒`
     }
   }
 };