ScaleManage.vue 21 KB

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