tcmdisease.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div>
  3. <crumbs title="中医疾病关联维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item>
  6. <el-button type="text" class="downTemplate" @click="exportModule">导入模板下载</el-button>
  7. <input
  8. type="file"
  9. name="uploadfile "
  10. id="upFile"
  11. @change="uploadFile($event)"
  12. />
  13. <!-- accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" -->
  14. <el-button size="mini" @click="importPage">{{uploadInfo}}</el-button>
  15. <el-button size="mini" @click="exportData">导出</el-button>
  16. </el-form-item>
  17. <el-form-item label="医院中医疾病名称:">
  18. <el-input size="mini" v-model="filter.hisName" placeholder="请输入" clearable></el-input>
  19. </el-form-item>
  20. <el-form-item label="标准中医疾病名称:">
  21. <el-input size="mini" v-model="filter.uniqueName" placeholder="请输入" clearable></el-input>
  22. </el-form-item>
  23. <el-form-item class="dododo">
  24. <el-button size="mini" @click="filterDatas">检索</el-button>
  25. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  26. </el-form-item>
  27. </el-form>
  28. </crumbs>
  29. <div class="contents">
  30. <el-table :data="list" border style="width: 100%">
  31. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="80"></el-table-column>
  32. <el-table-column :resizable="false" prop="gmtModified" label="操作时间" width="180"></el-table-column>
  33. <el-table-column :resizable="false" prop="hisName" label="医院中医疾病名称" show-overflow-tooltip></el-table-column>
  34. <el-table-column :resizable="false" prop="uniqueCode" label="中医疾病代码" show-overflow-tooltip></el-table-column>
  35. <el-table-column :resizable="false" prop="uniqueName" label="标准中医疾病名称" show-overflow-tooltip></el-table-column>
  36. <el-table-column :resizable="false" prop="operate" label="操作">
  37. <template slot-scope="scope">
  38. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  39. <span style="margin:0 3px;">|</span>
  40. <el-button
  41. @click="showDelDialog(scope.row.id)"
  42. class="delete"
  43. type="text"
  44. size="small"
  45. >删除</el-button>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <div class="pagination pagepage">
  50. <el-pagination
  51. :current-page.sync="currentPage"
  52. @current-change="currentChange"
  53. background
  54. :page-size="pageSize"
  55. :page-sizes="pageSizeArr"
  56. @size-change="handleSizeChange"
  57. :layout="pageLayout"
  58. :total="total"
  59. ></el-pagination>
  60. </div>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. import api from '@api/icss.js';
  66. import config from '@api/config.js';
  67. import utils from '@api/utils.js';
  68. export default {
  69. name: 'Tcmdisease',
  70. data: function() {
  71. return {
  72. list: [],
  73. searched: false,
  74. filter: {
  75. hisName: '', // 医院诊断名称
  76. uniqueName: '' //标准诊断名称
  77. },
  78. currentPage: 1,
  79. pageSize: config.pageSize,
  80. pageSizeArr: config.pageSizeArr,
  81. pageLayout: config.pageLayout,
  82. total: 0,
  83. fileName: '',
  84. formData: {},
  85. headers: {},
  86. uploadInfo: '导入'
  87. };
  88. },
  89. created() {
  90. const param = this.$route.params;
  91. if(param.currentPage){
  92. this.inCurrentPage = param.currentPage
  93. }
  94. if(param.filter){
  95. this.filter = param.filter
  96. }
  97. //返回时避免参数未赋值就获取列表
  98. setTimeout(()=> {
  99. this.getDataList();
  100. });
  101. // 非首页 编辑页返回 设置 this.currentPage
  102. if (Object.keys(this.$route.params).length !== 0) {
  103. this.currentPage = this.$route.params.currentPage;
  104. }
  105. },
  106. watch: {
  107. filter: {
  108. handler: function() {
  109. this.searched = false;
  110. },
  111. deep: true
  112. }
  113. },
  114. methods: {
  115. handleSizeChange(val) {
  116. this.pageSize = val;
  117. this.currentPage = utils.getCurrentPage(
  118. this.currentPage,
  119. this.total,
  120. this.pageSize
  121. );
  122. this.getDataList();
  123. },
  124. // 获取列表数据
  125. getDataList(isTurnPage) {
  126. const params = this.getFilterItems(isTurnPage);
  127. this.searched = true;
  128. const loading = this.$loading({
  129. lock: true,
  130. text: 'Loading',
  131. spinner: 'el-icon-loading',
  132. background: 'rgba(0, 0, 0, 0.7)'
  133. });
  134. api.getTcmdiseasePage(params).then(res => {
  135. loading.close();
  136. if (res.data.code === '0') {
  137. this.list = res.data.data && res.data.data.records;
  138. }
  139. this.total = res.data.data && res.data.data.total;
  140. if (this.inCurrentPage !== undefined) {
  141. this.currentPage = this.inCurrentPage;
  142. this.inCurrentPage = undefined;
  143. }
  144. });
  145. },
  146. // 处理列表请求数据参数
  147. getFilterItems(isTurnPage) {
  148. //翻页时筛选条件没点确定则清空
  149. if (isTurnPage && !this.searched) {
  150. this.clearFilter();
  151. }
  152. const param = {
  153. current: this.inCurrentPage || this.currentPage,
  154. size: this.pageSize,
  155. hisName: this.filter.hisName.trim(),
  156. uniqueName: this.filter.uniqueName.trim(),
  157. uniqueCode: ''
  158. };
  159. return param;
  160. },
  161. filterDatas() {
  162. this.currentPage = 1;
  163. this.getDataList();
  164. },
  165. addRelation() {
  166. const pam = this.searched
  167. ? {
  168. currentPage: this.currentPage,
  169. pageSize: this.pageSize,
  170. filter: this.filter
  171. }
  172. : { currentPage: this.currentPage, pageSize: this.pageSize };
  173. this.$router.push({ name: 'AddTcmdisease', params: pam });
  174. },
  175. // 修改诊断关联-跳转至编辑页面
  176. modifyRelation(row) {
  177. const item = Object.assign({}, row);
  178. const pam = this.searched
  179. ? {
  180. currentPage: this.currentPage,
  181. pageSize: this.pageSize,
  182. filter: this.filter
  183. }
  184. : { currentPage: this.currentPage, pageSize: this.pageSize };
  185. this.$router.push({
  186. name: 'AddTcmdisease',
  187. params: Object.assign(pam, { isEdit: true, data: item })
  188. });
  189. },
  190. currentChange(next) {
  191. this.currentPage = next;
  192. this.getDataList(true);
  193. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  194. // this.list = this.cacheData[next];
  195. // } else {
  196. // this.getDataList();
  197. // }
  198. },
  199. // 清空搜索参数
  200. clearFilter() {
  201. this.filter = {
  202. hisName: '',
  203. uniqueName: ''
  204. };
  205. },
  206. indexMethod(index) {
  207. return (this.currentPage - 1) * this.pageSize + index + 1;
  208. },
  209. getTagType(val) {
  210. return val;
  211. },
  212. warning(msg, type) {
  213. this.$message({
  214. showClose: true,
  215. message: msg,
  216. type: type || 'warning'
  217. });
  218. },
  219. showConfirmDialog(msg, resolve) {
  220. this.$confirm(msg, '提示', {
  221. confirmButtonText: '删除',
  222. cancelButtonText: '取消',
  223. cancelButtonClass: 'cancelBtn',
  224. confirmButtonClass: 'confirmC',
  225. type: 'warning'
  226. })
  227. .then(() => {
  228. resolve();
  229. })
  230. .catch(() => {});
  231. },
  232. // 删除关联
  233. showDelDialog(id) {
  234. this.showConfirmDialog('是否删除该关联?', () => {
  235. api
  236. .deleteTcmRecord({ id: id })
  237. .then(res => {
  238. if (res.data.code == '0') {
  239. if (!this.searched) {
  240. //未点确认时清空搜索条件
  241. this.clearFilter();
  242. }
  243. if (this.list.length == 1) {
  244. //当前在最后一页且只有一条数据时,删除后跳到前一页
  245. this.currentPage =
  246. this.currentPage === 1 ? 1 : this.currentPage - 1;
  247. }
  248. this.getDataList();
  249. this.warning(res.data.msg || '操作成功', 'success');
  250. } else {
  251. this.warning(res.data.msg);
  252. }
  253. })
  254. .catch(error => {
  255. if (error.code === '900010001') {
  256. return false;
  257. }
  258. this.warning(error);
  259. });
  260. });
  261. },
  262. // 导出数据
  263. exportData() {
  264. this.$confirm('确定要导出全部中医疾病关联数据吗?', '', {
  265. confirmButtonText: '确定',
  266. cancelButtonText: '取消',
  267. cancelButtonClass: 'leftbtn',
  268. customClass: 'exportBox6',
  269. title: '提示',
  270. type: 'warning'
  271. // beforeClose: (action, instance, done) => {
  272. // if (action === 'confirm') {
  273. // // instance.confirmButtonLoading = true;
  274. // // instance.confirmButtonText = '导出中...';
  275. // done()
  276. // api.exportDeptRecord().then(res => {
  277. // if (res.status === 200) {
  278. // setTimeout(() => {
  279. // utils.downloadExportedData(res.data, '科室关联数据.xls');
  280. // // done();
  281. // }, 1500);
  282. // }
  283. // });
  284. // } else {
  285. // done();
  286. // }
  287. // }
  288. })
  289. .then(() => {
  290. api.exportTcmRecord().then(res => {
  291. if (res.status === 200) {
  292. this.$message({ message: '导出成功', type: 'success' });
  293. utils.downloadExportedData(res.data, '中医疾病关联数据.xls');
  294. }
  295. });
  296. })
  297. .catch(() => {});
  298. },
  299. // 导入模板
  300. exportModule() {
  301. api.exportTcmModule().then(res => {
  302. if (res.status === 200) {
  303. setTimeout(() => {
  304. utils.downloadExportedData(res.data, '中医疾病导入模板.xls');
  305. }, 1500);
  306. }
  307. });
  308. },
  309. // 点击导入
  310. importPage() {
  311. let inp = document.getElementById('upFile');
  312. inp.click();
  313. },
  314. // 导入数据
  315. uploadFile(e) {
  316. let fileInfo = e.target.files[0];
  317. // this.fileName = e.target.files[0].name; // 表单同步显示
  318. e.preventDefault();
  319. let formData = new FormData();
  320. formData.append('file', fileInfo);
  321. const header = {
  322. headers: {
  323. 'Content-Type': 'multipart/form-data'
  324. }
  325. };
  326. this.uploadInfo = '导入中...';
  327. api.importTcmRecord(formData, header).then(res => {
  328. // console.log('导入文件结果', '===================', res);
  329. if (res.data.code === '00000001') {
  330. this.$confirm(`数据存在异常,导入失败,请修改后再试`, '提示', {
  331. confirmButtonText: '确定',
  332. // cancelButtonText: '取消',
  333. cancelButtonClass: 'cancelSure',
  334. confirmButtonClass: 'sure',
  335. customClass: 'exportConfirm',
  336. type: 'warning'
  337. })
  338. .then(() => {})
  339. .catch(() => {});
  340. this.getDataList(); // 重新获取列表
  341. setTimeout(() => {
  342. this.uploadInfo = '导入';
  343. }, 300);
  344. } else if (res.data === '' && res.status === 200) {
  345. this.$confirm(`导入成功`, '提示', {
  346. confirmButtonText: '确定',
  347. // cancelButtonText: '取消',
  348. cancelButtonClass: 'cancelSure',
  349. confirmButtonClass: 'sure',
  350. customClass: 'exportConfirm',
  351. type: 'success'
  352. })
  353. .then(() => {})
  354. .catch(() => {});
  355. this.getDataList(); // 重新获取列表
  356. setTimeout(() => {
  357. this.uploadInfo = '导入';
  358. }, 300);
  359. } else {
  360. this.$confirm(`${res.data.msg}`, '提示', {
  361. confirmButtonText: '确定',
  362. // cancelButtonText: '取消',
  363. cancelButtonClass: 'cancelSure',
  364. confirmButtonClass: 'sure',
  365. customClass: 'exportConfirm',
  366. type: 'warning'
  367. })
  368. .then(() => {})
  369. .catch(() => {});
  370. setTimeout(() => {
  371. this.uploadInfo = '导入';
  372. }, 300);
  373. }
  374. });
  375. //解决上传相同文件不触发change
  376. let inp = document.getElementById('upFile');
  377. inp.value = '';
  378. }
  379. }
  380. };
  381. </script>
  382. <style lang="less">
  383. @import '../../../less/admin.less';
  384. .delete {
  385. color: red;
  386. }
  387. .delete:hover {
  388. color: red;
  389. }
  390. .pagination {
  391. min-width: 1010px;
  392. }
  393. .downTemplate {
  394. margin-right: 8px;
  395. span {
  396. color: #02a7f0;
  397. }
  398. }
  399. #upFile {
  400. display: none !important;
  401. }
  402. .el-message-box {
  403. /deep/.cancelBtn {
  404. background-color: #d7d7d7;
  405. border-color: transparent;
  406. }
  407. /deep/.confirmC {
  408. background-color: #ff545b !important;
  409. border-color: transparent !important;
  410. }
  411. /deep/.el-message-box__header {
  412. border-bottom: 1px solid #dcdfe6;
  413. }
  414. }
  415. .exportBox6 {
  416. /deep/ .el-message-box__btns {
  417. margin-top: 20px;
  418. }
  419. /deep/ .el-message-box__message {
  420. // text-align: center;
  421. }
  422. /deep/.leftbtn {
  423. background-color: #d7d7d7;
  424. border-color: transparent !important;
  425. }
  426. /deep/ .el-message-box__header {
  427. border-bottom: 1px solid #dcdfe6;
  428. }
  429. }
  430. .exportConfirm {
  431. .cancelSure {
  432. display: none;
  433. }
  434. }
  435. </style>