ChronicAndIndexRelation.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div>
  3. <crumbs title="慢病指标值关联维护" style="min-width: 980px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="慢病名称:">
  6. <el-input size="mini" v-model="filter.diseaseName" placeholder="慢病名称" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button size="mini" @click="filterDatas">确认</el-button>
  10. <el-button size="mini" type="warning" @click="addRelation">添加关联</el-button>
  11. </el-form-item>
  12. </el-form>
  13. </crumbs>
  14. <div class="contents">
  15. <el-table
  16. :data="list"
  17. border
  18. style="width: 100%">
  19. <el-table-column
  20. :resizable = "false"
  21. type="index"
  22. :index = 'indexMethod'
  23. label="编号"
  24. width="60">
  25. </el-table-column>
  26. <el-table-column
  27. :resizable = "false"
  28. prop="gmtModified"
  29. label="操作时间"
  30. width="180">
  31. </el-table-column>
  32. <el-table-column
  33. :resizable = "false"
  34. prop="diseaseName"
  35. label="慢病名称"
  36. show-overflow-tooltip>
  37. </el-table-column>
  38. <el-table-column
  39. :resizable = "false"
  40. label="状态"
  41. show-overflow-tooltip>
  42. <template slot-scope="scope">
  43. <span :class="scope.row.state == 'N'?'':'delete'">
  44. {{scope.row.state == 'N'?'启用中':'已删除'}}
  45. </span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column
  49. :resizable = "false"
  50. prop="modifier"
  51. label="操作人">
  52. </el-table-column>
  53. <el-table-column
  54. :resizable = "false"
  55. prop="operate"
  56. label="操作">
  57. <template slot-scope="scope">
  58. <el-button :disabled="scope.row.state != 'N'" @click="modifyRelation(scope.row)" type="text" size="small">修改</el-button>
  59. <span style="margin:0 3px;">|</span>
  60. <el-button type="text" size="small" :class="scope.row.state == 'N'?'delete':'review'" @click="showDelDialog(scope.row)">{{scope.row.state == 'N'?'删除':'恢复'}}</el-button>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <div class="pagination">
  65. <el-pagination :current-page.sync="currentPage"
  66. @current-change="currentChange"
  67. background
  68. :page-size="pageSize"
  69. :page-sizes="pageSizeArr"
  70. @size-change="handleSizeChange"
  71. :layout="pageLayout"
  72. :total="total">
  73. </el-pagination>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <script>
  79. import api from '@api/icss.js';
  80. import config from '@api/config.js';
  81. import utils from '@api/utils.js';
  82. export default {
  83. name: 'ChronicAndIndexRelation', //慢病指标值关联维护
  84. data: function() {
  85. return {
  86. list: [],
  87. searched: false,
  88. filter: {
  89. diseaseName: ''
  90. },
  91. currentPage: 1,
  92. pageSize: config.pageSize,
  93. pageSizeArr:config.pageSizeArr,
  94. pageLayout:config.pageLayout,
  95. total: 0,
  96. }
  97. },
  98. created() {
  99. const that = this;
  100. setTimeout(function(){
  101. that.getDataList();
  102. });
  103. },
  104. watch: {
  105. 'filter': {
  106. handler: function () {
  107. this.searched = false;
  108. },
  109. deep: true
  110. }
  111. },
  112. beforeRouteEnter(to, from, next) {
  113. next(vm => {
  114. //const pm = to.param;
  115. Object.assign(vm, to.params);
  116. vm.inCurrentPage=to.params.currentPage;
  117. })
  118. },
  119. methods: {
  120. handleSizeChange(val){
  121. this.pageSize = val;
  122. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  123. this.getDataList();
  124. },
  125. getDataList(isTurnPage) {
  126. const param = 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.queryIndexConfigPages(param).then((res) => {
  135. loading.close()
  136. if(res.data.code == '0') {
  137. this.list = res.data.data.records;
  138. this.total = res.data.data.total;
  139. if(this.inCurrentPage!==undefined){
  140. this.currentPage=this.inCurrentPage;
  141. this.inCurrentPage = undefined;
  142. }
  143. }
  144. })
  145. },
  146. filterDatas() {
  147. this.currentPage = 1;
  148. this.getDataList();
  149. },
  150. addRelation() {
  151. const pam = this.searched ? {
  152. currentPage: this.currentPage,
  153. pageSize:this.pageSize,
  154. filter: this.filter
  155. } : {currentPage: this.currentPage,
  156. pageSize:this.pageSize};
  157. this.$router.push({name:'AddChronicAndIndexRelation', params: pam})
  158. },
  159. modifyRelation(row) {
  160. const param = {
  161. diseaseId: row.diseaseId
  162. };
  163. api.getIndexConfigLists(param).then((res) => {
  164. if(res.data.code == '0') {
  165. const pam = this.searched ? {
  166. currentPage: this.currentPage,
  167. pageSize:this.pageSize,
  168. filter: this.filter
  169. } : {currentPage: this.currentPage,
  170. pageSize:this.pageSize};
  171. const item = Object.assign({},row,{data: res.data.data});
  172. this.$router.push({name:'AddChronicAndIndexRelation',params:Object.assign(pam, {isEdit:true,data:item})});
  173. }
  174. })
  175. },
  176. currentChange(next) {
  177. this.currentPage = next;
  178. this.getDataList(true);
  179. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  180. // this.list = this.cacheData[next];
  181. // } else {
  182. // this.getDataList();
  183. // }
  184. },
  185. getFilterItems(isTurnPage) {
  186. //翻页时筛选条件没点确定则清空
  187. if(isTurnPage&&!this.searched){
  188. this.filter.diseaseName='';
  189. };
  190. const param = {
  191. current: this.inCurrentPage||this.currentPage,
  192. size: this.pageSize,
  193. diseaseName:this.filter.diseaseName.trim(),
  194. };
  195. return param;
  196. },
  197. indexMethod(index) {
  198. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  199. },
  200. getTagType(val) {
  201. return val
  202. },
  203. warning(msg,type){
  204. this.$message({
  205. showClose: true,
  206. message:msg,
  207. type:type||'warning'
  208. })
  209. },
  210. showConfirmDialog(msg,resolve){
  211. this.$alert(msg, '提示', {
  212. confirmButtonText: '确定',
  213. type: 'warning'
  214. }).then(() => {
  215. resolve();
  216. }).catch(() => {});
  217. },
  218. showDelDialog(row){
  219. const param = {
  220. diseaseId:row.diseaseId,
  221. state:row.state === 'N'?'Y':'N',
  222. }
  223. let warntTxt = row.state === 'N' ? '是否删除该关联?': '是否恢复该关联?';
  224. this.showConfirmDialog(warntTxt,()=>{
  225. api.cancelIndexConfigAlls(param).then((res)=>{
  226. if(res.data.code=='0'){
  227. if(!this.searched){
  228. //未点确认时清空搜索条件
  229. this.filter={
  230. diseaseName: ''
  231. };
  232. }
  233. if(row.state !== 'N'){ //恢复成功后跳转到筛选条件的首页
  234. this.currentPage = 1;
  235. }
  236. this.getDataList();
  237. this.warning(res.data.msg || '操作成功','success');
  238. }else{
  239. this.warning(res.data.msg);
  240. }
  241. }).catch((error)=>{
  242. this.warning(error);
  243. })
  244. });
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="less" scoped>
  250. @import "../../less/admin.less";
  251. .delete{
  252. color: red;
  253. }
  254. .delete:hover {
  255. color: red;
  256. }
  257. .review{
  258. color: #22ccc8;
  259. }
  260. .pagination {
  261. min-width: 1010px;
  262. }
  263. </style>