Fusion.vue 18 KB

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