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

167 lines
4.2 KiB

3 months ago
3 months ago
  1. <template>
  2. <div class="template-table">
  3. <!-- <SP001 v-if="sn == 'SP0012'" />
  4. <SWYPFXRYPZB v-if="sn == 'SP001'" /> -->
  5. <component ref="templateComponent" :is="getTemplateComponent()" :templateData="templateData" :fillType="fillType">
  6. </component>
  7. </div>
  8. </template>
  9. <script>
  10. import { EventBus } from "@/utils/eventBus"
  11. //色谱
  12. import SP001 from './comps/sp/SP001';
  13. import SWYPFXRYPZB from "./comps/sp/SWYPFXRYPZB.vue";
  14. import SWYPFXCBYPZB from "./comps/sp/SWYPFXCBYPZB.vue";
  15. import SWYPBQGZYZBB from "./comps/sp/SWYPBQGZYZBB.vue";
  16. import SWYPNBGZYZBB from "./comps/sp/SWYPNBGZYZBB.vue";
  17. //色谱生物样品分析方法学样品制备表-10个类似
  18. import ZQDYJMD from "./comps/sp/SWYPFXFFXYPZBB/ZQDYJMD.vue";
  19. import QXWDX from "./comps/sp/SWYPFXFFXYPZBB/QXWDX.vue";
  20. import Demo from "./comps/sp/Demo.vue";
  21. //公用
  22. import SYWZPZJHB from "./comps/gy/SYWZPZJHB.vue";
  23. import MJYLQSQD from "./comps/gy/MJYLQSQD.vue";
  24. export default {
  25. name: "TemplateTable",
  26. components: {
  27. MJYLQSQD, SYWZPZJHB,
  28. SP001, SWYPFXRYPZB, Demo, SWYPFXCBYPZB, SWYPBQGZYZBB, SWYPNBGZYZBB,ZQDYJMD,QXWDX
  29. },
  30. props: {
  31. sn: {
  32. type: String,
  33. default: '',
  34. },
  35. fillType: {
  36. type: String,
  37. default: 'preFill',
  38. },
  39. templateData: {
  40. type: Object,
  41. default: () => { },
  42. },
  43. emitName: {
  44. type: String,
  45. default: 'onModifyRecord',
  46. },
  47. },
  48. computed: {
  49. templateComponentMap() {
  50. if (!this.componentMap) {
  51. this.componentMap = {
  52. 'SP001': 'SWYPFXRYPZB',
  53. 'SP002': 'SWYPFXCBYPZB',
  54. 'SP003': 'SWYPBQGZYZBB',
  55. 'SP004': 'SWYPNBGZYZBB',
  56. 'SP008': 'ZQDYJMD',
  57. 'SP010': 'QXWDX',
  58. 'SYWZPZJHB': 'SYWZPZJHB',
  59. 'MJYLQSQD': 'MJYLQSQD',
  60. }
  61. }
  62. return this.componentMap || "Demo"
  63. }
  64. },
  65. watch: {
  66. sn: {
  67. immediate: true,
  68. handler(v) {
  69. console.log(v, "sn")
  70. }
  71. },
  72. templateData: {
  73. immediate: true,
  74. deep: true,
  75. handler(v) {
  76. if (v) {
  77. if (v.zdxgjl) {
  78. this.zdxgjl = JSON.parse(v.zdxgjl) || [];
  79. }
  80. if (v.fhyjjl) {
  81. this.fhyjjl = JSON.parse(v.fhyjjl) || [];
  82. }
  83. if (v.zdgxjl) {
  84. this.fieldCheckObj = JSON.parse(v.zdgxjl) || {};
  85. console.log(this.fieldCheckObj,v.zdgxjl,"v.zdgxjl")
  86. }
  87. }
  88. }
  89. }
  90. },
  91. provide() {
  92. return {
  93. //分发给子组件的fillType
  94. templateFillType: this.fillType,
  95. getZdxgjl: () => this.zdxgjl ,
  96. getFhyjjl: () => this.fhyjjl,
  97. getFieldCheckObj: () => this.fieldCheckObj,
  98. //更新提交记录
  99. updateZdxgjl: (data) => {
  100. this.zdxgjl.unshift(data);
  101. },
  102. //更新复核意见记录
  103. updateFhyjjl: (data) => {
  104. this.fhyjjl.unshift(data);
  105. },
  106. //替换复核意见记录
  107. replaceFhyjjl: (data) => {
  108. this.fhyjjl = data;
  109. },
  110. //更新字段检查对象
  111. updateFieldCheckObj: (data) => {
  112. this.fieldCheckObj = { ...this.fieldCheckObj, ...data };
  113. },
  114. }
  115. },
  116. data() {
  117. return {
  118. info: {},
  119. zdxgjl: [],
  120. fhyjjl: [],
  121. fieldCheckObj: {},
  122. };
  123. },
  124. mounted() {
  125. EventBus.$on('onModifyRecord', (data) => {
  126. this.$emit(this.emitName, data)
  127. })
  128. },
  129. beforeDestroy() {
  130. // 记得移除监听,避免内存泄漏
  131. EventBus.$off('onModifyRecord')
  132. },
  133. methods: {
  134. async getFormData() {
  135. if(this.fillType === "actFill"){
  136. //检查是否有未填写的复核意见
  137. const flag = this.fhyjjl.every((item)=>!!item.content && !!item.reply)
  138. console.log(this.fhyjjl,flag,"flag")
  139. if(!flag){
  140. this.$message.error("疑问项还未回复,请回复后再提交");
  141. return;
  142. }
  143. }
  144. return await this.$refs.templateComponent.getFormData();
  145. },
  146. getResource() {
  147. return this.$refs.templateComponent.getResource();
  148. },
  149. getFilledFormData() {
  150. return this.$refs.templateComponent.getFilledFormData();
  151. },
  152. getTemplateComponent() {
  153. return this.templateComponentMap[this.sn]
  154. },
  155. }
  156. };
  157. </script>
  158. <style rel="stylesheet/scss" lang="scss">
  159. .template-table {
  160. background: #fff;
  161. padding: 10px 10px;
  162. width: 100%;
  163. }
  164. </style>