DeptManage.vue 18 KB

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