AboutDisease.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div>
  3. <crumbs title="疾病相关维护" minWidth="995px">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="疾病名称:">
  6. <el-input size="mini" v-model="filter.term" placeholder="请输入名称"></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" style="margin:0 10px" @click="addMedicalMultR">新增疾病</el-button>
  11. </el-form-item>
  12. </el-form>
  13. </crumbs>
  14. <div class="contents">
  15. <el-table :data="list"
  16. border
  17. style="width: 100%">
  18. <el-table-column
  19. type="index"
  20. :index="indexMethod"
  21. label="编号"
  22. width="60">
  23. </el-table-column>
  24. <el-table-column
  25. prop="disName"
  26. label="疾病名称"
  27. show-overflow-tooltip>
  28. </el-table-column>
  29. <el-table-column
  30. prop="modifier"
  31. label="操作人">
  32. </el-table-column>
  33. <el-table-column
  34. prop="gmtModified"
  35. label="操作时间"
  36. :show-overflow-tooltip="true">
  37. </el-table-column>
  38. <el-table-column
  39. label="操作" width="160">
  40. <template slot-scope="scope">
  41. <el-button type="text" size="small" @click="toEditProduct(scope.row)">修改</el-button>
  42. <span style="margin:0 3px;">|</span>
  43. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row)">删除</el-button>
  44. </template>
  45. </el-table-column>
  46. </el-table>
  47. <el-pagination :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. </template>
  59. <script>
  60. import api from '@api/knowledgeTree.js';
  61. import config from '@api/config.js';
  62. import utils from '@api/utils.js';
  63. export default {
  64. name: 'AboutDisease',
  65. data: function () {
  66. return {
  67. list: [],
  68. stateSelect:[
  69. {id:'N',name:'启用中'},
  70. {id:'Y',name:'已删除'},
  71. ],
  72. isState:'',
  73. cacheData: {},
  74. currentPage: 1,
  75. pageSize: config.pageSize,
  76. pageSizeArr:config.pageSizeArr,
  77. pageLayout:config.pageLayout,
  78. total: 0,
  79. searched: false,
  80. filter: {
  81. term:'',
  82. type:''
  83. },
  84. typeList:[]
  85. }
  86. },
  87. created() {
  88. const that = this;
  89. //返回时避免参数未赋值就获取列表
  90. setTimeout(function(){
  91. that.getDataList();
  92. });
  93. // this.getTypeList();
  94. },
  95. watch: {
  96. 'filter': {
  97. handler: function () {
  98. this.searched = false;
  99. },
  100. deep: true
  101. }
  102. },
  103. beforeRouteEnter(to, from, next){
  104. next(vm => {
  105. //const pm = to.param;
  106. Object.assign(vm,to.params);
  107. vm.inCurrentPage=to.params.currentPage;
  108. })
  109. },
  110. methods: {
  111. handleSizeChange(val){
  112. this.pageSize = val;
  113. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  114. this.getDataList();
  115. },
  116. addMedicalMultR(){
  117. const pam = this.searched ? {
  118. currentPage: this.currentPage,
  119. pageSize:this.pageSize,
  120. filter: this.filter
  121. } : {currentPage: this.currentPage,
  122. pageSize:this.pageSize};
  123. this.$router.push({name:'DiseaseTree',
  124. params:pam});
  125. },
  126. toEditProduct(row){
  127. const param = {
  128. disName: row.disName,
  129. };
  130. const pam = this.searched ? {
  131. currentPage: this.currentPage,
  132. pageSize:this.pageSize,
  133. filter: this.filter
  134. } : {currentPage: this.currentPage,
  135. pageSize:this.pageSize};
  136. api.getBaseDetail(param).then((res) => {
  137. const {code,data,msg} = res.data;
  138. if(code=='0'){
  139. const item = Object.assign({},row,data);
  140. this.$router.push({name:'DiseaseTree',params:Object.assign(pam, {isEdit: true, data: item})});
  141. }else{
  142. this.$message({
  143. message: msg,
  144. type: 'warning'
  145. });
  146. }
  147. })
  148. },
  149. filterDatas(){
  150. this.currentPage = 1;
  151. this.getDataList();
  152. },
  153. getDataList(isTurnPage) {
  154. const param = this.getFilterItems(isTurnPage);
  155. this.searched = true;
  156. const loading = this.$loading({
  157. lock: true,
  158. text: 'Loading',
  159. spinner: 'el-icon-loading',
  160. background: 'rgba(0, 0, 0, 0.7)'
  161. });
  162. api.getDiseasePage(param).then((res) => {
  163. loading.close()
  164. if (res.data.code == '0') {
  165. const data = res.data.data;
  166. this.list = data.records;
  167. this.cacheData[param.current] = data.records;
  168. this.total = data.total;
  169. if(this.inCurrentPage!==undefined){
  170. this.currentPage=this.inCurrentPage;
  171. this.inCurrentPage = undefined;
  172. }
  173. }
  174. }).catch((error) => {
  175. console.log(error);
  176. });
  177. },
  178. getTypeList(){
  179. api.allKnowledgeType({'name':''}).then((res)=>{
  180. const data = res.data;
  181. if(data.code==0){
  182. this.typeList = data.data;
  183. }else{
  184. console.log(res.msg);
  185. }
  186. }).catch((error) => {
  187. console.log(error);
  188. });
  189. },
  190. /*getDetailList(id) {
  191. this.$router.push({name:'DeptInfoDetail', params:{id: id}})
  192. },*/
  193. getFilterItems(isTurnPage) {
  194. //翻页时筛选条件没点确定则清空
  195. if(isTurnPage&&!this.searched){
  196. this.clearFilter();
  197. };
  198. const param = {
  199. disName: this.filter.term.trim(),
  200. current: this.inCurrentPage||this.currentPage,
  201. size: this.pageSize
  202. };
  203. return param;
  204. },
  205. indexMethod(index) {
  206. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  207. },
  208. currentChange(next) {
  209. this.currentPage = next;
  210. if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  211. this.list = this.cacheData[next];
  212. } else {
  213. this.getDataList(true);
  214. }
  215. },
  216. warning(msg,type){
  217. this.$message({
  218. showClose: true,
  219. message:msg,
  220. type:type||'warning'
  221. })
  222. },
  223. showConfirmDialog(msg,resolve){
  224. this.$alert(msg, '提示', {
  225. confirmButtonText: '确定',
  226. type: 'warning'
  227. }).then(() => {
  228. resolve();
  229. }).catch(() => {});
  230. },
  231. showDelDialog(item){
  232. /*const param = {
  233. term:item.term,
  234. type:item.type,
  235. id:item.id
  236. }*/
  237. const param = {
  238. disName:item.disName
  239. }
  240. let waringTxt = '是否删除该关系,可能对现有系统造成影响'
  241. this.showConfirmDialog(waringTxt,()=>{
  242. api.diseaseDelete(param).then((res)=>{
  243. if(res.data.code=='0'){
  244. if(!this.searched){
  245. //未点确认时清空搜索条件
  246. this.clearFilter();
  247. }
  248. if(this.list.length==1){
  249. //当前在最后一页且只有一条数据时,删除后跳到前一页
  250. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  251. }
  252. this.warning(res.data.msg||'操作成功','success');
  253. this.getDataList();
  254. }else{
  255. this.warning(res.data.msg);
  256. }
  257. }).catch((error)=>{
  258. this.warning(error);
  259. })
  260. });
  261. },
  262. clearFilter(){
  263. this.filter={
  264. term:'',
  265. type:''
  266. };
  267. },
  268. uploadClick(){
  269. let inp = document.getElementById("upFile");
  270. inp.click();
  271. },
  272. uploadFile(e){
  273. let fileInfo = e.target.files[0];
  274. e.preventDefault();
  275. let formData = new FormData();
  276. formData.append('uploadfile', fileInfo);
  277. const header = {
  278. headers:{
  279. 'Content-Type': 'multipart/form-data'
  280. }
  281. }
  282. api.knowledgeUpload(formData,header).then((res)=>{
  283. if(res.data.code==0){
  284. this.$message({
  285. message: '上传成功',
  286. type: 'success',
  287. });
  288. this.getDataList();
  289. }else{
  290. this.$message({
  291. dangerouslyUseHTMLString: true,
  292. message:res.data.msg,
  293. type:'warning'
  294. });
  295. }
  296. })
  297. //解决上传相同文件不触发change
  298. let inp = document.getElementById("upFile");
  299. inp.value = "";
  300. },
  301. }
  302. }
  303. </script>
  304. <style lang="less" scoped>
  305. @import "../../less/admin.less";
  306. .delete{
  307. color: red;
  308. }
  309. .review{
  310. color: #22ccc8;
  311. }
  312. .el-table .cell{
  313. overflow: hidden;
  314. white-space: nowrap;
  315. }
  316. #upFile{
  317. display: none !important;
  318. }
  319. </style>