configuration-drug.component.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. endClearingList:any[] = [
  40. { label: '扫一扫清点', value: 1 },
  41. { label: '数量核对清点', value: 2 },
  42. ];
  43. // 手动填写
  44. drugsManualList:any[] = [];
  45. // 数据字典key列表
  46. dictionaryKeyList: any[] = [
  47. {
  48. name: '静配',
  49. value: 'drugsJpbag',
  50. postData: {
  51. drugsModel: undefined,//工单模式
  52. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  53. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  54. drugsVerifyPharmacy: [{ label:'是否开启', value: 0 }],//收药是否验证发药科室
  55. drugsEndCountMethod: undefined,//终点清点方式
  56. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  57. drugsStartCheckScanIds: [],//起点核对方式
  58. drugsStartManual: undefined,//起点科室手动填写
  59. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  60. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  61. drugsEndCheckScanIds: [],//终点核对方式
  62. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  63. drugsEndManual: undefined,//终点科室手动填写
  64. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  65. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  66. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  67. sendingMergeOrder: [{ label:'是否开启', value: 0 }],//待送达合并工单
  68. drugsResidueCreateOrder: [{ label:'是否开启', value: 0 }],//交接后,剩余药包是否建单
  69. urgentCreateOrder: [{ label:'是否开启', value: 0 }],//是否开启紧急配送建单
  70. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  71. autoCreateState: undefined // 药品自动建单状态
  72. }
  73. },
  74. {
  75. name: '西药',
  76. value: 'drugsWestern',
  77. postData: {
  78. drugsModel: undefined,//工单模式
  79. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  80. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  81. drugsVerifyPharmacy: [{ label:'是否开启', value: 0 }],//收药是否验证发药科室
  82. drugsEndCountMethod: undefined,//终点清点方式
  83. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  84. drugsStartCheckScanIds: [],//起点核对方式
  85. drugsStartManual: undefined,//起点科室手动填写
  86. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  87. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  88. drugsEndCheckScanIds: [],//终点核对方式
  89. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  90. drugsEndManual: undefined,//终点科室手动填写
  91. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  92. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  93. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  94. sendingMergeOrder: [{ label:'是否开启', value: 0 }],//待送达合并工单
  95. drugsResidueCreateOrder: [{ label:'是否开启', value: 0 }],//交接后,剩余药包是否建单
  96. urgentCreateOrder: [{ label:'是否开启', value: 0 }],//是否开启紧急配送建单
  97. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  98. autoCreateState: undefined // 药品自动建单状态
  99. }
  100. },
  101. {
  102. name: '退药',
  103. value: 'drugsReturn',
  104. postData: {
  105. drugsModel: undefined,//工单模式
  106. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  107. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  108. drugsVerifyPharmacy: [{ label:'是否开启', value: 0 }],//收药是否验证发药科室
  109. drugsEndCountMethod: undefined,//终点清点方式
  110. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  111. drugsStartCheckScanIds: [],//起点核对方式
  112. drugsStartManual: undefined,//起点科室手动填写
  113. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  114. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  115. drugsEndCheckScanIds: [],//终点核对方式
  116. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  117. drugsEndManual: undefined,//终点科室手动填写
  118. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  119. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  120. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  121. sendingMergeOrder: [{ label:'是否开启', value: 0 }],//待送达合并工单
  122. drugsResidueCreateOrder: [{ label:'是否开启', value: 0 }],//交接后,剩余药包是否建单
  123. urgentCreateOrder: [{ label:'是否开启', value: 0 }],//是否开启紧急配送建单
  124. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  125. autoCreateState: undefined // 药品自动建单状态
  126. }
  127. },
  128. {
  129. name: '毒麻',
  130. value: 'drugsPoison',
  131. postData: {
  132. drugsModel: undefined,//工单模式
  133. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  134. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  135. drugsVerifyPharmacy: [{ label:'是否开启', value: 0 }],//收药是否验证发药科室
  136. drugsEndCountMethod: undefined,//终点清点方式
  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. sendingMergeOrder: [{ label:'是否开启', value: 0 }],//待送达合并工单
  149. drugsResidueCreateOrder: [{ label:'是否开启', value: 0 }],//交接后,剩余药包是否建单
  150. urgentCreateOrder: [{ label:'是否开启', value: 0 }],//是否开启紧急配送建单
  151. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  152. autoCreateState: undefined // 药品自动建单状态
  153. }
  154. },
  155. {
  156. name: '中草药',
  157. value: 'drugsHerbal',
  158. postData: {
  159. drugsModel: undefined,//工单模式
  160. drugsCreateSign: [{ label:'是否开启', value: 0 }],//支持建单并签到
  161. drugsReceiveSign: [{ label:'是否开启', value: 0 }],//支持接单并签到
  162. drugsVerifyPharmacy: [{ label:'是否开启', value: 0 }],//收药是否验证发药科室
  163. drugsEndCountMethod: undefined,//终点清点方式
  164. drugsStartCheck: [{ label:'是否开启', value: 0 }],//起点科室支持核对
  165. drugsStartCheckScanIds: [],//起点核对方式
  166. drugsStartManual: undefined,//起点科室手动填写
  167. drugsStartPhoto: [{ label:'是否开启', value: 0 }],//起点科室支持拍照留存
  168. drugsEndCheck: [{ label:'是否开启', value: 0 }],//终点科室支持核对
  169. drugsEndCheckScanIds: [],//终点核对方式
  170. showPatientInfo: [{ label:'是否开启', value: 0 }],//药单显示患者
  171. drugsEndManual: undefined,//终点科室手动填写
  172. drugsEndPhoto: [{ label:'是否开启', value: 0 }],//终点科室支持拍照留存
  173. showDrugsBagTypeCount: [{ label:'是否开启', value: 0 }],//是否显示药品数、种类数
  174. showDrugsBagDetails: [{ label:'是否开启', value: 0 }],//是否支持查看药品详情信息
  175. sendingMergeOrder: [{ label:'是否开启', value: 0 }],//待送达合并工单
  176. drugsResidueCreateOrder: [{ label:'是否开启', value: 0 }],//交接后,剩余药包是否建单
  177. urgentCreateOrder: [{ label:'是否开启', value: 0 }],//是否开启紧急配送建单
  178. autoCreate: [{ label:'是否开启', value: 0 }], // 是否自动建单
  179. autoCreateState: undefined // 药品自动建单状态
  180. }
  181. },
  182. ];
  183. // 获取药品状态
  184. drugStateData:any = []
  185. getDrugState(){
  186. this.mainService.getDictionary("list", "drug_state").subscribe((data) => {
  187. this.drugStateData = data
  188. });
  189. }
  190. // 点击数据字典key
  191. activeDictionary:any;
  192. clickDictionaryKey(item){
  193. this.activeDictionary = item;
  194. this.init();
  195. }
  196. // 修改起点科室支持核对
  197. changeDrugsStartCheck(e){
  198. console.log(e);
  199. if(!e[0].checked){
  200. this.activeDictionary.postData.drugsStartCheckScanIds = this.activeDictionary.postData.drugsStartCheckScanIds.map(v => ({...v, checked: false}));
  201. this.activeDictionary.postData.drugsStartManual = undefined;
  202. this.activeDictionary.postData.drugsStartPhoto[0].checked = false;
  203. }
  204. }
  205. // 修改终点科室支持核对
  206. changeDrugsEndCheck(e){
  207. console.log(e);
  208. if(!e[0].checked){
  209. this.activeDictionary.postData.drugsEndCheckScanIds = this.activeDictionary.postData.drugsEndCheckScanIds.map(v => ({...v, checked: false}));;
  210. this.activeDictionary.postData.drugsEndManual = undefined;
  211. this.activeDictionary.postData.drugsEndPhoto[0].checked = false;
  212. }
  213. }
  214. // 切换tab
  215. tabModal(tabModalName:string){
  216. this.tabModalName = tabModalName;
  217. }
  218. // 保存
  219. submitForm() {
  220. if(!this.tasktype.id){
  221. this.msg.create("warning", "请先配置任务类型!");
  222. return;
  223. }
  224. if(!this.activeDictionary.postData.drugsModel){
  225. this.msg.create("warning", "请选择工单模式!");
  226. return;
  227. }
  228. if(this.activeDictionary.postData.drugsStartCheck[0].checked && !this.activeDictionary.postData.drugsStartCheckScanIds.filter(v => v.checked).length){
  229. this.msg.create("warning", "请选择起点科室的核对方式!");
  230. return;
  231. }
  232. if(!this.activeDictionary.postData.drugsEndCheck[0].checked){
  233. this.msg.create("warning", "终点科室支持核对必填!");
  234. return;
  235. }
  236. if(this.activeDictionary.postData.drugsEndCheck[0].checked && !this.activeDictionary.postData.drugsEndCheckScanIds.filter(v => v.checked).length){
  237. this.msg.create("warning", "请选择终点科室的核对方式!");
  238. return;
  239. }
  240. if(this.activeDictionary.postData.drugsModel==2 && !this.activeDictionary.postData.drugsEndCountMethod){
  241. this.msg.create("warning", "请选择终点清点方式!");
  242. return;
  243. }
  244. let postData:any = {
  245. id: this.configs.id,
  246. taskType: this.tasktype.id,
  247. hosId: this.hosId,
  248. drugsModel: this.activeDictionary.postData.drugsModel || undefined,
  249. drugsEndCountMethod: this.activeDictionary.postData.drugsEndCountMethod || undefined,
  250. drugsCreateSign: this.activeDictionary.postData.drugsCreateSign[0].checked ? 1 : 0,
  251. drugsReceiveSign: this.activeDictionary.postData.drugsReceiveSign[0].checked ? 1 : 0,
  252. drugsVerifyPharmacy: this.activeDictionary.postData.drugsVerifyPharmacy[0].checked ? 1 : 0,
  253. drugsStartCheck: this.activeDictionary.postData.drugsStartCheck[0].checked ? 1 : 0,
  254. drugsStartCheckScanIds: this.activeDictionary.postData.drugsStartCheckScanIds.filter(v => v.checked).map(v => v.value).toString() || undefined,
  255. drugsStartManual: this.activeDictionary.postData.drugsStartManual ? { id: this.activeDictionary.postData.drugsStartManual } : undefined,
  256. drugsStartPhoto: this.activeDictionary.postData.drugsStartPhoto[0].checked ? 1 : 0,
  257. drugsEndCheck: this.activeDictionary.postData.drugsEndCheck[0].checked ? 1 : 0,
  258. drugsEndCheckScanIds: this.activeDictionary.postData.drugsEndCheckScanIds.filter(v => v.checked).map(v => v.value).toString() || undefined,
  259. drugsEndManual: this.activeDictionary.postData.drugsEndManual ? { id: this.activeDictionary.postData.drugsEndManual } : undefined,
  260. drugsEndPhoto: this.activeDictionary.postData.drugsEndPhoto[0].checked ? 1 : 0,
  261. showPatientInfo: this.activeDictionary.postData.showPatientInfo[0].checked ? 1 : 0,
  262. showDrugsBagTypeCount: this.activeDictionary.postData.showDrugsBagTypeCount[0].checked ? 1 : 0,
  263. showDrugsBagDetails: this.activeDictionary.postData.showDrugsBagDetails[0].checked ? 1 : 0,
  264. sendingMergeOrder: this.activeDictionary.postData.sendingMergeOrder[0].checked ? 1 : 0,
  265. drugsResidueCreateOrder: this.activeDictionary.postData.drugsResidueCreateOrder[0].checked ? 1 : 0,
  266. urgentCreateOrder: this.activeDictionary.postData.urgentCreateOrder[0].checked ? 1 : 0,
  267. autoCreate: this.activeDictionary.postData.autoCreate[0].checked ? 1 : 0,
  268. autoCreateState:{
  269. id:this.activeDictionary.postData.autoCreateState || undefined
  270. }
  271. };
  272. this.btnLoading = true;
  273. this.mainService
  274. .simplePost("addData", "taskTypeConfig", postData)
  275. .subscribe((result) => {
  276. this.btnLoading = false;
  277. if (result.status == 200) {
  278. this.getConfig();
  279. }
  280. });
  281. }
  282. //初始化
  283. init() {
  284. this.loading = true;
  285. let drugs_bag_check_scan_type$ = this.mainService.getDictionary('list', 'drugs_bag_check_scan_type', true);
  286. let drugs_bag_manual_type$ = this.mainService.getDictionary('list', 'drugs_bag_manual_type', true);
  287. forkJoin(drugs_bag_check_scan_type$, drugs_bag_manual_type$).subscribe((data:any[]) => {
  288. let drugs_bag_check_scan_type = data[0] || [];
  289. let drugs_bag_manual_type = data[1] || [];
  290. this.activeDictionary.postData.drugsStartCheckScanIds = drugs_bag_check_scan_type.map(v => ({ label:v.name, value: v.id }));
  291. this.activeDictionary.postData.drugsEndCheckScanIds = drugs_bag_check_scan_type.map(v => ({ label:v.name, value: v.id }));
  292. this.drugsManualList = drugs_bag_manual_type.map(v => ({ label:v.name, value: v.id }));
  293. this.getTaskType();
  294. })
  295. }
  296. //获取任务类型
  297. getTaskType() {
  298. this.loading = true;
  299. let postData = {
  300. idx: 0,
  301. sum: 1,
  302. taskType: {
  303. simpleQuery: true,
  304. hosId: {
  305. id: this.hosId
  306. },
  307. ordinaryField: {
  308. key: 'ordinary_field',
  309. value: this.activeDictionary.value,
  310. }
  311. }
  312. };
  313. this.mainService
  314. .getFetchDataList("simple/data", "taskType", postData)
  315. .subscribe((result) => {
  316. this.loading = false;
  317. if (result.status == 200) {
  318. this.tasktype = result.list[0] || {};
  319. this.getConfig();
  320. }
  321. });
  322. }
  323. // 获取配置
  324. getConfig() {
  325. this.loading = true;
  326. let postData = {
  327. idx: 0,
  328. sum: 1,
  329. taskTypeConfig: {
  330. taskTypeDTO: {
  331. hosId: {
  332. id: this.hosId
  333. },
  334. ordinaryField: {
  335. key: 'ordinary_field',
  336. value: this.activeDictionary.value,
  337. }
  338. }
  339. }
  340. };
  341. this.mainService
  342. .getFetchDataList("simple/data", "taskTypeConfig", postData)
  343. .subscribe((result) => {
  344. this.loading = false;
  345. if (result.status == 200) {
  346. this.configs = result.list[0] || {};
  347. this.activeDictionary.postData.drugsModel = this.configs.drugsModel || undefined;
  348. this.activeDictionary.postData.drugsEndCountMethod = this.configs.drugsEndCountMethod || undefined;
  349. this.activeDictionary.postData.drugsCreateSign[0].checked = this.configs.drugsCreateSign == 1;
  350. this.activeDictionary.postData.drugsReceiveSign[0].checked = this.configs.drugsReceiveSign == 1;
  351. this.activeDictionary.postData.drugsVerifyPharmacy[0].checked = this.configs.drugsVerifyPharmacy == 1;
  352. this.activeDictionary.postData.drugsStartCheck[0].checked = this.configs.drugsStartCheck == 1;
  353. this.activeDictionary.postData.drugsStartCheckScanIds = this.activeDictionary.postData.drugsStartCheckScanIds.map(v => ({...v, checked: (this.configs.drugsStartCheckScanIds || '').split(',').includes(v.value.toString())}));
  354. this.activeDictionary.postData.drugsStartManual = this.configs.drugsStartManual ? this.configs.drugsStartManual.id : undefined;
  355. this.activeDictionary.postData.drugsStartPhoto[0].checked = this.configs.drugsStartPhoto == 1;
  356. this.activeDictionary.postData.drugsEndCheck[0].checked = this.configs.drugsEndCheck == 1;
  357. this.activeDictionary.postData.drugsEndCheckScanIds = this.activeDictionary.postData.drugsEndCheckScanIds.map(v => ({...v, checked: (this.configs.drugsEndCheckScanIds || '').split(',').includes(v.value.toString())}));
  358. this.activeDictionary.postData.drugsEndManual = this.configs.drugsEndManual ? this.configs.drugsEndManual.id : undefined;
  359. this.activeDictionary.postData.drugsEndPhoto[0].checked = this.configs.drugsEndPhoto == 1;
  360. this.activeDictionary.postData.showPatientInfo[0].checked = this.configs.showPatientInfo == 1;
  361. this.activeDictionary.postData.showDrugsBagTypeCount[0].checked = this.configs.showDrugsBagTypeCount == 1;
  362. this.activeDictionary.postData.showDrugsBagDetails[0].checked = this.configs.showDrugsBagDetails == 1;
  363. this.activeDictionary.postData.sendingMergeOrder[0].checked = this.configs.sendingMergeOrder == 1;
  364. this.activeDictionary.postData.drugsResidueCreateOrder[0].checked = this.configs.drugsResidueCreateOrder == 1;
  365. this.activeDictionary.postData.urgentCreateOrder[0].checked = this.configs.urgentCreateOrder == 1;
  366. this.activeDictionary.postData.autoCreate[0].checked = this.configs.autoCreate == 1;
  367. this.activeDictionary.postData.autoCreateState = this.configs.autoCreateState && this.configs.autoCreateState.id || undefined;
  368. }
  369. });
  370. }
  371. }