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

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