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

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