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

192 lines
5.6 KiB

  1. <template>
  2. <el-dialog :title="$t(title)" @close="onCancel" :visible.sync="visible" append-to-body width="80%">
  3. <!-- 麻醉/精神药品配制/领取申请单 -->
  4. <div v-if="type === 'MJYLQSQD'" class="header-row">
  5. <el-radio-group v-model="radio" @input="changeRadio">
  6. <el-radio :label="1">试验</el-radio>
  7. <el-radio :label="2">
  8. 部门
  9. </el-radio>
  10. </el-radio-group>
  11. <select-dept v-if="radio==2" v-model="depart" style="width:200px;margin-left:10px" />
  12. </div>
  13. <SelectTable v-if = "isShowTable" ref="selectSjRef" :columns="columns"
  14. :selectedId="selectedId"
  15. :searchForm="searchForm"
  16. :listApi="listApi"
  17. :selectedCode="selectedCode"
  18. @radioSelect="handleSelect"/>
  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_bzList } from '@/api/business/public/public';
  29. export default {
  30. components: {
  31. SelectTable,
  32. SelectDept
  33. },
  34. props: {
  35. type: {
  36. type: String,
  37. default: "",
  38. },
  39. title: {
  40. type: String,
  41. default: "page.business.resource.sj.xzsj",
  42. },
  43. selectedCode: {
  44. type: String,
  45. default: "bh",
  46. },
  47. listApi: {
  48. type: Function,
  49. default: public_sjList,
  50. },
  51. searchForm: {
  52. type: Object,
  53. default: () => {
  54. return {
  55. mc: {
  56. label:'page.business.resource.sj.sjmc',
  57. },
  58. bh: {
  59. label:'page.business.resource.sj.sjbh',
  60. },
  61. studyName: {
  62. label:'page.business.resource.sj.sssy',
  63. },
  64. }
  65. },
  66. },
  67. columns: {
  68. type: Array,
  69. default: () => [
  70. {
  71. prop: 'mc',
  72. label: 'page.business.resource.sj.sjmc',
  73. },
  74. {
  75. prop: 'bh',
  76. label: 'page.business.resource.sj.sjbh',
  77. },
  78. {
  79. prop: 'nd',
  80. label: 'page.business.resource.sj.sjnd',
  81. },
  82. {
  83. prop: 'nddw',
  84. label: 'page.business.resource.gsp.nddw',
  85. },
  86. {
  87. prop: 'sxr',
  88. label: 'page.business.resource.sj.sxr',
  89. },
  90. {
  91. prop: 'studyName',
  92. label: 'page.business.resource.sj.sssy',
  93. },
  94. ],
  95. },
  96. },
  97. data() {
  98. return {
  99. visible:false,
  100. selectedId: "",
  101. currentRow: {},
  102. radio:1,
  103. bzList:[],
  104. depart:"",
  105. }
  106. },
  107. computed: {
  108. isShowTable() {
  109. if(this.type === 'MJYLQSQD') {
  110. return this.radio === 1;
  111. }
  112. return true;
  113. },
  114. isDisabled() {
  115. if(this.type === 'MJYLQSQD') {
  116. if(this.radio === 1) {//选择试验的时候必须要选中一项才能点击确定
  117. return !this.selectedId;
  118. }else{
  119. return !this.depart;
  120. }
  121. }
  122. return !this.selectedId;
  123. }
  124. },
  125. methods: {
  126. show(){
  127. this.visible = true
  128. this.showTableData()
  129. if(this.type === 'MJYLQSQD'){
  130. this.getBzList()
  131. }
  132. },
  133. getBzList(){
  134. public_bzList(this.searchForm).then(response => {
  135. this.bzList = response.data
  136. });
  137. },
  138. showTableData(){
  139. if(this.$refs.selectSjRef){
  140. this.$refs.selectSjRef.show()
  141. }else{
  142. setTimeout(() => {
  143. this.showTableData()
  144. }, 100);
  145. }
  146. },
  147. onCancel() {
  148. this.visible = false
  149. this.$emit('cancel');
  150. },
  151. onSubmit() {
  152. let row = this.currentRow;
  153. if(this.type === 'MJYLQSQD') {
  154. if(this.radio === 1) {
  155. row = row;
  156. row.type=this.radio
  157. }else{
  158. const o = this.bzList.find(item => item.deptId == this.depart);
  159. if(o){
  160. row = o;
  161. row.type=this.radio
  162. }else{
  163. this.$message.error(`该部门没有设置部长!`)
  164. return
  165. }
  166. }
  167. }
  168. this.$emit('submit', this.selectedId,row);
  169. },
  170. handleSelect(code,row) {
  171. this.selectedId = code;
  172. this.currentRow = row;
  173. },
  174. changeRadio(val){
  175. if(val==1){
  176. this.showTableData()
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .header-row{
  184. display: flex;
  185. align-items: center;
  186. padding: 20px 0;
  187. }
  188. </style>