DrugManage.vue 19 KB

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