DeptManage.vue 16 KB

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