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

283 lines
10 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==='1' || selectType==='3' || selectType==='7' || 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.selectedId = "";
  136. this.otherReagent = "";
  137. this.otherChecked = false;
  138. this.checkType = checkType;
  139. this.mixType = mixType;
  140. this.sourceFrom = sourceFrom;
  141. this.studyFormId = studyFormId;
  142. this.studyId = studyId || '';
  143. this.visible = true;
  144. this.handleShowTableInfo(type);
  145. },
  146. hide() {
  147. this.visible = false;
  148. },
  149. handleOtherChange(val) {
  150. this.otherChecked = val;
  151. if (val) {//如果选中了其他,那么就清空选中的id
  152. this.selectedId = "";
  153. this.currentRow = null;
  154. }
  155. },
  156. handleShowTableInfo(type) {
  157. this.selectType = type;
  158. this.searchForm = typeMap[type].searchForm;
  159. // 对于前序表单类型,动态调用 getQxbdColumns 并传递组件实例
  160. if (type === '15') {
  161. this.columns = getQxbdColumns(this);
  162. } else {
  163. this.columns = typeMap[type].columns;
  164. }
  165. this.listApi = typeMap[type].listApi;
  166. this.listApi = typeMap[type].listApi || this.listApi;
  167. this.title = typeMap[type].title || this.title;
  168. setTimeout(() => {
  169. if (this.$refs.selectSjRef) {
  170. this.$refs.selectSjRef.show()
  171. }
  172. }, 10);
  173. },
  174. onCancel() {
  175. this.visible = false
  176. this.$emit('cancel');
  177. },
  178. onSubmit() {
  179. let row = this.otherChecked ?(this.checkType === "checkbox"?[{bh: this.otherReagent}]:{bh: this.otherReagent}):this.currentRow;
  180. const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
  181. const selectInfo = this.otherChecked ?{
  182. mc: "",
  183. bh: row.bh,
  184. nd: "",
  185. ly: "",
  186. nddw: "",
  187. sxrq: "",
  188. yxq: "",
  189. ndz: "",
  190. type: Number(this.selectType),
  191. kc: "",
  192. kcdw: "",
  193. gg: "",
  194. ggdw: "",
  195. }:{
  196. mc: row.mc,
  197. bh: row.bh,
  198. nd: row.nd,
  199. ly: row.ly,
  200. nddw: row.nddw,
  201. sxrq: row.sxr,
  202. yxq: row.yxq,
  203. ndz: (row.nd||"")+(row.nddw||""),
  204. type: Number(this.selectType),
  205. kc: row.kc,
  206. kcdw: row.kcdw,
  207. gg: row.gg,
  208. ggdw: row.ggdw,
  209. }
  210. const {qxbdType,checkType} = this;
  211. if(qxbdType){
  212. if(checkType === "radio"&& row.templateSn !== qxbdType){
  213. this.$message.error(`请选择正确前序表单`);
  214. return
  215. }
  216. if(checkType === "checkbox" ){
  217. const isAllType = row.every((item)=>item.templateSn === qxbdType)
  218. if(!isAllType){
  219. this.$message.error(`请选择正确前序表单`);
  220. return
  221. }
  222. }
  223. }
  224. this.$emit('submit', selectedValue, row);
  225. let callbackData = { selectInfo, uuid: this.uuid, selectedId: selectedValue, row,selectType:this.selectType,checkType };
  226. if(this.checkType === "checkbox"){
  227. let selectedInfo = "";
  228. if(this.otherChecked && this.otherReagent){
  229. selectedInfo = this.otherReagent;
  230. }else{
  231. selectedInfo = row.map((item)=>(item.bdbh||item.bh)).join("、");
  232. }
  233. callbackData = {
  234. uuid: this.uuid,
  235. selectedRows: row,
  236. selectedId:selectedInfo,
  237. checkType
  238. }
  239. }
  240. // 触发eventBus事件
  241. EventBus.$emit("onMixReagentSubmit", callbackData);
  242. // this.visible = false;
  243. },
  244. // 选择试剂时处理
  245. handleSelect(code, row) {
  246. if(this.checkType === "radio"){
  247. this.selectedId = code;
  248. }
  249. this.currentRow = row;
  250. },
  251. }
  252. }
  253. </script>
  254. <style lang="scss" scoped>
  255. .header-row {
  256. display: flex;
  257. align-items: center;
  258. padding: 20px 0;
  259. }
  260. .other-reagent {
  261. display: flex;
  262. align-items: center;
  263. padding: 20px 0;
  264. }
  265. .other-reagent-input {
  266. width: 200px;
  267. margin-left: 5px;
  268. }
  269. .mt-20 {
  270. margin-top: 20px;
  271. }
  272. .mb-20 {
  273. margin-bottom: 20px;
  274. }
  275. </style>