Lis.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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 size="mini" @click="importPage">导入</el-button>
  7. <el-button size="mini" @click="exportData">导出</el-button>
  8. </el-form-item>
  9. <el-form-item label="检验套餐:">
  10. <el-input size="mini" v-model="filter.hisName" placeholder="检验套餐" clearable></el-input>
  11. </el-form-item>
  12. <el-form-item label="检验细项:">
  13. <el-input size="mini" v-model="filter.hisDetailName" placeholder="检验细项" clearable></el-input>
  14. </el-form-item>
  15. <el-form-item label="标准检验项:">
  16. <el-input size="mini" v-model="filter.uniqueName" placeholder="标准检验项" clearable></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" @click="filterDatas">检索</el-button>
  20. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table :data="list" border style="width: 100%">
  26. <el-table-column :resizable="false" type="index" :index="indexMethod" label="编号" width="60"></el-table-column>
  27. <el-table-column :resizable="false" prop="gmtModified" label="操作时间" width="180"></el-table-column>
  28. <el-table-column :resizable="false" prop="hisName" label="检验套餐" show-overflow-tooltip></el-table-column>
  29. <el-table-column :resizable="false" prop="hisDetailName" label="检验细项" show-overflow-tooltip></el-table-column>
  30. <el-table-column :resizable="false" prop="uniqueCode" label="对应项编码" show-overflow-tooltip></el-table-column>
  31. <el-table-column :resizable="false" prop="uniqueName" label="标准检验项" show-overflow-tooltip></el-table-column>
  32. <el-table-column :resizable="false" prop="operate" label="操作">
  33. <template slot-scope="scope">
  34. <el-button @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  35. <span style="margin:0 3px;">|</span>
  36. <el-button
  37. @click="showDelDialog(scope.row.id)"
  38. class="delete"
  39. type="text"
  40. size="small"
  41. >删除</el-button>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div class="pagination">
  46. <el-pagination
  47. :current-page.sync="currentPage"
  48. @current-change="currentChange"
  49. background
  50. :page-size="pageSize"
  51. :page-sizes="pageSizeArr"
  52. @size-change="handleSizeChange"
  53. :layout="pageLayout"
  54. :total="total"
  55. ></el-pagination>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. import api from '@api/icss.js';
  62. import config from '@api/config.js';
  63. import utils from '@api/utils.js';
  64. export default {
  65. name: 'Lis', //化验大小项和公表维护
  66. data: function() {
  67. return {
  68. list: [],
  69. searched: false,
  70. filter: {
  71. hisName: '', // 检验套餐
  72. hisDetailName: '', //检验细项
  73. uniqueName: '' //标准检验项
  74. },
  75. currentPage: 1,
  76. pageSize: config.pageSize,
  77. pageSizeArr: config.pageSizeArr,
  78. pageLayout: config.pageLayout,
  79. total: 0
  80. };
  81. },
  82. created() {
  83. const that = this;
  84. //返回时避免参数未赋值就获取列表
  85. setTimeout(function() {
  86. that.getDataList();
  87. });
  88. },
  89. watch: {
  90. filter: {
  91. handler: function() {
  92. this.searched = false;
  93. },
  94. deep: true
  95. }
  96. },
  97. beforeRouteEnter(to, from, next) {
  98. next(vm => {
  99. //const pm = to.param;
  100. Object.assign(vm, to.params);
  101. vm.inCurrentPage = to.params.currentPage;
  102. });
  103. },
  104. methods: {
  105. handleSizeChange(val) {
  106. this.pageSize = val;
  107. this.currentPage = utils.getCurrentPage(
  108. this.currentPage,
  109. this.total,
  110. this.pageSize
  111. );
  112. this.getDataList();
  113. },
  114. // 获取列表数据
  115. getDataList(isTurnPage) {
  116. const params = this.getFilterItems(isTurnPage);
  117. this.searched = true;
  118. const loading = this.$loading({
  119. lock: true,
  120. text: 'Loading',
  121. spinner: 'el-icon-loading',
  122. background: 'rgba(0, 0, 0, 0.7)'
  123. });
  124. api.getLisPage(params).then(res => {
  125. loading.close();
  126. if (res.data.code === '0') {
  127. this.list = res.data.data && res.data.data.records;
  128. }
  129. this.total = res.data.data && res.data.data.total;
  130. if (this.inCurrentPage !== undefined) {
  131. this.currentPage = this.inCurrentPage;
  132. this.inCurrentPage = undefined;
  133. }
  134. });
  135. },
  136. // 处理列表请求数据参数
  137. getFilterItems(isTurnPage) {
  138. //翻页时筛选条件没点确定则清空
  139. if (isTurnPage && !this.searched) {
  140. this.clearFilter();
  141. }
  142. const param = {
  143. current: this.inCurrentPage || this.currentPage,
  144. size: this.pageSize,
  145. hisName: this.filter.hisName.trim(),
  146. uniqueName: this.filter.uniqueName.trim(),
  147. uniqueCode: '',
  148. hisDetailName: this.filter.hisDetailName.trim(),
  149. };
  150. return param;
  151. },
  152. filterDatas() {
  153. this.currentPage = 1;
  154. this.getDataList();
  155. },
  156. addRelation() {
  157. const pam = this.searched
  158. ? {
  159. currentPage: this.currentPage,
  160. pageSize: this.pageSize,
  161. filter: this.filter
  162. }
  163. : { currentPage: this.currentPage, pageSize: this.pageSize };
  164. this.$router.push({ name: 'AddLis', params: pam });
  165. },
  166. // 修改诊断关联-跳转至编辑页面
  167. modifyRelation(row) {
  168. const item = Object.assign({}, row);
  169. const pam = this.searched
  170. ? {
  171. currentPage: this.currentPage,
  172. pageSize: this.pageSize,
  173. filter: this.filter
  174. }
  175. : { currentPage: this.currentPage, pageSize: this.pageSize };
  176. this.$router.push({
  177. name: 'AddLis',
  178. params: Object.assign(pam, { isEdit: true, data: item })
  179. });
  180. },
  181. currentChange(next) {
  182. this.currentPage = next;
  183. this.getDataList(true);
  184. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  185. // this.list = this.cacheData[next];
  186. // } else {
  187. // this.getDataList();
  188. // }
  189. },
  190. // 清空搜索参数
  191. clearFilter() {
  192. this.filter = {
  193. hisName: '',
  194. uniqueName: '',
  195. hisDetailName: ''
  196. };
  197. },
  198. indexMethod(index) {
  199. return (this.currentPage - 1) * this.pageSize + index + 1;
  200. },
  201. getTagType(val) {
  202. return val;
  203. },
  204. warning(msg, type) {
  205. this.$message({
  206. showClose: true,
  207. message: msg,
  208. type: type || 'warning'
  209. });
  210. },
  211. showConfirmDialog(msg, resolve) {
  212. this.$alert(msg, '提示', {
  213. confirmButtonText: '确定',
  214. type: 'warning'
  215. })
  216. .then(() => {
  217. resolve();
  218. })
  219. .catch(() => {});
  220. },
  221. // 删除关联
  222. showDelDialog(id) {
  223. this.showConfirmDialog('是否删除该关联?', () => {
  224. api
  225. .deleteLisRecord({ id: id })
  226. .then(res => {
  227. if (res.data.code == '0') {
  228. if (!this.searched) {
  229. //未点确认时清空搜索条件
  230. this.clearFilter();
  231. }
  232. if (this.list.length == 1) {
  233. //当前在最后一页且只有一条数据时,删除后跳到前一页
  234. this.currentPage =
  235. this.currentPage === 1 ? 1 : this.currentPage - 1;
  236. }
  237. this.getDataList();
  238. this.warning(res.data.msg || '操作成功', 'success');
  239. } else {
  240. this.warning(res.data.msg);
  241. }
  242. })
  243. .catch(error => {
  244. this.warning(error);
  245. });
  246. });
  247. },
  248. // 导出数据
  249. exportData() {
  250. this.$confirm('确定要导出全部检验关联数据吗?', '', {
  251. confirmButtonText: '确定',
  252. cancelButtonText: '取消',
  253. cancelButtonClass: 'leftbtn',
  254. customClass: 'exportBox',
  255. title: '导出数据',
  256. beforeClose: (action, instance, done) => {
  257. if (action === 'confirm') {
  258. // instance.confirmButtonLoading = true;
  259. instance.confirmButtonText = '导出中...';
  260. api.exportLisRecord().then(res => {
  261. if (res.status === 200) {
  262. setTimeout(() => {
  263. utils.downloadExportedData(res.data, '检验数据.xls');
  264. done();
  265. }, 1500);
  266. }
  267. });
  268. } else {
  269. done();
  270. }
  271. }
  272. })
  273. .then(() => {
  274. this.$message({ message: '导出成功', type: 'success' });
  275. })
  276. .catch(() => {
  277. this.$message({ message: '导出失败', type: 'waring' });
  278. });
  279. },
  280. // 跳转至导入页面
  281. importPage() {
  282. const pam = this.searched
  283. ? {
  284. currentPage: this.currentPage,
  285. pageSize: this.pageSize,
  286. filter: this.filter
  287. }
  288. : { currentPage: this.currentPage, pageSize: this.pageSize };
  289. this.$router.push({ name: 'ImportLisRecord', params: pam });
  290. // this.$router.push({ name: 'ImportDiseaseRecord'});
  291. }
  292. }
  293. };
  294. </script>
  295. <style lang="less">
  296. @import '../../../less/admin.less';
  297. .delete {
  298. color: red;
  299. }
  300. .delete:hover {
  301. color: red;
  302. }
  303. .pagination {
  304. min-width: 1010px;
  305. }
  306. .exportBox {
  307. /deep/ .el-message-box__btns {
  308. margin-top: 20px;
  309. }
  310. /deep/ .el-message-box__message {
  311. text-align: center;
  312. }
  313. /deep/ .el-message-box__btns {
  314. text-align: center;
  315. margin-bottom: 24px;
  316. }
  317. /deep/ .leftbtn {
  318. margin-right: 46px;
  319. background-color: #d7d7d7;
  320. border-color: transparent;
  321. }
  322. }
  323. </style>