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

265 lines
9.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. :checkType="checkType"
  12. :studyFormId="studyFormId" :studyId="studyId" :listApi="listApi" :selectedCode="selectedCode" @radioSelect="handleSelect" />
  13. <!-- 只有步骤才会又这个选项 -->
  14. <!-- xb+xj也会 -->
  15. <div v-if="sourceFrom === 'step' || selectType==='9' || selectType==='11'" class="other-reagent">
  16. <el-checkbox v-model="otherChecked" @change="handleOtherChange">其他</el-checkbox>
  17. <el-input class="other-reagent-input" v-model="otherReagent"></el-input>
  18. </div>
  19. <template slot="footer" class="dialog-footer">
  20. <el-button @click="onCancel">{{ $t('form.cancel') }}</el-button>
  21. <el-button :disabled="isDisabled" type="primary" @click="onSubmit">{{ $t('form.saveConfirm') }}</el-button>
  22. </template>
  23. </el-dialog>
  24. </template>
  25. <script>
  26. import SelectTable from '@/components/Template/SelectTable.vue';
  27. import SelectDept from "@/views/business/comps/select/SelectDept";
  28. import { public_sjList, public_gyzjList, public_gspList, public_xbList,public_jcbList,public_qxFormFillList,public_xjList } from '@/api/business/public/public';
  29. import { getSjSearchForm, getSjColumns, getGyzjSearchForm, getGyzjColumns, getGspSearchForm, getGspColumns, getXbSearchForm, getXbColumns,getJcbSearchForm,getJcbColumns,getQxbdSearchForm,getQxbdColumns, getXjSearchForm, getXjColumns } from '@/views/business/comps/template/formConfig/formConfig.js';
  30. import { EventBus } from "@/utils/eventBus";
  31. const typeMap = {
  32. '1': {
  33. searchForm: getSjSearchForm(),
  34. columns: getSjColumns(),
  35. listApi: public_sjList,
  36. title:"选择试剂"
  37. },
  38. '7': {
  39. searchForm: getGspSearchForm(),
  40. columns: getGspColumns(),
  41. listApi: public_gspList,
  42. title:"选择供试品"
  43. },
  44. "9": {
  45. searchForm: getXjSearchForm(),
  46. columns: getXjColumns(),
  47. listApi: public_xjList,
  48. title:"选择细菌"
  49. },
  50. "11": {
  51. searchForm: getXbSearchForm(),
  52. columns: getXbColumns(),
  53. listApi: public_xbList,
  54. title:"选择细胞"
  55. },
  56. "3": {
  57. searchForm: getGyzjSearchForm(),
  58. columns: getGyzjColumns(),
  59. listApi: public_gyzjList,
  60. title:"选择给药制剂"
  61. },
  62. "13": {
  63. searchForm: getJcbSearchForm(),
  64. columns: getJcbColumns(),
  65. listApi: public_jcbList,
  66. title:"请选择检测板"
  67. },
  68. "15": {
  69. searchForm: getQxbdSearchForm(),
  70. listApi: public_qxFormFillList,
  71. title:"请选择前序表单"
  72. },
  73. }
  74. export default {
  75. components: {
  76. SelectTable,
  77. SelectDept
  78. },
  79. props: {
  80. type: {
  81. type: String,
  82. default: "",
  83. },
  84. },
  85. data() {
  86. return {
  87. visible: false,
  88. otherChecked: false,
  89. selectedId: "",
  90. selectedCode: "bh",
  91. currentRow: null,
  92. radio: 1,
  93. bzList: [],
  94. depart: "",
  95. studyFormId: '',//有个studyFormId需要从外面动态传过来
  96. studyId:'',//有个studyId需要从外面动态传过来
  97. uuid: '',//为了标识eventBus的事件id,
  98. selectType: '1',//默认选择试剂列表
  99. listApi: public_sjList,
  100. searchForm: getSjSearchForm(),
  101. columns: getSjColumns(),
  102. sourceFrom: "step",//来源
  103. otherReagent: "",//其他试剂
  104. mixType: false,//是否是混合试剂
  105. title:"选择试剂",
  106. currentType: '1',//当前选择的类型
  107. qxbdType:"",//前序表单类型
  108. //是否显示单选框或复选框
  109. checkType: "radio",
  110. }
  111. },
  112. computed: {
  113. isDisabled() {
  114. if (this.otherChecked && this.otherReagent) {//如果选中了其他,那么就不校验是否选择了试剂
  115. return false;
  116. }else if(this.checkType === "checkbox"){
  117. console.log(this.currentRow,"this.currentRow")
  118. return !this.currentRow || this.currentRow.length === 0;
  119. }
  120. return !this.selectedId;
  121. }
  122. },
  123. methods: {
  124. show(studyFormId, data,studyId) {
  125. if (data && data.uuid) {//为了标识eventBus的事件id
  126. this.uuid = data.uuid
  127. }
  128. //type:sj(试剂列表)gsp(供试品列表)gyzj(给药制剂列表)
  129. const { type, sourceFrom = "step", mixType = false ,checkType = "radio"} = data;
  130. this.currentType = type;
  131. if(type==15){
  132. this.selectedCode = 'id'
  133. this.qxbdType = data.qxbdType || '';
  134. }
  135. this.checkType = checkType;
  136. this.mixType = mixType;
  137. this.sourceFrom = sourceFrom;
  138. this.studyFormId = studyFormId;
  139. this.studyId = studyId || '';
  140. this.visible = true;
  141. this.handleShowTableInfo(type);
  142. },
  143. hide() {
  144. this.visible = false;
  145. },
  146. handleOtherChange(val) {
  147. this.otherChecked = val;
  148. if (val) {//如果选中了其他,那么就清空选中的id
  149. this.selectedId = "";
  150. this.currentRow = null;
  151. }
  152. },
  153. handleShowTableInfo(type) {
  154. this.selectType = type;
  155. this.searchForm = typeMap[type].searchForm;
  156. // 对于前序表单类型,动态调用 getQxbdColumns 并传递组件实例
  157. if (type === '15') {
  158. this.columns = getQxbdColumns(this);
  159. } else {
  160. this.columns = typeMap[type].columns;
  161. }
  162. this.listApi = typeMap[type].listApi;
  163. this.listApi = typeMap[type].listApi || this.listApi;
  164. this.title = typeMap[type].title || this.title;
  165. setTimeout(() => {
  166. if (this.$refs.selectSjRef) {
  167. this.$refs.selectSjRef.show()
  168. }
  169. }, 10);
  170. },
  171. onCancel() {
  172. this.visible = false
  173. this.$emit('cancel');
  174. },
  175. onSubmit() {
  176. let row = this.currentRow;
  177. const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
  178. const selectInfo = this.otherChecked ?{}:{
  179. mc: row.mc,
  180. bh: row.bh,
  181. nd: row.nd,
  182. ly: row.ly,
  183. nddw: row.nddw,
  184. sxrq: row.sxr,
  185. ndz: (row.nd||"")+(row.nddw||""),
  186. type: Number(this.selectType),
  187. kc: row.kc,
  188. kcdw: row.kcdw,
  189. gg: row.gg,
  190. ggdw: row.ggdw,
  191. }
  192. const {qxbdType,checkType} = this;
  193. if(qxbdType){
  194. if(checkType === "radio"&& row.templateSn !== qxbdType){
  195. this.$message.error(`请选择正确前序表单`);
  196. return
  197. }
  198. if(checkType === "checkbox" ){
  199. const isAllType = row.every((item)=>item.templateSn === qxbdType)
  200. if(!isAllType){
  201. this.$message.error(`请选择正确前序表单`);
  202. return
  203. }
  204. }
  205. }
  206. this.$emit('submit', selectedValue, row);
  207. let callbackData = { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType,checkType };
  208. if(this.checkType === "checkbox"){
  209. let selectedInfo = "";
  210. if(this.otherChecked && this.otherReagent){
  211. selectedInfo = this.otherReagent;
  212. }else{
  213. selectedInfo = row.map((item)=>(item.bdbh||item.bh)).join(",");
  214. }
  215. callbackData = {
  216. uuid: this.uuid,
  217. selectedRows: row,
  218. selectedId:selectedInfo,
  219. checkType
  220. }
  221. }
  222. // 触发eventBus事件
  223. EventBus.$emit("onMixReagentSubmit", callbackData);
  224. // this.visible = false;
  225. },
  226. // 选择试剂时处理
  227. handleSelect(code, row) {
  228. if(this.checkType === "radio"){
  229. this.selectedId = code;
  230. }
  231. this.currentRow = row;
  232. },
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .header-row {
  238. display: flex;
  239. align-items: center;
  240. padding: 20px 0;
  241. }
  242. .other-reagent {
  243. display: flex;
  244. align-items: center;
  245. padding: 20px 0;
  246. }
  247. .other-reagent-input {
  248. width: 200px;
  249. margin-left: 5px;
  250. }
  251. .mt-20 {
  252. margin-top: 20px;
  253. }
  254. .mb-20 {
  255. margin-bottom: 20px;
  256. }
  257. </style>