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

212 lines
7.2 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" :studyId="studyId" :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,public_jcbList,public_qxFormFillList } from '@/api/business/public/public';
  27. import { getSjSearchForm, getSjColumns, getGyzjSearchForm, getGyzjColumns, getGspSearchForm, getGspColumns, getXbSearchForm, getXbColumns,getJcbSearchForm,getJcbColumns,getQxbdSearchForm,getQxbdColumns } 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. "13": {
  55. searchForm: getJcbSearchForm(),
  56. columns: getJcbColumns(),
  57. listApi: public_jcbList,
  58. title:"请选择检测板"
  59. },
  60. "15": {
  61. searchForm: getQxbdSearchForm(),
  62. columns: getQxbdColumns(),
  63. listApi: public_qxFormFillList,
  64. title:"请选择前序表单"
  65. },
  66. }
  67. export default {
  68. components: {
  69. SelectTable,
  70. SelectDept
  71. },
  72. props: {
  73. type: {
  74. type: String,
  75. default: "",
  76. },
  77. },
  78. data() {
  79. return {
  80. visible: false,
  81. otherChecked: false,
  82. selectedId: "",
  83. selectedCode: "bh",
  84. currentRow: {},
  85. radio: 1,
  86. bzList: [],
  87. depart: "",
  88. studyFormId: '',//有个studyFormId需要从外面动态传过来
  89. studyId:'',//有个studyId需要从外面动态传过来
  90. uuid: '',//为了标识eventBus的事件id,
  91. selectType: '1',//默认选择试剂列表
  92. listApi: public_sjList,
  93. searchForm: getSjSearchForm(),
  94. columns: getSjColumns(),
  95. sourceFrom: "step",//来源
  96. otherReagent: "",//其他试剂
  97. mixType: false,//是否是混合试剂
  98. title:"选择试剂",
  99. currentType: '1',//当前选择的类型
  100. }
  101. },
  102. computed: {
  103. isDisabled() {
  104. if (this.otherChecked && this.otherReagent) {//如果选中了其他,那么就不校验是否选择了试剂
  105. return false;
  106. }
  107. return !this.selectedId;
  108. }
  109. },
  110. methods: {
  111. show(studyFormId, data,studyId) {
  112. if (data && data.uuid) {//为了标识eventBus的事件id
  113. this.uuid = data.uuid
  114. }
  115. //type:sj(试剂列表)gsp(供试品列表)gyzj(给药制剂列表)
  116. const { type, sourceFrom = "step", mixType = false } = data;
  117. this.currentType = type;
  118. if(type==15){
  119. this.selectedCode = 'id'
  120. }
  121. this.mixType = mixType;
  122. this.sourceFrom = sourceFrom;
  123. this.studyFormId = studyFormId;
  124. this.studyId = studyId || '';
  125. this.visible = true;
  126. this.handleShowTableInfo(type);
  127. },
  128. hide() {
  129. this.visible = false;
  130. },
  131. handleOtherChange(val) {
  132. this.otherChecked = val;
  133. if (val) {//如果选中了其他,那么就清空选中的id
  134. this.selectedId = "";
  135. this.currentRow = {};
  136. }
  137. },
  138. handleShowTableInfo(type) {
  139. this.selectType = type;
  140. this.searchForm = typeMap[type].searchForm;
  141. this.columns = typeMap[type].columns;
  142. this.listApi = typeMap[type].listApi;
  143. this.listApi = typeMap[type].listApi || this.listApi;
  144. this.title = typeMap[type].title || this.title;
  145. setTimeout(() => {
  146. if (this.$refs.selectSjRef) {
  147. this.$refs.selectSjRef.show()
  148. }
  149. }, 10);
  150. },
  151. onCancel() {
  152. this.visible = false
  153. this.$emit('cancel');
  154. },
  155. onSubmit() {
  156. let row = this.currentRow;
  157. const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
  158. const selectInfo = {
  159. mc: row.mc,
  160. bh: row.bh,
  161. nd: row.nd,
  162. ly: row.ly,
  163. nddw: row.nddw,
  164. sxrq: row.sxr,
  165. ndz: (row.nd||"")+(row.nddw||""),
  166. type: Number(this.selectType),
  167. }
  168. this.$emit('submit', selectedValue, row);
  169. // 触发eventBus事件
  170. EventBus.$emit("onMixReagentSubmit", { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType });
  171. // this.visible = false;
  172. },
  173. // 选择试剂时处理
  174. handleSelect(code, row) {
  175. this.selectedId = code;
  176. if(this.currentType==15){//如果是前序表单,那么选中的id是bdmc
  177. this.selectedId = row.bdmc+'('+row.bdbh+')'
  178. }
  179. this.currentRow = row;
  180. },
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .header-row {
  186. display: flex;
  187. align-items: center;
  188. padding: 20px 0;
  189. }
  190. .other-reagent {
  191. display: flex;
  192. align-items: center;
  193. padding: 20px 0;
  194. }
  195. .other-reagent-input {
  196. width: 200px;
  197. margin-left: 5px;
  198. }
  199. .mt-20 {
  200. margin-top: 20px;
  201. }
  202. .mb-20 {
  203. margin-bottom: 20px;
  204. }
  205. </style>