DeptManage.vue 19 KB

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