QualityControlTemp.vue 12 KB

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