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

182 lines
5.5 KiB

  1. <template>
  2. <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :title="$t(title)" @close="onCancel" :visible.sync="visible" append-to-body width="80%">
  3. <SelectTable ref="selectSjRef" :columns="columns"
  4. :selectedId="selectedId"
  5. :searchForm="searchForm"
  6. :studyFormId = "studyFormId"
  7. :listApi="listApi"
  8. :selectedCode="selectedCode"
  9. @radioSelect="handleSelect"/>
  10. <div class="other-reagent">
  11. <el-checkbox v-model="otherChecked" @change="handleOtherChange">其他</el-checkbox>
  12. <el-input class="other-reagent-input" v-model="otherReagent"></el-input>
  13. </div>
  14. <template slot="footer" class="dialog-footer">
  15. <el-button @click="onCancel">{{$t('form.cancel')}}</el-button>
  16. <el-button :disabled="isDisabled" type="primary" @click="onSubmit">{{$t('form.saveConfirm')}}</el-button>
  17. </template>
  18. </el-dialog>
  19. </template>
  20. <script>
  21. import SelectTable from '@/components/Template/SelectTable.vue';
  22. import SelectDept from "@/views/business/comps/select/SelectDept";
  23. import { public_yqList } from '@/api/business/public/public';
  24. import { EventBus } from "@/utils/eventBus";
  25. export default {
  26. components: {
  27. SelectTable,
  28. SelectDept
  29. },
  30. props: {
  31. type: {
  32. type: String,
  33. default: "",
  34. },
  35. title: {
  36. type: String,
  37. default: "选择仪器",
  38. },
  39. selectedCode: {
  40. type: String,
  41. default: "bh",
  42. },
  43. listApi: {
  44. type: Function,
  45. default: public_yqList,
  46. },
  47. searchForm: {
  48. type: Object,
  49. default: () => {
  50. return {
  51. mc: {
  52. label:'仪器名称',
  53. },
  54. bh: {
  55. label:'仪器编号',
  56. },
  57. ly: {
  58. label:'来源',
  59. },
  60. }
  61. },
  62. },
  63. columns: {
  64. type: Array,
  65. default: () => [
  66. {
  67. prop: 'mc',
  68. label: '仪器名称',
  69. },
  70. {
  71. prop: 'bh',
  72. label: '仪器编号',
  73. },
  74. {
  75. prop: 'ly',
  76. label: '来源(厂家)',
  77. },
  78. {
  79. prop: 'jzrq',
  80. label: '下次校准时间',
  81. },
  82. ],
  83. },
  84. },
  85. data() {
  86. return {
  87. visible:false,
  88. selectedId: "",
  89. currentRow: {},
  90. studyFormId:'',//有个studyFormId需要从外面动态传过来
  91. uuid:'',//为了标识eventBus的事件id,
  92. otherChecked: false,
  93. otherReagent: "",//其他试剂
  94. }
  95. },
  96. computed: {
  97. isDisabled() {
  98. if (this.otherChecked && this.otherReagent) {//如果选中了其他,那么就不校验是否选择了试剂
  99. return false;
  100. }else if(this.checkType === "checkbox"){
  101. console.log(this.currentRow,"this.currentRow")
  102. return !this.currentRow || this.currentRow.length === 0;
  103. }
  104. return !this.selectedId;
  105. }
  106. },
  107. methods: {
  108. show(studyFormId,data){
  109. if(data && data.uuid) {//为了标识eventBus的事件id
  110. this.uuid = data.uuid
  111. }
  112. this.selectedId = "";
  113. this.visible = true
  114. setTimeout(() => {
  115. if(this.$refs.selectSjRef){
  116. this.$refs.selectSjRef.show()
  117. }
  118. }, 10);
  119. this.studyFormId = studyFormId
  120. this.otherChecked = false;
  121. this.otherReagent = "";
  122. },
  123. onCancel() {
  124. this.visible = false
  125. this.$emit('cancel');
  126. },
  127. onSubmit() {
  128. let row = this.otherChecked ? {bh: this.otherReagent}:this.currentRow;
  129. const selectedValue = this.otherChecked ? this.otherReagent : this.selectedId;
  130. this.$emit('submit', selectedValue,row);
  131. const selectInfo = this.otherChecked ?{
  132. mc: "",
  133. bh: row.bh,
  134. xh: "",
  135. jzrq: "",
  136. }: {
  137. mc: row.mc,
  138. bh: row.bh,
  139. xh: row.xh,
  140. jzrq: row.jzrq,
  141. }
  142. // 触发eventBus事件
  143. EventBus.$emit("onInstrumentSubmit",{selectInfo,uuid:this.uuid,selectedId:selectedValue,row,type:"yq"});
  144. this.visible = false;
  145. },
  146. handleSelect(code,row) {
  147. this.selectedId = code;
  148. this.currentRow = row;
  149. },
  150. handleOtherChange(val) {
  151. this.otherChecked = val;
  152. if (val) {//如果选中了其他,那么就清空选中的id
  153. this.selectedId = "";
  154. this.currentRow = null;
  155. }
  156. },
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .header-row{
  162. display: flex;
  163. align-items: center;
  164. padding: 20px 0;
  165. }
  166. .other-reagent {
  167. display: flex;
  168. align-items: center;
  169. padding: 20px 0;
  170. }
  171. .other-reagent-input {
  172. width: 200px;
  173. margin-left: 5px;
  174. }
  175. </style>