configuration-drug.component.ts 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. import { Component, OnInit, ViewChild } from "@angular/core";
  2. import { MainService } from "../../../services/main.service";
  3. import { ToolService } from 'src/app/services/tool.service';
  4. import { NzMessageService } from 'ng-zorro-antd';
  5. import { Subject, forkJoin } from 'rxjs';
  6. import { debounceTime } from 'rxjs/operators';
  7. import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
  8. @Component({
  9. selector: "app-configuration-drug",
  10. templateUrl: "./configuration-drug.component.html",
  11. styleUrls: ["./configuration-drug.component.less"],
  12. })
  13. export class ConfigurationDrugComponent implements OnInit {
  14. @ViewChild("osComponentRef1", {
  15. read: OverlayScrollbarsComponent,
  16. static: false,
  17. })
  18. osComponentRef1: OverlayScrollbarsComponent;
  19. loading:boolean = false; //页面加载的loading
  20. btnLoading:boolean = false; //提交按钮的loading
  21. tabModalName:string = 'characteristics'; //当前选中的tab
  22. hosId = this.tool.getCurrentHospital().id; //当前院区
  23. // 配置
  24. configs:any = {};
  25. // 任务类型
  26. tasktype:any = {};
  27. constructor(private mainService: MainService,private tool: ToolService,private msg: NzMessageService) {}
  28. ngOnInit():void {
  29. this.activeDictionary = this.dictionaryKeyList[0];
  30. this.init();
  31. this.getDrugState();
  32. }
  33. // 工单模式
  34. drugsModelList:any[] = [
  35. { label: '一单一码', value: 1 },
  36. { label: '一单多码', value: 2 },
  37. ];
  38. // 手动填写
  39. drugsManualList:any[] = [];
  40. // 数据字典key列表
  41. dictionaryKeyList: any[] = [
  42. {
  43. name: '静配',
  44. value: 'drugsJpbag',
  45. postData: {
  46. drugsModel: undefined,//工单模式
  47. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  48. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  49. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  50. drugsStartCheckScanIds: [],//起点核对方式
  51. drugsStartManual: undefined,//起点科室手动填写
  52. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  53. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  54. drugsEndCheckScanIds: [],//终点核对方式
  55. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  56. drugsEndManual: undefined,//终点科室手动填写
  57. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  58. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  59. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  60. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  61. autoCreateState: undefined // 药品自动建单状态
  62. }
  63. },
  64. {
  65. name: '西药',
  66. value: 'drugsWestern',
  67. postData: {
  68. drugsModel: undefined,//工单模式
  69. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  70. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  71. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  72. drugsStartCheckScanIds: [],//起点核对方式
  73. drugsStartManual: undefined,//起点科室手动填写
  74. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  75. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  76. drugsEndCheckScanIds: [],//终点核对方式
  77. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  78. drugsEndManual: undefined,//终点科室手动填写
  79. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  80. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  81. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  82. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  83. autoCreateState: undefined // 药品自动建单状态
  84. }
  85. },
  86. {
  87. name: '退药',
  88. value: 'drugsReturn',
  89. postData: {
  90. drugsModel: undefined,//工单模式
  91. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  92. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  93. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  94. drugsStartCheckScanIds: [],//起点核对方式
  95. drugsStartManual: undefined,//起点科室手动填写
  96. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  97. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  98. drugsEndCheckScanIds: [],//终点核对方式
  99. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  100. drugsEndManual: undefined,//终点科室手动填写
  101. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  102. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  103. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  104. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  105. autoCreateState: undefined // 药品自动建单状态
  106. }
  107. },
  108. {
  109. name: '毒麻',
  110. value: 'drugsPoison',
  111. postData: {
  112. drugsModel: undefined,//工单模式
  113. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  114. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  115. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  116. drugsStartCheckScanIds: [],//起点核对方式
  117. drugsStartManual: undefined,//起点科室手动填写
  118. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  119. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  120. drugsEndCheckScanIds: [],//终点核对方式
  121. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  122. drugsEndManual: undefined,//终点科室手动填写
  123. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  124. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  125. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  126. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  127. autoCreateState: undefined // 药品自动建单状态
  128. }
  129. },
  130. {
  131. name: '中草药',
  132. value: 'drugsHerbal',
  133. postData: {
  134. drugsModel: undefined,//工单模式
  135. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  136. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  137. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  138. drugsStartCheckScanIds: [],//起点核对方式
  139. drugsStartManual: undefined,//起点科室手动填写
  140. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  141. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  142. drugsEndCheckScanIds: [],//终点核对方式
  143. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  144. drugsEndManual: undefined,//终点科室手动填写
  145. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  146. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  147. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  148. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  149. autoCreateState: undefined // 药品自动建单状态
  150. }
  151. },
  152. ];
  153. // 获取药品状态
  154. drugStateData:any = []
  155. getDrugState(){
  156. this.mainService.getDictionary("list", "drug_state").subscribe((data) => {
  157. this.drugStateData = data
  158. });
  159. }
  160. // 点击数据字典key
  161. activeDictionary:any;
  162. clickDictionaryKey(item){
  163. this.activeDictionary = item;
  164. this.init();
  165. }
  166. // 修改起点科室支持核对
  167. changeDrugsStartCheck(e){
  168. console.log(e);
  169. if(!e[0].checked){
  170. this.activeDictionary.postData.drugsStartCheckScanIds = this.activeDictionary.postData.drugsStartCheckScanIds.map(v => ({...v, checked: false}));
  171. this.activeDictionary.postData.drugsStartManual = undefined;
  172. this.activeDictionary.postData.drugsStartPhoto[0].checked = false;
  173. }
  174. }
  175. // 修改终点科室支持核对
  176. changeDrugsEndCheck(e){
  177. console.log(e);
  178. if(!e[0].checked){
  179. this.activeDictionary.postData.drugsEndCheckScanIds = this.activeDictionary.postData.drugsEndCheckScanIds.map(v => ({...v, checked: false}));;
  180. this.activeDictionary.postData.drugsEndManual = undefined;
  181. this.activeDictionary.postData.drugsEndPhoto[0].checked = false;
  182. }
  183. }
  184. // 切换tab
  185. tabModal(tabModalName:string){
  186. this.tabModalName = tabModalName;
  187. }
  188. // 保存
  189. submitForm() {
  190. if(!this.tasktype.id){
  191. this.msg.create("warning", "请先配置任务类型!");
  192. return;
  193. }
  194. if(!this.activeDictionary.postData.drugsModel){
  195. this.msg.create("warning", "请选择工单模式!");
  196. return;
  197. }
  198. if(this.activeDictionary.postData.drugsStartCheck[0].checked && !this.activeDictionary.postData.drugsStartCheckScanIds.filter(v => v.checked).length){
  199. this.msg.create("warning", "请选择起点科室的核对方式!");
  200. return;
  201. }
  202. if(this.activeDictionary.postData.drugsEndCheck[0].checked && !this.activeDictionary.postData.drugsEndCheckScanIds.filter(v => v.checked).length){
  203. this.msg.create("warning", "请选择终点科室的核对方式!");
  204. return;
  205. }
  206. let postData:any = {
  207. id: this.configs.id,
  208. taskType: this.tasktype.id,
  209. hosId: this.hosId,
  210. drugsModel: this.activeDictionary.postData.drugsModel || undefined,
  211. drugsCreateSign: this.activeDictionary.postData.drugsCreateSign[0].checked ? 1 : 0,
  212. drugsReceiveSign: this.activeDictionary.postData.drugsReceiveSign[0].checked ? 1 : 0,
  213. drugsStartCheck: this.activeDictionary.postData.drugsStartCheck[0].checked ? 1 : 0,
  214. drugsStartCheckScanIds: this.activeDictionary.postData.drugsStartCheckScanIds.filter(v => v.checked).map(v => v.value).toString() || undefined,
  215. drugsStartManual: this.activeDictionary.postData.drugsStartManual ? { id: this.activeDictionary.postData.drugsStartManual } : undefined,
  216. drugsStartPhoto: this.activeDictionary.postData.drugsStartPhoto[0].checked ? 1 : 0,
  217. drugsEndCheck: this.activeDictionary.postData.drugsEndCheck[0].checked ? 1 : 0,
  218. drugsEndCheckScanIds: this.activeDictionary.postData.drugsEndCheckScanIds.filter(v => v.checked).map(v => v.value).toString() || undefined,
  219. drugsEndManual: this.activeDictionary.postData.drugsEndManual ? { id: this.activeDictionary.postData.drugsEndManual } : undefined,
  220. drugsEndPhoto: this.activeDictionary.postData.drugsEndPhoto[0].checked ? 1 : 0,
  221. showPatientInfo: this.activeDictionary.postData.showPatientInfo[0].checked ? 1 : 0,
  222. showDrugsBagTypeCount: this.activeDictionary.postData.showDrugsBagTypeCount[0].checked ? 1 : 0,
  223. showDrugsBagDetails: this.activeDictionary.postData.showDrugsBagDetails[0].checked ? 1 : 0,
  224. autoCreate: this.activeDictionary.postData.autoCreate[0].checked ? 1 : 0,
  225. autoCreateState:{
  226. id:this.activeDictionary.postData.autoCreateState || undefined
  227. }
  228. };
  229. this.btnLoading = true;
  230. this.mainService
  231. .simplePost("addData", "taskTypeConfig", postData)
  232. .subscribe((result) => {
  233. this.btnLoading = false;
  234. if (result.status == 200) {
  235. this.getConfig();
  236. }
  237. });
  238. }
  239. //初始化
  240. init() {
  241. this.loading = true;
  242. let drugs_bag_check_scan_type$ = this.mainService.getDictionary('list', 'drugs_bag_check_scan_type', true);
  243. let drugs_bag_manual_type$ = this.mainService.getDictionary('list', 'drugs_bag_manual_type', true);
  244. forkJoin(drugs_bag_check_scan_type$, drugs_bag_manual_type$).subscribe((data:any[]) => {
  245. let drugs_bag_check_scan_type = data[0] || [];
  246. let drugs_bag_manual_type = data[1] || [];
  247. this.activeDictionary.postData.drugsStartCheckScanIds = drugs_bag_check_scan_type.map(v => ({ label:v.name, value: v.id }));
  248. this.activeDictionary.postData.drugsEndCheckScanIds = drugs_bag_check_scan_type.map(v => ({ label:v.name, value: v.id }));
  249. this.drugsManualList = drugs_bag_manual_type.map(v => ({ label:v.name, value: v.id }));
  250. this.getTaskType();
  251. })
  252. }
  253. //获取任务类型
  254. getTaskType() {
  255. this.loading = true;
  256. let postData = {
  257. idx: 0,
  258. sum: 1,
  259. taskType: {
  260. simpleQuery: true,
  261. hosId: {
  262. id: this.hosId
  263. },
  264. ordinaryField: {
  265. key: 'ordinary_field',
  266. value: this.activeDictionary.value,
  267. }
  268. }
  269. };
  270. this.mainService
  271. .getFetchDataList("simple/data", "taskType", postData)
  272. .subscribe((result) => {
  273. this.loading = false;
  274. if (result.status == 200) {
  275. this.tasktype = result.list[0] || {};
  276. this.getConfig();
  277. }
  278. });
  279. }
  280. // 获取配置
  281. getConfig() {
  282. this.loading = true;
  283. let postData = {
  284. idx: 0,
  285. sum: 1,
  286. taskTypeConfig: {
  287. taskTypeDTO: {
  288. hosId: {
  289. id: this.hosId
  290. },
  291. ordinaryField: {
  292. key: 'ordinary_field',
  293. value: this.activeDictionary.value,
  294. }
  295. }
  296. }
  297. };
  298. this.mainService
  299. .getFetchDataList("simple/data", "taskTypeConfig", postData)
  300. .subscribe((result) => {
  301. this.loading = false;
  302. if (result.status == 200) {
  303. this.configs = result.list[0] || {};
  304. this.activeDictionary.postData.drugsModel = this.configs.drugsModel || undefined;
  305. this.activeDictionary.postData.drugsCreateSign[0].checked = this.configs.drugsCreateSign == 1;
  306. this.activeDictionary.postData.drugsReceiveSign[0].checked = this.configs.drugsReceiveSign == 1;
  307. this.activeDictionary.postData.drugsStartCheck[0].checked = this.configs.drugsStartCheck == 1;
  308. this.activeDictionary.postData.drugsStartCheckScanIds = this.activeDictionary.postData.drugsStartCheckScanIds.map(v => ({...v, checked: (this.configs.drugsStartCheckScanIds || '').split(',').includes(v.value.toString())}));
  309. this.activeDictionary.postData.drugsStartManual = this.configs.drugsStartManual ? this.configs.drugsStartManual.id : undefined;
  310. this.activeDictionary.postData.drugsStartPhoto[0].checked = this.configs.drugsStartPhoto == 1;
  311. this.activeDictionary.postData.drugsEndCheck[0].checked = this.configs.drugsEndCheck == 1;
  312. this.activeDictionary.postData.drugsEndCheckScanIds = this.activeDictionary.postData.drugsEndCheckScanIds.map(v => ({...v, checked: (this.configs.drugsEndCheckScanIds || '').split(',').includes(v.value.toString())}));
  313. this.activeDictionary.postData.drugsEndManual = this.configs.drugsEndManual ? this.configs.drugsEndManual.id : undefined;
  314. this.activeDictionary.postData.drugsEndPhoto[0].checked = this.configs.drugsEndPhoto == 1;
  315. this.activeDictionary.postData.showPatientInfo[0].checked = this.configs.showPatientInfo == 1;
  316. this.activeDictionary.postData.showDrugsBagTypeCount[0].checked = this.configs.showDrugsBagTypeCount == 1;
  317. this.activeDictionary.postData.showDrugsBagDetails[0].checked = this.configs.showDrugsBagDetails == 1;
  318. this.activeDictionary.postData.autoCreate[0].checked = this.configs.autoCreate == 1;
  319. this.activeDictionary.postData.autoCreateState = this.configs.autoCreateState && this.configs.autoCreateState.id || undefined;
  320. }
  321. });
  322. }
  323. }