dose.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="剂型选择"
  5. width="500px"
  6. :close-on-click-modal="false"
  7. :append-to-body="true"
  8. v-dialogDrag
  9. class="userDialog"
  10. :visible.sync="visible"
  11. >
  12. <el-container style="height: 500px">
  13. <el-container>
  14. <el-main>
  15. <el-row :gutter="10" class="content">
  16. <el-col :span="12">
  17. <el-input
  18. placeholder="输入关键字进行过滤"
  19. size="small"
  20. v-model="filterText">
  21. </el-input>
  22. <el-tree
  23. class="filter-tree"
  24. :data="threedata"
  25. :props="defaultProps"
  26. node-key="id"
  27. highlight-current
  28. @node-click="clickTree"
  29. :filter-node-method="filterNode"
  30. ref="tree">
  31. </el-tree>
  32. </el-col>
  33. </el-row>
  34. </el-main>
  35. </el-container>
  36. </el-container>
  37. <span slot="footer">
  38. <el-button
  39. size="small"
  40. @click="visible = false"
  41. icon="el-icon-circle-close"
  42. >关闭</el-button
  43. >
  44. <el-button
  45. size="small"
  46. type="primary"
  47. icon="el-icon-circle-check"
  48. @click="doSubmit()"
  49. >确定</el-button
  50. >
  51. </span>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script>
  56. import { getDose } from '@/api/requisition/basic'
  57. export default {
  58. data() {
  59. return {
  60. loading: false,
  61. visible: false,
  62. filterText: '',
  63. threedata: [],
  64. defaultProps: {
  65. children: 'childrens',
  66. label: 'name'
  67. },
  68. // 判断是否为最末级节点
  69. isLast: false,
  70. // 选中的节点
  71. choosePoint: {}
  72. };
  73. },
  74. props: {},
  75. watch: {
  76. filterText(val) {
  77. this.$refs.tree.filter(val);
  78. }
  79. },
  80. methods: {
  81. init() {
  82. this.visible = true;
  83. this.$nextTick(() => {
  84. this.refreshList()
  85. });
  86. },
  87. // 获取数据列表
  88. refreshList(data) {
  89. this.loading = true;
  90. getDose({}).then(res => {
  91. console.log('res',res)
  92. if(res.code === 200) {
  93. this.threedata = res.data.tableBody
  94. }
  95. this.loading = false;
  96. });
  97. },
  98. clickTree(data) {
  99. console.log('树形节点信息:',data)
  100. if (data.childrens.length == 0) {
  101. this.isLast = true
  102. } else {
  103. this.isLast = false
  104. }
  105. this.choosePoint = data
  106. },
  107. filterNode(value, data) {
  108. console.log('value', value)
  109. console.log('data', data)
  110. if (!value) return true;
  111. return data.name.indexOf(value) !== -1;
  112. },
  113. doSubmit() {
  114. if(this.isLast == false) {
  115. this.$message({
  116. message: '请选择最末级节点',
  117. type: 'warning'
  118. });
  119. } else {
  120. console.log('子组件选择的数据',this.choosePoint)
  121. this.$emit("doSubmit", this.choosePoint);
  122. this.visible = false;
  123. }
  124. },
  125. },
  126. };
  127. </script>
  128. <style lang="scss">
  129. .userDialog {
  130. .el-dialog__body {
  131. padding: 10px 0px 0px 10px;
  132. color: #606266;
  133. font-size: 14px;
  134. word-break: break-all;
  135. }
  136. .el-main {
  137. padding: 20px 20px 5px 20px;
  138. .el-pagination {
  139. margin-top: 5px;
  140. }
  141. }
  142. }
  143. </style>