tcmdrome.vue 16 KB

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