华西海圻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.

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