DeptManage.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div>
  3. <crumbs :title="title + hospitaiName" linkTo="MedicalTermCDSS" style="min-width: 1096px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item>
  6. <el-button type="text" class="downTemplate" @click="exportModule">导入模板下载</el-button>
  7. <input
  8. type="file"
  9. name="uploadfile "
  10. id="upFile"
  11. @change="uploadFile($event)"
  12. accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  13. />
  14. <el-button size="mini" @click="importPage">{{uploadInfo}}</el-button>
  15. <el-button size="mini" @click="exportData">导出</el-button>
  16. </el-form-item>
  17. <el-form-item label="医院科室名称:">
  18. <el-input size="mini" v-model="filter.hisName" placeholder="请输入" clearable></el-input>
  19. </el-form-item>
  20. <el-form-item label="标准科室名称:">
  21. <el-input size="mini" v-model="filter.uniqueName" placeholder="请输入" clearable></el-input>
  22. </el-form-item>
  23. <el-form-item class="dododo">
  24. <el-button size="mini" @click="filterDatas">检索</el-button>
  25. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  26. </el-form-item>
  27. </el-form>
  28. </crumbs>
  29. <div class="contents">
  30. <el-table :data="list" border style="width: 100%">
  31. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="80"></el-table-column>
  32. <el-table-column :resizable="false" prop="gmtModified" label="操作时间" width="180"></el-table-column>
  33. <el-table-column :resizable="false" prop="hisCode" label="医院科室编码" show-overflow-tooltip></el-table-column>
  34. <el-table-column :resizable="false" prop="hisName" label="医院科室名称" show-overflow-tooltip></el-table-column>
  35. <el-table-column :resizable="false" prop="uniqueName" label="标准科室名称" show-overflow-tooltip></el-table-column>
  36. <el-table-column :resizable="false" prop="operate" label="操作">
  37. <template slot-scope="scope">
  38. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  39. <span style="margin:0 3px;">|</span>
  40. <el-button
  41. @click="showDelDialog(scope.row.id)"
  42. class="delete"
  43. type="text"
  44. size="small"
  45. >删除</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <div class="pagination pagepage">
  50. <el-pagination
  51. :current-page.sync="currentPage"
  52. @current-change="currentChange"
  53. background
  54. :page-size="pageSize"
  55. :page-sizes="pageSizeArr"
  56. @size-change="handleSizeChange"
  57. :layout="pageLayout"
  58. :total="total"
  59. ></el-pagination>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import api from '@api/cdss.js';
  66. import config from '@api/config.js';
  67. import utils from '@api/utils.js';
  68. export default {
  69. name: 'DeptManage',
  70. data: function() {
  71. return {
  72. list: [],
  73. searched: false,
  74. filter: {
  75. hisName: '', // 医院诊断名称
  76. uniqueName: '' //标准诊断名称
  77. },
  78. currentPage: 1,
  79. pageSize: config.pageSize,
  80. pageSizeArr: config.pageSizeArr,
  81. pageLayout: config.pageLayout,
  82. total: 0,
  83. fileName: '',
  84. formData: {},
  85. headers: {},
  86. uploadInfo: '导入',
  87. title: '科室关联维护 | ',
  88. hospitaiName: '',
  89. hospitalId: ''
  90. };
  91. },
  92. created() {
  93. const { data } = this.$route.params;
  94. this.hospitaiName = (data && data.name) || '';
  95. this.hospitalId = data && data.hospitalId;
  96. const that = this;
  97. //返回时避免参数未赋值就获取列表
  98. setTimeout(function() {
  99. that.getDataList();
  100. });
  101. // 非首页 编辑页返回 设置 this.currentPage
  102. if (Object.keys(this.$route.params).length !== 0) {
  103. this.currentPage = this.$route.params.currentPage;
  104. }
  105. },
  106. watch: {
  107. filter: {
  108. handler: function() {
  109. this.searched = false;
  110. },
  111. deep: true
  112. }
  113. },
  114. beforeRouteEnter(to, from, next) {
  115. next(vm => {
  116. //const pm = to.param;
  117. Object.assign(vm, to.params);
  118. vm.inCurrentPage = to.params.currentPage;
  119. });
  120. },
  121. methods: {
  122. handleSizeChange(val) {
  123. this.pageSize = val;
  124. this.currentPage = utils.getCurrentPage(
  125. this.currentPage,
  126. this.total,
  127. this.pageSize
  128. );
  129. this.getDataList();
  130. },
  131. // 获取列表数据
  132. getDataList(isTurnPage) {
  133. const params = this.getFilterItems(isTurnPage);
  134. this.searched = true;
  135. const loading = this.$loading({
  136. lock: true,
  137. text: 'Loading',
  138. spinner: 'el-icon-loading',
  139. background: 'rgba(0, 0, 0, 0.7)'
  140. });
  141. api.getDeptPage(params).then(res => {
  142. loading.close();
  143. if (res.data.code === '0') {
  144. this.list = res.data.data && res.data.data.records;
  145. }
  146. this.total = res.data.data && res.data.data.total;
  147. if (this.inCurrentPage !== undefined) {
  148. this.currentPage = this.inCurrentPage;
  149. this.inCurrentPage = undefined;
  150. }
  151. });
  152. },
  153. // 处理列表请求数据参数
  154. getFilterItems(isTurnPage) {
  155. const { data } = this.$route.params;
  156. //翻页时筛选条件没点确定则清空
  157. if (isTurnPage && !this.searched) {
  158. this.clearFilter();
  159. }
  160. const param = {
  161. current: this.inCurrentPage || this.currentPage,
  162. size: this.pageSize,
  163. hisName: this.filter.hisName.trim(),
  164. uniqueName: this.filter.uniqueName.trim(),
  165. uniqueCode: '',
  166. hospitalId: data && data.hospitalId
  167. };
  168. return param;
  169. },
  170. filterDatas() {
  171. this.currentPage = 1;
  172. this.getDataList();
  173. },
  174. addRelation() {
  175. const pam = this.searched
  176. ? {
  177. currentPage: this.currentPage,
  178. pageSize: this.pageSize,
  179. filter: this.filter
  180. }
  181. : { currentPage: this.currentPage, pageSize: this.pageSize };
  182. this.$router.push({
  183. name: 'AddDept',
  184. params: Object.assign(pam, {
  185. isEdit: false,
  186. data: { hospitalId: this.hospitalId },
  187. hospitaiName: this.hospitaiName
  188. })
  189. });
  190. },
  191. // 修改诊断关联-跳转至编辑页面
  192. modifyRelation(row) {
  193. const item = Object.assign({}, row);
  194. const pam = this.searched
  195. ? {
  196. currentPage: this.currentPage,
  197. pageSize: this.pageSize,
  198. filter: this.filter
  199. }
  200. : { currentPage: this.currentPage, pageSize: this.pageSize };
  201. this.$router.push({
  202. name: 'AddDept',
  203. params: Object.assign(pam, {
  204. isEdit: true,
  205. data: {...item, hospitalId: this.hospitalId},
  206. hospitaiName: this.hospitaiName
  207. })
  208. });
  209. },
  210. currentChange(next) {
  211. this.currentPage = next;
  212. this.getDataList(true);
  213. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  214. // this.list = this.cacheData[next];
  215. // } else {
  216. // this.getDataList();
  217. // }
  218. },
  219. // 清空搜索参数
  220. clearFilter() {
  221. this.filter = {
  222. hisName: '',
  223. uniqueName: ''
  224. };
  225. },
  226. indexMethod(index) {
  227. return (this.currentPage - 1) * this.pageSize + index + 1;
  228. },
  229. getTagType(val) {
  230. return val;
  231. },
  232. warning(msg, type) {
  233. this.$message({
  234. showClose: true,
  235. message: msg,
  236. type: type || 'warning'
  237. });
  238. },
  239. showConfirmDialog(msg, resolve) {
  240. this.$alert(msg, '提示', {
  241. confirmButtonText: '删除',
  242. // cancelButtonText: '取消',
  243. // cancelButtonClass: 'cancelBtn',
  244. // confirmButtonClass: 'confirmC',
  245. type: 'warning'
  246. })
  247. .then(() => {
  248. resolve();
  249. })
  250. .catch(() => {});
  251. },
  252. // 删除关联
  253. showDelDialog(id) {
  254. this.showConfirmDialog('是否删除该关联?', () => {
  255. api
  256. .deleteDeptRecord({ id: id })
  257. .then(res => {
  258. if (res.data.code == '0') {
  259. if (!this.searched) {
  260. //未点确认时清空搜索条件
  261. this.clearFilter();
  262. }
  263. if (this.list.length == 1) {
  264. //当前在最后一页且只有一条数据时,删除后跳到前一页
  265. this.currentPage =
  266. this.currentPage === 1 ? 1 : this.currentPage - 1;
  267. }
  268. this.getDataList();
  269. this.warning(res.data.msg || '操作成功', 'success');
  270. } else {
  271. this.warning(res.data.msg);
  272. }
  273. })
  274. .catch(error => {
  275. if (error.code === '900010001') {
  276. return false;
  277. }
  278. this.warning(error);
  279. });
  280. });
  281. },
  282. // 导出数据
  283. exportData() {
  284. this.$alert('确定要导出全部科室关联数据吗?', '', {
  285. confirmButtonText: '确定',
  286. // cancelButtonText: '取消',
  287. // cancelButtonClass: 'leftbtn',
  288. // customClass: 'exportBox6',
  289. title: '提示',
  290. type: 'warning'
  291. // beforeClose: (action, instance, done) => {
  292. // if (action === 'confirm') {
  293. // // instance.confirmButtonLoading = true;
  294. // // instance.confirmButtonText = '导出中...';
  295. // done()
  296. // api.exportDeptRecord().then(res => {
  297. // if (res.status === 200) {
  298. // setTimeout(() => {
  299. // utils.downloadExportedData(res.data, '科室关联数据.xls');
  300. // // done();
  301. // }, 1500);
  302. // }
  303. // });
  304. // } else {
  305. // done();
  306. // }
  307. // }
  308. })
  309. .then(() => {
  310. api.exportDeptRecord({ hospitalId: this.hospitalId }).then(res => {
  311. if (res.status === 200) {
  312. this.$message({ message: '导出成功', type: 'success' });
  313. utils.downloadExportedData(res.data, '科室关联数据.xls');
  314. }
  315. });
  316. })
  317. .catch(() => {});
  318. },
  319. // 导入模板
  320. exportModule() {
  321. api.exportDeptModule().then(res => {
  322. if (res.status === 200) {
  323. setTimeout(() => {
  324. utils.downloadExportedData(res.data, '科室导入模板.xls');
  325. }, 1500);
  326. }
  327. });
  328. },
  329. // 点击导入
  330. importPage() {
  331. let inp = document.getElementById('upFile');
  332. inp.click();
  333. },
  334. // 导入数据
  335. uploadFile(e) {
  336. let fileInfo = e.target.files[0];
  337. // this.fileName = e.target.files[0].name; // 表单同步显示
  338. e.preventDefault();
  339. let formData = new FormData();
  340. formData.append('file', fileInfo);
  341. const header = {
  342. headers: {
  343. 'Content-Type': 'multipart/form-data'
  344. }
  345. };
  346. this.uploadInfo = '导入中...';
  347. api.importDeptRecord(formData, header).then(res => {
  348. // console.log('导入文件结果', '===================', res);
  349. if (res.data.code === '00000001') {
  350. this.$alert(`数据存在异常,导入失败,请修改后再试`, '提示', {
  351. confirmButtonText: '确定',
  352. // cancelButtonText: '取消',
  353. // cancelButtonClass: 'cancelSure',
  354. // confirmButtonClass: 'sure',
  355. // customClass: 'exportConfirm',
  356. type: 'warning'
  357. })
  358. .then(() => {})
  359. .catch(() => {});
  360. this.getDataList(); // 重新获取列表
  361. setTimeout(() => {
  362. this.uploadInfo = '导入';
  363. }, 300);
  364. } else if (res.data === '' && res.status === 200) {
  365. this.$alert(`导入成功`, '提示', {
  366. confirmButtonText: '确定',
  367. // cancelButtonText: '取消',
  368. // cancelButtonClass: 'cancelSure',
  369. // confirmButtonClass: 'sure',
  370. // customClass: 'exportConfirm',
  371. type: 'warning'
  372. })
  373. .then(() => {})
  374. .catch(() => {});
  375. this.getDataList(); // 重新获取列表
  376. setTimeout(() => {
  377. this.uploadInfo = '导入';
  378. }, 300);
  379. } else {
  380. this.$alert(`${res.data.msg}`, '提示', {
  381. confirmButtonText: '确定',
  382. // cancelButtonText: '取消',
  383. // cancelButtonClass: 'cancelSure',
  384. // confirmButtonClass: 'sure',
  385. // customClass: 'exportConfirm',
  386. type: 'warning'
  387. })
  388. .then(() => {})
  389. .catch(() => {});
  390. setTimeout(() => {
  391. this.uploadInfo = '导入';
  392. }, 300);
  393. }
  394. });
  395. //解决上传相同文件不触发change
  396. let inp = document.getElementById('upFile');
  397. inp.value = '';
  398. }
  399. }
  400. };
  401. </script>
  402. <style lang="less" scoped>
  403. @import '../../../less/admin.less';
  404. .delete {
  405. color: red;
  406. }
  407. .delete:hover {
  408. color: red;
  409. }
  410. .pagination {
  411. min-width: 1010px;
  412. }
  413. .downTemplate {
  414. margin-right: 8px;
  415. span {
  416. color: #02a7f0;
  417. }
  418. }
  419. #upFile {
  420. display: none;
  421. }
  422. .el-message-box {
  423. /deep/.cancelBtn {
  424. background-color: #d7d7d7;
  425. border-color: transparent;
  426. }
  427. /deep/.confirmC {
  428. background-color: #ff545b !important;
  429. border-color: transparent !important;
  430. }
  431. /deep/.el-message-box__header {
  432. border-bottom: 1px solid #dcdfe6;
  433. }
  434. }
  435. .exportBox6 {
  436. /deep/ .el-message-box__btns {
  437. margin-top: 20px;
  438. }
  439. /deep/ .el-message-box__message {
  440. // text-align: center;
  441. }
  442. /deep/.leftbtn {
  443. background-color: #d7d7d7;
  444. border-color: transparent !important;
  445. }
  446. /deep/ .el-message-box__header {
  447. border-bottom: 1px solid #dcdfe6;
  448. }
  449. }
  450. .exportConfirm {
  451. .cancelSure {
  452. display: none;
  453. }
  454. }
  455. </style>