TemplateMaintenance.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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-select size="mini" v-model="filter.templateType" placeholder="模板类型" clearable>
  7. <el-option v-for="item in AdscriptionsType" :label="item.name" :value="item.key" :key="item.key" ></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="归属:">
  11. <el-select size="mini" v-model="filter.tagAdscription" placeholder="归属" clearable>
  12. <el-option
  13. v-for="item in Adscriptions"
  14. :label="item.name"
  15. :value="item.val"
  16. :key="item.val"
  17. ></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item label="属于:">
  21. <el-select size="mini" v-model="filter.ownTo" placeholder="属于" clearable>
  22. <el-option v-if="!!item.name" v-for="item in AdscriptionsOwnTo" :label="item.name" :value="item.conceptId" :key="item.conceptId" ></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button size="mini" @click="filterDatas">确认</el-button>
  27. <el-button size="mini" type="warning" @click="addIndeptTag">添加模板</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </crumbs>
  31. <div class="contents">
  32. <el-table
  33. :data="list"
  34. border
  35. style="width: 100%">
  36. <el-table-column
  37. type="index"
  38. :index = 'indexMethod'
  39. label="编号"
  40. :resizable = "false"
  41. width="60">
  42. </el-table-column>
  43. <el-table-column
  44. :resizable = "false"
  45. prop="gmtModified"
  46. label="操作时间"
  47. width="180">
  48. </el-table-column>
  49. <el-table-column
  50. :resizable = "false"
  51. prop="name"
  52. label="模板名称">
  53. </el-table-column>
  54. <el-table-column
  55. :resizable = "false"
  56. prop="moduleTypeName"
  57. label="模板类型">
  58. </el-table-column>
  59. <el-table-column
  60. :resizable = "false"
  61. prop="relationName"
  62. label="属于">
  63. </el-table-column>
  64. <el-table-column
  65. :resizable = "false"
  66. prop="ascriptionName"
  67. label="归属">
  68. </el-table-column>
  69. <el-table-column
  70. :resizable = "false"
  71. prop="userName"
  72. label="操作人">
  73. </el-table-column>
  74. <el-table-column
  75. :resizable = "false"
  76. prop="operate"
  77. label="操作">
  78. <template slot-scope="scope">
  79. <el-button @click="modifyIndeptTag(scope.row)" type="text" size="small">修改</el-button>
  80. <span style="margin:0 3px;">|</span>
  81. <el-button @click="showDelDialog(scope.row.id,scope.row.type)" class="delete" type="text" size="small">删除</el-button>
  82. </template>
  83. </el-table-column>
  84. </el-table>
  85. </div>
  86. <div class="pagination">
  87. <el-pagination :current-page.sync="currentPage"
  88. @current-change="currentChange"
  89. background
  90. :page-size="pageSize"
  91. :page-sizes="pageSizeArr"
  92. @size-change="handleSizeChange"
  93. :layout="pageLayout"
  94. :total="total">
  95. </el-pagination>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import api from '@api/icss.js';
  101. import config from '@api/config.js';
  102. export default {
  103. name: 'TemplateMaintenance',
  104. data: function() {
  105. return {
  106. list: [],
  107. Adscriptions: [],
  108. tmpAdscriptions: [],
  109. AdscriptionsType:[],
  110. AdscriptionsOwnTo:[],
  111. searched: false,
  112. filter: {
  113. templateType: '', //模板类型
  114. ownTo: '', //属于科室、慢病
  115. tagAdscription: '', //标签归属
  116. },
  117. currentPage: 1,
  118. pageSize: config.pageSize,
  119. pageSizeArr:config.pageSizeArr,
  120. pageLayout:config.pageLayout,
  121. total: 0,
  122. deptAndDisInfo:{},
  123. }
  124. },
  125. created() {
  126. this.getDropList().then(() => {
  127. this.getDataList()
  128. })
  129. this.getSubTemplate()
  130. },
  131. computed:{
  132. tmpType(){
  133. return this.filter.templateType
  134. }
  135. },
  136. watch: {
  137. 'filter': {
  138. handler: function () {
  139. this.searched = false;
  140. },
  141. deep: true
  142. },
  143. tmpType(newVal, preVal){
  144. this.filter.tagAdscription = ''
  145. //根据类型不同删选归属
  146. if((newVal+'') && (newVal == 0 || newVal == 1)){
  147. this.Adscriptions = this.tmpAdscriptions.filter((item) => {
  148. if(item.val != 4 && item.val != 5 && item.val != 6){
  149. return item
  150. }
  151. })
  152. }else if(newVal == 2){
  153. this.Adscriptions = this.tmpAdscriptions.filter((item) => {
  154. if(item.val != 1 && item.val != 31 && item.val != 22 && item.val != 322){
  155. return item
  156. }
  157. })
  158. }else{
  159. this.Adscriptions = this.tmpAdscriptions
  160. }
  161. if((newVal+'') != preVal){
  162. if(newVal == 1){
  163. this.AdscriptionsOwnTo = this.deptAndDisInfo.deptDTOS;
  164. this.filter.ownTo = ''
  165. }else if(newVal == 2){
  166. this.AdscriptionsOwnTo = this.deptAndDisInfo.disDTOS;
  167. this.filter.ownTo = ''
  168. }else{
  169. this.AdscriptionsOwnTo = []
  170. this.filter.ownTo = ''
  171. }
  172. }
  173. }
  174. },
  175. beforeRouteEnter(to, from, next) {
  176. next(vm => {
  177. //const pm = to.param;
  178. const flt = to.params.filter;
  179. vm.currentPage = to.params.currentPage||1;
  180. vm.pageSize = to.params.pageSize || config.pageSize;
  181. vm.deptAndDisInfo = JSON.parse(localStorage.getItem('deptDis')||null);
  182. if(flt){
  183. vm.filter.templateType = flt.templateType;
  184. setTimeout(function(){
  185. vm.filter.tagAdscription = flt.tagAdscription;
  186. vm.filter.ownTo = flt.ownTo;
  187. });
  188. }
  189. vm.inCurrentPage=to.params.currentPage;
  190. })
  191. },
  192. methods: {
  193. handleSizeChange(val){
  194. this.pageSize = val;
  195. this.getDataList();
  196. },
  197. getSubTemplate() {
  198. api.getAllDeptAndDisInfo({}).then((res) => {
  199. if (res.data.code === '0') {//获取科室和疾病所有信息
  200. let result = res.data.data
  201. this.deptAndDisInfo = result
  202. localStorage.setItem('deptDis',JSON.stringify(result))
  203. }
  204. })
  205. },
  206. getDropList() {
  207. let templateType = localStorage.getItem('icssEnumsData') ? JSON.parse(localStorage.getItem('icssEnumsData')).moduleInfoTypeEnum : []
  208. this.AdscriptionsType = templateType
  209. return api.getDropList().then((res) =>{
  210. if(res.data.code === '0') {
  211. this.Adscriptions = res.data.data[4];
  212. this.tmpAdscriptions = res.data.data[4];
  213. localStorage.setItem('typeLis',JSON.stringify(res.data.data[4]))
  214. }
  215. })
  216. },
  217. getDataList(isTurnPage) {
  218. const param = this.getFilterItems(isTurnPage);
  219. this.searched = true;
  220. api.getModuleInfoList(param).then((res) => {
  221. if(res.data.code == 0){
  222. const list = res.data.data.records;
  223. for (var i = 0; i < list.length; i++) {
  224. for (var z = 0; z < this.Adscriptions.length; z++) {
  225. if(list[i].type === this.Adscriptions[z].val) {
  226. list[i].typeCn = this.Adscriptions[z].name
  227. }
  228. }
  229. }
  230. this.list = list;
  231. this.total = res.data.data.total;
  232. if(this.inCurrentPage!==undefined){
  233. this.currentPage=this.inCurrentPage;
  234. this.inCurrentPage = undefined;
  235. }
  236. }
  237. })
  238. },
  239. filterDatas() {
  240. this.currentPage = 1;
  241. this.getDataList();
  242. },
  243. addIndeptTag() {
  244. const pam = this.searched ? {
  245. currentPage: this.currentPage,
  246. pageSize:this.pageSize,
  247. filter: this.filter
  248. } : {currentPage: this.currentPage,
  249. pageSize:this.pageSize};
  250. this.$router.push({name: 'TemplateMaintenanceWrap', params: pam})
  251. },
  252. modifyIndeptTag(row) {
  253. // api.detailsTag({ids:row.id}).then((res) => {
  254. // if (res.data.code === '0') {//获取科室和疾病所有信息
  255. // let result = res.data.data
  256. // console.log(result)
  257. // }
  258. // })
  259. Promise.all([
  260. api.getModuleInfoOne({moduleId:row.id}),
  261. api.getModuleDetailInfo({moduleId:row.id,type:row.type})
  262. ]).then((data)=>{
  263. let data0 = data[0].data;
  264. let data1 = data[1].data;
  265. let allData = {},topMsg={},rightMsg={};
  266. if(data0.code == 0){
  267. topMsg = Object.assign({},data0.data);
  268. }
  269. if(data1.code == 0){
  270. rightMsg = Object.assign({},data1);
  271. }
  272. allData = Object.assign({}, topMsg, rightMsg);
  273. const pam = this.searched ? {
  274. currentPage: this.currentPage,
  275. filter: this.filter
  276. } : {currentPage: this.currentPage};
  277. this.$router.push({
  278. name: 'TemplateMaintenanceWrap',
  279. params: Object.assign(pam, {isEdit: true, data: allData})
  280. });
  281. })
  282. },
  283. currentChange(next) {
  284. this.currentPage = next;
  285. this.getDataList(true);
  286. },
  287. getFilterItems(isTurnPage) {
  288. //翻页时筛选条件没点确定则清空
  289. if(isTurnPage&&!this.searched){
  290. this.filter={
  291. templateType: '', //模板类型
  292. ownTo: '', //属于科室、慢病
  293. tagAdscription: '', //标签归属
  294. };
  295. };
  296. const param = {
  297. current: this.inCurrentPage||this.currentPage,
  298. size: this.pageSize,
  299. type: this.filter.tagAdscription,
  300. moduleType:this.filter.templateType,
  301. relationId:this.filter.ownTo
  302. };
  303. return param;
  304. },
  305. indexMethod(index) {
  306. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  307. },
  308. warning(msg,type){
  309. this.$message({
  310. showClose: true,
  311. message:msg,
  312. type:type||'warning'
  313. })
  314. },
  315. showConfirmDialog(msg,resolve){
  316. this.$alert(msg, '提示', {
  317. confirmButtonText: '确定',
  318. type: 'warning'
  319. }).then(() => {
  320. resolve();
  321. }).catch(() => {});
  322. },
  323. clearfilter(){
  324. this.filter={
  325. templateType: '', //模板类型
  326. ownTo: '', //属于科室、慢病
  327. tagAdscription: '', //标签归属
  328. };
  329. },
  330. showDelDialog(id,type){
  331. this.showConfirmDialog('是否删除该标签?',()=>{
  332. api.delTemplate({ids:id,type:type}).then((res)=>{
  333. if(res.data.code=='0'){
  334. if(!this.searched){
  335. //未点确认时清空搜索条件
  336. this.clearfilter();
  337. }
  338. if(this.list.length==1){
  339. //当前在最后一页且只有一条数据时,删除后跳到前一页
  340. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  341. }
  342. this.getDataList();
  343. this.warning(res.data.msg || '操作成功','success');
  344. }else{
  345. this.warning(res.data.msg);
  346. }
  347. }).catch((error)=>{
  348. this.warning(error);
  349. })
  350. });
  351. }
  352. }
  353. }
  354. </script>
  355. <style lang="less">
  356. .delete{
  357. color: red
  358. }
  359. .delete:hover {
  360. color: red;
  361. }
  362. </style>