DeptManage.vue 17 KB

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