ChronicAndIndexRelation.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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. })
  117. },
  118. methods: {
  119. handleSizeChange(val){
  120. this.pageSize = val;
  121. this.currentPage = utils.getCurrentPage(this.currentChange, this.total, this.pageSize);
  122. this.getDataList();
  123. },
  124. getDataList(isTurnPage) {
  125. const param = this.getFilterItems(isTurnPage);
  126. this.searched = true;
  127. const loading = this.$loading({
  128. lock: true,
  129. text: 'Loading',
  130. spinner: 'el-icon-loading',
  131. background: 'rgba(0, 0, 0, 0.7)'
  132. });
  133. api.queryIndexConfigPages(param).then((res) => {
  134. loading.close()
  135. if(res.data.code == '0') {
  136. this.list = res.data.data.records;
  137. this.total = res.data.data.total;
  138. }
  139. })
  140. },
  141. filterDatas() {
  142. this.currentPage = 1;
  143. this.getDataList();
  144. },
  145. addRelation() {
  146. const pam = this.searched ? {
  147. currentPage: this.currentPage,
  148. pageSize:this.pageSize,
  149. filter: this.filter
  150. } : {currentPage: this.currentPage,
  151. pageSize:this.pageSize};
  152. this.$router.push({name:'AddChronicAndIndexRelation', params: pam})
  153. },
  154. modifyRelation(row) {
  155. const param = {
  156. diseaseId: row.diseaseId
  157. };
  158. api.getIndexConfigLists(param).then((res) => {
  159. if(res.data.code == '0') {
  160. const pam = this.searched ? {
  161. currentPage: this.currentPage,
  162. pageSize:this.pageSize,
  163. filter: this.filter
  164. } : {currentPage: this.currentPage,
  165. pageSize:this.pageSize};
  166. const item = Object.assign({},row,{data: res.data.data});
  167. this.$router.push({name:'AddChronicAndIndexRelation',params:Object.assign(pam, {isEdit:true,data:item})});
  168. }
  169. })
  170. },
  171. currentChange(next) {
  172. this.currentPage = next;
  173. this.getDataList(true);
  174. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  175. // this.list = this.cacheData[next];
  176. // } else {
  177. // this.getDataList();
  178. // }
  179. },
  180. getFilterItems(isTurnPage) {
  181. //翻页时筛选条件没点确定则清空
  182. if(isTurnPage&&!this.searched){
  183. this.filter.diseaseName='';
  184. };
  185. const param = {
  186. current: this.currentPage,
  187. size: this.pageSize,
  188. diseaseName:this.filter.diseaseName.trim(),
  189. };
  190. return param;
  191. },
  192. indexMethod(index) {
  193. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  194. },
  195. getTagType(val) {
  196. return val
  197. },
  198. warning(msg,type){
  199. this.$message({
  200. showClose: true,
  201. message:msg,
  202. type:type||'warning'
  203. })
  204. },
  205. showConfirmDialog(msg,resolve){
  206. this.$alert(msg, '提示', {
  207. confirmButtonText: '确定',
  208. type: 'warning'
  209. }).then(() => {
  210. resolve();
  211. }).catch(() => {});
  212. },
  213. showDelDialog(row){
  214. const param = {
  215. diseaseId:row.diseaseId,
  216. state:row.state === 'N'?'Y':'N',
  217. }
  218. let warntTxt = row.state === 'N' ? '是否删除该关联?': '是否恢复该关联?';
  219. this.showConfirmDialog(warntTxt,()=>{
  220. api.cancelIndexConfigAlls(param).then((res)=>{
  221. if(res.data.code=='0'){
  222. if(!this.searched){
  223. //未点确认时清空搜索条件
  224. this.filter={
  225. diseaseName: ''
  226. };
  227. }
  228. if(row.state !== 'N'){ //恢复成功后跳转到筛选条件的首页
  229. this.currentPage = 1;
  230. }
  231. this.getDataList();
  232. this.warning(res.data.msg || '操作成功','success');
  233. }else{
  234. this.warning(res.data.msg);
  235. }
  236. }).catch((error)=>{
  237. this.warning(error);
  238. })
  239. });
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="less" scoped>
  245. @import "../../less/admin.less";
  246. .delete{
  247. color: red;
  248. }
  249. .delete:hover {
  250. color: red;
  251. }
  252. .review{
  253. color: #22ccc8;
  254. }
  255. .pagination {
  256. min-width: 1010px;
  257. }
  258. </style>