Operation.vue 13 KB

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