新增功能
This commit is contained in:
@@ -6,7 +6,7 @@ import LibGenerateTestUserSig from './lib-generate-test-usersig-es.min.js';
|
||||
* 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ) 创建应用,即可看到 SDKAppId,
|
||||
* 它是腾讯云用于区分客户的唯一标识。
|
||||
*/
|
||||
let SDKAPPID = 1600127710;
|
||||
let SDKAPPID = 1600131325;
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ const EXPIRETIME = 604800;
|
||||
* 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。
|
||||
* 文档:https://cloud.tencent.com/document/product/647/17275#Server
|
||||
*/
|
||||
let SECRETKEY = '8a6b3ce533b0e46b9d6e17d5c77bac240bc0ccdce4e3db93a0d6a1e55160c73d';
|
||||
let SECRETKEY = 'adc84842a817f6b9d124a1a15a6de4d0b3a940bef678820ed46d40db474c8ea4';
|
||||
|
||||
/*
|
||||
* Module: GenerateTestUserSig
|
||||
|
||||
@@ -50,13 +50,13 @@
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "wx6b829b4ffce455b7",
|
||||
"appid" : "wx79b9a0bfbfe7cbcd",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
"optimization" : {
|
||||
"subPackages" : true
|
||||
},
|
||||
"optimization" : {
|
||||
"subPackages" : true
|
||||
},
|
||||
"usingComponents" : true
|
||||
},
|
||||
"mp-alipay" : {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.9 KiB |
Generated
+175
-1
@@ -23,6 +23,8 @@
|
||||
"echarts": "^5.6.0",
|
||||
"element-plus": "^2.9.4",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"jspdf": "^2.5.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"nprogress": "^0.2.0",
|
||||
@@ -4047,6 +4049,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/raf": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/raf/-/raf-3.4.3.tgz",
|
||||
"integrity": "sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/@types/svgo": {
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/svgo/-/svgo-2.6.4.tgz",
|
||||
@@ -5200,7 +5209,6 @@
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
|
||||
"integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==",
|
||||
"dev": true,
|
||||
"license": "(MIT OR Apache-2.0)",
|
||||
"bin": {
|
||||
"atob": "bin/atob.js"
|
||||
@@ -5377,6 +5385,15 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-arraybuffer": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz",
|
||||
"integrity": "sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/baseline-browser-mapping": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.0.tgz",
|
||||
@@ -5523,6 +5540,18 @@
|
||||
"browserslist": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/btoa": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/btoa/-/btoa-1.2.1.tgz",
|
||||
"integrity": "sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g==",
|
||||
"license": "(MIT OR Apache-2.0)",
|
||||
"bin": {
|
||||
"btoa": "bin/btoa.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||
@@ -5662,6 +5691,33 @@
|
||||
],
|
||||
"license": "CC-BY-4.0"
|
||||
},
|
||||
"node_modules/canvg": {
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://registry.npmjs.org/canvg/-/canvg-3.0.11.tgz",
|
||||
"integrity": "sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@types/raf": "^3.4.0",
|
||||
"core-js": "^3.8.3",
|
||||
"raf": "^3.4.1",
|
||||
"regenerator-runtime": "^0.13.7",
|
||||
"rgbcolor": "^1.0.1",
|
||||
"stackblur-canvas": "^2.0.0",
|
||||
"svg-pathdata": "^6.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/canvg/node_modules/regenerator-runtime": {
|
||||
"version": "0.13.11",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
|
||||
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/capital-case": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz",
|
||||
@@ -6059,6 +6115,15 @@
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/css-line-break": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/css-line-break/-/css-line-break-2.1.0.tgz",
|
||||
"integrity": "sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/css-select": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/css-select/-/css-select-4.3.0.tgz",
|
||||
@@ -6488,6 +6553,13 @@
|
||||
"domelementtype": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/dompurify": {
|
||||
"version": "2.5.9",
|
||||
"resolved": "https://registry.npmjs.org/dompurify/-/dompurify-2.5.9.tgz",
|
||||
"integrity": "sha512-i6mvVmWN4xo9LrhCOZrDgSs9noW6nOahbrmzjRbPF36YPyj5Ue5lgok0MHDWkG7xzpWFO2OYttXdzM7rJxHvNA==",
|
||||
"license": "(MPL-2.0 OR Apache-2.0)",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/domutils": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/domutils/-/domutils-1.7.0.tgz",
|
||||
@@ -7517,6 +7589,12 @@
|
||||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fflate": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz",
|
||||
"integrity": "sha512-cPJU47OaAoCbg0pBvzsgpTPhmhqI5eJjh/JIu8tPj5q+T7iLvW/JAYUqmE7KOB4R1ZyEhzBaIQpQpardBF5z8A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/figures": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/figures/-/figures-6.1.0.tgz",
|
||||
@@ -8162,6 +8240,19 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/html2canvas": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/html2canvas/-/html2canvas-1.4.1.tgz",
|
||||
"integrity": "sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"css-line-break": "^2.1.0",
|
||||
"text-segmentation": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/htmlparser2": {
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.1.tgz",
|
||||
@@ -8967,6 +9058,24 @@
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/jspdf": {
|
||||
"version": "2.5.2",
|
||||
"resolved": "https://registry.npmjs.org/jspdf/-/jspdf-2.5.2.tgz",
|
||||
"integrity": "sha512-myeX9c+p7znDWPk0eTrujCzNjT+CXdXyk7YmJq5nD5V7uLLKmSXnlQ/Jn/kuo3X09Op70Apm0rQSnFWyGK8uEQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.23.2",
|
||||
"atob": "^2.1.2",
|
||||
"btoa": "^1.2.1",
|
||||
"fflate": "^0.8.1"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"canvg": "^3.0.6",
|
||||
"core-js": "^3.6.0",
|
||||
"dompurify": "^2.5.4",
|
||||
"html2canvas": "^1.0.0-rc.5"
|
||||
}
|
||||
},
|
||||
"node_modules/keyv": {
|
||||
"version": "4.5.4",
|
||||
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
|
||||
@@ -10104,6 +10213,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
|
||||
@@ -10792,6 +10908,16 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/raf": {
|
||||
"version": "3.4.1",
|
||||
"resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz",
|
||||
"integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"performance-now": "^2.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/read-cache": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||
@@ -11162,6 +11288,16 @@
|
||||
"rgb": "bin/rgb"
|
||||
}
|
||||
},
|
||||
"node_modules/rgbcolor": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rgbcolor/-/rgbcolor-1.0.1.tgz",
|
||||
"integrity": "sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==",
|
||||
"license": "MIT OR SEE LICENSE IN FEEL-FREE.md",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">= 0.8.15"
|
||||
}
|
||||
},
|
||||
"node_modules/rollup": {
|
||||
"version": "4.59.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.59.0.tgz",
|
||||
@@ -11943,6 +12079,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/stackblur-canvas": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.7.0.tgz",
|
||||
"integrity": "sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.1.14"
|
||||
}
|
||||
},
|
||||
"node_modules/static-extend": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz",
|
||||
@@ -12442,6 +12588,16 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/svg-pathdata": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/svg-pathdata/-/svg-pathdata-6.0.3.tgz",
|
||||
"integrity": "sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/svgo": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/svgo/-/svgo-2.8.0.tgz",
|
||||
@@ -12650,6 +12806,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/text-segmentation": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/text-segmentation/-/text-segmentation-1.0.3.tgz",
|
||||
"integrity": "sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"utrie": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/thenify": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz",
|
||||
@@ -13673,6 +13838,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/utrie": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/utrie/-/utrie-1.0.2.tgz",
|
||||
"integrity": "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base64-arraybuffer": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
|
||||
+3
-1
@@ -25,6 +25,8 @@
|
||||
"echarts": "^5.6.0",
|
||||
"element-plus": "^2.9.4",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html2canvas": "^1.4.1",
|
||||
"jspdf": "^2.5.2",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"nprogress": "^0.2.0",
|
||||
@@ -67,4 +69,4 @@
|
||||
"vite-plugin-vue-setup-extend": "^0.4.0",
|
||||
"vue-tsc": "^2.2.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ export function orderLists(params: any) {
|
||||
return request.get({ url: '/order.order/lists', params })
|
||||
}
|
||||
|
||||
// 订单统计(0退款,1挂号费,2问诊费,3药品费用,4首付,5尾款,6其他)
|
||||
export function orderStats(params?: { order_type?: number; days?: number }) {
|
||||
return request.get({ url: '/order.order/orderStats', params })
|
||||
}
|
||||
|
||||
// 订单详情
|
||||
export function orderDetail(params: any) {
|
||||
return request.post({ url: '/order.order/detail', params })
|
||||
|
||||
@@ -5,6 +5,11 @@ export function tcmDiagnosisLists(params: any) {
|
||||
return request.get({ url: '/tcm.diagnosis/lists', params })
|
||||
}
|
||||
|
||||
// 医助理诊单统计(按部门、按人)
|
||||
export function assistantDiagnosisStats(params?: { start_time?: string; end_time?: string; days?: number }) {
|
||||
return request.get({ url: '/tcm.diagnosis/assistantDiagnosisStats', params })
|
||||
}
|
||||
|
||||
// 添加中医诊单
|
||||
export function tcmDiagnosisAdd(params: any) {
|
||||
return request.post({ url: '/tcm.diagnosis/add', params })
|
||||
@@ -137,3 +142,25 @@ export function getWechatExternalContact(params: any) {
|
||||
export function getMsgAuditPermitUsers() {
|
||||
return request.get({ url: '/tcm.diagnosis/getMsgAuditPermitUsers' })
|
||||
}
|
||||
|
||||
// ========== 中医处方单 ==========
|
||||
|
||||
// 添加处方
|
||||
export function prescriptionAdd(params: any) {
|
||||
return request.post({ url: '/tcm.prescription/add', params })
|
||||
}
|
||||
|
||||
// 处方详情
|
||||
export function prescriptionDetail(params: { id: number }) {
|
||||
return request.get({ url: '/tcm.prescription/detail', params })
|
||||
}
|
||||
|
||||
// 根据诊单获取处方列表
|
||||
export function prescriptionListByDiagnosis(params: { diagnosis_id: number }) {
|
||||
return request.get({ url: '/tcm.prescription/listByDiagnosis', params })
|
||||
}
|
||||
|
||||
// 根据预约获取处方
|
||||
export function prescriptionGetByAppointment(params: { appointment_id: number }) {
|
||||
return request.get({ url: '/tcm.prescription/getByAppointment', params })
|
||||
}
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visible"
|
||||
:title="`与 ${patientName} 聊天`"
|
||||
width="900px"
|
||||
top="10vh"
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
:destroy-on-close="true"
|
||||
class="chat-dialog"
|
||||
>
|
||||
<div class="chat-container">
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-show="visible"
|
||||
ref="chatWindowRef"
|
||||
class="chat-floating-window"
|
||||
:style="windowStyle"
|
||||
>
|
||||
<div
|
||||
class="chat-window-header"
|
||||
@mousedown="onHeaderMouseDown"
|
||||
>
|
||||
<span class="chat-window-title">与 {{ patientName }} 聊天</span>
|
||||
<el-button type="danger" link class="chat-close-btn" @click="handleClose">
|
||||
<el-icon><Close /></el-icon>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="chat-container">
|
||||
<div v-if="!isReady" class="loading-container">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span>{{ loadingText }}</span>
|
||||
@@ -49,20 +55,35 @@
|
||||
</UIKitProvider>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 挂载 TUICallKit 组件(固定居中显示) -->
|
||||
<TUICallKit
|
||||
v-if="isCallReady"
|
||||
:allowedMinimized="true"
|
||||
:allowedFullScreen="true"
|
||||
class="chat-dialog-call-kit"
|
||||
/>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 挂载 TUICallKit 组件(可拖动,仅在通话时显示) -->
|
||||
<div
|
||||
v-if="isCallReady && showCallKitWindow"
|
||||
ref="callKitWrapperRef"
|
||||
class="chat-dialog-call-kit-wrapper"
|
||||
:style="callKitStyle"
|
||||
>
|
||||
<div
|
||||
class="call-kit-drag-handle"
|
||||
@mousedown="onCallKitDragStart"
|
||||
>
|
||||
<span class="drag-handle-text">视频通话</span>
|
||||
<el-icon class="drag-handle-icon"><Rank /></el-icon>
|
||||
</div>
|
||||
<div class="call-kit-content">
|
||||
<TUICallKit
|
||||
:allowedMinimized="true"
|
||||
:allowedFullScreen="true"
|
||||
class="chat-dialog-call-kit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, nextTick, watch } from 'vue'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import { ref, nextTick, watch, computed } from 'vue'
|
||||
import { Loading, Close, Rank } from '@element-plus/icons-vue'
|
||||
import { getCallSignature } from '@/api/tcm'
|
||||
import feedback from '@/utils/feedback'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
@@ -94,6 +115,7 @@ const loadingText = ref('正在初始化...')
|
||||
const patientUserId = ref('')
|
||||
const conversationId = ref('')
|
||||
const isCallReady = ref(false)
|
||||
const showCallKitWindow = ref(false) // 仅在通话中显示视频窗口
|
||||
const { login, logout } = useLoginState()
|
||||
const { setActiveConversation, createC2CConversation, activeConversation } = useConversationListState()
|
||||
const userStore = useUserStore()
|
||||
@@ -166,12 +188,17 @@ watch(() => activeConversation.value, async (newConversation) => {
|
||||
|
||||
const open = async (data: { patientId: number; patientName: string; diagnosisId?: number }) => {
|
||||
visible.value = true
|
||||
posX.value = 100
|
||||
posY.value = 80
|
||||
callKitX.value = Math.max(0, (window.innerWidth - 600) / 2)
|
||||
callKitY.value = Math.max(0, (window.innerHeight - 436) / 2)
|
||||
patientName.value = data.patientName
|
||||
patientId.value = data.patientId
|
||||
diagnosisId.value = data.diagnosisId || null
|
||||
error.value = ''
|
||||
isReady.value = false
|
||||
isCallReady.value = false
|
||||
showCallKitWindow.value = false
|
||||
loadingText.value = '正在获取签名...'
|
||||
|
||||
try {
|
||||
@@ -220,6 +247,13 @@ const open = async (data: { patientId: number; patientName: string; diagnosisId?
|
||||
}
|
||||
}
|
||||
isCallReady.value = !!(window as any).__TUICallKitInited__
|
||||
if (isCallReady.value) {
|
||||
// 仅在通话时显示视频窗口,无通话时隐藏
|
||||
TUICallKitServer.setCallback({
|
||||
beforeCalling: () => { showCallKitWindow.value = true },
|
||||
afterCalling: () => { showCallKitWindow.value = false }
|
||||
})
|
||||
}
|
||||
console.log('Chat UIKit 登录成功,患者用户ID:', patientUserId.value)
|
||||
|
||||
loadingText.value = '加载聊天界面...'
|
||||
@@ -308,7 +342,90 @@ const startGroupVideoCall = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 浮动窗口位置与拖动
|
||||
const chatWindowRef = ref<HTMLElement>()
|
||||
const posX = ref(100)
|
||||
const posY = ref(80)
|
||||
const isDragging = ref(false)
|
||||
const dragStartX = ref(0)
|
||||
const dragStartY = ref(0)
|
||||
const posStartX = ref(0)
|
||||
const posStartY = ref(0)
|
||||
|
||||
// TUICallKit 视频窗口拖动
|
||||
const callKitWrapperRef = ref<HTMLElement>()
|
||||
const callKitX = ref(0)
|
||||
const callKitY = ref(0)
|
||||
const isCallKitDragging = ref(false)
|
||||
const callKitDragStartX = ref(0)
|
||||
const callKitDragStartY = ref(0)
|
||||
const callKitPosStartX = ref(0)
|
||||
const callKitPosStartY = ref(0)
|
||||
|
||||
const callKitStyle = computed(() => ({
|
||||
left: `${callKitX.value}px`,
|
||||
top: `${callKitY.value}px`
|
||||
}))
|
||||
|
||||
const onCallKitDragStart = (e: MouseEvent) => {
|
||||
isCallKitDragging.value = true
|
||||
callKitDragStartX.value = e.clientX
|
||||
callKitDragStartY.value = e.clientY
|
||||
callKitPosStartX.value = callKitX.value
|
||||
callKitPosStartY.value = callKitY.value
|
||||
document.addEventListener('mousemove', onCallKitDragMove)
|
||||
document.addEventListener('mouseup', onCallKitDragEnd)
|
||||
}
|
||||
|
||||
const onCallKitDragMove = (e: MouseEvent) => {
|
||||
if (!isCallKitDragging.value) return
|
||||
callKitX.value = Math.max(0, callKitPosStartX.value + e.clientX - callKitDragStartX.value)
|
||||
callKitY.value = Math.max(0, callKitPosStartY.value + e.clientY - callKitDragStartY.value)
|
||||
}
|
||||
|
||||
const onCallKitDragEnd = () => {
|
||||
isCallKitDragging.value = false
|
||||
document.removeEventListener('mousemove', onCallKitDragMove)
|
||||
document.removeEventListener('mouseup', onCallKitDragEnd)
|
||||
}
|
||||
|
||||
const windowStyle = computed(() => ({
|
||||
left: `${posX.value}px`,
|
||||
top: `${posY.value}px`
|
||||
}))
|
||||
|
||||
const onHeaderMouseDown = (e: MouseEvent) => {
|
||||
if ((e.target as HTMLElement).closest('.chat-close-btn')) return
|
||||
isDragging.value = true
|
||||
dragStartX.value = e.clientX
|
||||
dragStartY.value = e.clientY
|
||||
posStartX.value = posX.value
|
||||
posStartY.value = posY.value
|
||||
document.addEventListener('mousemove', onHeaderMouseMove)
|
||||
document.addEventListener('mouseup', onHeaderMouseUp)
|
||||
}
|
||||
|
||||
const onHeaderMouseMove = (e: MouseEvent) => {
|
||||
if (!isDragging.value) return
|
||||
posX.value = Math.max(0, posStartX.value + e.clientX - dragStartX.value)
|
||||
posY.value = Math.max(0, posStartY.value + e.clientY - dragStartY.value)
|
||||
}
|
||||
|
||||
const onHeaderMouseUp = () => {
|
||||
isDragging.value = false
|
||||
document.removeEventListener('mousemove', onHeaderMouseMove)
|
||||
document.removeEventListener('mouseup', onHeaderMouseUp)
|
||||
}
|
||||
|
||||
const handleClose = async () => {
|
||||
// 关闭时如有通话中/拨通中,自动挂断
|
||||
if (isCallReady.value && showCallKitWindow.value) {
|
||||
try {
|
||||
await TUICallKitServer.hangup()
|
||||
} catch (err) {
|
||||
console.warn('挂断通话时出错:', err)
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 登出 Chat
|
||||
// await logout()
|
||||
@@ -317,6 +434,7 @@ const handleClose = async () => {
|
||||
}
|
||||
|
||||
visible.value = false
|
||||
showCallKitWindow.value = false
|
||||
// isReady.value = false
|
||||
// error.value = ''
|
||||
// patientId.value = null
|
||||
@@ -329,31 +447,47 @@ defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.chat-dialog {
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 0;
|
||||
height: 75vh;
|
||||
overflow: visible;
|
||||
/* 浮动窗口:无遮罩,不遮挡页面,可任意拖动 */
|
||||
.chat-floating-window {
|
||||
position: fixed;
|
||||
width: 900px;
|
||||
height: 75vh;
|
||||
min-height: 400px;
|
||||
max-height: 90vh;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
|
||||
z-index: 2501;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-window-header {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #e4e7ed;
|
||||
background: #fff;
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-shrink: 0;
|
||||
|
||||
.chat-window-title {
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__header) {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #e4e7ed;
|
||||
}
|
||||
|
||||
// 确保对话框有合适的 z-index
|
||||
:deep(.el-overlay) {
|
||||
z-index: 2500;
|
||||
}
|
||||
|
||||
// 确保对话框本身的 z-index 低于 TUICallKit
|
||||
:deep(.el-dialog) {
|
||||
z-index: 2501;
|
||||
|
||||
.chat-close-btn {
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
height: 75vh;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -415,18 +549,61 @@ defineExpose({ open })
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* TUICallKit 容器样式 - 限制在对话框内拖动 */
|
||||
/* TUICallKit 可拖动容器 */
|
||||
.chat-dialog-call-kit-wrapper {
|
||||
position: fixed;
|
||||
width: 600px;
|
||||
height: 436px;
|
||||
max-width: 90vw;
|
||||
z-index: 300000;
|
||||
background: #1a1a1a;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.call-kit-drag-handle {
|
||||
height: 36px;
|
||||
padding: 0 16px;
|
||||
background: #2a2a2a;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
flex-shrink: 0;
|
||||
|
||||
.drag-handle-text {
|
||||
font-size: 14px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.drag-handle-icon {
|
||||
color: #999;
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.call-kit-content {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.chat-dialog-call-kit {
|
||||
position: fixed !important;
|
||||
top: 50% !important;
|
||||
left: 50% !important;
|
||||
transform: translate(-50%, -50%) !important;
|
||||
width: 600px !important;
|
||||
height: 400px !important;
|
||||
max-width: 90% !important;
|
||||
max-height: 80% !important;
|
||||
z-index: 300000 !important;
|
||||
pointer-events: auto !important;
|
||||
position: absolute !important;
|
||||
top: 0 !important;
|
||||
left: 0 !important;
|
||||
right: 0 !important;
|
||||
bottom: 0 !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
transform: none !important;
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
border-radius: 0 0 12px 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -444,8 +621,8 @@ body > div[data-reka-focus-guard] {
|
||||
z-index: 9999 !important;
|
||||
}
|
||||
|
||||
/* 确保聊天对话框内的弹出层也能正确显示 */
|
||||
.chat-dialog [data-reka-popper-content-wrapper] {
|
||||
/* 确保聊天窗口内的弹出层也能正确显示 */
|
||||
.chat-floating-window [data-reka-popper-content-wrapper] {
|
||||
z-index: 9999 !important;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,756 @@
|
||||
<template>
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
title="中医处方单"
|
||||
size="900px"
|
||||
:close-on-click-modal="false"
|
||||
@close="handleClose"
|
||||
>
|
||||
<div v-if="!savedPrescription" class="prescription-edit">
|
||||
<el-form ref="formRef" :model="formData" label-width="100px" class="prescription-form">
|
||||
<div class="info-section">
|
||||
<div class="section-title">患者信息</div>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="姓名">
|
||||
<span>{{ formData.patient_name }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="性别">
|
||||
<span>{{ formData.gender_desc }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="年龄">
|
||||
<span>{{ formData.age }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="电话">
|
||||
<span>{{ formData.phone }}</span>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="门诊号">
|
||||
<el-input v-model="formData.visit_no" placeholder="门诊号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<div class="section-title">诊断信息</div>
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="脉象" prop="pulse">
|
||||
<el-input v-model="formData.pulse" placeholder="脉象" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="舌象" prop="tongue">
|
||||
<el-input v-model="formData.tongue" placeholder="舌象" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="临床诊断" prop="clinical_diagnosis">
|
||||
<el-input
|
||||
v-model="formData.clinical_diagnosis"
|
||||
type="textarea"
|
||||
:rows="2"
|
||||
placeholder="请输入临床诊断"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<div class="section-title">
|
||||
中药处方 (RP)
|
||||
<el-button type="primary" size="small" @click="handleAddHerb">添加中药</el-button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<el-form-item label="处方价格" prop="amount" class="!mb-0">
|
||||
<el-input-number
|
||||
v-model="formData.amount"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入处方总价(元)"
|
||||
class="!w-40"
|
||||
/>
|
||||
<span class="ml-2 text-gray-500">元</span>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<div v-for="(herb, index) in formData.herbs" :key="index" class="herb-item">
|
||||
<el-form-item :label="`中药${index + 1}`">
|
||||
<div class="flex gap-2 items-center flex-wrap">
|
||||
<el-input
|
||||
v-model="herb.name"
|
||||
placeholder="药品名称"
|
||||
style="width: 160px"
|
||||
/>
|
||||
<el-input-number
|
||||
v-model="herb.dosage"
|
||||
:min="0.1"
|
||||
:step="1"
|
||||
:precision="1"
|
||||
placeholder="剂量(克)"
|
||||
style="width: 120px"
|
||||
/>
|
||||
<span class="text-gray-500">克</span>
|
||||
<el-button type="danger" size="small" link @click="handleRemoveHerb(index)">
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="info-section">
|
||||
<el-row :gutter="16">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="剂数" prop="dose_count">
|
||||
<el-input-number v-model="formData.dose_count" :min="1" :max="30" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-form-item label="用法" prop="usage_instruction">
|
||||
<el-input v-model="formData.usage_instruction" placeholder="如:水煎服一日二次" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="医师" prop="doctor_name">
|
||||
<el-input v-model="formData.doctor_name" placeholder="医师姓名" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="医师签名" prop="doctor_signature" required>
|
||||
<div class="signature-pad-wrap">
|
||||
<canvas
|
||||
ref="signatureCanvasRef"
|
||||
class="signature-canvas"
|
||||
width="280"
|
||||
height="120"
|
||||
@mousedown="onSignatureStart"
|
||||
@mousemove="onSignatureMove"
|
||||
@mouseup="onSignatureEnd"
|
||||
@mouseleave="onSignatureEnd"
|
||||
@touchstart.prevent="onSignatureStart"
|
||||
@touchmove.prevent="onSignatureMove"
|
||||
@touchend.prevent="onSignatureEnd"
|
||||
/>
|
||||
<div class="signature-actions">
|
||||
<el-button size="small" @click="clearSignature">清空签名</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-xs text-amber-600 mt-1">* 必填,请在框内手写医师签名</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
</div>
|
||||
|
||||
<div v-else class="prescription-preview">
|
||||
<div ref="prescriptionPrintRef" class="prescription-print">
|
||||
<div class="prescription-header">
|
||||
<h2 class="prescription-title">{{ templateConfig.stationName }}处方笺</h2>
|
||||
<div class="prescription-type">
|
||||
<div>普通处方</div>
|
||||
<div class="text-sm">当日有效</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="prescription-meta">
|
||||
<span>日期: {{ savedPrescription.prescription_date }}</span>
|
||||
<span class="ml-4">门诊号: {{ savedPrescription.visit_no }}</span>
|
||||
</div>
|
||||
<div class="prescription-patient">
|
||||
<span>姓名: {{ savedPrescription.patient_name }}</span>
|
||||
<span>性别: {{ savedPrescription.gender_desc }}</span>
|
||||
<span>年龄: {{ savedPrescription.age }}</span>
|
||||
<span>电话: {{ savedPrescription.phone }}</span>
|
||||
</div>
|
||||
<div class="prescription-patient">
|
||||
<span>脉象: {{ savedPrescription.pulse || '—' }}</span>
|
||||
<span>舌象: {{ savedPrescription.tongue || '—' }}</span>
|
||||
</div>
|
||||
<div class="prescription-patient">
|
||||
<span>临床诊断: {{ savedPrescription.clinical_diagnosis }}</span>
|
||||
</div>
|
||||
<div class="prescription-rp">
|
||||
<div class="rp-label">RP</div>
|
||||
<div class="herbs-grid">
|
||||
<div
|
||||
v-for="(h, i) in savedPrescription.herbs"
|
||||
:key="i"
|
||||
class="herb-cell"
|
||||
>
|
||||
{{ h.name }} {{ h.dosage }}克
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="prescription-disclaimer" v-if="templateConfig.showDisclaimer">
|
||||
{{ templateConfig.disclaimer }}
|
||||
</div>
|
||||
<div class="prescription-footer">
|
||||
<div class="footer-left">
|
||||
<div class="footer-dosage">
|
||||
共 {{ savedPrescription.dose_count }} 剂, {{ savedPrescription.usage_instruction }}
|
||||
</div>
|
||||
<div class="footer-amount">金额 {{ savedPrescription.amount }}</div>
|
||||
</div>
|
||||
<div class="footer-right footer-sign">
|
||||
<span class="signature-cell">
|
||||
医师
|
||||
<img
|
||||
v-if="savedPrescription.doctor_signature"
|
||||
:src="savedPrescription.doctor_signature"
|
||||
alt="医师签名"
|
||||
class="doctor-signature-img"
|
||||
/>
|
||||
<span v-else>{{ savedPrescription.doctor_name || '医师' }}</span>
|
||||
</span>
|
||||
<span>核对发药</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-2 mt-4">
|
||||
<el-button @click="handleDownloadImage">
|
||||
<el-icon><Download /></el-icon>
|
||||
下载图片
|
||||
</el-button>
|
||||
<el-button type="primary" @click="handleDownloadPdf">
|
||||
<el-icon><Document /></el-icon>
|
||||
下载PDF
|
||||
</el-button>
|
||||
<el-button @click="handleNewPrescription">新建处方</el-button>
|
||||
<el-button @click="handleClose">关闭</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template v-if="!savedPrescription" #footer>
|
||||
<div class="flex justify-end gap-2">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSave" :loading="saving">保存处方</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import feedback from '@/utils/feedback'
|
||||
import { prescriptionAdd, prescriptionDetail, prescriptionGetByAppointment } from '@/api/tcm'
|
||||
import { getDictData } from '@/api/app'
|
||||
import html2canvas from 'html2canvas'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import { Download, Document } from '@element-plus/icons-vue'
|
||||
|
||||
interface Herb {
|
||||
name: string
|
||||
dosage: number
|
||||
}
|
||||
|
||||
interface PrescriptionForm {
|
||||
diagnosis_id: number
|
||||
appointment_id: number
|
||||
patient_name: string
|
||||
gender: number
|
||||
gender_desc: string
|
||||
age: number
|
||||
phone: string
|
||||
visit_no: string
|
||||
prescription_date: string
|
||||
pulse: string
|
||||
tongue: string
|
||||
clinical_diagnosis: string
|
||||
herbs: Herb[]
|
||||
dose_count: number
|
||||
usage_instruction: string
|
||||
amount: number
|
||||
doctor_name: string
|
||||
doctor_signature: string
|
||||
}
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const visible = ref(false)
|
||||
const formRef = ref()
|
||||
const saving = ref(false)
|
||||
const prescriptionPrintRef = ref<HTMLElement>()
|
||||
const signatureCanvasRef = ref<HTMLCanvasElement>()
|
||||
const isDrawing = ref(false)
|
||||
const savedPrescription = ref<any>(null)
|
||||
|
||||
const templateConfig = reactive({
|
||||
stationName: '卫生服务站',
|
||||
showDisclaimer: true,
|
||||
disclaimer: ''
|
||||
})
|
||||
|
||||
const formData = reactive<PrescriptionForm>({
|
||||
diagnosis_id: 0,
|
||||
appointment_id: 0,
|
||||
patient_name: '',
|
||||
gender: 0,
|
||||
gender_desc: '女',
|
||||
age: 0,
|
||||
phone: '',
|
||||
visit_no: '',
|
||||
prescription_date: '',
|
||||
pulse: '',
|
||||
tongue: '',
|
||||
clinical_diagnosis: '',
|
||||
herbs: [],
|
||||
dose_count: 1,
|
||||
usage_instruction: '水煎服一日二次',
|
||||
amount: 0,
|
||||
doctor_name: '',
|
||||
doctor_signature: ''
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
const diagnosisTypeOptions = ref<any[]>([])
|
||||
const syndromeTypeOptions = ref<any[]>([])
|
||||
|
||||
const getDictLabel = (options: any[], value: string) => {
|
||||
if (!value) return ''
|
||||
const item = options.find((opt: any) => opt.value === value)
|
||||
return item ? item.name : value
|
||||
}
|
||||
|
||||
const loadDictOptions = async () => {
|
||||
try {
|
||||
const [dt, st] = await Promise.all([
|
||||
getDictData({ type: 'diagnosis_type' }),
|
||||
getDictData({ type: 'syndrome_type' })
|
||||
])
|
||||
diagnosisTypeOptions.value = dt?.diagnosis_type || []
|
||||
syndromeTypeOptions.value = st?.syndrome_type || []
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
const buildClinicalDiagnosis = (diagnosis: any) => {
|
||||
if (diagnosis?.symptoms?.trim()) return diagnosis.symptoms.trim()
|
||||
const dtLabel = getDictLabel(diagnosisTypeOptions.value, diagnosis?.diagnosis_type)
|
||||
const stLabel = getDictLabel(syndromeTypeOptions.value, diagnosis?.syndrome_type)
|
||||
const parts = [dtLabel, stLabel].filter(Boolean)
|
||||
return parts.length ? parts.join(' ') : ''
|
||||
}
|
||||
|
||||
const open = async (data: any, options?: { templateId?: number; stationName?: string }) => {
|
||||
if (options?.stationName) templateConfig.stationName = options.stationName
|
||||
|
||||
const diagnosis = data.diagnosis || data
|
||||
const diagnosisId = data.diagnosis_id ?? diagnosis?.id ?? data.id
|
||||
if (!diagnosisId) {
|
||||
feedback.msgWarning('缺少诊单信息')
|
||||
return
|
||||
}
|
||||
|
||||
await loadDictOptions()
|
||||
|
||||
const appointmentId = Number(data.id ?? data.appointment_id ?? 0)
|
||||
if (appointmentId) {
|
||||
try {
|
||||
const existing = await prescriptionGetByAppointment({ appointment_id: appointmentId })
|
||||
if (existing?.id) {
|
||||
const detail = await prescriptionDetail({ id: existing.id })
|
||||
savedPrescription.value = detail
|
||||
visible.value = true
|
||||
return
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
formData.diagnosis_id = Number(diagnosisId)
|
||||
formData.appointment_id = appointmentId
|
||||
formData.patient_name = data.patient_name || diagnosis.patient_name || ''
|
||||
formData.gender = data.patient_gender ?? diagnosis.gender ?? 0
|
||||
formData.gender_desc = formData.gender === 1 ? '男' : '女'
|
||||
formData.age = data.patient_age ?? diagnosis.age ?? 0
|
||||
formData.phone = data.patient_phone || diagnosis.phone || ''
|
||||
formData.visit_no = data.id ? `1K${String(data.id).padStart(8, '0')}` : ''
|
||||
formData.prescription_date = new Date().toISOString().slice(0, 10)
|
||||
formData.pulse = diagnosis.pulse || ''
|
||||
formData.tongue = diagnosis.tongue_coating || diagnosis.tongue || ''
|
||||
formData.clinical_diagnosis = buildClinicalDiagnosis(diagnosis)
|
||||
formData.herbs = []
|
||||
formData.dose_count = 1
|
||||
formData.usage_instruction = '水煎服一日二次'
|
||||
formData.amount = 0
|
||||
formData.doctor_name = userStore.userInfo?.name || ''
|
||||
formData.doctor_signature = ''
|
||||
|
||||
savedPrescription.value = null
|
||||
visible.value = true
|
||||
setTimeout(() => initSignatureCanvas(), 100)
|
||||
}
|
||||
|
||||
const openById = async (prescriptionId: number) => {
|
||||
try {
|
||||
const res = await prescriptionDetail({ id: prescriptionId })
|
||||
savedPrescription.value = res
|
||||
visible.value = true
|
||||
} catch (e) {
|
||||
feedback.msgError('加载处方失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
savedPrescription.value = null
|
||||
}
|
||||
|
||||
const getSignatureCoords = (e: MouseEvent | TouchEvent) => {
|
||||
const canvas = signatureCanvasRef.value
|
||||
if (!canvas) return { x: 0, y: 0 }
|
||||
const rect = canvas.getBoundingClientRect()
|
||||
const scaleX = canvas.width / rect.width
|
||||
const scaleY = canvas.height / rect.height
|
||||
if (e instanceof TouchEvent) {
|
||||
const touch = e.touches[0] || e.changedTouches[0]
|
||||
return {
|
||||
x: (touch.clientX - rect.left) * scaleX,
|
||||
y: (touch.clientY - rect.top) * scaleY
|
||||
}
|
||||
}
|
||||
return {
|
||||
x: (e.clientX - rect.left) * scaleX,
|
||||
y: (e.clientY - rect.top) * scaleY
|
||||
}
|
||||
}
|
||||
|
||||
const onSignatureStart = (e: MouseEvent | TouchEvent) => {
|
||||
isDrawing.value = true
|
||||
const ctx = signatureCanvasRef.value?.getContext('2d')
|
||||
if (!ctx) return
|
||||
const { x, y } = getSignatureCoords(e)
|
||||
ctx.beginPath()
|
||||
ctx.moveTo(x, y)
|
||||
}
|
||||
|
||||
const onSignatureMove = (e: MouseEvent | TouchEvent) => {
|
||||
if (!isDrawing.value) return
|
||||
const ctx = signatureCanvasRef.value?.getContext('2d')
|
||||
if (!ctx) return
|
||||
const { x, y } = getSignatureCoords(e)
|
||||
ctx.lineTo(x, y)
|
||||
ctx.stroke()
|
||||
}
|
||||
|
||||
const onSignatureEnd = () => {
|
||||
isDrawing.value = false
|
||||
const canvas = signatureCanvasRef.value
|
||||
if (canvas) {
|
||||
formData.doctor_signature = canvas.toDataURL('image/png')
|
||||
}
|
||||
}
|
||||
|
||||
const clearSignature = () => {
|
||||
const canvas = signatureCanvasRef.value
|
||||
if (canvas) {
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (ctx) {
|
||||
ctx.fillStyle = '#fff'
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
||||
}
|
||||
formData.doctor_signature = ''
|
||||
}
|
||||
}
|
||||
|
||||
const initSignatureCanvas = () => {
|
||||
const canvas = signatureCanvasRef.value
|
||||
if (canvas) {
|
||||
const ctx = canvas.getContext('2d')
|
||||
if (ctx) {
|
||||
ctx.fillStyle = '#fff'
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
||||
ctx.strokeStyle = '#333'
|
||||
ctx.lineWidth = 2
|
||||
ctx.lineCap = 'round'
|
||||
ctx.lineJoin = 'round'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const handleAddHerb = () => {
|
||||
formData.herbs.push({ name: '', dosage: 6 })
|
||||
}
|
||||
|
||||
const handleRemoveHerb = (index: number) => {
|
||||
formData.herbs.splice(index, 1)
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!formData.clinical_diagnosis?.trim()) {
|
||||
feedback.msgWarning('请输入临床诊断')
|
||||
return
|
||||
}
|
||||
if (formData.herbs.length === 0) {
|
||||
feedback.msgWarning('请至少添加一味中药')
|
||||
return
|
||||
}
|
||||
for (const h of formData.herbs) {
|
||||
if (!h.name?.trim()) {
|
||||
feedback.msgWarning('请填写中药名称')
|
||||
return
|
||||
}
|
||||
if (!h.dosage || h.dosage <= 0) {
|
||||
feedback.msgWarning(`请填写「${h.name}」的剂量`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (!formData.doctor_signature?.trim()) {
|
||||
feedback.msgWarning('请使用电子签名板手写医师签名')
|
||||
return
|
||||
}
|
||||
|
||||
saving.value = true
|
||||
try {
|
||||
const res = await prescriptionAdd({
|
||||
diagnosis_id: formData.diagnosis_id,
|
||||
appointment_id: formData.appointment_id,
|
||||
patient_name: formData.patient_name,
|
||||
gender: formData.gender,
|
||||
age: formData.age,
|
||||
phone: formData.phone,
|
||||
visit_no: formData.visit_no,
|
||||
prescription_date: formData.prescription_date,
|
||||
pulse: formData.pulse,
|
||||
tongue: formData.tongue,
|
||||
clinical_diagnosis: formData.clinical_diagnosis,
|
||||
herbs: formData.herbs,
|
||||
dose_count: formData.dose_count,
|
||||
usage_instruction: formData.usage_instruction,
|
||||
amount: formData.amount,
|
||||
doctor_name: formData.doctor_name,
|
||||
doctor_signature: formData.doctor_signature
|
||||
})
|
||||
const id = res?.id
|
||||
if (id) {
|
||||
const detail = await prescriptionDetail({ id })
|
||||
savedPrescription.value = detail
|
||||
emit('success')
|
||||
} else {
|
||||
feedback.msgError('保存失败')
|
||||
}
|
||||
} catch (e: any) {
|
||||
feedback.msgError(e?.msg || '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleNewPrescription = () => {
|
||||
savedPrescription.value = null
|
||||
}
|
||||
|
||||
const captureElement = async (): Promise<HTMLCanvasElement> => {
|
||||
const el = prescriptionPrintRef.value
|
||||
if (!el) throw new Error('未找到处方内容')
|
||||
return html2canvas(el, {
|
||||
scale: 2,
|
||||
useCORS: true,
|
||||
logging: false,
|
||||
backgroundColor: '#ffffff'
|
||||
})
|
||||
}
|
||||
|
||||
const handleDownloadImage = async () => {
|
||||
try {
|
||||
const canvas = await captureElement()
|
||||
const link = document.createElement('a')
|
||||
link.download = `处方_${savedPrescription.value?.patient_name || '未命名'}_${Date.now()}.png`
|
||||
link.href = canvas.toDataURL('image/png')
|
||||
link.click()
|
||||
feedback.msgSuccess('图片已下载')
|
||||
} catch (e) {
|
||||
feedback.msgError('下载图片失败')
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownloadPdf = async () => {
|
||||
try {
|
||||
const canvas = await captureElement()
|
||||
const imgData = canvas.toDataURL('image/png')
|
||||
const pdf = new jsPDF({
|
||||
orientation: 'portrait',
|
||||
unit: 'mm',
|
||||
format: 'a5'
|
||||
})
|
||||
const pageW = pdf.internal.pageSize.getWidth()
|
||||
const pageH = pdf.internal.pageSize.getHeight()
|
||||
const scale = Math.min(pageW / canvas.width, pageH / canvas.height)
|
||||
const imgW = canvas.width * scale
|
||||
const imgH = canvas.height * scale
|
||||
pdf.addImage(imgData, 'PNG', 0, 0, imgW, imgH)
|
||||
pdf.save(`处方_${savedPrescription.value?.patient_name || '未命名'}_${Date.now()}.pdf`)
|
||||
feedback.msgSuccess('PDF已下载')
|
||||
} catch (e) {
|
||||
feedback.msgError('下载PDF失败')
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
openById
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.prescription-form {
|
||||
.info-section {
|
||||
margin-bottom: 20px;
|
||||
padding: 16px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 6px;
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 12px;
|
||||
color: #303133;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.herb-item {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.signature-pad-wrap {
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
|
||||
.signature-canvas {
|
||||
display: block;
|
||||
cursor: crosshair;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.signature-actions {
|
||||
padding: 8px;
|
||||
border-top: 1px solid #ebeef5;
|
||||
}
|
||||
}
|
||||
|
||||
.prescription-print {
|
||||
width: 148mm;
|
||||
min-height: 210mm;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
|
||||
.prescription-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 16px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
||||
.prescription-title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.prescription-type {
|
||||
text-align: right;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.prescription-meta {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.prescription-patient {
|
||||
margin-bottom: 6px;
|
||||
|
||||
span {
|
||||
margin-right: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.prescription-rp {
|
||||
margin: 16px 0;
|
||||
padding: 12px;
|
||||
border: 1px solid #eee;
|
||||
|
||||
.rp-label {
|
||||
font-weight: 600;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.herbs-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px 16px;
|
||||
}
|
||||
|
||||
.herb-cell {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.prescription-disclaimer {
|
||||
text-align: center;
|
||||
color: #e6a23c;
|
||||
font-size: 12px;
|
||||
margin: 12px 0;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.prescription-footer {
|
||||
margin-top: 16px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed #ddd;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
gap: 24px;
|
||||
|
||||
.footer-left {
|
||||
.footer-dosage,
|
||||
.footer-amount {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.footer-right.footer-sign {
|
||||
text-align: right;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.signature-cell {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.doctor-signature-img {
|
||||
height: 28px;
|
||||
max-width: 100px;
|
||||
object-fit: contain;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,442 @@
|
||||
<template>
|
||||
<div class="edit-drawer">
|
||||
<el-drawer
|
||||
v-model="visible"
|
||||
:title="drawerTitle"
|
||||
direction="rtl"
|
||||
size="780px"
|
||||
:before-close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="100px" :rules="formRules">
|
||||
<el-divider content-position="left">基本信息</el-divider>
|
||||
|
||||
<!-- 医助创建诊单数(仅编辑时显示) -->
|
||||
<el-form-item v-if="mode === 'edit' && formData.diagnosis_count != null" label="创建诊单数">
|
||||
<span class="text-primary font-medium">{{ formData.diagnosis_count }}</span>
|
||||
<span class="text-tx-secondary text-sm ml-2">条</span>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 账号输入框 -->
|
||||
<el-form-item label="账号" prop="account">
|
||||
<el-input
|
||||
v-model="formData.account"
|
||||
placeholder="请输入账号"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 医生头像 -->
|
||||
<el-form-item label="头像">
|
||||
<div>
|
||||
<div>
|
||||
<material-picker v-model="formData.avatar" :limit="1" />
|
||||
</div>
|
||||
<div class="form-tips">建议尺寸:100*100px,支持jpg,jpeg,png格式</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 姓名输入框 -->
|
||||
<el-form-item label="姓名" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入姓名" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 性别 -->
|
||||
<el-form-item label="性别" prop="gender">
|
||||
<el-radio-group v-model="formData.gender">
|
||||
<el-radio :label="1">男</el-radio>
|
||||
<el-radio :label="2">女</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 年龄 -->
|
||||
<el-form-item label="年龄" prop="age">
|
||||
<el-input-number v-model="formData.age" :min="18" :max="100" placeholder="请输入年龄" />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 手机号输入框 -->
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="formData.phone" placeholder="请输入手机号" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">组织信息</el-divider>
|
||||
|
||||
<!-- 归属部门 -->
|
||||
<el-form-item label="归属部门" prop="dept_id">
|
||||
<el-tree-select
|
||||
class="flex-1"
|
||||
v-model="formData.dept_id"
|
||||
:data="optionsData.dept"
|
||||
clearable
|
||||
multiple
|
||||
node-key="id"
|
||||
:props="{
|
||||
label: 'name',
|
||||
disabled(data: any) {
|
||||
return data.status !== 1
|
||||
}
|
||||
}"
|
||||
check-strictly
|
||||
:default-expand-all="true"
|
||||
placeholder="请选择归属部门"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 岗位 -->
|
||||
<el-form-item label="岗位" prop="jobs_id">
|
||||
<el-select
|
||||
class="flex-1"
|
||||
v-model="formData.jobs_id"
|
||||
clearable
|
||||
multiple
|
||||
placeholder="请选择岗位"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in optionsData.jobs"
|
||||
:key="index"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">专业信息</el-divider>
|
||||
|
||||
<!-- 职称 -->
|
||||
<el-form-item label="职称" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="如:主任医师、副主任医师" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 所属科室 -->
|
||||
<el-form-item label="所属科室" prop="department">
|
||||
<el-input v-model="formData.department" placeholder="如:中医科、内科" clearable />
|
||||
</el-form-item>
|
||||
|
||||
<!-- 擅长领域 -->
|
||||
<el-form-item label="擅长领域" prop="specialty">
|
||||
<el-input
|
||||
v-model="formData.specialty"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入擅长领域"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">履历信息</el-divider>
|
||||
|
||||
<!-- 教育背景 -->
|
||||
<el-form-item label="教育背景" prop="education">
|
||||
<el-input
|
||||
v-model="formData.education"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入教育背景,如:北京中医药大学 中医学博士"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 工作经历 -->
|
||||
<el-form-item label="工作经历" prop="experience">
|
||||
<el-input
|
||||
v-model="formData.experience"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
placeholder="请输入工作经历"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 荣誉资质 -->
|
||||
<el-form-item label="荣誉资质" prop="honors">
|
||||
<el-input
|
||||
v-model="formData.honors"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
placeholder="请输入荣誉资质"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-divider content-position="left">账号设置</el-divider>
|
||||
|
||||
<!-- 密码输入框 -->
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input
|
||||
v-model="formData.password"
|
||||
show-password
|
||||
clearable
|
||||
:placeholder="mode === 'edit' ? '不修改请留空' : '请输入密码'"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 确认密码输入框 -->
|
||||
<el-form-item label="确认密码" prop="password_confirm">
|
||||
<el-input
|
||||
v-model="formData.password_confirm"
|
||||
show-password
|
||||
clearable
|
||||
:placeholder="mode === 'edit' ? '不修改请留空' : '请输入确认密码'"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 医生状态 -->
|
||||
<el-form-item label="医生状态">
|
||||
<el-switch v-model="formData.disable" :active-value="0" :inactive-value="1" />
|
||||
<span class="ml-2 text-gray-500">{{ formData.disable === 0 ? '启用' : '禁用' }}</span>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 多处登录 -->
|
||||
<el-form-item label="多处登录">
|
||||
<div>
|
||||
<el-switch
|
||||
v-model="formData.multipoint_login"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
/>
|
||||
<div class="form-tips">允许多人同时在线登录</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<div class="flex justify-end">
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit" :loading="loading">确定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { adminAdd, adminDetail, adminEdit } from '@/api/perms/admin'
|
||||
import { deptAll } from '@/api/org/department'
|
||||
import { jobsAll } from '@/api/org/post'
|
||||
import { useDictOptions } from '@/hooks/useDictOptions'
|
||||
import feedback from '@/utils/feedback'
|
||||
|
||||
const emit = defineEmits(['success', 'close'])
|
||||
const formRef = shallowRef<FormInstance>()
|
||||
const visible = ref(false)
|
||||
const mode = ref('add')
|
||||
const loading = ref(false)
|
||||
|
||||
const drawerTitle = computed(() => {
|
||||
return mode.value == 'edit' ? '编辑医助' : '新增医助'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
account: '',
|
||||
name: '',
|
||||
gender: 1,
|
||||
age: null as number | null,
|
||||
phone: '',
|
||||
role_id: [2], // 固定为医助角色
|
||||
dept_id: [],
|
||||
jobs_id: [],
|
||||
avatar: '',
|
||||
title: '', // 职称
|
||||
department: '', // 所属科室
|
||||
specialty: '', // 擅长领域
|
||||
education: '', // 教育背景
|
||||
experience: '', // 工作经历
|
||||
honors: '', // 荣誉资质
|
||||
password: '',
|
||||
password_confirm: '',
|
||||
disable: 0,
|
||||
multipoint_login: 1,
|
||||
diagnosis_count: null as number | null // 医助创建诊单数(详情接口返回)
|
||||
})
|
||||
|
||||
// 获取部门和岗位选项
|
||||
const { optionsData } = useDictOptions<{
|
||||
jobs: any[]
|
||||
dept: any[]
|
||||
}>({
|
||||
jobs: {
|
||||
api: jobsAll
|
||||
},
|
||||
dept: {
|
||||
api: deptAll
|
||||
}
|
||||
})
|
||||
|
||||
// 密码确认验证
|
||||
const passwordConfirmValidator = (rule: object, value: string, callback: any) => {
|
||||
if (formData.password) {
|
||||
if (!value) callback(new Error('请再次输入密码'))
|
||||
if (value !== formData.password) callback(new Error('两次输入密码不一致!'))
|
||||
}
|
||||
callback()
|
||||
}
|
||||
|
||||
// 手机号验证
|
||||
const phoneValidator = (rule: object, value: string, callback: any) => {
|
||||
if (value && !/^1[3-9]\d{9}$/.test(value)) {
|
||||
callback(new Error('请输入正确的手机号'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const formRules = reactive({
|
||||
account: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入账号',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入姓名',
|
||||
trigger: ['blur']
|
||||
}
|
||||
],
|
||||
gender: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择性别',
|
||||
trigger: ['change']
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
validator: phoneValidator,
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
trigger: ['blur']
|
||||
}
|
||||
] as any[],
|
||||
password_confirm: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入确认密码',
|
||||
trigger: ['blur']
|
||||
},
|
||||
{
|
||||
validator: passwordConfirmValidator,
|
||||
trigger: 'blur'
|
||||
}
|
||||
] as any[]
|
||||
})
|
||||
|
||||
const handleSubmit = async () => {
|
||||
try {
|
||||
await formRef.value?.validate()
|
||||
loading.value = true
|
||||
|
||||
mode.value == 'edit' ? await adminEdit(formData) : await adminAdd(formData)
|
||||
|
||||
feedback.msgSuccess(mode.value == 'edit' ? '编辑成功' : '新增成功')
|
||||
visible.value = false
|
||||
emit('success')
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const open = (type = 'add') => {
|
||||
mode.value = type
|
||||
visible.value = true
|
||||
|
||||
// 重置表单
|
||||
if (type === 'add') {
|
||||
Object.assign(formData, {
|
||||
id: '',
|
||||
account: '',
|
||||
name: '',
|
||||
gender: 1,
|
||||
age: null,
|
||||
phone: '',
|
||||
role_id: [2],
|
||||
dept_id: [],
|
||||
jobs_id: [],
|
||||
avatar: '',
|
||||
title: '',
|
||||
department: '',
|
||||
specialty: '',
|
||||
education: '',
|
||||
experience: '',
|
||||
honors: '',
|
||||
password: '',
|
||||
password_confirm: '',
|
||||
disable: 0,
|
||||
multipoint_login: 1,
|
||||
diagnosis_count: null
|
||||
})
|
||||
|
||||
// 新增时密码必填
|
||||
formRules.password = [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入密码',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
formRules.password_confirm = [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入确认密码',
|
||||
trigger: ['blur']
|
||||
},
|
||||
{
|
||||
validator: passwordConfirmValidator,
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const setFormData = async (row: any) => {
|
||||
// 编辑时密码不是必填
|
||||
formRules.password = []
|
||||
formRules.password_confirm = [
|
||||
{
|
||||
validator: passwordConfirmValidator,
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
|
||||
const data = await adminDetail({
|
||||
id: row.id
|
||||
})
|
||||
|
||||
for (const key in formData) {
|
||||
if (data[key] != null && data[key] != undefined) {
|
||||
//@ts-ignore
|
||||
formData[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
// 确保role_id包含医助角色
|
||||
if (!formData.role_id.includes(2)) {
|
||||
formData.role_id.push(2)
|
||||
}
|
||||
}
|
||||
|
||||
const handleClose = () => {
|
||||
visible.value = false
|
||||
emit('close')
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
setFormData
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.form-tips {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,164 @@
|
||||
<!-- 医助列表 -->
|
||||
<template>
|
||||
<div class="doctor-list">
|
||||
<el-card class="!border-none" shadow="never">
|
||||
<el-form class="mb-[-16px]" :model="formData" inline>
|
||||
<el-form-item class="w-[280px]" label="医助账号">
|
||||
<el-input
|
||||
v-model="formData.account"
|
||||
placeholder="请输入医助账号"
|
||||
clearable
|
||||
@keyup.enter="resetPage"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item class="w-[280px]" label="医助名称">
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
placeholder="请输入医助名称"
|
||||
clearable
|
||||
@keyup.enter="resetPage"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="resetPage">查询</el-button>
|
||||
<el-button @click="resetParams">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card v-loading="pager.loading" class="mt-4 !border-none" shadow="never">
|
||||
<el-button v-perms="['auth.admin/add']" type="primary" @click="handleAdd">
|
||||
<template #icon>
|
||||
<icon name="el-icon-Plus" />
|
||||
</template>
|
||||
新增医助
|
||||
</el-button>
|
||||
|
||||
<div class="mt-4">
|
||||
<el-table :data="pager.lists" size="large">
|
||||
<el-table-column label="ID" prop="id" min-width="60" />
|
||||
<el-table-column label="头像" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-avatar :size="50" :src="row.avatar"></el-avatar>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="账号" prop="account" min-width="120" />
|
||||
<el-table-column label="姓名" prop="name" min-width="100" />
|
||||
<el-table-column label="手机号" prop="phone" min-width="120" />
|
||||
<el-table-column label="创建时间" prop="create_time" min-width="180" />
|
||||
<el-table-column label="最近登录时间" prop="login_time" min-width="180" />
|
||||
<el-table-column label="最近登录IP" prop="login_ip" min-width="120" />
|
||||
<el-table-column label="状态" min-width="100" v-perms="['auth.admin/edit']">
|
||||
<template #default="{ row }">
|
||||
<el-switch
|
||||
v-model="row.disable"
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
@change="changeStatus(row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['auth.admin/edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handleEdit(row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['auth.admin/delete']"
|
||||
type="danger"
|
||||
link
|
||||
@click="handleDelete(row.id)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div class="flex mt-4 justify-end">
|
||||
<pagination v-model="pager" @change="getLists" />
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="doctorList">
|
||||
import { adminDelete, adminEdit, adminLists } from '@/api/perms/admin'
|
||||
import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
|
||||
import EditPopup from './edit.vue'
|
||||
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
|
||||
// 表单数据 - 固定role_id=1查询医助
|
||||
const formData = reactive({
|
||||
account: '',
|
||||
name: '',
|
||||
role_id: 2 // 固定为医助角色
|
||||
})
|
||||
|
||||
const showEdit = ref(false)
|
||||
|
||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
||||
fetchFun: adminLists,
|
||||
params: formData
|
||||
})
|
||||
|
||||
// 修改状态
|
||||
const changeStatus = (data: any) => {
|
||||
adminEdit({
|
||||
id: data.id,
|
||||
avatar: data.avatar,
|
||||
account: data.account,
|
||||
name: data.name,
|
||||
role_id: data.role_id,
|
||||
jobs_id: data.jobs_id,
|
||||
dept_id: data.dept_id,
|
||||
disable: data.disable,
|
||||
multipoint_login: data.multipoint_login
|
||||
}).finally(() => {
|
||||
getLists()
|
||||
})
|
||||
}
|
||||
|
||||
// 新增医助
|
||||
const handleAdd = async () => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('add')
|
||||
}
|
||||
|
||||
// 编辑医助
|
||||
const handleEdit = async (data: any) => {
|
||||
showEdit.value = true
|
||||
await nextTick()
|
||||
editRef.value?.open('edit')
|
||||
editRef.value?.setFormData(data)
|
||||
}
|
||||
|
||||
// 删除医助
|
||||
const handleDelete = async (id: number) => {
|
||||
await feedback.confirm('确定要删除该医助吗?')
|
||||
await adminDelete({ id })
|
||||
getLists()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLists()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.doctor-list {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -509,7 +509,11 @@ const getOrderTypeText = (type: number) => {
|
||||
const typeMap: Record<number, string> = {
|
||||
1: '挂号费',
|
||||
2: '问诊费',
|
||||
3: '药品费用'
|
||||
3: '药品费用',
|
||||
4: '首付费用',
|
||||
5: '尾款费用',
|
||||
6:'其他费用',
|
||||
7:'全部费用',
|
||||
}
|
||||
return typeMap[type] || '未知'
|
||||
}
|
||||
|
||||
@@ -190,6 +190,15 @@
|
||||
>
|
||||
视频二维码
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="row.status === 1"
|
||||
v-perms="['tcm.diagnosis/kaifang']"
|
||||
type="primary"
|
||||
link
|
||||
@click="handlePrescription(row)"
|
||||
>
|
||||
开方
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -250,8 +259,8 @@
|
||||
<!-- 编辑患者弹窗 -->
|
||||
<edit-popup ref="editRef" @success="getLists" />
|
||||
|
||||
<!-- 处方单抽屉 -->
|
||||
<prescription-drawer ref="prescriptionDrawerRef" @success="loadData" />
|
||||
<!-- 中医处方单 -->
|
||||
<tcm-prescription ref="prescriptionRef" @success="loadData" />
|
||||
|
||||
<!-- 聊天对话框 -->
|
||||
<chat-dialog ref="chatDialogRef" />
|
||||
@@ -298,7 +307,7 @@ import { appointmentLists, cancelAppointment, completeAppointment, appointmentDe
|
||||
import { getCallSignature, generateMiniProgramQrcode } from '@/api/tcm'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from '../diagnosis/edit.vue'
|
||||
import PrescriptionDrawer from './components/prescription-drawer.vue'
|
||||
import TcmPrescription from '@/components/tcm-prescription/index.vue'
|
||||
import ChatDialog from '@/components/chat-dialog/index.vue'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
import { getWeappConfig } from '@/api/channel/weapp'
|
||||
@@ -392,7 +401,7 @@ const handleReset = () => {
|
||||
const detailVisible = ref(false)
|
||||
const detailData = ref<any>(null)
|
||||
const editRef = ref()
|
||||
const prescriptionDrawerRef = ref()
|
||||
const prescriptionRef = ref()
|
||||
const chatDialogRef = ref()
|
||||
|
||||
// 小程序二维码相关
|
||||
@@ -525,6 +534,15 @@ const handleMiniProgramQRCode = async (row: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 开处方
|
||||
const handlePrescription = (row: any) => {
|
||||
if (!row.diagnosis_id && !row.patient_id) {
|
||||
feedback.msgWarning('该预约缺少诊单信息,请先编辑患者')
|
||||
return
|
||||
}
|
||||
prescriptionRef.value?.open(row)
|
||||
}
|
||||
|
||||
// 重新生成二维码
|
||||
const handleRegenerateQRCode = () => {
|
||||
if (currentQRCodeRow.value) {
|
||||
|
||||
@@ -284,6 +284,10 @@
|
||||
<el-option label="挂号费" :value="1" />
|
||||
<el-option label="问诊费" :value="2" />
|
||||
<el-option label="药品费用" :value="3" />
|
||||
<el-option label="首付费用" :value="4" />
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="全部费用" :value="7" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<div class="workbench">
|
||||
<div class="lg:flex">
|
||||
|
||||
|
||||
<!-- <div class="lg:flex">
|
||||
<el-card class="!border-none mb-4 lg:mr-4 lg:w-[350px]" shadow="never">
|
||||
<template #header>
|
||||
<span class="card-title">版本信息</span>
|
||||
@@ -72,8 +74,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
<div class="function mb-4">
|
||||
</div> -->
|
||||
<!-- <div class="function mb-4">
|
||||
<el-card class="flex-1 !border-none" shadow="never">
|
||||
<template #header>
|
||||
<span>常用功能</span>
|
||||
@@ -91,7 +93,232 @@
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<!-- 医助理诊单统计 -->
|
||||
<el-card class="!border-none mt-4 w-full" shadow="never">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<span>医助理诊单统计</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-tx-secondary text-sm">
|
||||
{{ assistantStats.date_range?.[0] }} 至 {{ assistantStats.date_range?.[1] }}
|
||||
</span>
|
||||
<el-select v-model="assistantStats.days" class="w-28" @change="loadAssistantStats">
|
||||
<el-option label="今天" :value="0" />
|
||||
<el-option label="最近7天" :value="7" />
|
||||
<el-option label="最近14天" :value="14" />
|
||||
<el-option label="最近30天" :value="30" />
|
||||
</el-select>
|
||||
<el-button type="primary" link @click="loadAssistantStats">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 今日统计 -->
|
||||
<div class="mb-4 p-4 rounded-lg bg-blue-50 border border-blue-100">
|
||||
<div class="flex items-center justify-between flex-wrap gap-4">
|
||||
<div class="flex items-center gap-6">
|
||||
<div>
|
||||
<span class="text-tx-secondary text-sm">今日创建诊单</span>
|
||||
<div class="text-2xl font-bold text-primary mt-1">{{ assistantStats.today_total ?? 0 }}</div>
|
||||
</div>
|
||||
<div v-if="assistantStats.today_ranking?.length" class="flex items-center gap-4 pl-6 border-l border-blue-200">
|
||||
<span class="text-tx-secondary text-sm">今日排行:</span>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="(a, idx) in assistantStats.today_ranking.slice(0, 5)"
|
||||
:key="a.id"
|
||||
class="inline-flex items-center gap-1 px-2 py-1 rounded text-sm bg-white"
|
||||
>
|
||||
<span class="text-amber-500 font-medium">{{ idx + 1 }}.</span>
|
||||
<span>{{ a.name }}</span>
|
||||
<span class="text-primary font-medium">{{ a.count }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
<!-- 医助排行 -->
|
||||
<div class="lg:col-span-1">
|
||||
<div class="font-medium text-gray-800 mb-3">医助排行</div>
|
||||
<div v-if="assistantStats.ranking?.length" class="space-y-2">
|
||||
<div
|
||||
v-for="(a, idx) in assistantStats.ranking"
|
||||
:key="a.id"
|
||||
class="flex items-center justify-between py-2 px-3 rounded-lg"
|
||||
:class="idx < 3 ? 'bg-amber-50' : 'bg-gray-50'"
|
||||
>
|
||||
<span class="flex items-center gap-2">
|
||||
<span
|
||||
class="w-6 h-6 rounded-full text-center text-xs font-medium leading-6"
|
||||
:class="idx === 0 ? 'bg-amber-400 text-white' : idx === 1 ? 'bg-gray-300 text-gray-700' : idx === 2 ? 'bg-amber-200 text-amber-800' : 'bg-gray-200 text-gray-600'"
|
||||
>
|
||||
{{ idx + 1 }}
|
||||
</span>
|
||||
<span class="text-gray-800">{{ a.name }}</span>
|
||||
</span>
|
||||
<span class="font-semibold text-primary">{{ a.count }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="py-8 text-center text-tx-secondary">暂无排行数据</div>
|
||||
</div>
|
||||
<!-- 图表 -->
|
||||
<div class="lg:col-span-2">
|
||||
<div class="font-medium text-gray-800 mb-2">诊单数分布</div>
|
||||
<v-charts
|
||||
v-if="assistantStats.chart.xAxis?.length"
|
||||
ref="assistantChart"
|
||||
style="height: 320px"
|
||||
:option="assistantChartOption"
|
||||
:autoresize="true"
|
||||
/>
|
||||
<div v-else class="h-[320px] flex items-center justify-center text-tx-secondary">
|
||||
暂无数据
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="assistantStats.departments?.length" class="mt-4 pt-4 border-t border-gray-100">
|
||||
<div class="font-medium text-gray-800 mb-3">按部门统计</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div
|
||||
v-for="dept in assistantStats.departments"
|
||||
:key="dept.dept_id"
|
||||
class="p-4 rounded-lg bg-gray-50"
|
||||
>
|
||||
<div class="font-medium text-gray-800 mb-2">{{ dept.dept_name }}(共{{ dept.total }})</div>
|
||||
<div class="space-y-1 text-sm">
|
||||
<div
|
||||
v-for="a in dept.assistants"
|
||||
:key="`${dept.dept_id}-${a.id}`"
|
||||
class="flex justify-between"
|
||||
>
|
||||
<span class="text-gray-600">{{ a.name }}</span>
|
||||
<span class="font-medium">{{ a.count }}</span>
|
||||
</div>
|
||||
<div v-if="!dept.assistants?.length" class="text-tx-secondary">暂无医助</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<!-- 订单统计 -->
|
||||
<el-card class="!border-none mt-4 w-full" shadow="never">
|
||||
<template #header>
|
||||
<span>订单统计</span>
|
||||
</template>
|
||||
<div class="order-stats-panel">
|
||||
<div class="flex justify-between items-center mb-4 flex-wrap gap-2">
|
||||
<span class="text-tx-secondary text-sm">{{ orderStatsDateRangeText }}</span>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-gray-600 text-sm">统计类型</span>
|
||||
<el-select v-model="orderStatsType" style="width: 120px" @change="loadOrderStats">
|
||||
<el-option label="挂号费" :value="1" />
|
||||
<el-option label="问诊费" :value="2" />
|
||||
<el-option label="药品费用" :value="3" />
|
||||
<el-option label="首付费用" :value="4" />
|
||||
<el-option label="尾款费用" :value="5" />
|
||||
<el-option label="其他费用" :value="6" />
|
||||
<el-option label="退款统计" :value="0" />
|
||||
</el-select>
|
||||
<span class="text-gray-600 text-sm">时间范围</span>
|
||||
<el-select v-model="orderStatsDays" style="width: 110px" @change="loadOrderStats">
|
||||
<el-option label="今天" :value="0" />
|
||||
<el-option label="最近7天" :value="7" />
|
||||
<el-option label="最近30天" :value="30" />
|
||||
</el-select>
|
||||
<el-button type="primary" link @click="loadOrderStats">刷新</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-4 p-4 rounded-lg bg-green-50 border border-green-100">
|
||||
<div class="flex items-center gap-6 flex-wrap">
|
||||
<div>
|
||||
<span class="text-tx-secondary text-sm">今日单数</span>
|
||||
<div class="text-2xl font-bold text-primary mt-1">{{ orderStatsData.today_total ?? 0 }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-tx-secondary text-sm">今日金额</span>
|
||||
<div class="text-2xl font-bold text-primary mt-1">¥{{ orderStatsData.today_amount ?? '0.00' }}</div>
|
||||
</div>
|
||||
<div v-if="orderStatsData.today_ranking?.length" class="flex items-center gap-4 pl-6 border-l border-green-200">
|
||||
<span class="text-tx-secondary text-sm">今日排行:</span>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="(a, idx) in orderStatsData.today_ranking.slice(0, 5)"
|
||||
:key="a.id"
|
||||
class="inline-flex items-center gap-1 px-2 py-1 rounded text-sm bg-white"
|
||||
>
|
||||
<span class="text-amber-500 font-medium">{{ Number(idx) + 1 }}.</span>
|
||||
<span>{{ a.name }}</span>
|
||||
<span class="text-primary font-medium">{{ a.count }}</span>
|
||||
<span class="text-gray-500">¥{{ a.amount }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4">
|
||||
<div class="lg:col-span-1">
|
||||
<div class="font-medium text-gray-800 mb-3">排行</div>
|
||||
<div v-if="orderStatsData.ranking?.length" class="space-y-2">
|
||||
<div
|
||||
v-for="(a, idx) in orderStatsData.ranking"
|
||||
:key="a.id"
|
||||
class="flex items-center justify-between py-2 px-3 rounded-lg bg-gray-50"
|
||||
>
|
||||
<span class="flex items-center gap-2">
|
||||
<span class="w-6 h-6 rounded-full text-center text-xs font-medium leading-6 bg-gray-200 text-gray-600">{{ Number(idx) + 1 }}</span>
|
||||
<span class="text-gray-800">{{ a.name }}</span>
|
||||
</span>
|
||||
<span class="text-right">
|
||||
<span class="font-semibold text-primary">{{ a.count }}</span>
|
||||
<span class="text-gray-500 text-sm ml-1">¥{{ a.amount }}</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="py-8 text-center text-tx-secondary">暂无数据</div>
|
||||
</div>
|
||||
<div class="lg:col-span-2">
|
||||
<div class="font-medium text-gray-800 mb-2">单数分布</div>
|
||||
<v-charts
|
||||
v-if="orderStatsData.chart?.xAxis?.length"
|
||||
:key="'order-chart-' + orderStatsType"
|
||||
style="height: 280px"
|
||||
:option="orderChartOption"
|
||||
:autoresize="true"
|
||||
/>
|
||||
<div v-else class="h-[280px] flex items-center justify-center text-tx-secondary">暂无数据</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="orderStatsData.departments?.length" class="mt-4 pt-4 border-t border-gray-100">
|
||||
<div class="font-medium text-gray-800 mb-3">按部门统计</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
||||
<div
|
||||
v-for="dept in orderStatsData.departments"
|
||||
:key="dept.dept_id"
|
||||
class="p-4 rounded-lg bg-gray-50"
|
||||
>
|
||||
<div class="font-medium text-gray-800 mb-2">{{ dept.dept_name }}({{ dept.total }}单 ¥{{ dept.amount }})</div>
|
||||
<div class="space-y-1 text-sm">
|
||||
<div
|
||||
v-for="m in dept.members"
|
||||
:key="`${dept.dept_id}-${m.id}`"
|
||||
class="flex justify-between"
|
||||
>
|
||||
<span class="text-gray-600">{{ m.name }}</span>
|
||||
<span><span class="font-medium">{{ m.count }}</span> <span class="text-gray-500">¥{{ m.amount }}</span></span>
|
||||
</div>
|
||||
<div v-if="!dept.members?.length" class="text-tx-secondary">暂无</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<div class="lg:flex gap-4">
|
||||
<el-card class="!border-none mb-4 lg:mb-0 w-full lg:w-2/3" shadow="never">
|
||||
<template #header>
|
||||
@@ -127,6 +354,8 @@
|
||||
import vCharts from 'vue-echarts'
|
||||
|
||||
import { getWorkbench } from '@/api/app'
|
||||
import { assistantDiagnosisStats } from '@/api/tcm'
|
||||
import { orderStats } from '@/api/order'
|
||||
import useSettingStore from '@/stores/modules/setting'
|
||||
import { useComponentRef } from '@/utils/getExposeType'
|
||||
import { calcColor } from '@/utils/util'
|
||||
@@ -134,6 +363,138 @@ import { calcColor } from '@/utils/util'
|
||||
const settingStore = useSettingStore()
|
||||
const saleChart = useComponentRef(vCharts)
|
||||
const visitorChart = useComponentRef(vCharts)
|
||||
const assistantChart = useComponentRef(vCharts)
|
||||
|
||||
const assistantStats = reactive<{
|
||||
days: number
|
||||
date_range?: [string, string]
|
||||
today_total?: number
|
||||
today_ranking?: { id: number; name: string; count: number }[]
|
||||
departments: any[]
|
||||
ranking: { id: number; name: string; count: number }[]
|
||||
chart: { xAxis: string[]; series: any[] }
|
||||
}>({
|
||||
days: 7,
|
||||
departments: [],
|
||||
today_ranking: [],
|
||||
ranking: [],
|
||||
chart: { xAxis: [], series: [] }
|
||||
})
|
||||
|
||||
const assistantChartOption = computed(() => ({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: assistantStats.chart.xAxis || [],
|
||||
axisLabel: { rotate: 30 }
|
||||
},
|
||||
yAxis: { type: 'value', name: '诊单数' },
|
||||
tooltip: { trigger: 'axis' },
|
||||
grid: { left: '3%', right: '4%', bottom: '15%', containLabel: true },
|
||||
series: (assistantStats.chart.series || []).map((s: any) => ({
|
||||
...s,
|
||||
type: 'bar',
|
||||
barWidth: '50%',
|
||||
itemStyle: {
|
||||
borderRadius: [6, 6, 0, 0],
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: calcColor(settingStore.theme, 0.8) },
|
||||
{ offset: 1, color: settingStore.theme }
|
||||
]
|
||||
}
|
||||
}
|
||||
}))
|
||||
}))
|
||||
|
||||
const loadAssistantStats = () => {
|
||||
assistantDiagnosisStats({ days: assistantStats.days })
|
||||
.then((res: any) => {
|
||||
assistantStats.date_range = res.date_range
|
||||
assistantStats.today_total = res.today_total ?? 0
|
||||
assistantStats.today_ranking = res.today_ranking || []
|
||||
assistantStats.departments = res.departments || []
|
||||
assistantStats.ranking = res.ranking || []
|
||||
assistantStats.chart = res.chart || { xAxis: [], series: [] }
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
const orderStatsType = ref(1)
|
||||
const orderStatsDays = ref(7)
|
||||
const orderStatsData = reactive<any>({
|
||||
date_range: [] as string[],
|
||||
today_total: 0,
|
||||
today_amount: '0.00',
|
||||
today_ranking: [],
|
||||
departments: [],
|
||||
ranking: [],
|
||||
chart: { xAxis: [], series: [] }
|
||||
})
|
||||
const orderStatsDateRangeText = computed(() => {
|
||||
const arr = orderStatsData.date_range
|
||||
if (arr?.length >= 2) return `${arr[0]} 至 ${arr[1]}`
|
||||
const days = orderStatsDays.value
|
||||
const end = new Date()
|
||||
const start = new Date()
|
||||
if (days === 0) {
|
||||
start.setHours(0, 0, 0, 0)
|
||||
return `${formatDate(start)} 至 ${formatDate(end)}`
|
||||
}
|
||||
start.setDate(start.getDate() - (days || 7))
|
||||
return `${formatDate(start)} 至 ${formatDate(end)}`
|
||||
})
|
||||
function formatDate(d: Date) {
|
||||
return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0')
|
||||
}
|
||||
const orderChartOption = computed(() => ({
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: orderStatsData.chart?.xAxis || [],
|
||||
axisLabel: { rotate: 30 }
|
||||
},
|
||||
yAxis: { type: 'value', name: '单数' },
|
||||
tooltip: { trigger: 'axis' },
|
||||
grid: { left: '3%', right: '4%', bottom: '15%', containLabel: true },
|
||||
series: (orderStatsData.chart?.series || []).map((s: any) => ({
|
||||
...s,
|
||||
type: 'bar',
|
||||
barWidth: '50%',
|
||||
itemStyle: {
|
||||
borderRadius: [6, 6, 0, 0],
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 0,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 1,
|
||||
colorStops: [
|
||||
{ offset: 0, color: calcColor(settingStore.theme, 0.8) },
|
||||
{ offset: 1, color: settingStore.theme }
|
||||
]
|
||||
}
|
||||
}
|
||||
}))
|
||||
}))
|
||||
const loadOrderStats = () => {
|
||||
orderStats({ order_type: orderStatsType.value, days: orderStatsDays.value })
|
||||
.then((res: any) => {
|
||||
Object.assign(orderStatsData, {
|
||||
date_range: res.date_range || [],
|
||||
today_total: res.today_total ?? 0,
|
||||
today_amount: res.today_amount ?? '0.00',
|
||||
today_ranking: res.today_ranking || [],
|
||||
departments: res.departments || [],
|
||||
ranking: res.ranking || [],
|
||||
chart: res.chart || { xAxis: [], series: [] }
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => settingStore.theme,
|
||||
@@ -347,6 +708,8 @@ const updateColor = () => {
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
loadAssistantStats()
|
||||
loadOrderStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
+6
-1
@@ -19,4 +19,9 @@ zyt_admin(用户表)
|
||||
|
||||
1000031
|
||||
|
||||
bLD-1HtnimxLuF1A-24-DeD0nBri0T_Dc1BzE6zbZb4
|
||||
bLD-1HtnimxLuF1A-24-DeD0nBri0T_Dc1BzE6zbZb4
|
||||
|
||||
|
||||
小程序 :wx79b9a0bfbfe7cbcd
|
||||
|
||||
appsecret:367963c99d60ce076c1863c659042af4
|
||||
@@ -25,6 +25,17 @@ class OrderController extends BaseAdminController
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单统计(挂号费/药品费用)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function orderStats()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = OrderLogic::orderStats($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
|
||||
@@ -50,6 +50,17 @@ class DiagnosisController extends BaseAdminController
|
||||
return $this->dataLists(new DiagnosisLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 医助理诊单统计(按部门、按人)
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function assistantDiagnosisStats()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = DiagnosisLogic::assistantDiagnosisStats($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加诊单
|
||||
* @return \think\response\Json
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\controller\tcm;
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\logic\tcm\PrescriptionLogic;
|
||||
use app\adminapi\validate\tcm\PrescriptionValidate;
|
||||
|
||||
/**
|
||||
* 中医处方单控制器
|
||||
*/
|
||||
class PrescriptionController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 添加处方
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->post()->goCheck('add');
|
||||
$params['creator_id'] = $this->adminId;
|
||||
$id = PrescriptionLogic::add($params, $this->adminId);
|
||||
if ($id === null) {
|
||||
return $this->fail(PrescriptionLogic::getError());
|
||||
}
|
||||
return $this->success('保存成功', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 处方详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new PrescriptionValidate())->get()->goCheck('detail');
|
||||
$detail = PrescriptionLogic::detail((int)$params['id']);
|
||||
if (!$detail) {
|
||||
return $this->fail('处方不存在');
|
||||
}
|
||||
return $this->data($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据诊单获取处方列表
|
||||
*/
|
||||
public function listByDiagnosis()
|
||||
{
|
||||
$diagnosisId = (int)($this->request->get('diagnosis_id') ?? 0);
|
||||
if (!$diagnosisId) {
|
||||
return $this->fail('诊单ID不能为空');
|
||||
}
|
||||
$list = PrescriptionLogic::listByDiagnosis($diagnosisId);
|
||||
return $this->data($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 根据预约获取处方
|
||||
*/
|
||||
public function getByAppointment()
|
||||
{
|
||||
$appointmentId = (int)($this->request->get('appointment_id') ?? 0);
|
||||
if (!$appointmentId) {
|
||||
return $this->fail('预约ID不能为空');
|
||||
}
|
||||
$prescription = PrescriptionLogic::getByAppointment($appointmentId);
|
||||
return $this->data($prescription ?? []);
|
||||
}
|
||||
}
|
||||
@@ -258,6 +258,12 @@ class AdminLogic extends BaseLogic
|
||||
])->findOrEmpty($params['id'])->toArray();
|
||||
|
||||
if ($action == 'detail') {
|
||||
$roleIds = AdminRole::where('admin_id', $params['id'])->column('role_id');
|
||||
if (in_array(2, $roleIds)) {
|
||||
$admin['diagnosis_count'] = \app\common\model\tcm\Diagnosis::where('assistant_id', $params['id'])
|
||||
->whereNull('delete_time')
|
||||
->count();
|
||||
}
|
||||
return $admin;
|
||||
}
|
||||
|
||||
|
||||
@@ -427,4 +427,213 @@ class OrderLogic
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private static $orderTypeNames = [
|
||||
0 => '退款统计',
|
||||
1 => '挂号费',
|
||||
2 => '问诊费',
|
||||
3 => '药品费用',
|
||||
4 => '首付费用',
|
||||
5 => '尾款费用',
|
||||
6 => '其他费用',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 订单统计(按订单类型或退款)
|
||||
* @param array $params order_type(0退款,1挂号费,2问诊费,3药品费用,4首付,5尾款,6其他), days(0今天,7,30)
|
||||
* @return array
|
||||
*/
|
||||
public static function orderStats(array $params = [])
|
||||
{
|
||||
$orderType = isset($params['order_type']) ? (int)$params['order_type'] : 1;
|
||||
if (!array_key_exists($orderType, self::$orderTypeNames)) {
|
||||
$orderType = 1;
|
||||
}
|
||||
$days = isset($params['days']) ? (int)$params['days'] : 7;
|
||||
|
||||
$endTime = !empty($params['end_time']) ? strtotime($params['end_time']) : time();
|
||||
if ($days === 0) {
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
} else {
|
||||
$days = $days > 0 ? min($days, 90) : 7;
|
||||
$startTime = strtotime("-{$days} days", $endTime);
|
||||
}
|
||||
$startStr = date('Y-m-d H:i:s', $startTime);
|
||||
$endStr = date('Y-m-d H:i:s', $endTime);
|
||||
|
||||
$depts = \app\common\model\dept\Dept::where('status', 1)
|
||||
->whereNull('delete_time')
|
||||
->order('sort desc, id asc')
|
||||
->column('name', 'id');
|
||||
|
||||
$query = Order::where('create_time', 'between', [$startStr, $endStr])
|
||||
->whereNull('delete_time');
|
||||
if ($orderType === 0) {
|
||||
$query->where('status', 4);
|
||||
} else {
|
||||
$query->where('order_type', $orderType)->where('status', 2);
|
||||
}
|
||||
$orderRows = $query
|
||||
->field('creator_id, count(*) as cnt, sum(amount) as total_amount')
|
||||
->group('creator_id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$creatorIds = array_unique(array_column($orderRows, 'creator_id'));
|
||||
$creatorIds = array_filter($creatorIds);
|
||||
if (empty($creatorIds)) {
|
||||
return [
|
||||
'order_type' => $orderType,
|
||||
'order_type_name' => self::$orderTypeNames[$orderType],
|
||||
'date_range' => [date('Y-m-d', $startTime), date('Y-m-d', $endTime)],
|
||||
'today_total' => 0,
|
||||
'today_amount' => '0.00',
|
||||
'today_ranking' => [],
|
||||
'departments' => [],
|
||||
'ranking' => [],
|
||||
'chart' => ['xAxis' => [], 'series' => []],
|
||||
];
|
||||
}
|
||||
|
||||
$counts = [];
|
||||
$amounts = [];
|
||||
foreach ($orderRows as $row) {
|
||||
$counts[$row['creator_id']] = (int)$row['cnt'];
|
||||
$amounts[$row['creator_id']] = round((float)$row['total_amount'], 2);
|
||||
}
|
||||
|
||||
$adminDepts = \app\common\model\auth\AdminDept::whereIn('admin_id', $creatorIds)
|
||||
->select()
|
||||
->toArray();
|
||||
$adminToDepts = [];
|
||||
foreach ($adminDepts as $ad) {
|
||||
$adminId = $ad['admin_id'];
|
||||
if (!isset($adminToDepts[$adminId])) {
|
||||
$adminToDepts[$adminId] = [];
|
||||
}
|
||||
$adminToDepts[$adminId][] = (int)$ad['dept_id'];
|
||||
}
|
||||
|
||||
$admins = \app\common\model\auth\Admin::whereIn('id', $creatorIds)
|
||||
->whereNull('delete_time')
|
||||
->column('name', 'id');
|
||||
|
||||
$todayStart = strtotime(date('Y-m-d'));
|
||||
$todayEnd = time();
|
||||
$todayStr = date('Y-m-d H:i:s', $todayStart);
|
||||
$todayEndStr = date('Y-m-d H:i:s', $todayEnd);
|
||||
$todayQuery = Order::where('create_time', 'between', [$todayStr, $todayEndStr])
|
||||
->whereNull('delete_time');
|
||||
if ($orderType === 0) {
|
||||
$todayQuery->where('status', 4);
|
||||
} else {
|
||||
$todayQuery->where('order_type', $orderType)->where('status', 2);
|
||||
}
|
||||
$todayRows = $todayQuery
|
||||
->field('creator_id, count(*) as cnt, sum(amount) as total_amount')
|
||||
->group('creator_id')
|
||||
->select()
|
||||
->toArray();
|
||||
$todayCounts = [];
|
||||
$todayAmounts = [];
|
||||
foreach ($todayRows as $row) {
|
||||
$todayCounts[$row['creator_id']] = (int)$row['cnt'];
|
||||
$todayAmounts[$row['creator_id']] = round((float)$row['total_amount'], 2);
|
||||
}
|
||||
$todayTotal = array_sum($todayCounts);
|
||||
$todayAmount = array_sum($todayAmounts);
|
||||
$todayRanking = [];
|
||||
foreach ($creatorIds as $cid) {
|
||||
$cnt = (int)($todayCounts[$cid] ?? 0);
|
||||
$amt = (float)($todayAmounts[$cid] ?? 0);
|
||||
if ($cnt > 0 || $amt > 0) {
|
||||
$todayRanking[] = [
|
||||
'id' => (int)$cid,
|
||||
'name' => $admins[$cid] ?? '未知',
|
||||
'count' => $cnt,
|
||||
'amount' => number_format($amt, 2, '.', ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
usort($todayRanking, fn($a, $b) => $b['count'] <=> $a['count']);
|
||||
|
||||
$deptData = [];
|
||||
$assignedIds = [];
|
||||
foreach ($depts as $deptId => $deptName) {
|
||||
$members = [];
|
||||
foreach ($adminToDepts as $adminId => $deptIdsArr) {
|
||||
if (!in_array((int)$deptId, $deptIdsArr)) {
|
||||
continue;
|
||||
}
|
||||
$assignedIds[] = $adminId;
|
||||
$members[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => (int)($counts[$adminId] ?? 0),
|
||||
'amount' => number_format((float)($amounts[$adminId] ?? 0), 2, '.', ''),
|
||||
];
|
||||
}
|
||||
$deptTotal = array_sum(array_column($members, 'count'));
|
||||
$deptAmount = array_sum(array_map(fn($m) => (float)$m['amount'], $members));
|
||||
$deptData[] = [
|
||||
'dept_id' => (int)$deptId,
|
||||
'dept_name' => $deptName,
|
||||
'members' => $members,
|
||||
'total' => $deptTotal,
|
||||
'amount' => number_format($deptAmount, 2, '.', ''),
|
||||
];
|
||||
}
|
||||
$unassignedIds = array_diff($creatorIds, array_unique($assignedIds));
|
||||
if (!empty($unassignedIds)) {
|
||||
$members = [];
|
||||
foreach ($unassignedIds as $adminId) {
|
||||
$members[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => (int)($counts[$adminId] ?? 0),
|
||||
'amount' => number_format((float)($amounts[$adminId] ?? 0), 2, '.', ''),
|
||||
];
|
||||
}
|
||||
$deptData[] = [
|
||||
'dept_id' => 0,
|
||||
'dept_name' => '未分配部门',
|
||||
'members' => $members,
|
||||
'total' => array_sum(array_column($members, 'count')),
|
||||
'amount' => number_format(array_sum(array_map(fn($m) => (float)$m['amount'], $members)), 2, '.', ''),
|
||||
];
|
||||
}
|
||||
|
||||
$ranking = [];
|
||||
foreach ($creatorIds as $adminId) {
|
||||
$ranking[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => (int)($counts[$adminId] ?? 0),
|
||||
'amount' => number_format((float)($amounts[$adminId] ?? 0), 2, '.', ''),
|
||||
];
|
||||
}
|
||||
usort($ranking, fn($a, $b) => $b['count'] <=> $a['count']);
|
||||
|
||||
$chartNames = [];
|
||||
$chartData = [];
|
||||
foreach ($ranking as $i => $r) {
|
||||
$chartNames[] = ($i + 1) . '.' . $r['name'];
|
||||
$chartData[] = $r['count'];
|
||||
}
|
||||
|
||||
return [
|
||||
'order_type' => $orderType,
|
||||
'order_type_name' => self::$orderTypeNames[$orderType],
|
||||
'date_range' => [date('Y-m-d', $startTime), date('Y-m-d', $endTime)],
|
||||
'today_total' => $todayTotal,
|
||||
'today_amount' => number_format($todayAmount, 2, '.', ''),
|
||||
'today_ranking' => $todayRanking,
|
||||
'departments' => $deptData,
|
||||
'ranking' => $ranking,
|
||||
'chart' => [
|
||||
'xAxis' => $chartNames,
|
||||
'series' => [['name' => '单数', 'data' => $chartData]],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1066,7 +1066,6 @@ class DiagnosisLogic extends BaseLogic
|
||||
|
||||
// 获取access_token(如果是重试,强制刷新)
|
||||
$forceRefresh = $retryCount > 0;
|
||||
|
||||
$accessToken = self::getWxAccessToken($config['app_id'], $config['app_secret'], $forceRefresh);
|
||||
|
||||
if (!$accessToken) {
|
||||
@@ -1723,4 +1722,168 @@ class DiagnosisLogic extends BaseLogic
|
||||
curl_close($ch);
|
||||
return $result ? json_decode($result, true) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 医助理诊单统计(按部门维度,按人统计创建数量)
|
||||
* @param array $params start_time, end_time, days(可选,默认7)
|
||||
* @return array
|
||||
*/
|
||||
public static function assistantDiagnosisStats(array $params = [])
|
||||
{
|
||||
$days = isset($params['days']) ? (int)$params['days'] : 7;
|
||||
|
||||
$endTime = !empty($params['end_time']) ? strtotime($params['end_time']) : time();
|
||||
if ($days === 0) {
|
||||
$startTime = strtotime(date('Y-m-d'));
|
||||
} else {
|
||||
$days = $days > 0 ? min($days, 90) : 7;
|
||||
$startTime = !empty($params['start_time']) ? strtotime($params['start_time']) : strtotime("-{$days} days", $endTime);
|
||||
if ($startTime > $endTime) {
|
||||
$startTime = strtotime("-{$days} days", $endTime);
|
||||
}
|
||||
}
|
||||
|
||||
$depts = \app\common\model\dept\Dept::where('status', 1)
|
||||
->whereNull('delete_time')
|
||||
->order('sort desc, id asc')
|
||||
->column('name', 'id');
|
||||
|
||||
$assistantIds = \app\common\model\auth\AdminRole::where('role_id', 2)
|
||||
->column('admin_id');
|
||||
if (empty($assistantIds)) {
|
||||
return [
|
||||
'date_range' => [date('Y-m-d', $startTime), date('Y-m-d', $endTime)],
|
||||
'today_total' => 0,
|
||||
'today_ranking' => [],
|
||||
'departments' => [],
|
||||
'ranking' => [],
|
||||
'chart' => ['xAxis' => [], 'series' => []],
|
||||
];
|
||||
}
|
||||
|
||||
$adminDepts = \app\common\model\auth\AdminDept::whereIn('admin_id', $assistantIds)
|
||||
->select()
|
||||
->toArray();
|
||||
$adminToDepts = [];
|
||||
foreach ($adminDepts as $ad) {
|
||||
$adminId = $ad['admin_id'];
|
||||
if (!isset($adminToDepts[$adminId])) {
|
||||
$adminToDepts[$adminId] = [];
|
||||
}
|
||||
$adminToDepts[$adminId][] = (int)$ad['dept_id'];
|
||||
}
|
||||
|
||||
$admins = \app\common\model\auth\Admin::whereIn('id', $assistantIds)
|
||||
->whereNull('delete_time')
|
||||
->column('name', 'id');
|
||||
|
||||
$countRows = Diagnosis::where('assistant_id', 'in', $assistantIds)
|
||||
->where('create_time', 'between', [$startTime, $endTime])
|
||||
->whereNull('delete_time')
|
||||
->field('assistant_id, count(*) as cnt')
|
||||
->group('assistant_id')
|
||||
->select()
|
||||
->toArray();
|
||||
$counts = [];
|
||||
foreach ($countRows as $row) {
|
||||
$counts[$row['assistant_id']] = (int)$row['cnt'];
|
||||
}
|
||||
|
||||
$todayStart = strtotime(date('Y-m-d'));
|
||||
$todayEnd = time();
|
||||
$todayCountRows = Diagnosis::where('assistant_id', 'in', $assistantIds)
|
||||
->where('create_time', 'between', [$todayStart, $todayEnd])
|
||||
->whereNull('delete_time')
|
||||
->field('assistant_id, count(*) as cnt')
|
||||
->group('assistant_id')
|
||||
->select()
|
||||
->toArray();
|
||||
$todayCounts = [];
|
||||
foreach ($todayCountRows as $row) {
|
||||
$todayCounts[$row['assistant_id']] = (int)$row['cnt'];
|
||||
}
|
||||
$todayTotal = array_sum($todayCounts);
|
||||
$todayRanking = [];
|
||||
foreach ($assistantIds as $adminId) {
|
||||
$cnt = (int)($todayCounts[$adminId] ?? 0);
|
||||
$todayRanking[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => $cnt,
|
||||
];
|
||||
}
|
||||
usort($todayRanking, fn($a, $b) => $b['count'] <=> $a['count']);
|
||||
$todayRanking = array_values(array_filter($todayRanking, fn($a) => $a['count'] > 0));
|
||||
|
||||
$deptData = [];
|
||||
$assignedAdminIds = [];
|
||||
foreach ($depts as $deptId => $deptName) {
|
||||
$assistants = [];
|
||||
foreach ($adminToDepts as $adminId => $deptIds) {
|
||||
if (!in_array((int)$deptId, $deptIds)) {
|
||||
continue;
|
||||
}
|
||||
$assignedAdminIds[] = $adminId;
|
||||
$cnt = (int)($counts[$adminId] ?? 0);
|
||||
$assistants[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => $cnt,
|
||||
];
|
||||
}
|
||||
$deptData[] = [
|
||||
'dept_id' => (int)$deptId,
|
||||
'dept_name' => $deptName,
|
||||
'assistants' => $assistants,
|
||||
'total' => array_sum(array_column($assistants, 'count')),
|
||||
];
|
||||
}
|
||||
$unassignedIds = array_diff($assistantIds, array_unique($assignedAdminIds));
|
||||
if (!empty($unassignedIds)) {
|
||||
$assistants = [];
|
||||
foreach ($unassignedIds as $adminId) {
|
||||
$cnt = (int)($counts[$adminId] ?? 0);
|
||||
$assistants[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => $cnt,
|
||||
];
|
||||
}
|
||||
$deptData[] = [
|
||||
'dept_id' => 0,
|
||||
'dept_name' => '未分配部门',
|
||||
'assistants' => $assistants,
|
||||
'total' => array_sum(array_column($assistants, 'count')),
|
||||
];
|
||||
}
|
||||
|
||||
$ranking = [];
|
||||
foreach ($assistantIds as $adminId) {
|
||||
$ranking[] = [
|
||||
'id' => (int)$adminId,
|
||||
'name' => $admins[$adminId] ?? '未知',
|
||||
'count' => (int)($counts[$adminId] ?? 0),
|
||||
];
|
||||
}
|
||||
usort($ranking, fn($a, $b) => $b['count'] <=> $a['count']);
|
||||
|
||||
$allAssistantNames = [];
|
||||
$allAssistantData = [];
|
||||
foreach ($ranking as $i => $a) {
|
||||
$allAssistantNames[] = ($i + 1) . '.' . $a['name'];
|
||||
$allAssistantData[] = $a['count'];
|
||||
}
|
||||
|
||||
return [
|
||||
'date_range' => [date('Y-m-d', $startTime), date('Y-m-d', $endTime)],
|
||||
'today_total' => $todayTotal,
|
||||
'today_ranking' => $todayRanking,
|
||||
'departments' => $deptData,
|
||||
'ranking' => $ranking,
|
||||
'chart' => [
|
||||
'xAxis' => $allAssistantNames,
|
||||
'series' => [['name' => '诊单数', 'data' => $allAssistantData]],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\logic\tcm;
|
||||
|
||||
use app\common\model\tcm\Prescription;
|
||||
use app\common\model\tcm\Diagnosis;
|
||||
|
||||
class PrescriptionLogic
|
||||
{
|
||||
private static $error = '';
|
||||
|
||||
public static function setError(string $msg): void
|
||||
{
|
||||
self::$error = $msg;
|
||||
}
|
||||
|
||||
public static function getError(): string
|
||||
{
|
||||
return self::$error;
|
||||
}
|
||||
|
||||
private static function generateSn(): string
|
||||
{
|
||||
return 'RX' . date('Ymd') . str_pad((string)mt_rand(1, 9999), 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加处方
|
||||
*/
|
||||
public static function add(array $params, int $adminId): ?int
|
||||
{
|
||||
$diagnosis = Diagnosis::find($params['diagnosis_id']);
|
||||
if (!$diagnosis) {
|
||||
self::setError('诊单不存在');
|
||||
return null;
|
||||
}
|
||||
|
||||
$herbs = $params['herbs'] ?? [];
|
||||
if (empty($herbs) || !is_array($herbs)) {
|
||||
self::setError('请添加中药');
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($herbs as $h) {
|
||||
if (empty($h['name'])) {
|
||||
self::setError('中药名称不能为空');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$sn = self::generateSn();
|
||||
while (Prescription::where('sn', $sn)->find()) {
|
||||
$sn = self::generateSn();
|
||||
}
|
||||
|
||||
$data = [
|
||||
'sn' => $sn,
|
||||
'diagnosis_id' => (int)$params['diagnosis_id'],
|
||||
'appointment_id' => (int)($params['appointment_id'] ?? 0),
|
||||
'patient_id' => (int)$diagnosis->patient_id,
|
||||
'patient_name' => $params['patient_name'] ?? $diagnosis->patient_name,
|
||||
'gender' => (int)($params['gender'] ?? $diagnosis->gender),
|
||||
'age' => (int)($params['age'] ?? $diagnosis->age ?? 0),
|
||||
'phone' => $params['phone'] ?? $diagnosis->phone ?? '',
|
||||
'visit_no' => $params['visit_no'] ?? $sn,
|
||||
'prescription_date' => $params['prescription_date'] ?? date('Y-m-d'),
|
||||
'pulse' => $params['pulse'] ?? $diagnosis->pulse ?? '',
|
||||
'tongue' => $params['tongue'] ?? $diagnosis->tongue_coating ?? '',
|
||||
'clinical_diagnosis' => $params['clinical_diagnosis'] ?? '',
|
||||
'herbs' => $herbs,
|
||||
'dose_count' => (int)($params['dose_count'] ?? 1),
|
||||
'usage_instruction' => $params['usage_instruction'] ?? '水煎服一日二次',
|
||||
'amount' => (float)($params['amount'] ?? 0),
|
||||
'doctor_name' => $params['doctor_name'] ?? '',
|
||||
'doctor_signature' => $params['doctor_signature'] ?? '',
|
||||
'template_id' => (int)($params['template_id'] ?? 0),
|
||||
'creator_id' => $adminId,
|
||||
];
|
||||
|
||||
$prescription = new Prescription();
|
||||
$prescription->save($data);
|
||||
return (int)$prescription->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处方详情
|
||||
*/
|
||||
public static function detail(int $id): ?array
|
||||
{
|
||||
$row = Prescription::find($id);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
$arr = $row->toArray();
|
||||
$arr['gender_desc'] = $arr['gender'] == 1 ? '男' : '女';
|
||||
return $arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据诊单ID获取处方列表
|
||||
*/
|
||||
public static function listByDiagnosis(int $diagnosisId): array
|
||||
{
|
||||
return Prescription::where('diagnosis_id', $diagnosisId)
|
||||
->whereNull('delete_time')
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据预约ID获取处方
|
||||
*/
|
||||
public static function getByAppointment(int $appointmentId): ?array
|
||||
{
|
||||
$row = Prescription::where('appointment_id', $appointmentId)
|
||||
->whereNull('delete_time')
|
||||
->order('id', 'desc')
|
||||
->find();
|
||||
return $row ? $row->toArray() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\validate\tcm;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PrescriptionValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'diagnosis_id' => 'require|number',
|
||||
'appointment_id' => 'number',
|
||||
'patient_name' => 'require',
|
||||
'clinical_diagnosis' => 'require',
|
||||
'herbs' => 'require|array',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'diagnosis_id.require' => '诊单ID不能为空',
|
||||
'patient_name.require' => '患者姓名不能为空',
|
||||
'clinical_diagnosis.require' => '临床诊断不能为空',
|
||||
'herbs.require' => '请添加中药',
|
||||
];
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['diagnosis_id', 'patient_name', 'clinical_diagnosis', 'herbs']);
|
||||
}
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\model\tcm;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
/**
|
||||
* 中医处方单模型
|
||||
*/
|
||||
class Prescription extends BaseModel
|
||||
{
|
||||
protected $name = 'tcm_prescription';
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_time';
|
||||
protected $updateTime = 'update_time';
|
||||
protected $deleteTime = 'delete_time';
|
||||
protected $dateFormat = false;
|
||||
|
||||
protected $json = ['herbs'];
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
public function getGenderDescAttr($value, $data)
|
||||
{
|
||||
return ($data['gender'] ?? 0) == 1 ? '男' : '女';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
-- 处方单增加医师电子签名字段
|
||||
ALTER TABLE `zyt_tcm_prescription` ADD COLUMN `doctor_signature` longtext DEFAULT NULL COMMENT '医师电子签名(base64)' AFTER `doctor_name`;
|
||||
@@ -0,0 +1,33 @@
|
||||
-- 中医处方单表
|
||||
CREATE TABLE IF NOT EXISTS `zyt_tcm_prescription` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`sn` varchar(50) NOT NULL DEFAULT '' COMMENT '处方编号',
|
||||
`diagnosis_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '诊单ID',
|
||||
`appointment_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '预约ID',
|
||||
`patient_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '患者ID',
|
||||
`patient_name` varchar(50) NOT NULL DEFAULT '' COMMENT '患者姓名',
|
||||
`gender` tinyint(1) NOT NULL DEFAULT '0' COMMENT '性别:0-女 1-男',
|
||||
`age` int(3) NOT NULL DEFAULT '0' COMMENT '年龄',
|
||||
`phone` varchar(20) DEFAULT '' COMMENT '电话',
|
||||
`visit_no` varchar(50) DEFAULT '' COMMENT '门诊号',
|
||||
`prescription_date` date DEFAULT NULL COMMENT '处方日期',
|
||||
`pulse` varchar(100) DEFAULT '' COMMENT '脉象',
|
||||
`tongue` varchar(100) DEFAULT '' COMMENT '舌象',
|
||||
`clinical_diagnosis` varchar(500) DEFAULT '' COMMENT '临床诊断',
|
||||
`herbs` text COMMENT '中药列表JSON:[{name, dosage}]',
|
||||
`dose_count` int(11) NOT NULL DEFAULT '1' COMMENT '剂数',
|
||||
`usage_instruction` varchar(200) DEFAULT '水煎服一日二次' COMMENT '用法',
|
||||
`amount` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '金额',
|
||||
`doctor_name` varchar(50) DEFAULT '' COMMENT '医师姓名',
|
||||
`template_id` int(11) unsigned DEFAULT '0' COMMENT '模板ID',
|
||||
`creator_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人ID',
|
||||
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`update_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||||
`delete_time` int(10) unsigned DEFAULT NULL COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_sn` (`sn`),
|
||||
KEY `idx_diagnosis` (`diagnosis_id`),
|
||||
KEY `idx_appointment` (`appointment_id`),
|
||||
KEY `idx_patient` (`patient_id`),
|
||||
KEY `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='中医处方单表';
|
||||
Reference in New Issue
Block a user