Hospital.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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="resetFildF(scope.row)"
  45. v-if="scope.row.id !== -1"
  46. :style="scope.row.id !== -1? 'color: #48c5d7;' : 'color: #bfbfbf;'"
  47. type="text"
  48. size="small"
  49. >方案重置</el-button>
  50. <el-button type="text" size="small" v-else disabled>方案重置</el-button>
  51. <!-- <span style="margin:0 3px;">|</span>
  52. <el-button
  53. @click="startOrEndHos(scope.row,'start')"
  54. type="text"
  55. size="small"
  56. v-if="scope.row.status === 0"
  57. >启用</el-button>
  58. <el-button
  59. @click="startOrEndHos(scope.row,'end')"
  60. class="delete"
  61. type="text"
  62. size="small"
  63. v-if="scope.row.status === 1"
  64. >禁用</el-button> -->
  65. <span style="margin:0 3px;">|</span>
  66. <el-button @click="showDelDialog(scope.row)" class="delete" type="text" size="small">删除</el-button>
  67. </template>
  68. </el-table-column>
  69. </el-table>
  70. <div class="pagination pagepage">
  71. <el-pagination
  72. :current-page.sync="currentPage"
  73. @current-change="currentChange"
  74. background
  75. :page-size="pageSize"
  76. :page-sizes="pageSizeArr"
  77. @size-change="handleSizeChange"
  78. :layout="pageLayout"
  79. :total="total"
  80. ></el-pagination>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <script>
  86. import api from "@api/cdss.js";
  87. import config from "@api/config.js";
  88. import utils from "@api/utils.js";
  89. export default {
  90. name: "HospitalCDSS",
  91. data: function() {
  92. return {
  93. list: [],
  94. searched: false,
  95. filter: {
  96. hospitalName: "" // 医院名称
  97. },
  98. currentPage: 1,
  99. pageSize: config.pageSize,
  100. pageSizeArr: config.pageSizeArr,
  101. pageLayout: config.pageLayout,
  102. total: 0,
  103. HospitalInfoList: []
  104. };
  105. },
  106. created() {
  107. const that = this;
  108. //返回时避免参数未赋值就获取列表
  109. setTimeout(function() {
  110. that.getDataList();
  111. });
  112. // 非首页 编辑页返回 设置 this.currentPage
  113. if (Object.keys(this.$route.params).length !== 0) {
  114. this.currentPage = this.$route.params.currentPage;
  115. }
  116. this._getHospitalInfo();
  117. },
  118. watch: {
  119. filter: {
  120. handler: function() {
  121. this.searched = false;
  122. },
  123. deep: true
  124. }
  125. },
  126. beforeRouteEnter(to, from, next) {
  127. next(vm => {
  128. //const pm = to.param;
  129. Object.assign(vm, to.params);
  130. vm.inCurrentPage = to.params.currentPage;
  131. });
  132. },
  133. methods: {
  134. handleSizeChange(val) {
  135. this.pageSize = val;
  136. this.currentPage = utils.getCurrentPage(
  137. this.currentPage,
  138. this.total,
  139. this.pageSize
  140. );
  141. this.getDataList();
  142. },
  143. // 启用/禁用医院
  144. startOrEndHos(row, type) {
  145. let msg = "";
  146. let status = 1;
  147. if (type === "start") {
  148. msg = `确定要启用${row.name}吗?`;
  149. status = 1;
  150. } else {
  151. msg = `确定要禁用${row.name}吗?`;
  152. status = 0;
  153. }
  154. this.$alert(msg, "提示", {
  155. confirmButtonText: "确定",
  156. type: "warning"
  157. })
  158. .then(() => {
  159. api
  160. .changeStatusCDSS({
  161. id: row.id,
  162. status: status
  163. })
  164. .then(res => {
  165. if (res.data.code === "0") {
  166. this.getDataList();
  167. this.$message({
  168. showClose: true,
  169. message: "保存成功",
  170. type: "success",
  171. duration: 1000
  172. });
  173. }
  174. });
  175. })
  176. .catch(() => {});
  177. },
  178. // 获取列表数据
  179. getDataList(isTurnPage) {
  180. const params = this.getFilterItems(isTurnPage);
  181. this.searched = true;
  182. const loading = this.$loading({
  183. lock: true,
  184. text: "Loading",
  185. spinner: "el-icon-loading",
  186. background: "rgba(0, 0, 0, 0.7)"
  187. });
  188. api.getHospitalPageCDSS(params).then(res => {
  189. loading.close();
  190. console.log('数据列表???', res);
  191. if (res.data.code === "0") {
  192. this.list = res.data.data && res.data.data.records;
  193. }
  194. this.total = res.data.data && res.data.data.total;
  195. if (this.inCurrentPage !== undefined) {
  196. this.currentPage = this.inCurrentPage;
  197. this.inCurrentPage = undefined;
  198. }
  199. });
  200. },
  201. // 处理列表请求数据参数
  202. getFilterItems(isTurnPage) {
  203. const { data } = this.$route.params;
  204. //翻页时筛选条件没点确定则清空
  205. if (isTurnPage && !this.searched) {
  206. this.clearFilter();
  207. }
  208. const param = {
  209. current: this.inCurrentPage || this.currentPage,
  210. size: this.pageSize,
  211. name: this.filter.hospitalName.trim().replace(/%/g,"\\%").replace(/_/g,"\\_")
  212. };
  213. return param;
  214. },
  215. // 获取医院下拉列表
  216. _getHospitalInfo() {
  217. api.getHospitalInfo().then(res => {
  218. if (res.data.code === "0") {
  219. this.HospitalInfoList = res.data.data;
  220. }
  221. });
  222. },
  223. filterDatas() {
  224. this.currentPage = 1;
  225. this.getDataList();
  226. },
  227. addRelation() {
  228. const pam = this.searched
  229. ? {
  230. currentPage: this.currentPage,
  231. pageSize: this.pageSize,
  232. filter: this.filter
  233. }
  234. : { currentPage: this.currentPage, pageSize: this.pageSize };
  235. this.$router.push({
  236. name: "AddHospitalCDSS",
  237. params: Object.assign(pam, {
  238. isEdit: false
  239. })
  240. });
  241. },
  242. // 修改诊断关联-跳转至编辑页面
  243. modifyRelation(row) {
  244. const item = Object.assign({}, row);
  245. const pam = this.searched
  246. ? {
  247. currentPage: this.currentPage,
  248. pageSize: this.pageSize,
  249. filter: this.filter
  250. }
  251. : { currentPage: this.currentPage, pageSize: this.pageSize };
  252. this.$router.push({
  253. name: "AddHospitalCDSS",
  254. params: Object.assign(pam, {
  255. isEdit: true,
  256. data: { ...item }
  257. // hospitaiName: this.hospitaiName
  258. })
  259. });
  260. },
  261. currentChange(next) {
  262. this.currentPage = next;
  263. this.getDataList(true);
  264. },
  265. // 清空搜索参数
  266. clearFilter() {
  267. this.filter = {
  268. hospitalName: ""
  269. };
  270. },
  271. indexMethod(index) {
  272. return (this.currentPage - 1) * this.pageSize + index + 1;
  273. },
  274. getTagType(val) {
  275. return val;
  276. },
  277. warning(msg, type) {
  278. this.$message({
  279. showClose: true,
  280. message: msg,
  281. type: type || "warning"
  282. });
  283. },
  284. showConfirmDialog(msg, resolve) {
  285. this.$alert(msg, "提示", {
  286. confirmButtonText: "删除",
  287. // cancelButtonText: '取消',
  288. // cancelButtonClass: 'cancelBtn',
  289. // confirmButtonClass: 'confirmC',
  290. type: "warning"
  291. })
  292. .then(() => {
  293. resolve();
  294. })
  295. .catch(() => {});
  296. },
  297. // 删除关联
  298. showDelDialog(row) {
  299. // console.log(row); return
  300. this.showConfirmDialog(
  301. `医院删除后无法恢复,确定要删除${row.name}吗?`,
  302. () => {
  303. api
  304. .deleteHosRecordCDSS({ id: row.id })
  305. .then(res => {
  306. // console.log(res, '=============');
  307. if (res.data.code == "0") {
  308. if (!this.searched) {
  309. //未点确认时清空搜索条件
  310. this.clearFilter();
  311. }
  312. if (this.list.length == 1) {
  313. //当前在最后一页且只有一条数据时,删除后跳到前一页
  314. this.currentPage =
  315. this.currentPage === 1 ? 1 : this.currentPage - 1;
  316. }
  317. this.getDataList();
  318. this._getHospitalInfo(); // 更新下拉列表
  319. this.warning(res.data.msg || "操作成功", "success");
  320. } else {
  321. this.warning(res.data.msg);
  322. }
  323. })
  324. .catch(error => {
  325. if (error.code === "900010001") {
  326. return false;
  327. }
  328. this.warning(error);
  329. });
  330. }
  331. );
  332. },
  333. // 方案重置
  334. resetFildF(row) {
  335. this.$confirm(`此操作将重置${row.name}数据, 是否继续?`, "提示", {
  336. confirmButtonText: "确定",
  337. cancelButtonText: "取消",
  338. type: "warning"
  339. })
  340. .then(() => {
  341. api.getResetFildF({
  342. hospitalId: row.id
  343. }).then(res => {
  344. console.log("重置数据", res);
  345. const tokenStr = JSON.parse(localStorage.getItem("token"));
  346. if (res.data.code === "0" && tokenStr) {
  347. this.getDataList();
  348. this.$message({
  349. showClose: true,
  350. message: "重置成功",
  351. type: "success",
  352. duration: 1000
  353. });
  354. }
  355. });
  356. })
  357. .catch(() => {
  358. this.$message({
  359. type: "info",
  360. message: "已取消重置"
  361. });
  362. });
  363. }
  364. }
  365. };
  366. </script>
  367. <style lang="less" scoped>
  368. @import "../../../less/admin.less";
  369. .delete {
  370. color: red;
  371. }
  372. .delete:hover {
  373. color: red;
  374. }
  375. .pagination {
  376. min-width: 1010px;
  377. }
  378. .downTemplate {
  379. margin-right: 8px;
  380. span {
  381. color: #02a7f0;
  382. }
  383. }
  384. #upFile {
  385. display: none !important;
  386. }
  387. .el-message-box {
  388. /deep/.cancelBtn {
  389. background-color: #d7d7d7;
  390. border-color: transparent;
  391. }
  392. /deep/.confirmC {
  393. background-color: #ff545b !important;
  394. border-color: transparent !important;
  395. }
  396. }
  397. .exportBox6 {
  398. /deep/ .el-message-box__btns {
  399. margin-top: 20px;
  400. }
  401. /deep/ .el-message-box__message {
  402. // text-align: center;
  403. }
  404. /deep/.leftbtn {
  405. background-color: #d7d7d7;
  406. border-color: transparent !important;
  407. }
  408. /deep/ .el-message-box__header {
  409. border-bottom: 1px solid #dcdfe6;
  410. }
  411. }
  412. </style>