tcmdrome.vue 19 KB

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