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

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