TemplateMaintenance.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. import utils from '@api/utils.js';
  103. export default {
  104. name: 'TemplateMaintenance',
  105. data: function() {
  106. return {
  107. list: [],
  108. Adscriptions: [],
  109. tmpAdscriptions: [],
  110. AdscriptionsType:[],
  111. AdscriptionsOwnTo:[],
  112. searched: false,
  113. filter: {
  114. templateType: '', //模板类型
  115. ownTo: '', //属于科室、慢病
  116. tagAdscription: '', //标签归属
  117. },
  118. currentPage: 1,
  119. pageSize: config.pageSize,
  120. pageSizeArr:config.pageSizeArr,
  121. pageLayout:config.pageLayout,
  122. total: 0,
  123. deptAndDisInfo:{},
  124. }
  125. },
  126. created() {
  127. this.getDropList().then(() => {
  128. this.getDataList()
  129. })
  130. this.getSubTemplate()
  131. },
  132. computed:{
  133. tmpType(){
  134. return this.filter.templateType
  135. }
  136. },
  137. watch: {
  138. 'filter': {
  139. handler: function () {
  140. this.searched = false;
  141. },
  142. deep: true
  143. },
  144. tmpType(newVal, preVal){
  145. this.filter.tagAdscription = ''
  146. //根据类型不同删选归属
  147. if((newVal+'') && (newVal == 0 || newVal == 1)){
  148. this.Adscriptions = this.tmpAdscriptions.filter((item) => {
  149. if(item.val != 4 && item.val != 5 && item.val != 6){
  150. return item
  151. }
  152. })
  153. }else if(newVal == 2){
  154. this.Adscriptions = this.tmpAdscriptions.filter((item) => {
  155. if(item.val != 1 && item.val != 31 && item.val != 22 && item.val != 322){
  156. return item
  157. }
  158. })
  159. }else{
  160. this.Adscriptions = this.tmpAdscriptions
  161. }
  162. if((newVal+'') != preVal){
  163. if(newVal == 1){
  164. this.AdscriptionsOwnTo = this.deptAndDisInfo.deptDTOS;
  165. this.filter.ownTo = ''
  166. }else if(newVal == 2){
  167. this.AdscriptionsOwnTo = this.deptAndDisInfo.disDTOS;
  168. this.filter.ownTo = ''
  169. }else{
  170. this.AdscriptionsOwnTo = []
  171. this.filter.ownTo = ''
  172. }
  173. }
  174. }
  175. },
  176. beforeRouteEnter(to, from, next) {
  177. next(vm => {
  178. //const pm = to.param;
  179. const flt = to.params.filter;
  180. vm.currentPage = to.params.currentPage||1;
  181. vm.pageSize = to.params.pageSize || config.pageSize;
  182. vm.deptAndDisInfo = JSON.parse(localStorage.getItem('deptDis')||null);
  183. if(flt){
  184. vm.filter.templateType = flt.templateType;
  185. setTimeout(function(){
  186. vm.filter.tagAdscription = flt.tagAdscription;
  187. vm.filter.ownTo = flt.ownTo;
  188. });
  189. }
  190. vm.inCurrentPage=to.params.currentPage;
  191. })
  192. },
  193. methods: {
  194. handleSizeChange(val){
  195. this.pageSize = val;
  196. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  197. this.getDataList();
  198. },
  199. getSubTemplate() {
  200. api.getAllDeptAndDisInfo({}).then((res) => {
  201. if (res.data.code === '0') {//获取科室和疾病所有信息
  202. let result = res.data.data
  203. this.deptAndDisInfo = result
  204. localStorage.setItem('deptDis',JSON.stringify(result))
  205. }
  206. })
  207. },
  208. getDropList() {
  209. let templateType = localStorage.getItem('icssEnumsData') ? JSON.parse(localStorage.getItem('icssEnumsData')).moduleInfoTypeEnum : []
  210. this.AdscriptionsType = templateType
  211. return api.getDropList().then((res) =>{
  212. if(res.data.code === '0') {
  213. this.Adscriptions = res.data.data[4];
  214. this.tmpAdscriptions = res.data.data[4];
  215. localStorage.setItem('typeLis',JSON.stringify(res.data.data[4]))
  216. }
  217. })
  218. },
  219. getDataList(isTurnPage) {
  220. const param = this.getFilterItems(isTurnPage);
  221. this.searched = true;
  222. const loading = this.$loading({
  223. lock: true,
  224. text: 'Loading',
  225. spinner: 'el-icon-loading',
  226. background: 'rgba(0, 0, 0, 0.7)'
  227. });
  228. api.getModuleInfoList(param).then((res) => {
  229. loading.close()
  230. if(res.data.code == 0){
  231. const list = res.data.data.records;
  232. for (var i = 0; i < list.length; i++) {
  233. for (var z = 0; z < this.Adscriptions.length; z++) {
  234. if(list[i].type === this.Adscriptions[z].val) {
  235. list[i].typeCn = this.Adscriptions[z].name
  236. }
  237. }
  238. }
  239. this.list = list;
  240. this.total = res.data.data.total;
  241. if(this.inCurrentPage!==undefined){
  242. this.currentPage=this.inCurrentPage;
  243. this.inCurrentPage = undefined;
  244. }
  245. }
  246. })
  247. },
  248. filterDatas() {
  249. this.currentPage = 1;
  250. this.getDataList();
  251. },
  252. addIndeptTag() {
  253. const pam = this.searched ? {
  254. currentPage: this.currentPage,
  255. pageSize:this.pageSize,
  256. filter: this.filter
  257. } : {currentPage: this.currentPage,
  258. pageSize:this.pageSize};
  259. this.$router.push({name: 'TemplateMaintenanceWrap', params: pam})
  260. },
  261. modifyIndeptTag(row) {
  262. // api.detailsTag({ids:row.id}).then((res) => {
  263. // if (res.data.code === '0') {//获取科室和疾病所有信息
  264. // let result = res.data.data
  265. // console.log(result)
  266. // }
  267. // })
  268. Promise.all([
  269. api.getModuleInfoOne({moduleId:row.id}),
  270. api.getModuleDetailInfo({moduleId:row.id,type:row.type})
  271. ]).then((data)=>{
  272. let data0 = data[0].data;
  273. let data1 = data[1].data;
  274. let allData = {},topMsg={},rightMsg={};
  275. if(data0.code == 0){
  276. topMsg = Object.assign({},data0.data);
  277. }
  278. if(data1.code == 0){
  279. rightMsg = Object.assign({},data1);
  280. }
  281. allData = Object.assign({}, topMsg, rightMsg);
  282. const pam = this.searched ? {
  283. currentPage: this.currentPage,
  284. filter: this.filter
  285. } : {currentPage: this.currentPage};
  286. this.$router.push({
  287. name: 'TemplateMaintenanceWrap',
  288. params: Object.assign(pam, {isEdit: true, data: allData})
  289. });
  290. })
  291. },
  292. currentChange(next) {
  293. this.currentPage = next;
  294. this.getDataList(true);
  295. },
  296. getFilterItems(isTurnPage) {
  297. //翻页时筛选条件没点确定则清空
  298. if(isTurnPage&&!this.searched){
  299. this.filter={
  300. templateType: '', //模板类型
  301. ownTo: '', //属于科室、慢病
  302. tagAdscription: '', //标签归属
  303. };
  304. };
  305. const param = {
  306. current: this.inCurrentPage||this.currentPage,
  307. size: this.pageSize,
  308. type: this.filter.tagAdscription,
  309. moduleType:this.filter.templateType,
  310. relationId:this.filter.ownTo
  311. };
  312. return param;
  313. },
  314. indexMethod(index) {
  315. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  316. },
  317. warning(msg,type){
  318. this.$message({
  319. showClose: true,
  320. message:msg,
  321. type:type||'warning'
  322. })
  323. },
  324. showConfirmDialog(msg,resolve){
  325. this.$alert(msg, '提示', {
  326. confirmButtonText: '确定',
  327. type: 'warning'
  328. }).then(() => {
  329. resolve();
  330. }).catch(() => {});
  331. },
  332. clearfilter(){
  333. this.filter={
  334. templateType: '', //模板类型
  335. ownTo: '', //属于科室、慢病
  336. tagAdscription: '', //标签归属
  337. };
  338. },
  339. showDelDialog(id,type){
  340. this.showConfirmDialog('是否删除该标签?',()=>{
  341. api.delTemplate({ids:id,type:type}).then((res)=>{
  342. if(res.data.code=='0'){
  343. if(!this.searched){
  344. //未点确认时清空搜索条件
  345. this.clearfilter();
  346. }
  347. if(this.list.length==1){
  348. //当前在最后一页且只有一条数据时,删除后跳到前一页
  349. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  350. }
  351. this.getDataList();
  352. this.warning(res.data.msg || '操作成功','success');
  353. }else{
  354. this.warning(res.data.msg);
  355. }
  356. }).catch((error)=>{
  357. this.warning(error);
  358. })
  359. });
  360. }
  361. }
  362. }
  363. </script>
  364. <style lang="less">
  365. .delete{
  366. color: red
  367. }
  368. .delete:hover {
  369. color: red;
  370. }
  371. </style>