ScaleManage.vue 21 KB

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