Hospital.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <div>
  3. <crumbs title="医院管理" style="min-width: 960px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="医院名称:" class="selectMedicine">
  6. <el-select size="mini" v-model="filter.hospitalName" placeholder="请选择" clearable>
  7. <el-option
  8. v-for="item in HospitalInfoList"
  9. :label="item.name"
  10. :value="item.name"
  11. :key="item.id"
  12. ></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item class="dododo">
  16. <el-button size="mini" @click="filterDatas">检索</el-button>
  17. <el-button size="mini" type="warning" @click="addRelation">添加医院</el-button>
  18. </el-form-item>
  19. </el-form>
  20. </crumbs>
  21. <div class="contents">
  22. <el-table :data="list" border style="width: 100%">
  23. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="60"></el-table-column>
  24. <el-table-column :resizable="false" prop="id" label="医院ID"></el-table-column>
  25. <el-table-column :resizable="false" prop="name" label="医院名称" show-overflow-tooltip></el-table-column>
  26. <el-table-column :resizable="false" prop="spell" label="医院名称拼音" show-overflow-tooltip></el-table-column>
  27. <el-table-column :resizable="false" prop="sonHospital" label="关联子医院" show-overflow-tooltip></el-table-column>
  28. <el-table-column :resizable="false" prop="address" label="医院地址" show-overflow-tooltip></el-table-column>
  29. <el-table-column :resizable="false" prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column>
  30. <!-- <el-table-column
  31. :resizable="false"
  32. prop="status"
  33. label="状态"
  34. show-overflow-tooltip
  35. width="180"
  36. >
  37. <template slot-scope="scope">{{scope.row.status == 1 ? '已启用': '已禁用'}}</template>
  38. </el-table-column> -->
  39. <el-table-column :resizable="false" prop="operate" label="操作">
  40. <template slot-scope="scope">
  41. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  42. <!-- <span style="margin:0 3px;">|</span>
  43. <el-button
  44. @click="startOrEndHos(scope.row,'start')"
  45. type="text"
  46. size="small"
  47. v-if="scope.row.status === 0"
  48. >启用</el-button>
  49. <el-button
  50. @click="startOrEndHos(scope.row,'end')"
  51. class="delete"
  52. type="text"
  53. size="small"
  54. v-if="scope.row.status === 1"
  55. >禁用</el-button> -->
  56. <span style="margin:0 3px;">|</span>
  57. <el-button @click="showDelDialog(scope.row)" class="delete" type="text" size="small">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. <div class="pagination pagepage">
  62. <el-pagination
  63. :current-page.sync="currentPage"
  64. @current-change="currentChange"
  65. background
  66. :page-size="pageSize"
  67. :page-sizes="pageSizeArr"
  68. @size-change="handleSizeChange"
  69. :layout="pageLayout"
  70. :total="total"
  71. ></el-pagination>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import api from '@api/cdss.js';
  78. import config from '@api/config.js';
  79. import utils from '@api/utils.js';
  80. export default {
  81. name: 'HospitalCDSS',
  82. data: function() {
  83. return {
  84. list: [],
  85. searched: false,
  86. filter: {
  87. hospitalName: '' // 医院名称
  88. },
  89. currentPage: 1,
  90. pageSize: config.pageSize,
  91. pageSizeArr: config.pageSizeArr,
  92. pageLayout: config.pageLayout,
  93. total: 0,
  94. HospitalInfoList: []
  95. };
  96. },
  97. created() {
  98. const that = this;
  99. //返回时避免参数未赋值就获取列表
  100. setTimeout(function() {
  101. that.getDataList();
  102. });
  103. // 非首页 编辑页返回 设置 this.currentPage
  104. if (Object.keys(this.$route.params).length !== 0) {
  105. this.currentPage = this.$route.params.currentPage;
  106. }
  107. this._getHospitalInfo();
  108. },
  109. watch: {
  110. filter: {
  111. handler: function() {
  112. this.searched = false;
  113. },
  114. deep: true
  115. }
  116. },
  117. beforeRouteEnter(to, from, next) {
  118. next(vm => {
  119. //const pm = to.param;
  120. Object.assign(vm, to.params);
  121. vm.inCurrentPage = to.params.currentPage;
  122. });
  123. },
  124. methods: {
  125. handleSizeChange(val) {
  126. this.pageSize = val;
  127. this.currentPage = utils.getCurrentPage(
  128. this.currentPage,
  129. this.total,
  130. this.pageSize
  131. );
  132. this.getDataList();
  133. },
  134. // 启用/禁用医院
  135. startOrEndHos(row, type) {
  136. let msg = '';
  137. let status = 1;
  138. if (type === 'start') {
  139. msg = `确定要启用${row.name}吗?`;
  140. status = 1;
  141. } else {
  142. msg = `确定要禁用${row.name}吗?`;
  143. status = 0;
  144. }
  145. this.$alert(msg, '提示', {
  146. confirmButtonText: '确定',
  147. type: 'warning'
  148. })
  149. .then(() => {
  150. api
  151. .changeStatusCDSS({
  152. id: row.id,
  153. status: status
  154. })
  155. .then(res => {
  156. if (res.data.code === '0') {
  157. this.getDataList();
  158. this.$message({
  159. showClose: true,
  160. message: '保存成功',
  161. type: 'success',
  162. duration: 1000
  163. });
  164. }
  165. });
  166. })
  167. .catch(() => {});
  168. },
  169. // 获取列表数据
  170. getDataList(isTurnPage) {
  171. const params = this.getFilterItems(isTurnPage);
  172. this.searched = true;
  173. const loading = this.$loading({
  174. lock: true,
  175. text: 'Loading',
  176. spinner: 'el-icon-loading',
  177. background: 'rgba(0, 0, 0, 0.7)'
  178. });
  179. api.getHospitalPageCDSS(params).then(res => {
  180. loading.close();
  181. if (res.data.code === '0') {
  182. this.list = res.data.data && res.data.data.records;
  183. }
  184. this.total = res.data.data && res.data.data.total;
  185. if (this.inCurrentPage !== undefined) {
  186. this.currentPage = this.inCurrentPage;
  187. this.inCurrentPage = undefined;
  188. }
  189. });
  190. },
  191. // 处理列表请求数据参数
  192. getFilterItems(isTurnPage) {
  193. const { data } = this.$route.params;
  194. //翻页时筛选条件没点确定则清空
  195. if (isTurnPage && !this.searched) {
  196. this.clearFilter();
  197. }
  198. const param = {
  199. current: this.inCurrentPage || this.currentPage,
  200. size: this.pageSize,
  201. name: this.filter.hospitalName.trim()
  202. };
  203. return param;
  204. },
  205. // 获取医院下拉列表
  206. _getHospitalInfo() {
  207. api.getHospitalInfo().then(res => {
  208. if (res.data.code === '0') {
  209. this.HospitalInfoList = res.data.data;
  210. }
  211. });
  212. },
  213. filterDatas() {
  214. this.currentPage = 1;
  215. this.getDataList();
  216. },
  217. addRelation() {
  218. const pam = this.searched
  219. ? {
  220. currentPage: this.currentPage,
  221. pageSize: this.pageSize,
  222. filter: this.filter
  223. }
  224. : { currentPage: this.currentPage, pageSize: this.pageSize };
  225. this.$router.push({
  226. name: 'AddHospitalCDSS',
  227. params: Object.assign(pam, {
  228. isEdit: false
  229. })
  230. });
  231. },
  232. // 修改诊断关联-跳转至编辑页面
  233. modifyRelation(row) {
  234. const item = Object.assign({}, row);
  235. const pam = this.searched
  236. ? {
  237. currentPage: this.currentPage,
  238. pageSize: this.pageSize,
  239. filter: this.filter
  240. }
  241. : { currentPage: this.currentPage, pageSize: this.pageSize };
  242. this.$router.push({
  243. name: 'AddHospitalCDSS',
  244. params: Object.assign(pam, {
  245. isEdit: true,
  246. data: { ...item }
  247. // hospitaiName: this.hospitaiName
  248. })
  249. });
  250. },
  251. currentChange(next) {
  252. this.currentPage = next;
  253. this.getDataList(true);
  254. },
  255. // 清空搜索参数
  256. clearFilter() {
  257. this.filter = {
  258. hospitalName: ''
  259. };
  260. },
  261. indexMethod(index) {
  262. return (this.currentPage - 1) * this.pageSize + index + 1;
  263. },
  264. getTagType(val) {
  265. return val;
  266. },
  267. warning(msg, type) {
  268. this.$message({
  269. showClose: true,
  270. message: msg,
  271. type: type || 'warning'
  272. });
  273. },
  274. showConfirmDialog(msg, resolve) {
  275. this.$alert(msg, '提示', {
  276. confirmButtonText: '删除',
  277. // cancelButtonText: '取消',
  278. // cancelButtonClass: 'cancelBtn',
  279. // confirmButtonClass: 'confirmC',
  280. type: 'warning'
  281. })
  282. .then(() => {
  283. resolve();
  284. })
  285. .catch(() => {});
  286. },
  287. // 删除关联
  288. showDelDialog(row) {
  289. // console.log(row); return
  290. this.showConfirmDialog(`医院删除后无法恢复,确定要删除${row.name}吗?`, () => {
  291. api
  292. .deleteHosRecordCDSS({ id: row.id })
  293. .then(res => {
  294. // console.log(res, '=============');
  295. if (res.data.code == '0') {
  296. if (!this.searched) {
  297. //未点确认时清空搜索条件
  298. this.clearFilter();
  299. }
  300. if (this.list.length == 1) {
  301. //当前在最后一页且只有一条数据时,删除后跳到前一页
  302. this.currentPage =
  303. this.currentPage === 1 ? 1 : this.currentPage - 1;
  304. }
  305. this.getDataList();
  306. this._getHospitalInfo(); // 更新下拉列表
  307. this.warning(res.data.msg || '操作成功', 'success');
  308. } else {
  309. this.warning(res.data.msg);
  310. }
  311. })
  312. .catch(error => {
  313. if (error.code === '900010001') {
  314. return false;
  315. }
  316. this.warning(error);
  317. });
  318. });
  319. }
  320. }
  321. };
  322. </script>
  323. <style lang="less" scoped>
  324. @import '../../../less/admin.less';
  325. .delete {
  326. color: red;
  327. }
  328. .delete:hover {
  329. color: red;
  330. }
  331. .pagination {
  332. min-width: 1010px;
  333. }
  334. .downTemplate {
  335. margin-right: 8px;
  336. span {
  337. color: #02a7f0;
  338. }
  339. }
  340. #upFile {
  341. display: none !important;
  342. }
  343. .el-message-box {
  344. /deep/.cancelBtn {
  345. background-color: #d7d7d7;
  346. border-color: transparent;
  347. }
  348. /deep/.confirmC {
  349. background-color: #ff545b !important;
  350. border-color: transparent !important;
  351. }
  352. }
  353. .exportBox6 {
  354. /deep/ .el-message-box__btns {
  355. margin-top: 20px;
  356. }
  357. /deep/ .el-message-box__message {
  358. // text-align: center;
  359. }
  360. /deep/.leftbtn {
  361. background-color: #d7d7d7;
  362. border-color: transparent !important;
  363. }
  364. /deep/ .el-message-box__header {
  365. border-bottom: 1px solid #dcdfe6;
  366. }
  367. }
  368. </style>