Fusion.vue 15 KB

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