DeptManage.vue 21 KB

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