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

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