Fusion.vue 21 KB

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