ScaleManage.vue 15 KB

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