华西海圻ELN前端工程
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

529 lines
15 KiB

3 months ago
  1. <template>
  2. <div class="template-table">
  3. <component ref="templateComponent" :sn="sn" :is="getTemplateComponent()" :templateData="templateData"
  4. :fillType="fillType">
  5. </component>
  6. <SubPackageDialog ref="subPackageDialogRef"></SubPackageDialog>
  7. <TagPrintDialog ref="tagPrintDialogRef"></TagPrintDialog>
  8. <SelectReagentDialog ref="selectReagentDialogRef" />
  9. <SelectInstrumentDialog ref="selectInstrumentDialogRef" />
  10. <SelectMixReagentDialog ref="selectMixReagentDialogRef"/>
  11. <EditSign ref="editSignRef" @cancel="handleEditSignCancel" @callback="handleEditSignCallback" />
  12. </div>
  13. </template>
  14. <script>
  15. import { EventBus } from "@/utils/eventBus";
  16. import { debounce } from 'lodash-es'
  17. import SubPackageDialog from "./dialog/SubPackageDialog.vue";//分装弹窗
  18. import TagPrintDialog from "./dialog/PrintTagDialog.vue";//标签打印弹窗
  19. import SelectReagentDialog from "./dialog/SelectReagentDialog.vue";//选择试剂弹窗
  20. import SelectInstrumentDialog from "./dialog/SelectInstrumentDialog.vue";//选择仪器弹窗
  21. import SelectMixReagentDialog from "./dialog/SelectMixReagentDialog.vue";//选择试剂/供试品/给药制剂弹窗
  22. import EditSign from "./dialog/EditSign.vue";//电子签名弹窗
  23. //色谱
  24. import SP001 from "./comps/sp/SP001.vue";
  25. import SP003 from "./comps/sp/SP003.vue";
  26. import SP00456 from "./comps/sp/SP00456.vue";
  27. import SP007 from "./comps/sp/SP007.vue";
  28. //色谱生物样品分析方法学样品制备表-10个类似
  29. import SP008 from "./comps/sp/SP008.vue";
  30. import SP009 from "./comps/sp/SP009.vue";
  31. import SP0019 from "./comps/sp/SP0019.vue";
  32. import SP0020 from "./comps/sp/SP0020.vue";
  33. import SP0021 from "./comps/sp/SP0021.vue";
  34. import Demo from "./comps/sp/Demo.vue";
  35. //供试品
  36. import GSP001 from "./comps/gsp/GSP001.vue";
  37. import GSP002 from "./comps/gsp/GSP002.vue";
  38. import GSP003 from "./comps/gsp/GSP003.vue";
  39. import GSP004 from "./comps/gsp/GSP004.vue";
  40. import GSP005 from "./comps/gsp/GSP005.vue";
  41. import GSP009 from "./comps/gsp/GSP009.vue";
  42. import GSP010 from "./comps/gsp/GSP010.vue";
  43. //试验物质配制计划表/麻精药领取申请单/毒麻药品配制记录表
  44. import SYWZPZJHB from "./comps/gsp/SYWZPZJHB.vue";
  45. import MJYLQSQD from "./comps/gsp/MJYLQSQD.vue";
  46. import DMYPPZJLB from "./comps/gsp/DMYPPZJLB.vue";
  47. // PCR
  48. //PCR001-使用SP001
  49. import PCR002 from "./comps/pcr/PCR002.vue";
  50. import PCR003 from "./comps/pcr/PCR003.vue";
  51. import PCR004 from "./comps/pcr/PCR004.vue";
  52. import PCR005 from "./comps/pcr/PCR005.vue";
  53. import PCR007 from "./comps/pcr/PCR007.vue";
  54. import PCR008 from "./comps/pcr/PCR008.vue";
  55. import PCR009 from "./comps/pcr/PCR009.vue";
  56. import PCR010 from "./comps/pcr/PCR010.vue";
  57. import PCR011 from "./comps/pcr/PCR011.vue";
  58. import PCR012 from "./comps/pcr/PCR012.vue";
  59. //LBA
  60. // LBA001-使用SP001
  61. import LBA002 from "./comps/lba/LBA002.vue";
  62. import LBA003 from "./comps/lba/LBA003.vue";
  63. import LBA004 from "./comps/lba/LBA004.vue";
  64. import LBA005 from "./comps/lba/LBA005.vue";
  65. import LBA006 from "./comps/lba/LBA006.vue";
  66. import LBA007 from "./comps/lba/LBA007.vue";
  67. import LBA008 from "./comps/lba/LBA008.vue";
  68. //ADA
  69. // ADA001-使用SP001
  70. // ADA002-使用LBA002
  71. // ADA003-使用LBA003
  72. // ADA004-使用LBA004
  73. // ADA005-使用LBA005
  74. // ADA006-使用LBA006
  75. // ADA007-使用LBA007
  76. //样品
  77. // YP001-使用SP001
  78. import YP002 from "./comps/yp/YP002.vue";
  79. import YP003 from "./comps/yp/YP003.vue";
  80. import YP004 from "./comps/yp/YP004.vue";
  81. import YP005 from "./comps/yp/YP005.vue";
  82. //细胞
  83. import XB001 from "./comps/xb/XB001.vue";
  84. //动技
  85. import DJ001 from "./comps/dj/DJ001.vue";
  86. import DJ002 from "./comps/dj/DJ002.vue";
  87. import DJ003 from "./comps/dj/DJ003.vue";
  88. //病理
  89. import BL001 from "./comps/bl/BL001.vue";
  90. import BL002 from "./comps/bl/BL002.vue";
  91. //毒理
  92. // DL001-SYWZPZJHB
  93. // DL002-使用SP001
  94. import DL003 from './comps/dl/DL003.vue'
  95. import DL004 from './comps/dl/DL004.vue'
  96. import DL005 from './comps/dl/DL005.vue'
  97. import DL006 from './comps/dl/DL006.vue'
  98. import DL007 from './comps/dl/DL007.vue'
  99. import DL008 from './comps/dl/DL008.vue'
  100. import DL009 from './comps/dl/DL009.vue'
  101. import DL010 from './comps/dl/DL010.vue'
  102. import DL011 from './comps/dl/DL011.vue'
  103. import DL012 from './comps/dl/DL012.vue'
  104. import DL013 from './comps/dl/DL013.vue'
  105. import DL014 from './comps/dl/DL014.vue'
  106. import DL015 from './comps/dl/DL015.vue'
  107. import DL016 from "./comps/dl/DL016.vue";
  108. import DL017 from "./comps/dl/DL017.vue";
  109. import DL018 from "./comps/dl/DL018.vue";
  110. import DL019 from "./comps/dl/DL019.vue";
  111. import DL020 from "./comps/dl/DL020.vue";
  112. import DL021 from "./comps/dl/DL021.vue";
  113. import DL022 from "./comps/dl/DL022.vue";
  114. import DL023 from "./comps/dl/DL023.vue";
  115. import DL024 from "./comps/dl/DL024.vue";
  116. export default {
  117. name: "TemplateTable",
  118. components: {
  119. Demo,
  120. SubPackageDialog, TagPrintDialog, SelectReagentDialog, SelectInstrumentDialog, SelectMixReagentDialog, EditSign,
  121. //试验物质配制计划表/麻精药领取申请单/毒麻药品配制记录表
  122. MJYLQSQD, SYWZPZJHB, DMYPPZJLB,
  123. //供试品
  124. GSP001,GSP002, GSP003,GSP004,GSP005,GSP009, GSP010,
  125. //色谱
  126. SP001, SP003, SP00456,SP007, SP008, SP009,SP0019,SP0020,SP0021,
  127. // PCR
  128. PCR002, PCR003, PCR004, PCR005,PCR007, PCR008, PCR009,PCR010, PCR011, PCR012,
  129. //LBA
  130. LBA002,
  131. LBA003,
  132. LBA004,
  133. LBA005,
  134. LBA006,
  135. LBA007,
  136. LBA008,
  137. //样品
  138. YP002,
  139. YP003,
  140. YP004,
  141. YP005,
  142. // 毒理
  143. DL003,
  144. DL004,
  145. DL005,
  146. DL006,
  147. DL007,
  148. DL008,
  149. DL009,
  150. DL010,
  151. DL011,
  152. DL012,
  153. DL013,
  154. DL014,
  155. DL015,
  156. DL016,
  157. DL017,
  158. DL018,
  159. DL019,
  160. DL020,
  161. DL021,
  162. DL022,
  163. DL023,
  164. DL024,
  165. //细胞
  166. XB001,
  167. //动技
  168. DJ001,
  169. DJ002,
  170. DJ003,
  171. //病理
  172. BL001,
  173. BL002
  174. },
  175. data() {
  176. return {
  177. componentMap: null,
  178. }
  179. },
  180. methods: {
  181. getTemplateComponent() {
  182. if (!this.sn) return 'Demo';
  183. let componentName = this.componentMap[this.sn] || 'Demo';
  184. return componentName;
  185. },
  186. handleEditSignCancel(e) {
  187. EventBus.$emit('edit-sign-cancel', e);
  188. },
  189. },
  190. props: {
  191. sn: {
  192. type: String,
  193. default: '',
  194. },
  195. fillType: {
  196. type: String,
  197. default: 'preFill',
  198. },
  199. templateData: {
  200. type: Object,
  201. default: () => { },
  202. },
  203. emitName: {
  204. type: String,
  205. default: 'onModifyRecord',
  206. },
  207. },
  208. computed: {
  209. templateComponentMap() {
  210. if (!this.componentMap) {
  211. this.componentMap = {
  212. //色谱
  213. 'SP001': 'SP001',
  214. 'SP002': 'SP001',
  215. 'SP003': 'SP003',
  216. 'SP004': 'SP00456',
  217. 'SP005': 'SP00456',
  218. 'SP006': 'SP00456',
  219. 'SP007': 'SP007',
  220. 'SP008': 'SP008',
  221. 'SP009': 'SP009',
  222. 'SP010': 'SP008',
  223. 'SP011': 'SP008',
  224. 'SP012': 'SP008',
  225. 'SP013': 'SP008',
  226. 'SP014': 'SP008',
  227. 'SP015': 'SP008',
  228. 'SP016': 'SP008',
  229. 'SP017': 'SP008',
  230. 'SP018': 'SP008',
  231. 'SP019': 'SP0019',
  232. 'SP020': 'SP0020',
  233. 'SP021': 'SP0021',
  234. //供试品
  235. 'GSP001': 'GSP001',
  236. 'GSP002': 'GSP002',
  237. 'GSP003': 'GSP003',
  238. 'GSP004': 'GSP004',
  239. 'GSP005': 'GSP005',
  240. 'GSP006': 'GSP002',
  241. 'GSP008': 'GSP002',
  242. 'GSP009': 'GSP009',
  243. 'GSP010': 'GSP010',
  244. 'GSP011': 'GSP009',
  245. 'GSP012': 'GSP002',
  246. 'GSP013': 'GSP002',
  247. 'GSP014': 'GSP002',
  248. //试验物质配制计划表/麻精药领取申请单/毒麻药品配制记录表
  249. 'SYWZPZJHB': 'SYWZPZJHB',
  250. 'MJYLQSQD': 'MJYLQSQD',
  251. 'DMYPPZJLB': 'DMYPPZJLB',
  252. //PCR
  253. 'PCR001': 'SP001',
  254. 'PCR002': 'PCR002',
  255. 'PCR003': 'PCR003',
  256. 'PCR004': 'PCR004',
  257. 'PCR005': 'PCR005',
  258. 'PCR006': 'SP0020',
  259. 'PCR007': 'PCR007',
  260. 'PCR008': 'PCR008',
  261. 'PCR009': 'PCR009',
  262. 'PCR010': 'PCR010',
  263. 'PCR011': 'PCR011',
  264. 'PCR012': 'PCR012',
  265. 'PCR013': 'SP00456',
  266. //LBA
  267. 'LBA001': 'SP001',
  268. 'LBA002': 'LBA002',
  269. 'LBA003': 'LBA003',
  270. 'LBA004': 'LBA004',
  271. 'LBA005': 'SP00456',
  272. 'LBA006': 'LBA006',
  273. 'LBA007': 'SP00456',
  274. 'LBA008': 'LBA008',
  275. //ADA
  276. 'ADA001': 'SP001',
  277. 'ADA002': 'LBA002',
  278. 'ADA003': 'LBA003',
  279. 'ADA004': 'LBA004',
  280. 'ADA005': 'SP00456',
  281. 'ADA006': 'LBA006',
  282. 'ADA007': 'SP00456',
  283. //样品
  284. 'YP001': 'SP001',
  285. 'YP002': 'YP002',
  286. 'YP003': 'YP003',
  287. 'YP004': 'YP004',
  288. 'YP005': 'YP005',
  289. //细胞
  290. 'XB001': 'XB001',
  291. //动技
  292. 'DJ001': 'DJ001',
  293. 'DJ002': 'DJ002',
  294. 'DJ003': 'DJ003',
  295. //病理
  296. 'BL001': 'BL001',
  297. 'BL002': 'BL002',
  298. //毒理
  299. //DL001-SYWZPZJHB
  300. 'DL002': 'SP001',
  301. 'DL003': 'DL003',
  302. 'DL004': 'DL004',
  303. 'DL005': 'DL005',
  304. 'DL006': 'DL006',
  305. 'DL007': 'DL007',
  306. 'DL008': 'DL008',
  307. 'DL009': 'DL009',
  308. 'DL010': 'DL010',
  309. 'DL011': 'DL011',
  310. 'DL012': 'DL012',
  311. 'DL013': 'DL013',
  312. 'DL014': 'DL014',
  313. 'DL015': 'DL015',
  314. 'DL016': 'DL016',
  315. 'DL017': 'DL017',
  316. 'DL018': 'DL018',
  317. 'DL019': 'DL019',
  318. 'DL020': 'DL020',
  319. 'DL021': 'DL021',
  320. 'DL022': 'DL022',
  321. 'DL023': 'DL023',
  322. 'DL024': 'DL024',
  323. }
  324. }
  325. return this.componentMap || "Demo"
  326. }
  327. },
  328. watch: {
  329. sn: {
  330. immediate: true,
  331. handler(v) {
  332. console.log(v, "sn")
  333. }
  334. },
  335. templateData: {
  336. immediate: true,
  337. deep: true,
  338. handler(v) {
  339. if (v) {
  340. if (v.zdxgjl) {
  341. this.zdxgjl = JSON.parse(v.zdxgjl) || [];
  342. }
  343. if (v.fhyjjl) {
  344. this.fhyjjl = JSON.parse(v.fhyjjl) || [];
  345. }
  346. if (v.zdgxjl) {
  347. this.fieldCheckObj = JSON.parse(v.zdgxjl) || {};
  348. }
  349. }
  350. }
  351. }
  352. },
  353. provide() {
  354. return {
  355. //分发给子组件的fillType
  356. templateData: this.templateData,
  357. templateFillType: this.fillType,
  358. getZdxgjl: () => this.zdxgjl,
  359. getFhyjjl: () => this.fhyjjl,
  360. getFieldCheckObj: () => this.fieldCheckObj,
  361. //更新提交记录
  362. updateZdxgjl: (data) => {
  363. this.zdxgjl.unshift(data);
  364. },
  365. //更新复核意见记录
  366. updateFhyjjl: (data) => {
  367. this.fhyjjl.unshift(data);
  368. },
  369. //替换复核意见记录
  370. replaceFhyjjl: (data) => {
  371. this.fhyjjl = data;
  372. },
  373. //更新字段检查对象
  374. updateFieldCheckObj: (data) => {
  375. this.fieldCheckObj = { ...this.fieldCheckObj, ...data };
  376. },
  377. }
  378. },
  379. data() {
  380. return {
  381. info: {},
  382. zdxgjl: [],
  383. fhyjjl: [],
  384. fieldCheckObj: {},
  385. currentEditSignUuid: null, // 当前请求EditSign的HandleFormItem的uuid
  386. latestParams: {},//用于存储最新的params
  387. hasCustomTable: false,//是否有自定义表格
  388. };
  389. },
  390. created() {
  391. this.debouncedEmit = debounce(this.emitToParent, 100)
  392. },
  393. mounted() {
  394. EventBus.$on('onModifyRecord', this.handleModyfyRecord);
  395. //分装弹窗
  396. EventBus.$on("showSubPackageDialog", (data) => {
  397. this.$refs.subPackageDialogRef.show(data)
  398. })
  399. //标签打印弹窗
  400. EventBus.$on("showTagPrintDialog", (data) => {
  401. this.$refs.tagPrintDialogRef.show(data)
  402. })
  403. //选择仪器弹窗
  404. EventBus.$on("showSelectInstrumentDialog", (data) => {
  405. this.$refs.selectInstrumentDialogRef.show(data.studyFormId, data)
  406. })
  407. //选择试剂弹窗
  408. EventBus.$on("showSelectReagentDialog", (data) => {
  409. this.$refs.selectReagentDialogRef.show(data.studyFormId, data)
  410. })
  411. //选择试剂/供试品/给药制剂弹窗
  412. EventBus.$on("showSelectMixReagentDialog", (data) => {
  413. this.$refs.selectMixReagentDialogRef.show(data.studyFormId, data,this.templateData.studyId)
  414. })
  415. EventBus.$on("hideSelectMixReagentDialog", (data) => {
  416. this.$refs.selectMixReagentDialogRef.hide()
  417. })
  418. //显示电子签名弹窗
  419. EventBus.$on("showEditSignDialog", (data) => {
  420. this.currentEditSignUuid = data.uuid;
  421. this.$refs.editSignRef.show();
  422. })
  423. },
  424. beforeDestroy() {
  425. // 记得移除监听,避免内存泄漏
  426. EventBus.$off('onModifyRecord');
  427. EventBus.$off("showSubPackageDialog");
  428. EventBus.$off("showTagPrintDialog");
  429. EventBus.$off("showSelectReagentDialog");
  430. EventBus.$off("showSelectInstrumentDialog");
  431. EventBus.$off("showSelectMixReagentDialog");
  432. EventBus.$off("showEditSignDialog");
  433. EventBus.$off("hideSelectMixReagentDialog");
  434. this.debouncedEmit.cancel()
  435. },
  436. methods: {
  437. handleModyfyRecord(data) {
  438. const { source } = data;
  439. if (source === "customTable") {
  440. this.latestParams = data;
  441. // delete this.latestParams.source
  442. this.hasCustomTable = true
  443. // 取消之前的等待
  444. this.debouncedEmit.cancel()
  445. this.emitToParent()
  446. }else if(!source && !this.hasCustomTable){
  447. this.latestParams = data
  448. this.debouncedEmit()
  449. }
  450. },
  451. emitToParent() {
  452. if (this.latestParams) {
  453. console.log(this.latestParams,"this.latestParams")
  454. this.$emit(this.emitName, this.latestParams)
  455. }
  456. },
  457. // 处理电子签名取消事件
  458. handleEditSignCancel() {
  459. if (this.currentEditSignUuid) {
  460. EventBus.$emit('onEditSignCancel', { uuid: this.currentEditSignUuid });
  461. EventBus.$emit('onFormEditSignCancel', { uuid: this.currentEditSignUuid });
  462. this.currentEditSignUuid = null;
  463. }
  464. },
  465. // 处理电子签名确认回调事件
  466. handleEditSignCallback(data) {
  467. if (this.currentEditSignUuid) {
  468. EventBus.$emit('onEditSignCallback', { uuid: this.currentEditSignUuid, data });
  469. this.currentEditSignUuid = null;
  470. }
  471. },
  472. async getFormData() {
  473. if (this.fillType === "actFill") {
  474. //检查是否有未填写的复核意见
  475. const flag = this.fhyjjl.every((item) => !!item.content && !!item.reply)
  476. console.log(this.fhyjjl, flag, "flag")
  477. if (!flag) {
  478. this.$message.error("疑问项还未回复,请回复后再提交");
  479. return;
  480. }
  481. }
  482. return await this.$refs.templateComponent.getFormData();
  483. },
  484. getResource() {
  485. return this.$refs.templateComponent.getResource();
  486. },
  487. getYqResource() {
  488. return this.$refs.templateComponent.getYqResource();
  489. },
  490. getJcbList() {
  491. return this.$refs.templateComponent.getJcbList();
  492. },
  493. getXbxj() {
  494. return this.$refs.templateComponent.getXbxj();
  495. },
  496. getFilledFormData() {
  497. return this.$refs.templateComponent.getFilledFormData();
  498. },
  499. getTemplateComponent() {
  500. return this.templateComponentMap[this.sn]
  501. },
  502. }
  503. };
  504. </script>
  505. <style rel="stylesheet/scss" lang="scss">
  506. .template-table {
  507. background: #fff;
  508. padding: 10px 10px;
  509. width: 100%;
  510. }
  511. </style>