QualityControlTemp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <div>
  3. <crumbs title="模板维护">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="模板名称:">
  6. <el-input size="mini" v-model.trim="filter.modeName" placeholder="模板名称" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item label="数据模块:">
  9. <el-select size="mini" v-model.trim="filter.modeId" @change="getValue" placeholder="数据模块" clearable>
  10. <el-option v-for="item in moduleList" :label="item.name" :value="item.val" :key="item.id" ></el-option>
  11. </el-select>
  12. </el-form-item>
  13. <el-form-item label="所属医院:">
  14. <el-select size="mini" v-model.trim="filter.hospitalName" @change="getValue" placeholder="所属医院" clearable>
  15. <el-option v-for="item in hospitalList" :label="item.name" :value="item.val" :key="item.id" ></el-option>
  16. </el-select>
  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="addTemp">添加模板</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table
  26. :data="list"
  27. border
  28. style="width: 100%">
  29. <el-table-column
  30. :resizable = "false"
  31. type="index"
  32. :index = 'indexMethod'
  33. label="编号"
  34. width="60">
  35. </el-table-column>
  36. <el-table-column
  37. :resizable = "false"
  38. prop="name"
  39. label="模板名称"
  40. width="180">
  41. </el-table-column>
  42. <el-table-column
  43. :resizable = "false"
  44. prop="modeId"
  45. label="数据模块">
  46. </el-table-column>
  47. <el-table-column
  48. :resizable = "false"
  49. prop="hospitalId"
  50. label="所属医院">
  51. </el-table-column>
  52. <el-table-column
  53. :resizable = "false"
  54. prop="operate"
  55. label="操作">
  56. <template slot-scope="scope">
  57. <el-button @click="modifyIndeptTag(scope.row, 'modify')" type="text" size="small">修改</el-button>
  58. <span style="margin:0 3px;">|</span>
  59. <el-button @click="modifyIndeptTag(scope.row, 'copy')" class="text" type="text" size="small">复制</el-button>
  60. <span style="margin:0 3px;">|</span>
  61. <el-button @click="showDelDialog(scope.row)" class="delete" type="text" size="small">删除</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <el-pagination :current-page.sync="currentPage"
  66. @current-change="currentChange"
  67. background
  68. :page-size.sync="pageSize"
  69. :page-sizes="pageSizeArr"
  70. @size-change="handleSizeChange"
  71. :layout="pageLayout"
  72. :total="total">
  73. </el-pagination>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import api from '@api/qualityControl.js';
  79. import config from '@api/config.js';
  80. export default {
  81. name: 'QualityControlTemp',
  82. data: function() {
  83. return {
  84. list: [],
  85. hospitalList: [],
  86. moduleList:[],
  87. searched: false,
  88. filter: {
  89. modeName: '', //模板名称
  90. modeId: '',//模板Id
  91. hospitalName: '', //所属医院
  92. },
  93. currentPage: 1,
  94. pageSize: config.pageSize,
  95. pageSizeArr:config.pageSizeArr,
  96. pageLayout:config.pageLayout,
  97. total: 0,
  98. }
  99. },
  100. created() {
  101. this.getAllTypes().then(()=>{
  102. this.getDataList()
  103. })
  104. },
  105. watch: {
  106. 'filter': {
  107. handler: function () {
  108. this.searched = false;
  109. },
  110. deep: true
  111. }
  112. },
  113. beforeRouteEnter(to, from, next) {
  114. next(vm => {
  115. //const pm = to.param;
  116. Object.assign(vm, to.params);
  117. vm.inCurrentPage=to.params.currentPage;
  118. })
  119. },
  120. methods: {
  121. getAllTypes(){
  122. if(localStorage.getItem("qcModuleTypes")){
  123. this.hospitalList = JSON.parse(localStorage.getItem("qcHospitalTypes"));
  124. this.moduleList = JSON.parse(localStorage.getItem("qcModuleTypes"));
  125. return new Promise(function(resolve, reject){
  126. resolve()
  127. });
  128. }
  129. //获取枚举信息
  130. return api.getQcTypes().then((res)=>{
  131. if(res.data.code==="0"){
  132. const data = res.data.data;
  133. localStorage.setItem("qcFieldTypes",JSON.stringify(data[11]));
  134. localStorage.setItem("qcModuleTypes",JSON.stringify(data[12]));
  135. localStorage.setItem("qcHospitalTypes",JSON.stringify(data[13]));
  136. this.hospitalList = JSON.parse(localStorage.getItem("qcHospitalTypes"));
  137. this.moduleList = JSON.parse(localStorage.getItem("qcModuleTypes"));
  138. }else{
  139. this.warning("获取枚举信息失败");
  140. }
  141. });
  142. },
  143. handleSizeChange(val){
  144. this.pageSize = val;
  145. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  146. this.getDataList();
  147. },
  148. getValue(val) {
  149. console.log('changeVal', val, this.filter.tagAdscription)
  150. },
  151. getDataList(isTurnPage) {
  152. const param = this.getFilterItems(isTurnPage);
  153. this.searched = true;
  154. const loading = this.$loading({
  155. lock: true,
  156. text: 'Loading',
  157. spinner: 'el-icon-loading',
  158. background: 'rgba(0, 0, 0, 0.7)'
  159. });
  160. api.getQCTemplist(param).then((res) => {
  161. loading.close()
  162. let list = res.data.data.records
  163. for(let i = 0; i < list.length; i++){
  164. list[i].hospitalId = this.hospitalList.find(item => item.val == list[i].hospitalId).name
  165. list[i].modeId = this.moduleList.find(item => item.val == list[i].modeId).name
  166. }
  167. this.list = list;
  168. this.total = res.data.data.total;
  169. if(this.inCurrentPage!==undefined){
  170. this.currentPage=this.inCurrentPage;
  171. this.inCurrentPage = undefined;
  172. }
  173. })
  174. },
  175. filterDatas() {
  176. this.currentPage = 1;
  177. this.getDataList();
  178. },
  179. addTemp() {
  180. const pam = this.searched ? {
  181. currentPage: this.currentPage,
  182. pageSize:this.pageSize,
  183. filter: this.filter
  184. } : {currentPage: this.currentPage,pageSize:this.pageSize};
  185. this.$router.push({
  186. name: 'AddQualityControlTemp',
  187. params: pam
  188. })
  189. },
  190. modifyIndeptTag(row, type) {
  191. api.getQCTempDetail({moduleId:row.id}).then((res)=>{
  192. const {code,data,msg} = res.data;
  193. if(code=='0'){
  194. const item = Object.assign({},row,data);
  195. const pam = this.searched ? {
  196. currentPage: this.currentPage,
  197. filter: this.filter
  198. } : {currentPage: this.currentPage};
  199. if(type == 'modify') {
  200. this.$router.push({name: 'AddQualityControlTemp', params: Object.assign(pam, {isEdit: true, data: item})});
  201. } else if( type == 'copy') {
  202. this.$router.push({name: 'AddQualityControlTemp', params: Object.assign(pam, {isCopy: true, data: item})});
  203. } else {
  204. return
  205. }
  206. }else{
  207. this.$message({
  208. message: msg,
  209. type: 'warning'
  210. });
  211. }
  212. });
  213. //this.$router.push({name:'AddIndeptLabel',params:{isEdit:true,data:row}});
  214. },
  215. currentChange(next) {
  216. this.currentPage = next;
  217. this.getDataList(true);
  218. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  219. // this.list = this.cacheData[next];
  220. // } else {
  221. // this.getDataList();
  222. // }
  223. },
  224. clearFilter(){
  225. this.filter={
  226. name: "",
  227. modeId: "",
  228. hospitalName: ""
  229. };
  230. },
  231. getFilterItems(isTurnPage) {
  232. //翻页时筛选条件没点确定则清空
  233. if(isTurnPage&&!this.searched){
  234. this.clearFilter();
  235. };
  236. const {modeName, modeId, hospitalName} = this.filter
  237. const param = {
  238. name: modeName,
  239. current: this.inCurrentPage||this.currentPage,
  240. size: this.pageSize,
  241. modeId: modeId,
  242. hospitalId: hospitalName
  243. };
  244. return param;
  245. },
  246. indexMethod(index) {
  247. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  248. },
  249. getTagType(val) {
  250. return val
  251. },
  252. warning(msg,type){
  253. this.$message({
  254. showClose: true,
  255. dangerouslyUseHTMLString: true,
  256. message:'<p>'+msg+'</p>',
  257. type:type||'warning'
  258. })
  259. },
  260. showConfirmDialog(msg,resolve){
  261. this.$alert(msg, '提示', {
  262. confirmButtonText: '确定',
  263. type: 'warning'
  264. }).then(() => {
  265. resolve();
  266. }).catch(() => {});
  267. },
  268. showDelDialog(row){
  269. const param = {
  270. "ids": row.id,
  271. }
  272. this.showConfirmDialog('是否删除该标签?',()=>{
  273. api.delQCTemp(param).then((res)=>{
  274. if(res.data.code=='0'){
  275. if(!this.searched){
  276. //未点确认时清空搜索条件
  277. this.clearFilter();
  278. }
  279. if(this.list.length==1){
  280. //当前在最后一页且只有一条数据时,删除后跳到前一页
  281. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  282. }
  283. this.getDataList();
  284. this.warning(res.data.msg || '操作成功','success');
  285. }else{
  286. this.warning(res.data.msg);
  287. }
  288. }).catch((error)=>{
  289. this.warning(error);
  290. })
  291. });
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="less">
  297. @import "../../less/admin.less";
  298. .delete{
  299. color: red
  300. }
  301. .delete:hover {
  302. color: red;
  303. }
  304. .el-select .el-input .el-icon-arrow-up{
  305. display: inline-block!important;
  306. }
  307. .el-select .el-input .el-icon-circle-close{
  308. float:left;
  309. }
  310. .el-pagination__sizes{
  311. margin-right: 20px;
  312. .el-input .el-input__inner{
  313. height: 28px;
  314. line-height: 28px;
  315. }
  316. }
  317. </style>