Fusion.vue 20 KB

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