ChooseDoctorComponent.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="医生姓名" prop="doctorName">
  5. <el-input
  6. v-model="queryParams.doctorName"
  7. placeholder="请输入医生姓名"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="所属医院" prop="hospitalId" >
  14. <el-select v-model="queryParams.hospitalId" placeholder="请选择所属医院" clearable filterable size="small">
  15. <el-option v-for="(option, index) in hospitalList" :key="index" :value="option.dictValue" :label="option.dictLabel"></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="科室" prop="deptId">
  19. <el-select v-model="queryParams.deptId" placeholder="请选择所属科室" clearable size="small">
  20. <el-option
  21. v-for="dict in depList"
  22. :key="dict.dictValue"
  23. :label="dict.dictLabel"
  24. :value="dict.dictValue"
  25. />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="职称" prop="position">
  29. <el-select v-model="queryParams.position" placeholder="职称" clearable size="small">
  30. <el-option
  31. v-for="dict in positionOptions"
  32. :key="dict.dictValue"
  33. :label="dict.dictLabel"
  34. :value="dict.dictValue"
  35. />
  36. </el-select>
  37. </el-form-item>
  38. <el-form-item label="手机号" prop="mobile">
  39. <el-input
  40. v-model="queryParams.mobile"
  41. placeholder="请输入手机号"
  42. clearable
  43. size="small"
  44. @keyup.enter.native="handleQuery"
  45. />
  46. </el-form-item>
  47. <el-form-item>
  48. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  49. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  50. </el-form-item>
  51. </el-form>
  52. <el-table border v-loading="loading" :data="list" @selection-change="handleSelectionChange" ref="doctorTable" :row-key="'doctorId'" :reserve-selection="true">
  53. <el-table-column type="selection" width="55" align="center" />
  54. <el-table-column label="医生名称" align="center" prop="doctorName"/>
  55. <el-table-column label="所属医院" align="center" prop="hospitalName"/>
  56. <el-table-column label="科室" align="center" prop="deptName"/>
  57. <el-table-column label="职称" align="center" prop="position"/>
  58. <el-table-column label="手机号" align="center" prop="mobile"/>
  59. </el-table>
  60. <pagination
  61. v-show="total>0"
  62. :total="total"
  63. :page.sync="queryParams.pageNum"
  64. :limit.sync="queryParams.pageSize"
  65. @pagination="getList"
  66. />
  67. <div class="footer-button">
  68. <el-button @click="cancel">取消</el-button>
  69. <el-button type="primary" @click="submit">确定</el-button>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. import{listDepartment} from "@/api/his/disease";
  75. import{listAllHospital} from "@/api/his/hospital";
  76. import { getChooseDoctorList } from '@/api/his/doctor'
  77. export default {
  78. name: "ChooseDoctorComponent",
  79. props: {
  80. doctorIds: {
  81. type: Array,
  82. default: () => []
  83. }
  84. },
  85. activated() {
  86. // keep-alive 激活时恢复选中
  87. this.$nextTick(() => {
  88. this.restoreSelection()
  89. })
  90. },
  91. watch: {
  92. // doctorIds 变化时重新恢复选中
  93. doctorIds: {
  94. immediate: false,
  95. handler() {
  96. this.$nextTick(() => this.restoreSelection())
  97. }
  98. }
  99. },
  100. data() {
  101. return {
  102. // 遮罩层
  103. loading: false,
  104. // 显示搜索条件
  105. showSearch: true,
  106. // 查询参数
  107. queryParams: {
  108. pageNum: 1,
  109. pageSize: 10,
  110. doctorName: null,
  111. hospitalId: null,
  112. deptId: null,
  113. position: null,
  114. mobile: null
  115. },
  116. //医院列表
  117. hospitalList:[],
  118. //科室列表
  119. depList:[],
  120. positionOptions: [],
  121. // 总条数
  122. total: 0,
  123. // 课程列表
  124. list: [],
  125. selected: [],
  126. }
  127. },
  128. created() {
  129. this.getHospitaldeplist();
  130. this.getdeplist();
  131. this.getDicts("sys_doc_position").then(response => {
  132. this.positionOptions = response.data;
  133. });
  134. this.handleQuery()
  135. },
  136. methods: {
  137. handleQuery() {
  138. this.queryParams.pageNum = 1
  139. this.getList()
  140. },
  141. resetQuery() {
  142. this.queryParams = {
  143. pageNum: 1,
  144. pageSize: 10,
  145. doctorName: null,
  146. hospitalId: null,
  147. deptId: null,
  148. position: null,
  149. mobile: null
  150. }
  151. this.handleQuery()
  152. },
  153. getList() {
  154. this.loading = true
  155. getChooseDoctorList(this.queryParams).then(response => {
  156. this.list = response.data.list
  157. this.total = response.data.total
  158. this.loading = false
  159. // 列表加载后,根据传入的 videoIds 自动选中
  160. this.$nextTick(() => this.restoreSelection())
  161. })
  162. },
  163. /** 查询医院列表 */
  164. getHospitaldeplist() {
  165. listAllHospital().then(response => {
  166. this.hospitalList = response.rows;
  167. });
  168. },
  169. /** 查询科室列表 */
  170. getdeplist() {
  171. listDepartment().then(response => {
  172. this.depList = response.rows;
  173. });
  174. },
  175. handleSelectionChange(selection) {
  176. this.selected = selection
  177. },
  178. cancel() {
  179. this.$emit('closeChoose')
  180. },
  181. submit() {
  182. this.$emit('selectConfirm', this.selected)
  183. },
  184. // 恢复勾选状态
  185. restoreSelection() {
  186. const tableRef = this.$refs.doctorTable
  187. if (!tableRef || !Array.isArray(this.list) || !Array.isArray(this.doctorIds)) return
  188. tableRef.clearSelection()
  189. if (this.doctorIds.length === 0) return
  190. const idsSet = new Set(this.doctorIds)
  191. this.list.forEach(row => {
  192. if (row && idsSet.has(row.doctorId)) {
  193. tableRef.toggleRowSelection(row, true)
  194. }
  195. })
  196. }
  197. },
  198. }
  199. </script>
  200. <style scoped>
  201. .footer-button {
  202. display: flex;
  203. justify-content: flex-end;
  204. margin-top: 40px;
  205. }
  206. </style>