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

191 lines
6.3 KiB

  1. <!-- 试剂/供试品/给药制剂弹窗 -->
  2. <template>
  3. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="$t(title)" @close="onCancel"
  4. :visible.sync="visible" append-to-body width="80%">
  5. <el-radio-group v-show="mixType" v-model="selectType" @change="handleShowTableInfo" class="mt-20 mb-20">
  6. <el-radio-button label="1">试剂列表</el-radio-button>
  7. <el-radio-button label="7">供试品列表</el-radio-button>
  8. <el-radio-button label="3">给药制剂列表</el-radio-button>
  9. </el-radio-group>
  10. <SelectTable ref="selectSjRef" :columns="columns" :selectedId="selectedId" :searchForm="searchForm"
  11. :studyFormId="studyFormId" :listApi="listApi" :selectedCode="selectedCode" @radioSelect="handleSelect" />
  12. <!-- 只有步骤才会又这个选项 -->
  13. <div v-if="sourceFrom === 'step'" class="other-reagent">
  14. <el-checkbox v-model="otherChecked" @change="handleOtherChange">其他</el-checkbox>
  15. <el-input class="other-reagent-input" v-model="otherReagent"></el-input>
  16. </div>
  17. <template slot="footer" class="dialog-footer">
  18. <el-button @click="onCancel">{{ $t('form.cancel') }}</el-button>
  19. <el-button :disabled="isDisabled" type="primary" @click="onSubmit">{{ $t('form.saveConfirm') }}</el-button>
  20. </template>
  21. </el-dialog>
  22. </template>
  23. <script>
  24. import SelectTable from '@/components/Template/SelectTable.vue';
  25. import SelectDept from "@/views/business/comps/select/SelectDept";
  26. import { public_sjList, public_gyzjList, public_gspList, public_xbList } from '@/api/business/public/public';
  27. import { getSjSearchForm, getSjColumns, getGyzjSearchForm, getGyzjColumns, getGspSearchForm, getGspColumns, getXbSearchForm, getXbColumns } from '@/views/business/comps/template/formConfig/formConfig.js';
  28. import { EventBus } from "@/utils/eventBus";
  29. const typeMap = {
  30. '1': {
  31. searchForm: getSjSearchForm(),
  32. columns: getSjColumns(),
  33. listApi: public_sjList,
  34. title:"选择试剂"
  35. },
  36. '7': {
  37. searchForm: getGspSearchForm(),
  38. columns: getGspColumns(),
  39. listApi: public_gspList,
  40. title:"选择供试品"
  41. },
  42. "11": {
  43. searchForm: getXbSearchForm(),
  44. columns: getXbColumns(),
  45. listApi: public_xbList,
  46. title:"选择细胞"
  47. },
  48. "3": {
  49. searchForm: getGyzjSearchForm(),
  50. columns: getGyzjColumns(),
  51. listApi: public_gyzjList,
  52. title:"选择给药制剂"
  53. },
  54. }
  55. export default {
  56. components: {
  57. SelectTable,
  58. SelectDept
  59. },
  60. props: {
  61. type: {
  62. type: String,
  63. default: "",
  64. },
  65. selectedCode: {
  66. type: String,
  67. default: "bh",
  68. },
  69. },
  70. data() {
  71. return {
  72. visible: false,
  73. otherChecked: false,
  74. selectedId: "",
  75. currentRow: {},
  76. radio: 1,
  77. bzList: [],
  78. depart: "",
  79. studyFormId: '',//有个studyFormId需要从外面动态传过来
  80. uuid: '',//为了标识eventBus的事件id,
  81. selectType: '1',//默认选择试剂列表
  82. listApi: public_sjList,
  83. searchForm: getSjSearchForm(),
  84. columns: getSjColumns(),
  85. sourceFrom: "step",//来源
  86. otherReagent: "",//其他试剂
  87. mixType: false,//是否是混合试剂
  88. title:"选择试剂"
  89. }
  90. },
  91. computed: {
  92. isDisabled() {
  93. if (this.otherChecked && this.otherReagent) {//如果选中了其他,那么就不校验是否选择了试剂
  94. return false;
  95. }
  96. return !this.selectedId;
  97. }
  98. },
  99. methods: {
  100. show(studyFormId, data) {
  101. if (data && data.uuid) {//为了标识eventBus的事件id
  102. this.uuid = data.uuid
  103. }
  104. //type:sj(试剂列表)gsp(供试品列表)gyzj(给药制剂列表)
  105. const { type, sourceFrom = "step", mixType = false } = data;
  106. this.mixType = mixType;
  107. this.sourceFrom = sourceFrom;
  108. this.studyFormId = studyFormId;
  109. this.visible = true;
  110. this.handleShowTableInfo(type);
  111. },
  112. handleOtherChange(val) {
  113. this.otherChecked = val;
  114. if (val) {//如果选中了其他,那么就清空选中的id
  115. this.selectedId = "";
  116. this.currentRow = {};
  117. }
  118. },
  119. handleShowTableInfo(type) {
  120. this.selectType = type;
  121. this.searchForm = typeMap[type].searchForm;
  122. this.columns = typeMap[type].columns;
  123. this.listApi = typeMap[type].listApi;
  124. this.listApi = typeMap[type].listApi || this.listApi;
  125. this.title = typeMap[type].title || this.title;
  126. setTimeout(() => {
  127. if (this.$refs.selectSjRef) {
  128. this.$refs.selectSjRef.show()
  129. }
  130. }, 10);
  131. },
  132. onCancel() {
  133. this.visible = false
  134. this.$emit('cancel');
  135. },
  136. onSubmit() {
  137. let row = this.currentRow;
  138. const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
  139. const selectInfo = {
  140. mc: row.mc,
  141. bh: row.bh,
  142. nd: row.nd,
  143. ly: row.ly,
  144. nddw: row.nddw,
  145. sxrq: row.sxr,
  146. ndz: (row.nd||"")+(row.nddw||""),
  147. type: Number(this.selectType),
  148. }
  149. this.$emit('submit', selectedValue, row);
  150. // 触发eventBus事件
  151. EventBus.$emit("onMixReagentSubmit", { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType });
  152. this.visible = false;
  153. },
  154. // 选择试剂时处理
  155. handleSelect(code, row) {
  156. this.selectedId = code;
  157. this.currentRow = row;
  158. },
  159. }
  160. }
  161. </script>
  162. <style lang="scss" scoped>
  163. .header-row {
  164. display: flex;
  165. align-items: center;
  166. padding: 20px 0;
  167. }
  168. .other-reagent {
  169. display: flex;
  170. align-items: center;
  171. padding: 20px 0;
  172. }
  173. .other-reagent-input {
  174. width: 200px;
  175. margin-left: 5px;
  176. }
  177. .mt-20 {
  178. margin-top: 20px;
  179. }
  180. .mb-20 {
  181. margin-bottom: 20px;
  182. }
  183. </style>