ScaleManage.vue 16 KB

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