DeptManage.vue 17 KB

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