ScaleManage.vue 19 KB

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