DrugManage.vue 16 KB

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