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

169 lines
4.7 KiB

  1. <template>
  2. <el-dialog :title="title" @close="onCancel" :visible.sync="visible" append-to-body>
  3. <!-- 麻醉/精神药品配制/领取申请单 -->
  4. <div v-if="type === 'MJYLQSQD'" class="header-row">
  5. <el-radio-group v-model="radio">
  6. <el-radio :label="1">试验</el-radio>
  7. <el-radio :label="2">
  8. 部门
  9. </el-radio>
  10. </el-radio-group>
  11. <el-select v-model="depart" filterable placeholder="请选择">
  12. <el-option
  13. v-for="item in options"
  14. :key="item.value"
  15. :label="item.label"
  16. :value="item.value">
  17. </el-option>
  18. </el-select>
  19. </div>
  20. <SelectTable v-if = "isShowTable" :columns="columns"
  21. :selectedId="selectedId"
  22. :searchForm="searchForm"
  23. :listApi="listApi"
  24. @radioSelect="handleSelect"/>
  25. <template slot="footer" class="dialog-footer">
  26. <el-button @click="onCancel">取消</el-button>
  27. <el-button :disabled="isDisabled" type="primary" @click="onSubmit">确定</el-button>
  28. </template>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. import SelectTable from '@/components/Template/SelectTable.vue';
  33. import { getReagentList } from '@/api/template';
  34. export default {
  35. components: {
  36. SelectTable,
  37. },
  38. props: {
  39. type: {
  40. type: String,
  41. default: "",
  42. },
  43. visible: {
  44. type: Boolean,
  45. default: false,
  46. },
  47. title: {
  48. type: String,
  49. default: "选择试剂",
  50. },
  51. listApi: {
  52. type: Function,
  53. default: getReagentList,
  54. },
  55. searchForm: {
  56. type: Object,
  57. default: () => {
  58. return {
  59. name: {
  60. label:"试剂名称",
  61. },
  62. code: {
  63. label:"试剂编号",
  64. },
  65. vol: {
  66. label:"所属试验",
  67. },
  68. }
  69. },
  70. },
  71. columns: {
  72. type: Array,
  73. default: () => [
  74. {
  75. prop: 'name',
  76. label: '试剂名称',
  77. },
  78. {
  79. prop: 'code',
  80. label: '试剂编号',
  81. },
  82. {
  83. prop: 'vol',
  84. label: '试剂浓度',
  85. },
  86. {
  87. prop: 'unit',
  88. label: '浓度单位',
  89. },
  90. {
  91. prop: 'expireDate',
  92. label: '失效日',
  93. },
  94. {
  95. prop: 'ss',
  96. label: '所属试验',
  97. },
  98. ],
  99. },
  100. },
  101. data() {
  102. return {
  103. selectedId: "",
  104. currentRow: {},
  105. radio:1,
  106. depart:"",
  107. options:[
  108. {
  109. value:1,
  110. label:"部门1",
  111. },
  112. {
  113. value:2,
  114. label:"部门",
  115. },
  116. ]
  117. }
  118. },
  119. computed: {
  120. isShowTable() {
  121. if(this.type === 'MJYLQSQD') {
  122. return this.radio === 1;
  123. }
  124. return true;
  125. },
  126. isDisabled() {
  127. if(this.type === 'MJYLQSQD') {
  128. if(this.radio === 1) {//选择试验的时候必须要选中一项才能点击确定
  129. return !this.selectedId;
  130. }else{
  131. return !this.depart;
  132. }
  133. }
  134. return !this.selectedId;
  135. }
  136. },
  137. methods: {
  138. onCancel() {
  139. this.$emit('cancel');
  140. },
  141. onSubmit() {
  142. let row = this.currentRow;
  143. if(this.type === 'MJYLQSQD') {
  144. if(this.radio === 1) {
  145. row = {syNo:row.ss,SD:row.code};
  146. }else{
  147. const o = this.options.find(item => item.value === this.depart);
  148. row = {syNo:o.label,SD:o.value};
  149. }
  150. }
  151. this.$emit('submit', this.selectedId,row);
  152. },
  153. handleSelect(code,row) {
  154. this.selectedId = code;
  155. this.currentRow = row;
  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. </style>