TemplateMaintenance.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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;
  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. })
  190. },
  191. methods: {
  192. handleSizeChange(val){
  193. this.pageSize = val;
  194. this.getDataList();
  195. },
  196. getSubTemplate() {
  197. api.getAllDeptAndDisInfo({}).then((res) => {
  198. if (res.data.code === '0') {//获取科室和疾病所有信息
  199. let result = res.data.data
  200. this.deptAndDisInfo = result
  201. localStorage.setItem('deptDis',JSON.stringify(result))
  202. }
  203. })
  204. },
  205. getDropList() {
  206. let templateType = localStorage.getItem('icssEnumsData') ? JSON.parse(localStorage.getItem('icssEnumsData')).moduleInfoTypeEnum : []
  207. this.AdscriptionsType = templateType
  208. return api.getDropList().then((res) =>{
  209. if(res.data.code === '0') {
  210. this.Adscriptions = res.data.data[4];
  211. this.tmpAdscriptions = res.data.data[4];
  212. localStorage.setItem('typeLis',JSON.stringify(res.data.data[4]))
  213. }
  214. })
  215. },
  216. getDataList(isTurnPage) {
  217. const param = this.getFilterItems(isTurnPage);
  218. this.searched = true;
  219. api.getModuleInfoList(param).then((res) => {
  220. if(res.data.code == 0){
  221. const list = res.data.data.records;
  222. for (var i = 0; i < list.length; i++) {
  223. for (var z = 0; z < this.Adscriptions.length; z++) {
  224. if(list[i].type === this.Adscriptions[z].val) {
  225. list[i].typeCn = this.Adscriptions[z].name
  226. }
  227. }
  228. }
  229. this.list = list;
  230. this.total = res.data.data.total;
  231. }
  232. })
  233. },
  234. filterDatas() {
  235. this.currentPage = 1;
  236. this.getDataList();
  237. },
  238. addIndeptTag() {
  239. const pam = this.searched ? {
  240. currentPage: this.currentPage,
  241. pageSize:this.pageSize,
  242. filter: this.filter
  243. } : {currentPage: this.currentPage,
  244. pageSize:this.pageSize};
  245. this.$router.push({name: 'TemplateMaintenanceWrap', params: pam})
  246. },
  247. modifyIndeptTag(row) {
  248. // api.detailsTag({ids:row.id}).then((res) => {
  249. // if (res.data.code === '0') {//获取科室和疾病所有信息
  250. // let result = res.data.data
  251. // console.log(result)
  252. // }
  253. // })
  254. Promise.all([
  255. api.getModuleInfoOne({moduleId:row.id}),
  256. api.getModuleDetailInfo({moduleId:row.id,type:row.type})
  257. ]).then((data)=>{
  258. let data0 = data[0].data;
  259. let data1 = data[1].data;
  260. let allData = {},topMsg={},rightMsg={};
  261. if(data0.code == 0){
  262. topMsg = Object.assign({},data0.data);
  263. }
  264. if(data1.code == 0){
  265. rightMsg = Object.assign({},data1);
  266. }
  267. allData = Object.assign({}, topMsg, rightMsg);
  268. const pam = this.searched ? {
  269. currentPage: this.currentPage,
  270. filter: this.filter
  271. } : {currentPage: this.currentPage};
  272. this.$router.push({
  273. name: 'TemplateMaintenanceWrap',
  274. params: Object.assign(pam, {isEdit: true, data: allData})
  275. });
  276. })
  277. },
  278. currentChange(next) {
  279. this.currentPage = next;
  280. this.getDataList(true);
  281. },
  282. getFilterItems(isTurnPage) {
  283. //翻页时筛选条件没点确定则清空
  284. if(isTurnPage&&!this.searched){
  285. this.filter={
  286. templateType: '', //模板类型
  287. ownTo: '', //属于科室、慢病
  288. tagAdscription: '', //标签归属
  289. };
  290. };
  291. const param = {
  292. current: this.currentPage,
  293. size: this.pageSize,
  294. type: this.filter.tagAdscription,
  295. moduleType:this.filter.templateType,
  296. relationId:this.filter.ownTo
  297. };
  298. return param;
  299. },
  300. indexMethod(index) {
  301. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  302. },
  303. warning(msg,type){
  304. this.$message({
  305. showClose: true,
  306. message:msg,
  307. type:type||'warning'
  308. })
  309. },
  310. showConfirmDialog(msg,resolve){
  311. this.$alert(msg, '提示', {
  312. confirmButtonText: '确定',
  313. type: 'warning'
  314. }).then(() => {
  315. resolve();
  316. }).catch(() => {});
  317. },
  318. clearfilter(){
  319. this.filter={
  320. templateType: '', //模板类型
  321. ownTo: '', //属于科室、慢病
  322. tagAdscription: '', //标签归属
  323. };
  324. },
  325. showDelDialog(id,type){
  326. this.showConfirmDialog('是否删除该标签?',()=>{
  327. api.delTemplate({ids:id,type:type}).then((res)=>{
  328. if(res.data.code=='0'){
  329. if(!this.searched){
  330. //未点确认时清空搜索条件
  331. this.clearfilter();
  332. }
  333. if(this.list.length==1){
  334. //当前在最后一页且只有一条数据时,删除后跳到前一页
  335. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  336. }
  337. this.getDataList();
  338. this.warning(res.data.msg || '操作成功','success');
  339. }else{
  340. this.warning(res.data.msg);
  341. }
  342. }).catch((error)=>{
  343. this.warning(error);
  344. })
  345. });
  346. }
  347. }
  348. }
  349. </script>
  350. <style lang="less">
  351. .delete{
  352. color: red
  353. }
  354. .delete:hover {
  355. color: red;
  356. }
  357. </style>