QualityControlTemp.vue 11 KB

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