cnhis-design-vue 3.2.10 → 3.2.11-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -87
- package/es/components/button-print/src/utils/print.js +1 -1
- package/es/components/classification/src/components/table-modal/index.vue.d.ts +3 -0
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcess.js +1 -1
- package/es/components/fabric-chart/src/hooks/birthProcess/useBirthProcessChart.js +1 -1
- package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useSurgicalAnesthesiaChart.js +1 -1
- package/es/components/field-set/src/FieldColor.vue.d.ts +1 -1
- package/es/components/field-set/src/components/edit-dialog.vue.d.ts +1 -1
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue.d.ts +3 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/timeRendererPlugin/editTime.vue2.js +1 -1
- package/es/components/iho-table/src/plugins/verticalTablePlugin/src/utils.js +1 -1
- package/es/components/iho-table/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/scale-view/src/ScaleView.vue2.js +1 -1
- package/es/components/select-label/src/LabelFormContent.vue2.js +1 -1
- package/es/env.d.ts +25 -25
- package/es/shared/assets/img/ai__avatar.png.js +1 -1
- package/es/shared/assets/img/defaultCover/10review_successful.png.js +1 -1
- package/es/shared/assets/img/defaultCover/11review_fail.png.js +1 -1
- package/es/shared/assets/img/defaultCover/12no_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/13no_menu_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/14no_call_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/15no_use_tag.png.js +1 -1
- package/es/shared/assets/img/defaultCover/16no_table_data.png.js +1 -1
- package/es/shared/assets/img/defaultCover/1location.png.js +1 -1
- package/es/shared/assets/img/defaultCover/2notfound.png.js +1 -1
- package/es/shared/assets/img/defaultCover/3loading.png.js +1 -1
- package/es/shared/assets/img/defaultCover/4no_permission.png.js +1 -1
- package/es/shared/assets/img/defaultCover/5no_data.png.js +1 -1
- package/es/shared/assets/img/defaultCover/6no_network.png.js +1 -1
- package/es/shared/assets/img/defaultCover/7no_doctor.png.js +1 -1
- package/es/shared/assets/img/defaultCover/8system_error.png.js +1 -1
- package/es/shared/assets/img/defaultCover/9system_upgrade.png.js +1 -1
- package/es/shared/assets/img/failure.png.js +1 -1
- package/es/shared/assets/img/logo.png.js +1 -1
- package/es/shared/assets/img/no-permission.png.js +1 -1
- package/es/shared/assets/img/nodata.png.js +1 -1
- package/es/shared/assets/img/notfound.png.js +1 -1
- package/es/shared/assets/img/qr.png.js +1 -1
- package/es/shared/assets/img/success.png.js +1 -1
- package/es/shared/assets/img/table_style_2.png.js +1 -1
- package/es/shared/assets/img/video.png.js +1 -1
- package/es/shared/assets/img/video_default_cover.png.js +1 -1
- package/es/shared/assets/img/xb_big.png.js +1 -1
- package/es/shared/assets/img/xb_small.png.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/es/shared/utils/index.js +1 -1
- package/package.json +2 -2
- package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
- package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +0 -1
- package/es/components/bpmn-workflow/types/ModelingModule.d.ts +0 -1
- package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +0 -1
- package/es/shared/components/VueDraggable/src/vuedraggable.d.ts +0 -86
- package/es/shared/utils/fabricjs/index.d.ts +0 -6823
- package/es/shared/utils/tapable/index.d.ts +0 -139
package/README.md
CHANGED
@@ -1,87 +1,87 @@
|
|
1
|
-
# 安装
|
2
|
-
|
3
|
-
```shell
|
4
|
-
npm i cnhis-design-vue@[版本号]
|
5
|
-
# or
|
6
|
-
yarn add cnhis-design-vue@[版本号] #推荐
|
7
|
-
```
|
8
|
-
|
9
|
-
## 1.全局引入
|
10
|
-
|
11
|
-
```typescript
|
12
|
-
// main.ts
|
13
|
-
import { createApp } from 'vue';
|
14
|
-
import App from './App.vue';
|
15
|
-
import 'cnhis-design-vue/es/packages/index.css';
|
16
|
-
import cui from 'cnhis-design-vue';
|
17
|
-
|
18
|
-
const app = createApp(App);
|
19
|
-
app.use(cui).mount('#app');
|
20
|
-
```
|
21
|
-
|
22
|
-
## 2. 按需引入
|
23
|
-
|
24
|
-
组件现在支持了自动按需引入, 但是样式文件需要额外的处理
|
25
|
-
|
26
|
-
### 2.1 样式处理方式1 (按需引入样式)
|
27
|
-
|
28
|
-
```shell
|
29
|
-
# 安装自动导入样式的插件
|
30
|
-
npm i -d vite-plugin-style-import
|
31
|
-
```
|
32
|
-
|
33
|
-
```typescript
|
34
|
-
// vite.config.ts
|
35
|
-
import { defineConfig } from 'vite';
|
36
|
-
import { createStyleImportPlugin } from 'vite-plugin-style-import';
|
37
|
-
|
38
|
-
export default defineConfig({
|
39
|
-
plugins: [
|
40
|
-
// ...otherPlugins
|
41
|
-
createStyleImportPlugin({
|
42
|
-
libs: [
|
43
|
-
{
|
44
|
-
libraryName: 'cnhis-design-vue',
|
45
|
-
esModule: true,
|
46
|
-
ensureStyleFile: true,
|
47
|
-
resolveStyle: name => {
|
48
|
-
return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
]
|
52
|
-
})
|
53
|
-
]
|
54
|
-
});
|
55
|
-
```
|
56
|
-
|
57
|
-
### 2.2 样式处理方式2 (全局引入样式)
|
58
|
-
|
59
|
-
```typescript
|
60
|
-
// main.ts
|
61
|
-
import 'cnhis-design-vue/es/components/index.css';
|
62
|
-
```
|
63
|
-
|
64
|
-
## 3.FAQ
|
65
|
-
|
66
|
-
### 3.1 项目打包后样式丢失
|
67
|
-
|
68
|
-
处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
|
69
|
-
|
70
|
-
```typescript
|
71
|
-
// vite.config.ts
|
72
|
-
import { defineConfig } from 'vite';
|
73
|
-
|
74
|
-
export default defineConfig({
|
75
|
-
build: {
|
76
|
-
rollupOptions: {
|
77
|
-
// ..otherOptions
|
78
|
-
output: {
|
79
|
-
dir: './dist',
|
80
|
-
manualChunks: {
|
81
|
-
'cnhis-vendor': ['cnhis-design-vue']
|
82
|
-
}
|
83
|
-
}
|
84
|
-
}
|
85
|
-
}
|
86
|
-
});
|
87
|
-
```
|
1
|
+
# 安装
|
2
|
+
|
3
|
+
```shell
|
4
|
+
npm i cnhis-design-vue@[版本号]
|
5
|
+
# or
|
6
|
+
yarn add cnhis-design-vue@[版本号] #推荐
|
7
|
+
```
|
8
|
+
|
9
|
+
## 1.全局引入
|
10
|
+
|
11
|
+
```typescript
|
12
|
+
// main.ts
|
13
|
+
import { createApp } from 'vue';
|
14
|
+
import App from './App.vue';
|
15
|
+
import 'cnhis-design-vue/es/packages/index.css';
|
16
|
+
import cui from 'cnhis-design-vue';
|
17
|
+
|
18
|
+
const app = createApp(App);
|
19
|
+
app.use(cui).mount('#app');
|
20
|
+
```
|
21
|
+
|
22
|
+
## 2. 按需引入
|
23
|
+
|
24
|
+
组件现在支持了自动按需引入, 但是样式文件需要额外的处理
|
25
|
+
|
26
|
+
### 2.1 样式处理方式1 (按需引入样式)
|
27
|
+
|
28
|
+
```shell
|
29
|
+
# 安装自动导入样式的插件
|
30
|
+
npm i -d vite-plugin-style-import
|
31
|
+
```
|
32
|
+
|
33
|
+
```typescript
|
34
|
+
// vite.config.ts
|
35
|
+
import { defineConfig } from 'vite';
|
36
|
+
import { createStyleImportPlugin } from 'vite-plugin-style-import';
|
37
|
+
|
38
|
+
export default defineConfig({
|
39
|
+
plugins: [
|
40
|
+
// ...otherPlugins
|
41
|
+
createStyleImportPlugin({
|
42
|
+
libs: [
|
43
|
+
{
|
44
|
+
libraryName: 'cnhis-design-vue',
|
45
|
+
esModule: true,
|
46
|
+
ensureStyleFile: true,
|
47
|
+
resolveStyle: name => {
|
48
|
+
return `cnhis-design-vue/es/components/${ name.slice(2) }/style/index.css`;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
]
|
52
|
+
})
|
53
|
+
]
|
54
|
+
});
|
55
|
+
```
|
56
|
+
|
57
|
+
### 2.2 样式处理方式2 (全局引入样式)
|
58
|
+
|
59
|
+
```typescript
|
60
|
+
// main.ts
|
61
|
+
import 'cnhis-design-vue/es/components/index.css';
|
62
|
+
```
|
63
|
+
|
64
|
+
## 3.FAQ
|
65
|
+
|
66
|
+
### 3.1 项目打包后样式丢失
|
67
|
+
|
68
|
+
处理方法, 将 cnhis-design-vue 从 vendor 包中移除 (没有出现此问题则不需要)
|
69
|
+
|
70
|
+
```typescript
|
71
|
+
// vite.config.ts
|
72
|
+
import { defineConfig } from 'vite';
|
73
|
+
|
74
|
+
export default defineConfig({
|
75
|
+
build: {
|
76
|
+
rollupOptions: {
|
77
|
+
// ..otherOptions
|
78
|
+
output: {
|
79
|
+
dir: './dist',
|
80
|
+
manualChunks: {
|
81
|
+
'cnhis-vendor': ['cnhis-design-vue']
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
});
|
87
|
+
```
|
@@ -1 +1 @@
|
|
1
|
-
import t from"axios";import{cloneDeep as e,isArray as i}from"lodash-es";import{IdentityVerificationDialog as r,PreviewDialog as s}from"./dialog.js";import{isIReport as a,getFileUrl as n,useBrowserPrint as o}from"./browserPrint.js";import{getCurrentInstance as l}from"vue";import{uuidGenerator as c}from"../../../../shared/utils/index.js";import{format as h}from"date-fns";import{io as p}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,g=`${d}/fdp-api/print/assembly/printIReport`,y=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${d}/bi-api/reprot/print/open/client/printIReportForHex`,w=`${d}/bi-api/reprot/print/open/client/previewIReport`,v=`${d}/bi-api/reprot/print/open/client/getRemote`,P=`${d}/printService/file`;let _=null;class b{constructor(){var t,e,i;if(this.webview=null,this.dialog=new r,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,_)return _;_=this;const a=window;this.CMonitor=a.$CMonitor;try{this.webview=a.top?null==(t=a.top.chrome)?void 0:t.webview:null==(e=a.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(i=a.chrome)?void 0:i.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:r,reject:s}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void r({result:(null==i?void 0:i.res)?"success":"fail"});r(i.res||"")}catch(t){s(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=p(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("ihoPrint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=c();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)})),new Promise(((e,r)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),r({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async resetPrinter(t,e){const i=a(t),r=this.getIReportFormatId(i,t);if(i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:r}}).then((({data:t})=>t.status?{type:"resetSuccess",result:"success",message:null==t?void 0:t.message}:{type:"resetError",result:"error",message:null==t?void 0:t.message})).catch((t=>({type:"resetError",result:"error",message:"重置打印机错误"}))):{type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:r}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:r}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:this.printOrigin+"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:r(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[r]}).then((({data:t})=>t));function r(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const r=t.message||t.Message;this._handleMonitorNotify(r);const s={type:"printError",message:r,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:r,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(s),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,r,s){const a={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:r},n=await this._queryServicesPrint(a);return this._handleQueryPrintDataResult(n,e,s)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,svrUpdateIp:i,params:r,paramsArr:s,cmdid:a,print:n,signature:o,copies:l,printdlgshow:c="0",nobillnode:p="1",btnprint:u="1",messageTimeout:m=0}){const d={templateId:t,formatId:e,svrUpdateIp:i,params:r,cmdid:a,nobillnode:p,printdlgshow:c,btnprint:u,copies:l,messageTimeout:m,...o?{signature:o}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=h(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=d,await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:r,messageTimeout:s=0}){const a={};let n={};try{n=Object.assign({},a,JSON.parse(i))}catch(t){n=a}const o={templateId:t,formatId:e,cmdid:"9",token:r,params:JSON.stringify(n),messageTimeout:s};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:v})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:g,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:y,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForBase16(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForPdf(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:w,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,r=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),s=r[r.length-2],a=r[r.length-1],l=await n(`${P}/${s}/${a}`),c=o(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let r=i.length;const s=new Uint8Array(r);for(;r--;)s[r]=i.charCodeAt(r);return new Blob([s],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,signature:c,btnprint:h,messageTimeout:p=0},m,d){const g=a(i),y=this.getIReportFormatId(g,i);if(g&&(u||2==t)){const t=await this._queryPrintForPdf(e,y,r,n);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const i=o(t,"preview");return this.instance||(this.instance=l()),this.showPreview(this.instance,i),null==m?void 0:m({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:y,params:r,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),i=this._handleResult(t,d);if(!i)return!1;if(this.isRemote){const t=await this._browserPrint(i,"preview");this.instance||(this.instance=l()),this.showPreview(this.instance,t)}await this.getPicAndUpload(i),null==m||m(i)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const r=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=c(),s=await this.messageCollect(t,{exec:"printA",data:r});if(s&&Array.isArray(s)){s.some((t=>"success"===t.res.result))?null==e||e(s):(null==i||i(s),this._handleMonitorNotify(s))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(s||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,isDownloadFile:d=!0,messageTimeout:g=0},y,f,w,v="printDirect"){const P=a(i),_=this.getIReportFormatId(P,i);if(P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notOpenedApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w):f({type:"connectAppFail",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w))}await this._queryProxyOrigin();const b=await this._testConnection();if(!this._handleResultTest(b,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:_,params:r,paramsArr:s,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,messageTimeout:g}),i=this._handleResult(t,f,w);if(!i)return!1;d&&["downloadPDF"].includes(v)&&await this._browserPrint(i,v),null==y||y(i)}catch(t){const e="printDirect"===v?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:r},s,a,n){const o=await this._queryPrintForBase64(t,e,i,r);if(!o.success)return a({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=s,this._errorCallbackFn=a,n&&(this._cancelCallbackFn=n),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,r,s){var n;const o=e(t);if(this.webview&&this.downloadPath&&(Reflect.has(o,"print")||Reflect.set(o,"print",{print:"1",type:"1"}),!o.print.filename)){const t=h(new Date,"yyyy-MM-dd"),e=c(),i=h(new Date,"yyyyMMddHHmmss")+e;o.print.filename=`${this.downloadPath}/${t}/${i}/${i}`.replace(/\\/g,"/")}const l=a(o.formatId);if(o.formatId=this.getIReportFormatId(l,o.formatId),l&&(u||2==o.iReportExecuteMode)){const t=await this._queryPrintForBase16(o.templateId||"",o.formatId,o.params||"",o.authorizationKey);return(null==t?void 0:t.success)?r({filebase64:null==(n=null==t?void 0:t.map)?void 0:n.hex,isIreport:!0}):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(o,(async t=>{t||s({result:"error",message:""});const e=this,a=await async function(t){const r=[],s=JSON.parse(t);if(!i(s))return await e._downloadPDF("");if(1===s.length)return await e._downloadPDF(s[0]||"");for(let t=0,i=s.length;t<i;t++)r.push(await e._downloadPDF(s[t]||""));return r}(t.filedir);r(a,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:r},void 0,a);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,a);if(!l)return!1;s&&s(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this._handleEventQueryPrintData(t,e,i,r,a);return!!o&&(s&&s(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,s);return!!o&&(r&&r(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s=0},a,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s}),c=this._handleResult(l,n);if(!c)return!1;a&&a(c)}async addPrintFormat({templateId:t,params:e,token:i},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,s);if(!o)return!1;r&&r(o)}}export{b as Print};
|
1
|
+
import t from"axios";import{cloneDeep as e,isArray as i}from"lodash-es";import{IdentityVerificationDialog as r,PreviewDialog as s}from"./dialog.js";import{isIReport as a,getFileUrl as n,useBrowserPrint as o}from"./browserPrint.js";import{getCurrentInstance as l}from"vue";import{uuidGenerator as c}from"../../../../shared/utils/index.js";import{format as h}from"date-fns";import{io as p}from"socket.io-client";const u=String(navigator.platform).toLowerCase().includes("linux"),m=t.create({timeout:6e4,withCredentials:!1}),d=`${window.location.protocol}//${window.location.host}`,g=`${d}/fdp-api/print/assembly/printIReport`,y=`${d}/bi-api/reprot/print/open/client/printIReportForBase64`,f=`${d}/bi-api/reprot/print/open/client/printIReportForHex`,w=`${d}/bi-api/reprot/print/open/client/previewIReport`,v=`${d}/bi-api/reprot/print/open/client/getRemote`,P=`${d}/printService/file`;let _=null;class I{constructor(){var t,e,i;if(this.webview=null,this.dialog=new r,this.dialogPreview=new s,this.instance=null,this.downloadPath="",this.printOrigin="http://127.0.0.1:11111",this.printDomesticOrigin="http://127.0.0.1:17521",this.isRemote=!1,this.CMonitor=null,this.queryServicesParams=null,this.isConnectHiPrint=!1,this.clientInfo=null,this.printerList=[],this.hiPrintSocket=null,this.base64Fragment="",this._successCallbackFn=null,this._errorCallbackFn=null,this._cancelCallbackFn=null,this.messageHandlerQueue=[],this.getIReportFormatId=(t,e)=>t?e.split("_")[1]:e,_)return _;_=this;const a=window;this.CMonitor=a.$CMonitor;try{this.webview=a.top?null==(t=a.top.chrome)?void 0:t.webview:null==(e=a.chrome)?void 0:e.webview}catch(t){console.log(t),this.webview=null==(i=a.chrome)?void 0:i.webview}if(this.webview){this.currentMessageHandler=this.messageHandler.bind(this),this.webview.addEventListener("message",this.currentMessageHandler);try{this.webview.postMessage({exec:"config",data:""})}catch(t){const e="当前浏览器版本不支持获取配置接口";this._handleMonitorNotify(e),console.log("非封装浏览器或者"+e)}}}messageHandler(t){var e;if(console.log("打印事件message",t),!t)return this._handleMonitorNotify("接收到空的浏览器事件,"+t),console.log("当前回执",t,"接收到空的浏览器事件");let i;try{i=JSON.parse(t.data||"{}")}catch(e){console.log("解析e.data失败,"+e),this._handleMonitorNotify("解析e.data失败,"+t)}if(["print","pdf","resetprint"].includes(null==i?void 0:i.cmd)){console.log("打印命令执行了",i);const e=this.messageHandlerQueue.shift();if(!e)return console.log("当前回执",t,"没有可用的handler");const{resolve:r,reject:s}=e;try{if("resetprint"===(null==i?void 0:i.cmd))return void r({result:(null==i?void 0:i.res)?"success":"fail"});r(i.res||"")}catch(t){s(t)}}else"config"===(null==i?void 0:i.exec)&&(this.downloadPath=(null==(e=i.res)?void 0:e.downloadpath)||"")}_initDomesticSystem(t){try{if(this.hiPrintSocket)return this.isConnectHiPrint;this.hiPrintSocket=p(this.printDomesticOrigin,{reconnection:!1,transports:["websocket"],auth:{token:"no-use-vue-plugin-hiprint"}}),this.hiPrintSocket&&(this.hiPrintSocket.on("connect",(()=>{this.isConnectHiPrint=!0})),this.hiPrintSocket.on("disconnect",(()=>{this.isConnectHiPrint=!1,this.hiPrintSocket=null})),this.hiPrintSocket.on("clientInfo",(t=>{console.log("获取到客户端信息>>>>>",t),t.clientUrl&&(this.clientInfo=t)})),this.hiPrintSocket.on("printerList",(e=>{console.log("获取到打印机列表信息>>>>>",e),this.printerList=e,t&&t(!0)})),this.hiPrintSocket.on("success",(t=>{console.log("打印成功>>>>>",t),this.base64Fragment="",this._successCallbackFn&&this._successCallbackFn(t)})),this.hiPrintSocket.on("replayPrinterTemplate",(t=>{console.log("获取到数据的回复>>>>>",t),t&&this.hiPrintSocket.emit("news",t)})),this.hiPrintSocket.on("error",(t=>{console.log("打印失败>>>>>",t),this.base64Fragment="","cancel"==(null==t?void 0:t.result)?this._cancelCallbackFn&&this._cancelCallbackFn(t):this._errorCallbackFn&&this._errorCallbackFn(t)})))}catch(e){console.log("ihoPrint系统连接失败",e),t&&t(!1)}}async getPicAndUpload(t){try{const e=t=>"[object Object]"===Object.prototype.toString.call(t);if("success"===(null==t?void 0:t.result)&&"Y"==(null==t?void 0:t.uploadTemplateFlag)&&!(null==t?void 0:t.filebase64)&&this.queryServicesParams){const t=e(this.queryServicesParams.params)?this.queryServicesParams.params:JSON.parse(this.queryServicesParams.params);t.uploadTemplateFlag="Y",this.queryServicesParams.params=JSON.stringify(t),this.queryServicesParams.cmdid="7",this.queryServicesParams.print={print:1,type:6,zip:0},this.queryServicesParams.paramsArr=[{params:JSON.stringify(t)}];await this._queryBase64ServicesPrint(this.queryServicesParams)}}catch(t){console.log(t)}finally{this.queryServicesParams=null}}async postMessage(t,e=0){if(!this.webview)return Promise.reject();const i=c();return e&&e>0?this.messageCollectAndNotifyFail(i,t,e):this.messageCollect(i,t)}messageCollect(t,e){return new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)}))}messageCollectAndNotifyFail(t,e,i){return Promise.race([new Promise(((i,r)=>{this.messageHandlerQueue.push({resolve:i,reject:r,id:t}),this.webview.postMessage(e)})),new Promise(((e,r)=>{setTimeout((()=>{const e=this.messageHandlerQueue.findIndex((e=>e.id===t));e>-1&&this.messageHandlerQueue.splice(e,1),r({type:"timeout"})}),i)}))])}destroy(){}show(...t){return this.dialog.show(...t)}showPreview(...t){return this.dialogPreview.show(...t)}_testDomesticSystemConnection(){return new Promise((t=>{m({url:`${this.printDomesticOrigin}/test`,method:"get",withCredentials:!1,params:{}}).then((({data:e})=>{e.status?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}_testConnection(){return this.webview?Promise.resolve(!0):new Promise((t=>{m({url:`${this.printOrigin}/test`,method:"get",withCredentials:!1,params:{inputdata:{result:"success"}}}).then((({data:e})=>{"success"===e.result?t(!0):t(!1)})).catch((e=>{t(!1)}))}))}async resetPrinter(t,e){const i=a(t),r=this.getIReportFormatId(i,t);if(i&&(u||2==e)){return await this._testDomesticSystemConnection()?m({url:`${this.printDomesticOrigin}/resetPrint`,method:"get",withCredentials:!1,params:{formatId:r}}).then((({data:t})=>t.status?{type:"resetSuccess",result:"success",message:null==t?void 0:t.message}:{type:"resetError",result:"error",message:null==t?void 0:t.message})).catch((t=>({type:"resetError",result:"error",message:"重置打印机错误"}))):{type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"}}return this.webview?this.postMessage({exec:"resetprint",data:{formatID:r}}):m({url:`${this.printOrigin}/services/printset`,method:"get",withCredentials:!1,params:{inputdata:r}}).then((({data:t})=>t))}_queryServicesPrint(e){return this.webview?this.postMessage({exec:"print",data:{inputData:e}},null==e?void 0:e.messageTimeout):t({url:this.printOrigin+"/services/print",method:"get",params:{inputData:JSON.stringify(e)}}).then((({data:t})=>t))}_queryBase64ServicesPrint(t){return this.webview?this.postMessage({exec:"print",data:{inputData:t}}):m({url:this.printOrigin+"/services/Printqueue",method:"get",params:{inputData:JSON.stringify(t)}}).then((({data:t})=>t))}_callPrintWithFile(t){const e={cmdid:"7",flag:"1"},i={inputData:JSON.stringify(Object.assign({},e,t))};return this.webview?this.postMessage({exec:"print",data:r(i)}):m({url:this.printOrigin+"/PrintLocal",method:"post",data:i,transformRequest:[r]}).then((({data:t})=>t));function r(t){let e="";for(const i in t)e+=encodeURIComponent(i)+"="+encodeURIComponent(t[i])+"&";return e=e.slice(0,-1),e}}_handleMonitorNotify(t){var e,i;null==(i=null==(e=this.CMonitor)?void 0:e.notify)||i.call(e,{name:"custom_info",message:t,businessName:"打印sdk"})}_handleResult(t,e,i){if(!t){const t="打印命令返回空数据";return this._handleMonitorNotify(""),null==e||e({type:"printError",message:t,result:"error",errinfo:t}),!1}if("success"!==t.result){const r=t.message||t.Message;this._handleMonitorNotify(r);const s={type:"printError",message:r,result:t.result,errinfo:t.errinfo};return"cancel"==t.result?(i&&i({type:"printCancel",message:r,result:t.result,errinfo:t.errinfo}),!1):(null==e||e(s),!1)}return t}_handleResultTest(t,e){return!!t||(console.log("notInstalledApp"),null==e||e({type:"notInstalledApp",message:"请打开打印服务器插件",result:"error"}),!1)}async _handleEventQueryPrintData(t,e,i,r,s){const a={templateId:t,formatId:e,params:i,cmdid:"7",messageTimeout:r},n=await this._queryServicesPrint(a);return this._handleQueryPrintDataResult(n,e,s)}_handleQueryPrintDataResult(t,e,i){if(!(null==t?void 0:t.file)){try{const e=t.message||t.Message;console.log(e),null==i||i({result:"error",type:"queryPrintDataFailure",message:e})}catch(t){console.log(t)}return!1}return{file:t.file,printerName:t.defprinter,pageCount:t.pagecount,formatId:e}}async _handleEventDirect({templateId:t,formatId:e,svrUpdateIp:i,params:r,paramsArr:s,cmdid:a,print:n,signature:o,copies:l,printdlgshow:c="0",nobillnode:p="1",btnprint:u="1",messageTimeout:m=0}){const d={templateId:t,formatId:e,svrUpdateIp:i,params:r,cmdid:a,nobillnode:p,printdlgshow:c,btnprint:u,copies:l,messageTimeout:m,...o?{signature:o}:{}};if(s&&(d.paramsArr=s),n){try{n=JSON.parse(n)}catch(t){}d.print=n}else if(this.isRemote){const t=h(new Date,"yyyyMMddHHmmss");d.print={print:"1",type:"1",zip:"0",filename:`F:\\WorkSpace\\crmweb\\web\\${t}\\${t}`}}return this.queryServicesParams=d,await this._queryServicesPrint(d)}async _handleEventEditFormat({templateId:t,formatId:e="",params:i="",token:r,messageTimeout:s=0}){const a={};let n={};try{n=Object.assign({},a,JSON.parse(i))}catch(t){n=a}const o={templateId:t,formatId:e,cmdid:"9",token:r,params:JSON.stringify(n),messageTimeout:s};return await this._queryServicesPrint(o)}async _queryProxyOrigin(){if(this.isRemote)return;const{data:t}=await m({method:"get",url:v})||{},{map:e={}}=t;e.isRemote&&(this.printOrigin=d+"/printService",this.isRemote=!0)}async _queryPrintFile(t,e=""){const{data:i}=await m({method:"post",url:g,responseType:"blob",params:{formatId:t.split("_")[1],params:e}})||{};return i}paramsSerializer(t){return Object.keys(t).forEach((e=>{const i=t[e];t[e]=i,"biParams"==e&&(t[e]=encodeURIComponent(i))})),t}async _queryPrintForBase64(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:y,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForBase16(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:f,params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _queryPrintForPdf(t,e,i="",r){const s="object"==typeof i?i:JSON.parse(i),{data:a}=await m({method:"post",url:w,responseType:"blob",params:{id:t,formatId:e,params:this.paramsSerializer(s),authorizationKey:r}})||{};return a}async _browserPrint(t,e){if(this.isRemote){const{filedir:i}=t,r=JSON.parse(i)[0].replace(/\\/g,"/").split("/"),s=r[r.length-2],a=r[r.length-1],l=await n(`${P}/${s}/${a}`),c=o(null,e,l);if("preview"===e)return c}}_base64ToBlob(t,e){const i=window.atob(t);let r=i.length;const s=new Uint8Array(r);for(;r--;)s[r]=i.charCodeAt(r);return new Blob([s],{type:e})}async preview({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,signature:c,btnprint:h,messageTimeout:p=0},m,d){const g=a(i),y=this.getIReportFormatId(g,i);if(g&&(u||2==t)){const t=await this._queryPrintForPdf(e,y,r,n);if(!t)return null==d?void 0:d({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"});const i=o(t,"preview");return this.instance||(this.instance=l()),this.showPreview(this.instance,i),null==m?void 0:m({result:"success",message:"",file:t})}await this._queryProxyOrigin();const f=await this._testConnection();if(!this._handleResultTest(f,d))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:y,params:r,paramsArr:s,cmdid:this.isRemote?"7":"8",signature:c,btnprint:h,messageTimeout:p}),i=this._handleResult(t,d);if(!i)return!1;if(this.isRemote){const t=await this._browserPrint(i,"preview");this.instance||(this.instance=l()),this.showPreview(this.instance,t)}await this.getPicAndUpload(i),null==m||m(i)}catch(t){const e="预览失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==d||d(i),this._handleMonitorNotify(i)}}async printSync(t,e,i){const r=t.map((t=>{const e={params:"",printdlgshow:"0",nobillnode:"1",btnprint:"1",...t,cmdid:"7",...t.signature?{signature:t.signature}:{}};if(e.print)try{e.print=JSON.parse(e.print)}catch(t){}return{inputData:e}}));try{const t=c(),s=await this.messageCollect(t,{exec:"printA",data:r});if(s&&Array.isArray(s)){s.some((t=>"success"===t.res.result))?null==e||e(s):(null==i||i(s),this._handleMonitorNotify(s))}else{const t="打印命令返回无效数据";this._handleMonitorNotify(s||""),null==i||i({type:"printError",message:t,result:"error",errinfo:t})}}catch(t){const e={error:t,result:"error",message:"打印失败"};null==i||i(e),this._handleMonitorNotify(e)}}async printDirect({iReportExecuteMode:t,templateId:e,formatId:i,params:r="",paramsArr:s,authorizationKey:n,print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,isDownloadFile:d=!0,messageTimeout:g=0},y,f,w,v="printDirect"){const P=a(i),_=this.getIReportFormatId(P,i);if(P&&(u||2==t)){if(!await this._testDomesticSystemConnection())return void f({type:"notInstalledApp",result:"error",message:"请开启ihoPrint客户端"});return void(this._initDomesticSystem((async t=>{t?await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w):f({type:"notInstalledApp",result:"error",message:"连接ihoPrint客户端失败"})}))&&await this.printToHiPrint({templateId:e,formatId:_,params:r,authorizationKey:n},y,f,w))}await this._queryProxyOrigin();const I=await this._testConnection();if(!this._handleResultTest(I,f))return!1;try{const t=await this._handleEventDirect({templateId:e,formatId:_,params:r,paramsArr:s,cmdid:"7",print:o,signature:l,printdlgshow:c,nobillnode:h,copies:p,svrUpdateIp:m,messageTimeout:g}),i=this._handleResult(t,f,w);if(!i)return!1;d&&["downloadPDF"].includes(v)&&await this._browserPrint(i,v),null==y||y(i)}catch(t){const e="printDirect"===v?"打印失败":"下载失败",i="timeout"===(null==t?void 0:t.type)?{...t,message:e,result:"error"}:{message:e,result:"error"};null==f||f(i),this._handleMonitorNotify(i)}}async printToHiPrint({templateId:t,formatId:e,params:i,authorizationKey:r},s,a,n){const o=await this._queryPrintForBase64(t,e,i,r);if(!o.success)return a({message:o.resultMsg,result:"error"});const{base64:l,formatId:c}=o.map;this.base64Fragment=l,this._successCallbackFn=s,this._errorCallbackFn=a,n&&(this._cancelCallbackFn=n),this.hiPrintSocket.emit("news",{printerList:this.printerList,type:"askPrinterTemplate",markTemplateId:c,pdf_stream:this.base64Fragment})}_downloadPDF(t){return this.webview?this.postMessage({exec:"pdf",data:{file:t}}):m.get(this.printOrigin+"/download",{params:{inputData:t}}).then((({data:t})=>t))}async downloadPDF(t,r,s){var n;const o=e(t);if(this.webview&&this.downloadPath&&(Reflect.has(o,"print")||Reflect.set(o,"print",{print:"1",type:"1"}),!o.print.filename)){const t=h(new Date,"yyyy-MM-dd"),e=c(),i=h(new Date,"yyyyMMddHHmmss")+e;o.print.filename=`${this.downloadPath}/${t}/${i}/${i}`.replace(/\\/g,"/")}const l=a(o.formatId);if(o.formatId=this.getIReportFormatId(l,o.formatId),l&&(u||2==o.iReportExecuteMode)){const t=await this._queryPrintForBase16(o.templateId||"",o.formatId,o.params||"",o.authorizationKey);return(null==t?void 0:t.success)?r({filebase64:null==(n=null==t?void 0:t.map)?void 0:n.hex,isIreport:!0}):null==s?void 0:s({type:"queryPrintDataFailure",result:"error",message:"获取文件失败!"})}this.printDirect(o,(async t=>{t||s({result:"error",message:""});const e=this,a=await async function(t){const r=[],s=JSON.parse(t);if(!i(s))return await e._downloadPDF("");if(1===s.length)return await e._downloadPDF(s[0]||"");for(let t=0,i=s.length;t<i;t++)r.push(await e._downloadPDF(s[t]||""));return r}(t.filedir);r(a,t)}),(t=>s(t)),(t=>{console.log(t)}),"downloadPDF")}async print({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this.queryPrintData({templateId:t,formatId:e,params:i,messageTimeout:r},void 0,a);if(!o)return!1;const l=this.printFileData({formatId:e,file:o.file,printerName:o.printerName},void 0,a);if(!l)return!1;s&&s(l)}async queryPrintData({templateId:t,formatId:e,params:i="",messageTimeout:r=0},s,a){const n=await this._testConnection();if(!this._handleResultTest(n,a))return!1;const o=await this._handleEventQueryPrintData(t,e,i,r,a);return!!o&&(s&&s(o),o)}async printFileData({formatId:t,file:e,printerName:i="Default"},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._callPrintWithFile({formatId:t,printname:i,file:e}),o=this._handleResult(n,s);return!!o&&(r&&r(o),o)}async editPrintFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s=0},a,n){const o=await this._testConnection();if(!this._handleResultTest(o,n))return!1;const l=await this._handleEventEditFormat({templateId:t,formatId:e,params:i,token:r,messageTimeout:s}),c=this._handleResult(l,n);if(!c)return!1;a&&a(c)}async addPrintFormat({templateId:t,params:e,token:i},r,s){const a=await this._testConnection();if(!this._handleResultTest(a,s))return!1;const n=await this._handleEventEditFormat({templateId:t,params:e,token:i}),o=this._handleResult(n,s);if(!o)return!1;r&&r(o)}}export{I as Print};
|
@@ -1 +1 @@
|
|
1
|
-
import{fabric as
|
1
|
+
import{fabric as t}from"../../../../../shared/utils/fabricjs/index.js";import{drawLine as e,drawArrow as n,drawPoint as i,defaultStyle as o,drawText as r,defaultTextStyle as l,drawTextAndIconGroup as s,defaultRectStyle as a}from"../useDraw.js";import{useGrid as c}from"../useGrid.js";import{useBirthProcessCumputedPoint as u}from"../useCumputedPoint.js";import"../useEvent.js";import{getScaleInfo as d,drawScaleNumber as h,drawScaleLine as f}from"../useScaleColumn.js";import{useCommon as p}from"../useCommon.js";import"vue";import{getIndex as g,isEffectiveNode as m,getTime as v,getScaleNumberList as y}from"../../utils/index.js";import{cloneDeep as k,last as b,range as x}from"lodash-es";import"../temperature/useShadow.js";import"@vueuse/shared";import{format as w}from"date-fns";import"naive-ui";import"@vueuse/core";function S(S,C,j,P,I){const{computedX:E,computedY:T,getXValue:X,getYValue:A}=u(C),{getEqualXTypes:L,handleAddPrevent:Y,isGridLimit:M,setPrevAndNextPoint:H,getPointEventProps:z}=p(S,j,C),{xAxis:G,grid:W,originX:D,originY:N,xCellWidth:O,endY:R,startTime:V,leftAddAreaWidth:B,leftScales:F,rightScales:$,yCellHeight:q,endX:J,scaleValues:K,canvasWidth:Q,borderStyle:U,rightAddAreaWidth:Z,event:_,originYCervix:tt,other:et,canvasHeight:nt,scalebarBorder:it}=C,ot=k(K),rt=new Set;function lt(){ot.filter((({showData:t=!0})=>t)).forEach(((t,s)=>{var a;const c=[],u=[],d=[];null==(a=t.data)||a.forEach(((a,h)=>{!function(a,h,f){let p,g;const{pointAttr:m={},lineAttr:v={},title:y="",key:k,type:b="circle",childbirthStyle:x={}}=t,w=t.data[f+1],C=dt(w,t);if(a&&C&&!h.breakpoint)g=e([...a,...C],{...v});else if(a&&!C&&!h.breakpoint){const n=dt(w,t);g=n?e([...a,...n],{...v}):null}let I,E;if(h.childbirth){const{type:t="arrow",style:e={}}=x;if("arrow"===t){const t=a[1]+q;I=n([a[0],a[1],t],e)}else I=i(t,{left:a[0],top:a[1],...e,...o,hoverCursor:"default"});E=r([a[0]+O/2,a[1]+q/2],{value:String(h.childbirth),...l,originX:"left",originY:"center",fill:e.stroke||e.fill,fontSize:e.fontSize||l.fontSize}),I&&d.push(I),d.push(E)}const T=u[f-1],L={origin:{data:h,title:y,key:k||"",dataIndex:s,index:f},leftLine:T,rightLine:g,childbirthIcon:I,childbirthText:E,...m,...z()};a&&(T||(L.leftLine=null),p=i(b,{left:a[0],top:a[1],...L}));u.push(g),p&&(!function(t){_.hovered&&(t.on("mouseover",(()=>{ut(t,"hover")})),t.on("mouseout",(()=>{P.show=!1})));if(t.lockMovementX&&t.lockMovementY)return;t.on("moving",(()=>{ct(t),function(t){var e,n,i,o;null==(e=t.leftLine)||e.setCoords().set({x2:t.left,y2:t.top}),null==(n=t.rightLine)||n.setCoords().set({x1:t.left,y1:t.top}),null==(i=t.childbirthIcon)||i.setCoords().set({left:t.left,top:t.top}),null==(o=t.childbirthText)||o.setCoords().set({left:t.left+O/2,top:t.top+q/2})}(t),_.hovered&&ut(t)})),t.on("mouseup",(e=>{if(P.show=!1,1===e.button){const{key:e}=t.origin,n={...t.origin,data:{...t.origin.data,time:X(t.left),value:A(e,t.top)}};S.value.discardActiveObject(),j("change",n),st(n,"change")}}))}(p),c.push(p),rt.add(p))}(dt(a,t),a,h)})),Promise.all(c).then((t=>{const e=u.filter((t=>t));H(t),Promise.all(d).then((n=>{S.value.add(...e,...t,...n),t.forEach((t=>{null==t||t.bringToFront();const{childbirthIcon:e}=t;e&&Reflect.has(e,"zIndex")&&e.zIndex>0&&e.bringToFront()}))}))}))}))}function st(t,e="add"){const{dataIndex:n,data:i,index:o,key:r}=t,l=ot.find((t=>t.key===r));switch(e){case"remove":l.data.splice(o,1);break;case"change":l.data[o]=i;break;default:{const t=g(i.time,l.data);l.data.splice(t,0,i);break}}at()}function at(){var t;rt.size&&(null==(t=S.value)||t.remove(...function(t){const e=[];return t.forEach((t=>{t&&e.push(t),(null==t?void 0:t.leftLine)&&e.push(null==t?void 0:t.leftLine),(null==t?void 0:t.rightLine)&&e.push(null==t?void 0:t.rightLine),(null==t?void 0:t.childbirthIcon)&&e.push(null==t?void 0:t.childbirthIcon),(null==t?void 0:t.childbirthText)&&e.push(null==t?void 0:t.childbirthText)})),e}([...rt]))),rt.clear(),lt()}function ct(t){const e=t.prevPoint?t.prevPoint.left:D,n=t.nextPoint?t.nextPoint.left:J;t.setCoords(),["cervix","fetalPresentation"].includes(t.origin.key)&&t.top<tt&&t.set("top",tt),t.top<N&&t.set("top",N),t.top>R&&t.set("top",R),t.left<e&&t.set("left",e),t.left>n&&t.set("left",n)}function ut(t,e="moving"){const{title:n,key:i,data:o}=t.origin;P.point={x:t.left,y:t.top},P.list=[`${n} ${"hover"===e?o.value:A(i,t.top)}`,`时间 ${X(t.left).slice(-5)}`],P.show=!0}function dt(t,e){if(m(t)&&function(t){const e=V+864e5,n=v(t);return n>=V&&n<=e}(t.time)){const n=E(t.time),i=T(e.key,e.range,t.value);return[n,i<N?N:i>R?R:i]}}function ht(t,e){return t+1>e[1]?e[0]:t+1}return c(S,C),function(){const e=it?{width:Q-B-Z-1,left:B}:{width:J-D-($.length?0:1),left:D},n=new t.Rect({...U,height:R-1,top:0,fill:"transparent",...e});S.value.add(n)}(),function(){function e(e,n="left"){let i="left"===n?B:J;e.forEach(((e,n)=>{const{range:s,spaceValue:c,width:u,title:p,titleStyle:g,key:m,position:v="center",spaceGridNumber:k=1,showNumber:b,showMaxMinNumber:x}=e,w=[],C=[],j=i+u/2,P=y(s,c),I=P.length,{lineXMain:E,lineXSub:T,textLeft:X}=d(v,i,u);P.forEach(((t,n)=>{const i=R-n*q*k,o=0===n?R-8:n!==P.length-1||N||tt&&"FHR"!==m?i:N+8;!b||(0===n||n===I-1)&&!x||w.push(h(String(t),e,X,o)),C.push(...f(e,n,E,T,i,q,N,I,1))}));const A=[],L=it?new t.Rect({...a,strokeWidth:.5,width:u,height:R,left:j,top:R/2}):null;L&&A.push(L);const Y=r([j,N>0?N-q/2:q/2],{value:String(p),...l,...g});Y&&A.push(Y);const M=new t.Group([...C,...w,...A],{objectCaching:!1,...o});S.value.add(M),M.sendToBack(),i+=u}))}e(F),e($,"right")}(),function(){const{show:e,startTime:n,range:i=[0,23],position:s="top",style:a}=G.time,{show:c,range:u=[0,23],position:d,style:h={}}=G.processTime;if(e||c){const f=[],p=x(u[0],u[1]+1),g=[],m=[],v=q/2;for(let t=0;t<W.mainXCell;t++){if(e){const{textAlign:e="center"}=a,o=D+("center"===e?O/2:0),c=0===t&&"center"!==e?o+5:o,u=0===t?+n.slice(11,13):ht(b(f),i);f.push(u);const d="top"===s?N-v:R+v;g.push(r([c+t*O,d],{value:String(u),...l,...a})),t===W.mainXCell-1&&"center"!==e&&g.push(r([J-1,d],{value:String(ht(b(f),i)),...l,...a,originX:"center"!==e?"right":"center"}))}if(c&&t<=p.length){const{textAlign:e="center"}=h,n=D+("center"===e?O/2:0),i=0===t&&"center"!==e?n+5:n,o="top"===d?v:nt-v;m.push(r([i+t*O,o],{value:String(p[t]),...l,...h})),t===W.mainXCell-1&&"center"!==e&&m.push(r([J-1,o],{value:String(b(p)),...l,...a,originX:"center"!==e?"right":"center"}))}}const y=new t.Group([...g,...m],{objectCaching:!1,...o});S.value.add(y),S.value.sendToBack(y)}}(),function(){var t;const n=Object.values(et),i=[],o={},r=ot.find((t=>"cervix"===t.key&&t.show)),l=null==(t=null==r?void 0:r.data)?void 0:t.find((t=>3==+t.value));function s(t,e){const{key:n,range:i}=r||{},o=T(n,i,10),l=[0,e],s=[-e/t,0],a=[(R-o-e)/t,R-o],c=[J-D,t*(J-D)+e];let u=[],d=[];function h([n,i]){return Math.abs(i-t*n-e)<=1}function f([t,e]){const[n,i]=[...p([t,e])];return n>=D&&n<=J&&i>=o&&i<=R}function p([t,e]){return[D+t,R-e]}return h(l)&&f(l)&&(u=p(l)),h(s)&&f(s)&&(u=p(s)),h(a)&&f(a)&&(d=p(a)),h(c)&&f(c)&&(d=p(c)),[...u,...d]}n.forEach((t=>{if(!t.show)return;const{key:n}=t;switch(n){case"fetalPresentation":{const{range:o,show:r}=ot.find((t=>t.key===n));if(r){const r=T(n,o,0);i.push(e([D,r,J,r],{...t}))}break}case"alert":if(l){const{key:n,range:a}=r||{},c=216e5,u={time:w(new Date(v(l.time)+c),"yyyy-MM-dd HH:mm"),value:10},[d,h]=[E(l.time)-D,R-T(n,a,l.value)],[f,p]=[E(u.time)-D,R-T(n,a,u.value)],g=(p-h)/(f-d),m=h-d*g,y=s(g,m);y.length>0&&(i.push(e(y,{...t})),Object.assign(o,{k:g,b:m}))}break;case"handling":if(l){const{k:n,b:r}=o,a=144e5,c=s(n,r-(E(w(new Date(v(l.time)+a),"yyyy-MM-dd HH:mm"))-E(l.time))*n);c.length>0&&i.push(e(c,{...t}))}}})),S.value.add(...i)}(),lt(),function(){function t(t,e){const n=ot.findIndex((e=>e.key===t.key));return{renderItem:()=>t.title,origin:{title:t.title,unit:t.unit,dataIndex:n,key:t.key},pointer:e}}C.event.evented&&S.value.on("mouse:up",(e=>{if(3===e.button){const{x:n=0,y:i=0}=e.pointer||{};n>=D&&n<=J&&i>=N&&i<=R&&(I.point={x:n,y:i},I.show=!0,e.target?(I.target=e.target,I.list=["删除节点"],[...rt].forEach((t=>{t.origin&&t.left===e.target.left&&t.top===e.target.top&&I.list.push({renderItem:()=>t.origin.title,origin:{...t.origin},mode:"remove",pointer:e.pointer})}))):(I.target=null,I.list=["新增节点"],ot.filter((t=>t.show)).forEach((o=>{if(!L([...rt],n,"key").includes(o.key)){if(["cervix","fetalPresentation"].includes(o.key)&&i<tt)return;I.list.push(t(o,e.pointer))}})),1===I.list.length&&(I.show=!1,Y("repeat"),console.log("当前时间段内无可新增节点"))))}}))}(),function(){const t=Q-Z/2;function e(t,e){if(!t.length)return;let i=N;const o=[];t.forEach((t=>{const n=t.title.split("").join("\n"),r=K.findIndex((e=>e.key===t.key)),{text:l,icon:a}=s(n,t,{text:{originY:"top",left:e,top:i},icon:{left:e,topY:i,originY:"top",origin:{type:t.type,dataIndex:r},...C.event}},"vertical");var c;i+=l.height+a.height+15,(c=a).on("moving",(()=>{c.set("originY","center"),M(c)?(ct(c),ut(c)):P.show=!1})),c.on("mouseup:before",(t=>{if(P.show=!1,0===t.e.button&&M(c))if(L([...rt],c.left,"key").includes(c.origin.key))Y("repeat");else{const t={data:{time:X(c.left),value:A(c.origin.key,c.top)},...c.origin};j("add",t),st(t)}!function(t){t.setCoords().set({originY:"top",left:t.originLeft,top:t.originTop})}(c)})),o.push(l,a)})),n(o),S.value.add(...o)}function n(t){const e=b(t),n=(R-N)/2,i=(e.height+e.top-N)/2;t.forEach((t=>{const e=t.top+n-i;t.set({top:e,originTop:e})}))}e(F,B/2),e($,t)}(),{clickMenu:function({item:t,target:e}){const n={...t.origin};"remove"===t.mode?(j("remove",n),st(n,"remove")):(Object.assign(n,{data:{time:X(t.pointer.x),value:A(t.origin.key,t.pointer.y)}}),j("add",n),st(n))},redrawPoints:at}}export{S as useBirthProcess};
|
@@ -1 +1 @@
|
|
1
|
-
import{reactive as e,computed as a,watch as t,toRefs as l}from"vue";import{defaultBorderStyle as
|
1
|
+
import{reactive as e,computed as a,watch as t,toRefs as l}from"vue";import{defaultBorderStyle as r}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import"date-fns";import{getTime as u}from"../../utils/index.js";import"lodash-es";import"../useEvent.js";import"../temperature/useShadow.js";import"@vueuse/shared";import"naive-ui";import"@vueuse/core";import{useBirthProcess as i}from"./useBirthProcess.js";function s(s,d,n,o,v,c){const h=e({select:null,redrawPoints:null,clickMenu:null}),m=a((()=>d.data.scaleValues.map((e=>{var a;return{...e,width:null!=(a=e.width)?a:60}})).filter((({layout:e="left",show:a=!0})=>"left"===e&&a)))),f=a((()=>d.data.scaleValues.map((e=>{var a;return{...e,width:null!=(a=e.width)?a:60}})).filter((({layout:e="left",show:a=!0})=>"right"===e&&a)))),p=a((()=>{var e;return(null==(e=f.value)?void 0:e.length)?30:0})),g=a((()=>{var e;return 30+(null==(e=m.value)?void 0:e.reduce(((e,a)=>e+=a.width),0))})),w=a((()=>{var e;const{width:a}=d.data,t=null==(e=f.value)?void 0:e.reduce(((e,a)=>e+=a.width),0);return a-p.value-t})),x=a((()=>d.data.grid.mainXCell)),b=a((()=>{const e=d.data.grid.mainYCell||14;return d.data.scaleValues.find((e=>e.show&&"FHR"===e.key))||14!==e?e:10})),y=a((()=>(w.value-g.value)/x.value)),V=a((()=>{const{xAxis:e,height:a}=d.data,t=Object.values(e).reduce(((e,a)=>(a.show&&e++,e)),0);return a/(b.value+t)})),j=a((()=>{const{xAxis:e}=d.data,a=Object.values(e).reduce(((e,a)=>(a.show&&"top"===a.position&&e++,e)),0);return V.value*a})),A=a((()=>{var e;const{scaleValues:a}=d.data;if(!(null==(e=a.find((e=>"FHR"===e.key)))?void 0:e.show)&&!j.value)return j.value;const t=a.find((e=>"cervix"===e.key)),[,l]=(null==t?void 0:t.range)||[0,10],r=(null==t?void 0:t.spaceValue)||1;return k.value-l*r*V.value})),k=a((()=>{const{xAxis:e,height:a}=d.data,t=Object.values(e).reduce(((e,a)=>(a.show&&"bottom"===a.position&&e++,e)),0);return a-V.value*t})),C=a((()=>u(d.data.xAxis.time.startTime))),Y=a((()=>36e5/y.value)),S=a((()=>{const{scaleValues:e}=d.data,a=e.find((e=>"cervix"===e.key));return V.value/((null==a?void 0:a.spaceValue)||1)})),H=a((()=>{const{scaleValues:e}=d.data,a=e.find((e=>"FHR"===e.key));return V.value/((null==a?void 0:a.spaceValue)||10)})),P=a((()=>{const{scaleValues:e}=d.data,a=e.find((e=>"fetalPresentation"===e.key));return V.value/((null==a?void 0:a.spaceValue)||1)})),R=a((()=>{var e;return(null==(e=d.data.grid)?void 0:e.event)||{selectable:!0,evented:!0,hovered:!0}})),X=e({canvasWidth:d.data.width,canvasHeight:d.data.height,borderStyle:{...r,...d.data.borderStyle||{}},selectionStyle:d.data.selectionStyle||{},grid:d.data.grid,other:d.data.other,originX:g.value,endX:w.value,originY:j.value,endY:k.value,xCellWidth:y.value,yCellHeight:V.value,gridXNumber:x.value,gridYNumber:b.value,xAxis:d.data.xAxis,leftScales:m.value,rightScales:f.value,leftAddAreaWidth:30,rightAddAreaWidth:p.value,startTime:C.value,timeXCell:Y.value,cervixYCell:S.value,FHRYCell:H.value,fetalPresentationYCell:P.value,scaleValues:d.data.scaleValues,event:R.value,originYCervix:A.value,scalebarBorder:!Reflect.has(d.data,"scalebarBorder")||d.data.scalebarBorder});return t((()=>s.value),(e=>{e&&function(){const{clickMenu:e,redrawPoints:a}=i(s,X,n,v,c);h.redrawPoints=a,h.clickMenu=e}()}),{immediate:!0}),{propItems:X,...l(h)}}export{s as useBirthProcessChart};
|
package/es/components/fabric-chart/src/hooks/surgicalAnesthesia/useSurgicalAnesthesiaChart.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{reactive as e,ref as t,computed as a,unref as r,onMounted as i,nextTick as o,onBeforeUnmount as l,watch as n,toRefs as u}from"vue";import{useDialog as s}from"naive-ui";import{defaultBorderStyle as d}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{format as c}from"date-fns";import{getChildrenSize as p}from"../../utils/index.js";import{cloneDeep as m,range as v,flatten as h}from"lodash-es";import"../useEvent.js";import"../temperature/useShadow.js";import{OTHER_MENU as f}from"../../constants/index.js";import"@vueuse/shared";import"@vueuse/core";import{useTop as g}from"./useTop.js";import{useLeft as w}from"./useLeft.js";import{useCenter as y}from"./useCenter.js";import{useOther as b}from"./useOther.js";function x(x,j,C,Y,H,S,T){var D;const M=s(),k=e({redrawPoints:null,clickMenu:null}),A=t();let P=null;const X=p((null==(D=j.data.top)?void 0:D.treeData)||[]),G=a((()=>j.data.layout||{top:"drug",center:"xAxis",bottom:"intraoperatively"})),N=a((()=>{var e;return null!=(e=j.data.left.width)?e:0})),V=a((()=>{const{grid:e}=j.data;return e.mainXCell*e.subXCell})),L=a((()=>{const{grid:e}=j.data;return e.mainYCell*e.subYCell})),O=a((()=>{const{show:e=!0,tree:t={}}=j.data.top;if(!e)return 0;const{rowNumber:a=X}=t;return X<a?a:X})),E=a((()=>j.data.top.tree.cellHeight)),W=a((()=>E.value*O.value)),I=a((()=>ne(oe("drug")||"top"))),F=a((()=>I.value+W.value)),q=a((()=>{var e;return Date.parse((null==(e=j.data.xAxis)?void 0:e.startTime)||c(new Date,"yyyy-MM-dd HH:mm:ss"))})),z=a((()=>{const e=m(j.data.xAxis),{spaceValue:t,spaceTimeStamp:a}=e,r=v(V.value/t+1).map((r=>0===r?e.startTime:c(new Date(q.value+r*t*a),"yyyy-MM-dd HH:mm:ss")));return{...e,list:r,left:N.value}})),B=function(){const{show:e=!0,tree:t={}}=j.data.top;if(!e)return[];const a=m(j.data.top.treeData);let r=0;const{cellWidth:i,cellHeight:o}=j.data.top.tree,{rowNumber:l=X}=t;X<l&&a.push(...v(l-X).map((()=>({}))));return function e(t,a=0){t.forEach((t=>{var l;const n={top:r*o+I.value,left:a*i,width:i,height:o};if(r++,null==(l=t.children)?void 0:l.length){r--;const i=p(t.children);n.height=i*o,e(t.children,a+1)}else n.width=N.value-n.left;Object.assign(t,n)}))}(a),a}(),J=a((()=>ne(oe("xAxis")||"center"))),K=a((()=>{var e;const{width:t,right:a}=j.data;if(!a)return t;return t-(null!=(e=a.width)?e:0)})),Q=a((()=>ne(oe("intraoperatively")||"bottom"))),R=a((()=>{var e;const{show:t
|
1
|
+
import{reactive as e,ref as t,computed as a,unref as r,onMounted as i,nextTick as o,onBeforeUnmount as l,watch as n,toRefs as u}from"vue";import{useDialog as s}from"naive-ui";import{defaultBorderStyle as d}from"../useDraw.js";import"../../../../../shared/utils/fabricjs/index.js";import{format as c}from"date-fns";import{getChildrenSize as p}from"../../utils/index.js";import{cloneDeep as m,range as v,flatten as h}from"lodash-es";import"../useEvent.js";import"../temperature/useShadow.js";import{OTHER_MENU as f}from"../../constants/index.js";import"@vueuse/shared";import"@vueuse/core";import{useTop as g}from"./useTop.js";import{useLeft as w}from"./useLeft.js";import{useCenter as y}from"./useCenter.js";import{useOther as b}from"./useOther.js";function x(x,j,C,Y,H,S,T){var D;const M=s(),k=e({redrawPoints:null,clickMenu:null}),A=t();let P=null;const X=p((null==(D=j.data.top)?void 0:D.treeData)||[]),G=a((()=>j.data.layout||{top:"drug",center:"xAxis",bottom:"intraoperatively"})),N=a((()=>{var e;return null!=(e=j.data.left.width)?e:0})),V=a((()=>{const{grid:e}=j.data;return e.mainXCell*e.subXCell})),L=a((()=>{const{grid:e}=j.data;return e.mainYCell*e.subYCell})),O=a((()=>{const{show:e=!0,tree:t={}}=j.data.top;if(!e)return 0;const{rowNumber:a=X}=t;return X<a?a:X})),E=a((()=>j.data.top.tree.cellHeight)),W=a((()=>E.value*O.value)),I=a((()=>ne(oe("drug")||"top"))),F=a((()=>I.value+W.value)),q=a((()=>{var e;return Date.parse((null==(e=j.data.xAxis)?void 0:e.startTime)||c(new Date,"yyyy-MM-dd HH:mm:ss"))})),z=a((()=>{const e=m(j.data.xAxis),{spaceValue:t,spaceTimeStamp:a}=e,r=v(V.value/t+1).map((r=>0===r?e.startTime:c(new Date(q.value+r*t*a),"yyyy-MM-dd HH:mm:ss")));return{...e,list:r,left:N.value}})),B=function(){const{show:e=!0,tree:t={}}=j.data.top;if(!e)return[];const a=m(j.data.top.treeData);let r=0;const{cellWidth:i,cellHeight:o}=j.data.top.tree,{rowNumber:l=X}=t;X<l&&a.push(...v(l-X).map((()=>({}))));return function e(t,a=0){t.forEach((t=>{var l;const n={top:r*o+I.value,left:a*i,width:i,height:o};if(r++,null==(l=t.children)?void 0:l.length){r--;const i=p(t.children);n.height=i*o,e(t.children,a+1)}else n.width=N.value-n.left;Object.assign(t,n)}))}(a),a}(),J=a((()=>ne(oe("xAxis")||"center"))),K=a((()=>{var e;const{width:t,right:a}=j.data;if(!a)return t;return t-(null!=(e=a.width)?e:0)})),Q=a((()=>ne(oe("intraoperatively")||"bottom"))),R=a((()=>{var e;const{show:t,height:a}=(null==(e=j.data.other)?void 0:e.mark)||{};return t&&a?a:0})),U=a((()=>Q.value+(j.data.height-W.value-z.value.height-R.value))),Z=a((()=>(K.value-N.value)/V.value)),$=a((()=>(U.value-Q.value)/L.value)),_=a((()=>z.value.spaceTimeStamp/Z.value)),ee=a((()=>{const{scaleValues:e}=j.data;return h(e.map((e=>e.dataList.filter((e=>e.show)).map(((t,a)=>({...t,bigType:e.type,unit:e.unit,dataIndex:a}))))))})),te=a((()=>ue("pulse"))),ae=a((()=>ue("temperature"))),re=a((()=>{var e;return(null==(e=j.data.grid)?void 0:e.event)||{selectable:!0,evented:!0,hovered:!0}})),ie=e({canvasWidth:j.data.width,canvasHeight:j.data.height,borderStyle:{...d,...j.data.borderStyle},pointSelectionStyle:j.data.pointSelectionStyle||{},grid:j.data.grid,top:j.data.top,left:j.data.left,other:j.data.other,topGridYNumber:r(O),topGridYCellHeight:r(E),topGridOriginY:r(I),topGridEndY:r(F),treeData:B,xAxis:r(z),originYXAxis:r(J),startTime:r(q),timeXCell:r(_),gridXNumber:r(V),gridYNumber:r(L),xCellWidth:r(Z),yCellHeight:r($),originX:r(N),endX:r(K),originY:r(Q),endY:r(U),markHeight:r(R),itemList:r(ee),scaleValues:j.data.scaleValues,pulseYCell:r(te),temperatureYCell:r(ae),event:r(re),dialog:M});function oe(e){let t="";return Object.entries(G.value).some((([a,r])=>{if(r===e)return t=a,!0})),t}function le(e){const t=G.value[e],a=z.value.height;switch(t){case"drug":return W.value;case"xAxis":return a;default:return j.data.height-W.value-a}}function ne(e){switch(e){case"top":return 0;case"center":return le("top");default:return le("top")+le("center")}}function ue(e){const{scaleValues:t}=j.data,a=t.find((t=>t.type===e));return $.value*(a.spaceGridNumber||1)/(a.spaceValue||1)}return i((async()=>{await o(),g(x,ie,C,H);const{redrawPoints:e,clickMenu:t,moveLimit:a,setPopup:r,updateData:i,getGridPoints:l,getContainPoints:n,showDialog:u,removeCurrentSelection:s,pauseFlickerPoint:d}=y(x,ie,C,H,S,T);A.value=d,w(x,ie,C,H,a,r,i,l);const{clickMenu:c}=b(x,ie,C,H,S,a,n,u,s);k.redrawPoints=e,k.clickMenu=e=>{const{item:a}=e;a.type&&f.map((e=>e.type)).includes(a.type)?c(e):t(e)}})),l((()=>{A.value()})),T&&n((()=>null==H?void 0:H.point),(()=>{H.movable?(H.show=!0,P&&clearTimeout(P),P=setTimeout((()=>{H.show=!1,H.movable=!1}),3e3)):P&&clearTimeout(P)}),{deep:!0}),{propItems:ie,...u(k)}}export{x as useSurgicalAnesthesiaChart};
|
@@ -598,7 +598,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
598
598
|
formRef: import("vue").Ref<any>;
|
599
599
|
conditionRef: import("vue").Ref<any>;
|
600
600
|
filterVisible: import("vue").Ref<boolean>;
|
601
|
-
title: import("vue").ComputedRef<"复制" | "
|
601
|
+
title: import("vue").ComputedRef<"复制" | "新增" | "修改" | "过滤条件">;
|
602
602
|
model: {
|
603
603
|
name: string;
|
604
604
|
color: string;
|
@@ -60,7 +60,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
60
60
|
formRef: import("vue").Ref<any>;
|
61
61
|
conditionRef: import("vue").Ref<any>;
|
62
62
|
filterVisible: import("vue").Ref<boolean>;
|
63
|
-
title: import("vue").ComputedRef<"复制" | "
|
63
|
+
title: import("vue").ComputedRef<"复制" | "新增" | "修改" | "过滤条件">;
|
64
64
|
model: {
|
65
65
|
name: string;
|
66
66
|
color: string;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as C,NButtonGroup as w,NTooltip as S}from"naive-ui";import{format as j}from"date-fns";import{getHistoryRecordApi as E,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as A}from"../hooks/useSession.js";import{MESSAGE_TYPE as z}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P,toString as q}from"lodash-es";import B from"./PersonProfile.vue.js";import J from"./MessageTemplate.vue.js";import{emojis as W}from"../utils/emoji.js";import U from"./ContextMenu.js";import X from"./ChatAdd.vue.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as F,VideocamOutline as G,DocumentSharp as K,ChatbubbleEllipsesOutline as Y,EllipsisHorizontal as $,ArrowDownSharp as Q}from"@vicons/ionicons5";import{useScrollLoading as V}from"../../../../shared/hooks/useScrollLoading.js";const Z={key:0,class:"tip-text"},ee={key:1,class:"tip-text"},te={key:2,class:"message-box"},ne={key:0,class:"content-box"},se={class:"name-box"},oe=["data-time"],ie=["onContextmenu"],re={key:0,class:"reference-content"},ae=["innerHTML"],ce=["src"],le=["innerHTML"],ue=["innerHTML"],me={style:{"margin-left":"8px"}},pe={class:"size"};var de=e({__name:"ChatMain",setup(e){const de=t(),{state:fe,setMsgList:ge,relayMessage:ve}=b(),{setCurrentSessionItem:ye,isGroupChat:he}=A(fe),Te=t(),Me=t(!1),ke=t({left:0,top:0}),_e=t(),xe=t(),Ie={page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")},Ce=n((()=>({"--c-tip-top":he.value?"1px":"-20px","--c-tip-gap":he.value?"10px":"0px"})));function we({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Q,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function Se(){try{if(!Ie.hasMore)return;Ie.page++;const e=await E({sessionKey:fe.currentSessionItem.sessionKey,page:Ie.page,lastSendTime:Ie.lastSendTime});if(!Array.isArray(e)||0===e.length)return Ie.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;Ie.lastSendTime=P(e).sendTime,ge(Ie.page>1?[...fe.msgList,...e]:e),1===Ie.page&&fe.currentSessionItem.unreadNum&&(await L({chatType:fe.currentSessionItem.chatType,messageIdSet:[t],receiver:fe.userInfo.id,sender:fe.currentSessionItem.receiver}),ye({unreadNum:0}))}catch(e){console.log(e)}}async function je(e,t){_e.value=t,async function(e){var t,n,s,o,i,r;Me.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=de.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=Te.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=de.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";ke.value=v}(e)}function Ee(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==z.TEMPLATE||!!n}function Le(e){const{chatMessageType:t}=e.content;return e.sender===fe.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[z.TEXT,z.EMOJI].includes(t)}function be(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===z.BLEND){const e=q(n).match(/<img[^>]*>/gi);return!e||!e.length}return t&&[z.TEXT,z.EMOJI].includes(t)}function Ae(e){const{chatMessageType:t,msg:n=""}=e.content,s=q(n).match(/<img[^>]*>/gi);return t===z.BLEND&&s&&s.length}function ze(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===z.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function He(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===z.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function De(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=fe.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function Re(e){fe.currentReferenceMsg=e,fe.currentReferenceMsg.content.referenceContent=null,Object.assign(fe.currentReferenceMsg,{chatType:fe.currentSessionItem.chatType,receiver:fe.currentSessionItem.receiver,receiverAvatar:fe.currentSessionItem.avatar,receiverName:fe.currentSessionItem.name})}function Ne(e,t){var n;"reply"!==e?"relay"===e&&(null==(n=xe.value)||n.click()):Re(t)}function Oe(e,t){const n=fe.msgList.find((e=>e.id===_e.value));ve({checkedIds:e,remark:t,content:n.content})}return V(de,(()=>{Se()}),"top",(()=>{Me.value=!1})),s((()=>fe.id),(e=>{e&&(fe.currentReferenceMsg=null,Object.assign(Ie,{page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")}),Se())}),{immediate:!0}),s((()=>fe.isAppendMsg),(e=>{e&&(ge([fe.currentMsg,...fe.msgList]),async function(){var e;null==(e=de.value)||e.scrollTo({top:0,behavior:"auto"})}(),fe.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(fe).id}]),ref_key:"chatMainRef",ref:de,style:c(a(Ce))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":we},{default:u((()=>[(o(!0),i(m,null,p(a(fe).msgList,((e,t)=>(o(),i(m,{key:e.id},[Ee(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(fe).userInfo.id}])},[De(e,t)?(o(),i("p",Z,d(e.__sendTime),1)):f("v-if",!0),ze(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[ze(e,"system")?(o(),g(J,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",ee,[v("span",null,d(e.sender==a(fe).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Le(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){fe.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",te,[l(B,{"user-id":e.sender,placement:e.sender==a(fe).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",ne,[v("div",se,[v("span",{class:"name","data-time":e.__time},d(a(he)?e.senderName:""),9,oe)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(z).EMOJI&&!e.content.referenceContent,template:e.content.chatMessageType===a(z).TEMPLATE,"template--3":He(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(z).FILE}]),onContextmenu:h((t=>je(t,e.id)),["prevent"])},[be(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",re,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,ae)])):f("v-if",!0),e.content.chatMessageType===a(z).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(W).findEmoji(e.__content)},null,10,ce)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,le))],64)):f("v-if",!0),Ae(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,ue)):f("v-if",!0),ze(e,"template")?(o(),g(J,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(z).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(z).AUDIO}),component:e.content.chatMessageType===a(z).AUDIO?a(F):a(G)},null,8,["class","component"]),v("span",me,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(z).FILE?(o(),g(a(C),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(K)},null,8,["component"]),l(a(C),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",pe,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(w),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>Re(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(Y)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>je(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a($)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,ie)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(U),{ref_key:"contextmenuRef",ref:Te,show:Me.value,"onUpdate:show":t[0]||(t[0]=e=>Me.value=e),position:ke.value,"msg-id":_e.value,onSelect:Ne},null,8,["show","position","msg-id"]),l(X,{title:"转发消息",mode:"relay",onComfirm:Oe},{trigger:u((()=>[v("span",{style:{display:"none"},ref_key:"relayTriggerRef",ref:xe},"转发",512)])),_:1})],6))}});export{de as default};
|
1
|
+
import{defineComponent as e,ref as t,computed as n,watch as s,openBlock as o,createElementBlock as i,normalizeClass as r,unref as a,normalizeStyle as c,createVNode as l,withCtx as u,Fragment as m,renderList as p,toDisplayString as d,createCommentVNode as f,createBlock as g,createElementVNode as v,createTextVNode as y,withModifiers as h,nextTick as T}from"vue";import{NImageGroup as M,NButton as k,NAvatar as _,NImage as x,NIcon as I,NSpace as C,NButtonGroup as w,NTooltip as S}from"naive-ui";import{format as j}from"date-fns";import{getHistoryRecordApi as E,readMessageApi as L}from"../api/index.js";import{useState as b}from"../hooks/useState.js";import{useSession as A}from"../hooks/useSession.js";import{MESSAGE_TYPE as z}from"../constants/index.js";import"trtc-sdk-v5";import{isAudioOrVideoMessage as H,simplifyMessage as D,getAVTime as R,downloadFile as N}from"../utils/index.js";import{first as O,last as P,toString as q}from"lodash-es";import B from"./PersonProfile.vue.js";import J from"./MessageTemplate.vue.js";import{emojis as W}from"../utils/emoji.js";import U from"./ContextMenu.js";import X from"./ChatAdd.vue.js";import"../../../../shared/utils/index.js";import"@vueuse/core";import"@vue/shared";import"@vueuse/shared";import"../../../../shared/hooks/selectHooks/useSearchContent.js";import{CallOutline as F,VideocamOutline as G,DocumentSharp as K,ChatbubbleEllipsesOutline as Y,EllipsisHorizontal as $,ArrowDownSharp as Q}from"@vicons/ionicons5";import{useScrollLoading as V}from"../../../../shared/hooks/useScrollLoading.js";const Z={key:0,class:"tip-text"},ee={key:1,class:"tip-text"},te={key:2,class:"message-box"},ne={key:0,class:"content-box"},se={class:"name-box"},oe=["data-time"],ie=["onContextmenu"],re={key:0,class:"reference-content"},ae=["innerHTML"],ce=["src"],le=["innerHTML"],ue=["innerHTML"],me={style:{"margin-left":"8px"}},pe={class:"size"};var de=e({__name:"ChatMain",setup(e){const de=t(),{state:fe,setMsgList:ge,relayMessage:ve}=b(),{setCurrentSessionItem:ye,isGroupChat:he}=A(fe),Te=t(),Me=t(!1),ke=t({left:0,top:0}),_e=t(),xe=t(),Ie={page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")},Ce=n((()=>({"--c-tip-top":he.value?"1px":"-20px","--c-tip-gap":he.value?"10px":"0px"})));function we({nodes:e}){var t,n;const{_ctx:s}=null==(t=e.download)?void 0:t.children,o=s?null==(n=null==s?void 0:s.proxy)?void 0:n.previewSrc:"";return[e.prev,e.next,e.rotateCounterclockwise,e.rotateClockwise,e.resizeToOriginalSize,e.zoomOut,e.zoomIn,l(S,null,{trigger:()=>l(I,{style:"cursor: pointer",color:"rgba(255, 255, 255, 0.75",size:24,component:Q,onClick:()=>o&&N(o,"img")},null),default:()=>"下载"}),e.close]}async function Se(){try{if(!Ie.hasMore)return;Ie.page++;const e=await E({sessionKey:fe.currentSessionItem.sessionKey,page:Ie.page,lastSendTime:Ie.lastSendTime});if(!Array.isArray(e)||0===e.length)return Ie.hasMore=!1,console.log("接口返回不是一个数组,或者没有更多消息了");const t=O(e).id;Ie.lastSendTime=P(e).sendTime,ge(Ie.page>1?[...fe.msgList,...e]:e),1===Ie.page&&fe.currentSessionItem.unreadNum&&(await L({chatType:fe.currentSessionItem.chatType,messageIdSet:[t],receiver:fe.userInfo.id,sender:fe.currentSessionItem.receiver}),ye({unreadNum:0}))}catch(e){console.log(e)}}async function je(e,t){_e.value=t,async function(e){var t,n,s,o,i,r;Me.value=!0,await T();const{clientX:a,clientY:c}=e,{width:l=0,height:u=0,left:m=0,top:p=0}=(null==(t=de.value)?void 0:t.getBoundingClientRect())||{},d=null!=(o=null==(s=null==(n=Te.value)?void 0:n.$el)?void 0:s.getBoundingClientRect().height)?o:220,f=null!=(r=null==(i=de.value)?void 0:i.scrollTop)?r:0,g=5,v={};a<=m+l/2?v.left=a-m+g+"px":v.right=m+l-a-g+"px";c-p<d/2?v.top=f+g+"px":p+u-c<=d/2?v.bottom=Math.abs(f)+g+"px":v.top=f+c-p-d/2+"px";ke.value=v}(e)}function Ee(e){const{chatMessageType:t,messageTemplate:n}=e.content;return t!==z.TEMPLATE||!!n}function Le(e){const{chatMessageType:t}=e.content;return e.sender===fe.userInfo.id&&Date.now()-new Date(e.sendTime).getTime()<864e5&&[z.TEXT,z.EMOJI].includes(t)}function be(e){const{chatMessageType:t,msg:n=""}=e.content;if(t===z.BLEND){const e=q(n).match(/<img[^>]*>/gi);return!e||!e.length}return t&&[z.TEXT,z.EMOJI].includes(t)}function Ae(e){const{chatMessageType:t,msg:n=""}=e.content,s=q(n).match(/<img[^>]*>/gi);return t===z.BLEND&&s&&s.length}function ze(e,t){var n,s;const{chatMessageType:o,messageTemplate:i}=e.content;if(o===z.TEMPLATE)return"system"===t?2==(null==(n=null==i?void 0:i.setting)?void 0:n.style.id):2!=(null==(s=null==i?void 0:i.setting)?void 0:s.style.id)}function He(e){var t,n;const{chatMessageType:s,messageTemplate:o}=e;return s===z.TEMPLATE&&3==(null==(n=null==(t=null==o?void 0:o.setting)?void 0:t.style)?void 0:n.id)}function De(e,t){var n;const s=new Date(e.sendTime).getTime(),o=null==(n=fe.msgList[t+1])?void 0:n.sendTime;if(o){return s-new Date(o).getTime()>3e5}return!0}function Re(e){fe.currentReferenceMsg=e,fe.currentReferenceMsg.content.referenceContent=null,Object.assign(fe.currentReferenceMsg,{chatType:fe.currentSessionItem.chatType,receiver:fe.currentSessionItem.receiver,receiverAvatar:fe.currentSessionItem.avatar,receiverName:fe.currentSessionItem.name})}function Ne(e,t){var n;"reply"!==e?"relay"===e&&(null==(n=xe.value)||n.click()):Re(t)}function Oe(e,t){const n=fe.msgList.find((e=>e.id===_e.value));ve({checkedIds:e,remark:t,content:n.content})}return V(de,(()=>{Se()}),"top",(()=>{Me.value=!1})),s((()=>fe.id),(e=>{e&&(fe.currentReferenceMsg=null,Object.assign(Ie,{page:0,hasMore:!0,lastSendTime:j(new Date,"yyyy-MM-dd HH:mm:ss")}),Se())}),{immediate:!0}),s((()=>fe.isAppendMsg),(e=>{e&&(ge([fe.currentMsg,...fe.msgList]),async function(){var e;null==(e=de.value)||e.scrollTo({top:0,behavior:"auto"})}(),fe.isAppendMsg=!1)}),{immediate:!0}),(e,t)=>(o(),i("div",{class:r(["chat-main",{"home-bg":!a(fe).id}]),ref_key:"chatMainRef",ref:de,style:c(a(Ce))},[l(a(M),{"show-toolbar-tooltip":"","render-toolbar":we},{default:u((()=>[(o(!0),i(m,null,p(a(fe).msgList,((e,t)=>(o(),i(m,{key:e.id},[Ee(e)?(o(),i("div",{key:0,class:r(["message-item",{"message-item--mine":e.sender==a(fe).userInfo.id}])},[De(e,t)?(o(),i("p",Z,d(e.__sendTime),1)):f("v-if",!0),ze(e,"system")||"WITHDRAWN"===e.status?(o(),i(m,{key:1},[ze(e,"system")?(o(),g(J,{key:0,data:e},null,8,["data"])):f("v-if",!0),"WITHDRAWN"===e.status?(o(),i("p",ee,[v("span",null,d(e.sender==a(fe).userInfo.id?"你":e.senderName)+"撤回了一条消息",1),Le(e)?(o(),g(a(k),{key:0,size:"tiny",style:{color:"var(--c-primary-color)","margin-left":"5px"},text:"",onClick:()=>function(e){fe.currentReEditMsg=e}(e)},{default:u((()=>[y(" 重新编辑 ")])),_:2},1032,["onClick"])):f("v-if",!0)])):f("v-if",!0)],64)):(o(),i("div",te,[l(B,{"user-id":e.sender,placement:e.sender==a(fe).userInfo.id?"left":"right"},{trigger:u((()=>[l(a(_),{round:"",size:38,src:e.senderAvatar},null,8,["src"])])),_:2},1032,["user-id","placement"]),e.content?(o(),i("div",ne,[v("div",se,[v("span",{class:"name","data-time":e.__time},d(a(he)?e.senderName:""),9,oe)]),v("div",{class:r(["content",{emoji:e.content.chatMessageType===a(z).EMOJI&&!e.content.referenceContent,template:e.content.chatMessageType===a(z).TEMPLATE,"template--3":He(e.content),"audio-video":a(H)(e.content),file:e.content.chatMessageType===a(z).FILE}]),onContextmenu:h((t=>je(t,e.id)),["prevent"])},[be(e)?(o(),i(m,{key:0},[e.content.referenceContent?(o(),i("div",re,[v("span",null,d(e.content.referenceContent.senderName)+":",1),v("pre",{innerHTML:a(D)(e.content.referenceContent.content)},null,8,ae)])):f("v-if",!0),e.content.chatMessageType===a(z).EMOJI?(o(),i("img",{key:1,class:r([e.content.referenceContent?"emoji--min":"emoji--big"]),src:a(W).findEmoji(e.__content)},null,10,ce)):(o(),i("pre",{key:2,innerHTML:e.__content},null,8,le))],64)):f("v-if",!0),Ae(e)?(o(),i("pre",{key:1,innerHTML:e.__content},null,8,ue)):f("v-if",!0),ze(e,"template")?(o(),g(J,{key:2,data:e},null,8,["data"])):f("v-if",!0),e.content.chatMessageType===a(z).IMAGE?(o(),g(a(x),{key:3,width:"240",src:e.__content},null,8,["src"])):f("v-if",!0),a(H)(e.content)?(o(),i(m,{key:4},[l(a(I),{class:r({"is-audio":e.content.chatMessageType===a(z).AUDIO}),component:e.content.chatMessageType===a(z).AUDIO?a(F):a(G)},null,8,["class","component"]),v("span",me,d(a(R)(e.__content)),1)],64)):f("v-if",!0),e.content.chatMessageType===a(z).FILE?(o(),g(a(C),{key:5,"wrap-item":!1},{default:u((()=>[l(a(I),{class:"icon-file",size:"40",component:a(K)},null,8,["component"]),l(a(C),{"wrap-item":!1,vertical:"",justify:"space-between",style:{"row-gap":"0"}},{default:u((()=>[v("span",null,d(e.__content),1),v("span",pe,d(e.__size),1)])),_:2},1024)])),_:2},1024)):f("v-if",!0),l(a(w),{class:"quick-menu"},{default:u((()=>[a(H)(e.content)?f("v-if",!0):(o(),i(m,{key:0},[f(' <n-button quaternary size="tiny">\r\n\t\t\t\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<i class="chat--iconfont chat--icon-face" />\r\n\t\t\t\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t\t\t\t</n-button> '),l(a(k),{quaternary:"",size:"tiny",onClick:()=>Re(e)},{icon:u((()=>[l(a(I),{size:"17",component:a(Y)},null,8,["component"])])),_:2},1032,["onClick"])],64)),l(a(k),{quaternary:"",size:"tiny",onClick:t=>je(t,e.id)},{icon:u((()=>[l(a(I),{size:"14",component:a($)},null,8,["component"])])),_:2},1032,["onClick"])])),_:2},1024)],42,ie)])):f("v-if",!0)]))],2)):f("v-if",!0)],64)))),128))])),_:1}),l(a(U),{ref_key:"contextmenuRef",ref:Te,show:Me.value,"onUpdate:show":t[0]||(t[0]=e=>Me.value=e),position:ke.value,"msg-id":_e.value,onSelect:Ne},null,8,["show","position","msg-id"]),l(X,{title:"转发消息",mode:"relay",onComfirm:Oe},{trigger:u((()=>[v("span",{style:{display:"none"},ref_key:"relayTriggerRef",ref:xe},"转发",512)])),_:1})],6))}});export{de as default};
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as t,ref as e,reactive as a,computed as o,openBlock as l,createBlock as
|
1
|
+
import{defineComponent as t,ref as e,reactive as a,computed as o,openBlock as l,createBlock as r,unref as n,withCtx as s,renderSlot as i,createElementBlock as c,Fragment as u,withDirectives as d,createElementVNode as p,createVNode as m,createCommentVNode as v,toDisplayString as f,createTextVNode as g,renderList as y,vShow as k}from"vue";import{NPopover as h,NAvatar as b,NButton as w,NIcon as j}from"naive-ui";import{ChatbubbleEllipses as C,EyeOffOutline as I,EyeOutline as _,Close as x}from"@vicons/ionicons5";import{useState as z}from"../hooks/useState.js";import{useSession as N}from"../hooks/useSession.js";import{CHAT_TYPE as S}from"../constants/index.js";import"trtc-sdk-v5";import"date-fns";import"lodash-es";import"../utils/emoji.js";import"../../../../shared/utils/index.js";import{openSessionApi as $,getUserDetailApi as D}from"../api/index.js";const E={class:"person-profile-main"},L={class:"left"},P={class:"profile"},q={class:"profile__text"},B={class:"right"},G={class:"right__content"},O={class:"label"},T={class:"content"};var U=t({__name:"PersonProfile",props:{userId:{type:String,required:!0},disabled:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:U}){const A=t,{state:F}=z(),{openSession:H}=N(F),J=e(!1),K=e(!1),M=e(!1),Q=a({}),R=[{label:"机构",value:"",key:"orgName"},{label:"姓名",value:"",key:"name"},{label:"归属科室",value:"",key:"deptName"},{label:"业务科室",value:"",key:"businessDeptNames"},{label:"手机号",value:"",key:"phone"},{label:"岗位",value:"",key:"post"},{label:"工号",value:"",key:"jobId"},{label:"性别",value:"",key:"orgName"}],V=o((()=>(Q.id&&R.forEach((t=>{const{key:e}=t;t.value=Q[e]})),R)));async function W(){J.value=!1;let t=F.sessionList.find((t=>t.receiver===A.userId));if(!t)try{t=await $({chatType:S.SINGLE,receiver:A.userId,sender:F.userInfo.id})}catch(t){console.log("error :>> ",t)}t&&H(t),U("close")}async function X(t){if(!t)return;const e=await D({userId:A.userId});(null==e?void 0:e.id)?Object.assign(Q,e):Q.id=""}function Y(t){const{key:e,value:a}=t;return"phone"!==e||M.value?a:(a||"").replace(/(\d{3})\d{4}(\d{4})/,"$1****$2")}return(e,a)=>(l(),r(n(h),{raw:"",class:"person-profile-wrapper",show:J.value,"onUpdate:show":[a[3]||(a[3]=t=>J.value=t),X],trigger:t.disabled?"manual":"click","show-arrow":!1,to:"body",shift:""},{trigger:s((()=>[i(e.$slots,"trigger")])),default:s((()=>[Q.id?(l(),c(u,{key:0},[d(p("div",E,[p("div",L,[p("div",P,[m(n(b),{src:Q.avatar,bordered:"",round:"",size:100,onClickCapture:a[0]||(a[0]=t=>K.value=!0)},null,8,["src"]),v(' <n-upload abstract accept="image/*" @change="onChange">\r\n\t\t\t\t\t\t\t<n-upload-trigger #="{ handleClick }" abstract>\r\n\t\t\t\t\t\t\t\t<n-button\r\n\t\t\t\t\t\t\t\t\tcircle\r\n\t\t\t\t\t\t\t\t\tsecondary\r\n\t\t\t\t\t\t\t\t\tclass="edit-avatar"\r\n\t\t\t\t\t\t\t\t\tv-show="userDetail.id === state.userInfo.id"\r\n\t\t\t\t\t\t\t\t\t@click="handleClick"\r\n\t\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\t\t<template #icon>\r\n\t\t\t\t\t\t\t\t\t\t<n-icon size="16" color="#666666" :component="Camera" />\r\n\t\t\t\t\t\t\t\t\t</template>\r\n\t\t\t\t\t\t\t\t</n-button>\r\n\t\t\t\t\t\t\t</n-upload-trigger>\r\n\t\t\t\t\t\t</n-upload> '),p("div",q,[p("h4",null,f(Q.name),1),p("p",null,f(Q.orgName),1)]),m(n(w),{strong:"",secondary:"",onClick:W},{default:s((()=>[m(n(j),{size:"13",color:"#666666",component:n(C),style:{"margin-right":"6px"}},null,8,["component"]),g(" 发消息 ")])),_:1})])]),p("div",B,[p("div",G,[(l(!0),c(u,null,y(n(V),((t,e)=>(l(),c("div",{class:"info-item",key:e},[p("span",O,f(t.label),1),p("div",T,[p("span",null,f(Y(t)),1),"phone"===t.key&&Y(t)?(l(),r(n(j),{key:0,size:"16",color:"#666666",component:M.value?n(I):n(_),style:{"margin-left":"10px"},onClick:a[1]||(a[1]=t=>M.value=!M.value)},null,8,["component"])):v("v-if",!0)])])))),128))])])],512),[[k,!K.value]]),d(p("div",{class:"large-avatar",onClick:a[2]||(a[2]=t=>K.value=!1)},[m(n(w),{circle:"",size:"small",secondary:""},{icon:s((()=>[m(n(j),{size:24,component:n(x),color:"#fff"},null,8,["component"])])),_:1}),m(n(b),{size:310,round:"",src:Q.avatar},null,8,["src"])],512),[[k,K.value]])],64)):v("v-if",!0)])),_:3},8,["show","trigger"]))}});export{U as default};
|
@@ -55,6 +55,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
55
55
|
isShow: import("vue").Ref<boolean>;
|
56
56
|
timePickerRef: import("vue").Ref<any>;
|
57
57
|
inputValue: import("vue").Ref<any>;
|
58
|
+
newValue: string | undefined;
|
58
59
|
inputProps: import("vue").ComputedRef<{
|
59
60
|
style: string;
|
60
61
|
} | {
|
@@ -65,11 +66,12 @@ declare const _default: import("vue").DefineComponent<{
|
|
65
66
|
valueFormat: any;
|
66
67
|
timeConfig: AnyObject;
|
67
68
|
clickShortcutOption: (item: string) => void;
|
68
|
-
|
69
|
+
saveValue: (value: string | null) => void;
|
69
70
|
isDisabled: (value: string) => boolean;
|
70
71
|
onChange: () => void;
|
71
72
|
onKeydown: (event: KeyboardEvent) => void;
|
72
73
|
formatTime: (time: string) => string;
|
74
|
+
updateFormattedValue: () => void;
|
73
75
|
NInput: any;
|
74
76
|
NPopover: any;
|
75
77
|
NSpace: any;
|
@@ -1 +1 @@
|
|
1
|
-
import{defineComponent as e,useAttrs as t,inject as l,ref as a,computed as r,reactive as o,watch as u,nextTick as n,
|
1
|
+
import{defineComponent as e,useAttrs as t,inject as l,ref as a,computed as r,reactive as o,watch as u,nextTick as n,onBeforeUnmount as i,openBlock as m,createBlock as d,unref as v,withCtx as c,createVNode as s,mergeProps as f,isRef as p,createElementBlock as h,Fragment as b,renderList as y,createTextVNode as g,toDisplayString as w,createCommentVNode as k}from"vue";import{noop as _}from"lodash-es";import{NPopover as V,NInput as F,NSpace as S,NScrollbar as $,NButton as H}from"naive-ui";import{useIhoTableFormEvent as x}from"../../../../utils/index.js";import D from"../../../../../../time-picker/index.js";import{parse as C,isValid as O,format as j,getHours as E,getMinutes as A,getSeconds as I}from"date-fns";var P=e({__name:"editTime",props:{formattedValue:{type:String},column:{type:Object},row:{type:Object},rowIndex:{type:Number},shortcutOptions:{type:Array,default:()=>[]},ignoreGlobEmit:{type:Boolean,default:!1}},emits:["update:formattedValue","click"],setup(e,{emit:P}){const R=e,U=t(),{emitFormChangeWithParams:q=_}=R.ignoreGlobEmit?{}:x({...R,$table:l("$xetable")}),G=a(null),M=a(!1),N=a(),W=a();let z=R.formattedValue;const B=r((()=>W.value&&X(W.value)?{style:"text-decoration: line-through"}:{})),K=r({get(){if(!W.value)return null;const e=C(W.value,L.valueFormat,new Date);return O(e)?j(e,L.valueFormat):R.formattedValue?ee(R.formattedValue):null},set(e){Q(e)}}),{placeholder:T="请选择",valueFormat:J="HH:mm"}=U,L=o({...U,placeholder:T,valueFormat:J,format:J});function Q(e){if(W.value=e||"",e&&X(e))return;R.formattedValue!==e&&(z=e)}function X(e){var t,l,a;const r=C(e,L.format,new Date),o=E(r),u=A(r),n=I(r),i=null==(t=L.isHourDisabled)?void 0:t.call(L,o),m=null==(l=L.isMinuteDisabled)?void 0:l.call(L,u,o),d=null==(a=L.isSecondDisabled)?void 0:a.call(L,n,u,o);return i||m||d}function Y(){[L.valueFormat.replace(/[^\w]/g,""),L.valueFormat].some((e=>{const t=C(W.value,e,new Date);if(!W.value||O(t)){return Q(W.value?j(t,L.valueFormat):null),!0}return!1}))}function Z(e){var t;const{key:l}=e;"Enter"===l&&(null==(t=G.value)||t.blur(),M.value=!1)}function ee(e){var t;const l=L.valueFormat.match(/\W/)[0]||":",a=e.split(l).map(Number),r=`${a[0].toString().padStart(2,"0")}${l}${a[1].toString().padStart(2,"0")}`;return"HH:mm"===L.valueFormat?r:"HH:mm:ss"===L.valueFormat?`${r}${l}${(null!=(t=a[2])?t:0).toString().padStart(2,"0")}`:e}function te(){z&&X(z)||R.formattedValue!==z&&(P("update:formattedValue",z),q({oldValue:R.formattedValue}))}return u((()=>R.formattedValue),(e=>{if(!e)return"";W.value=ee(e)}),{immediate:!0}),u((()=>M.value),(async e=>{var t,l,a,r,o;e?(z=K.value,await n(),null==(o=null==(r=null==(a=null==(l=null==(t=N.value)?void 0:t.$timePicker)?void 0:l.panelInstRef)?void 0:a.$el)?void 0:r.querySelectorAll(".n-time-picker-col"))||o.forEach((e=>{var t,l;return null==(l=null==(t=null==e?void 0:e.querySelector)?void 0:t.call(e,".n-time-picker-col__item--active"))?void 0:l.scrollIntoView()}))):te()})),i((()=>{te()})),(t,l)=>(m(),d(v(V),{show:M.value,"onUpdate:show":l[3]||(l[3]=e=>M.value=e),trigger:"click",showArrow:!1,placement:"bottom-start",style:{padding:"0"}},{trigger:c((()=>[s(v(F),{ref_key:"formRef",ref:G,clearable:"",placeholder:v(T),value:W.value,"onUpdate:value":l[0]||(l[0]=e=>W.value=e),valueModifiers:{trim:!0},"input-props":v(B),onChange:Y,onKeydown:Z},null,8,["placeholder","value","input-props"])])),default:c((()=>[s(v(S),null,{default:c((()=>[s(v(D),f({ref_key:"timePickerRef",ref:N,show:""},v(L),{class:"iho-table__time-picker",to:!1,"formatted-value":v(K),"onUpdate:formatted-value":l[1]||(l[1]=e=>p(K)?K.value=e:null),onConfirm:l[2]||(l[2]=()=>M.value=!1)}),null,16,["formatted-value"]),s(v($),{class:"iho-table__scrollbar"},{default:c((()=>[e.shortcutOptions.length?(m(),d(v(S),{key:0,vertical:"",wrap:!1},{default:c((()=>[(m(!0),h(b,null,y(e.shortcutOptions,(e=>(m(),d(v(H),{size:"tiny",key:e,disabled:X(e),onClick:t=>function(e){Q(ee(e)),M.value=!1}(e)},{default:c((()=>[g(w(e),1)])),_:2},1032,["disabled","onClick"])))),128))])),_:1})):k("v-if",!0)])),_:1})])),_:1})])),_:1},8,["show"]))}});export{P as default};
|