QuestionModules.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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="filter.name" placeholder="模板名称" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item label="归属:">
  9. <el-select size="mini" v-model="filter.type" placeholder="归属" clearable>
  10. <el-option v-if="item.val!=6&&item.val!=7&&item.val!=8&&item.val!=9&&item.val!=10&&item.val!=21&&item.val!=22" v-for="item in Adscriptions" :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="filter.moduleType" placeholder="类型" clearable>
  15. <el-option v-for="item in tagTypes" :label="item.name" :value="item.val" :key="item.id"></el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="归属科室:" v-if="filter.moduleType==1">
  19. <el-select size="mini" v-model="filter.relationId" placeholder="归属" clearable>
  20. <el-option v-for="item in deptList" :label="item.name" :value="item.conceptId" :key="item.conceptId" ></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button size="mini" @click="filterDatas">确认</el-button>
  25. <el-button size="mini" type="warning" @click="addModule">添加模板</el-button>
  26. </el-form-item>
  27. </el-form>
  28. </crumbs>
  29. <div class="contents">
  30. <el-table
  31. :data="list"
  32. border
  33. style="width: 100%">
  34. <el-table-column
  35. :resizable = "false"
  36. type="index"
  37. :index = 'indexMethod'
  38. label="编号"
  39. width="60">
  40. </el-table-column>
  41. <el-table-column
  42. :resizable = "false"
  43. prop="gmtModified"
  44. label="操作时间"
  45. width="180">
  46. </el-table-column>
  47. <el-table-column
  48. :resizable = "false"
  49. prop="name"
  50. label="模板名称">
  51. </el-table-column>
  52. <el-table-column
  53. :resizable = "false"
  54. prop="ascriptionName"
  55. label="模板归属"
  56. width="80">
  57. </el-table-column>
  58. <el-table-column
  59. :resizable = "false"
  60. prop="moduleTypeName"
  61. label="模板类型">
  62. </el-table-column>
  63. <el-table-column
  64. :resizable = "false"
  65. prop="relationName"
  66. label="归属科室">
  67. </el-table-column>
  68. <el-table-column
  69. :resizable = "false"
  70. prop="userName"
  71. label="操作人"
  72. width="120">
  73. </el-table-column>
  74. <el-table-column
  75. :resizable = "false"
  76. prop="operate"
  77. label="操作"
  78. width="120">
  79. <template slot-scope="scope">
  80. <el-button @click="modifyModule(scope.row)" type="text" size="small">修改</el-button>
  81. <span style="margin:0 3px;">|</span>
  82. <el-button @click="showDelDialog(scope.row)" class="delete" type="text" size="small">删除</el-button>
  83. </template>
  84. </el-table-column>
  85. </el-table>
  86. <el-pagination v-if="total>pageSize"
  87. :current-page.sync="currentPage"
  88. @current-change="currentChange"
  89. background
  90. :page-size="pageSize"
  91. layout="total,prev, pager, next, jumper"
  92. :total="total">
  93. </el-pagination>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import api from '@api/preTreat.js';
  99. export default {
  100. name: 'QuestionModules',
  101. data: function() {
  102. return {
  103. list: [],
  104. tagTypes: [],
  105. searched:false,
  106. Adscriptions: [],
  107. deptList:[],
  108. filter: {
  109. name: '', //模板名称
  110. type: '', //模板归属
  111. moduleType: '', //模板类型
  112. relationId:'', //归属科室
  113. },
  114. currentPage: 1,
  115. pageSize: 10,
  116. total: 0,
  117. }
  118. },
  119. created() {
  120. this.getDropList();
  121. },
  122. watch:{
  123. 'filter':{
  124. handler:function(){
  125. this.searched = false;
  126. },
  127. deep:true
  128. }
  129. },
  130. beforeRouteEnter(to, from, next){
  131. next(vm => {
  132. //const pm = to.param;
  133. Object.assign(vm,to.params);
  134. })
  135. },
  136. methods: {
  137. getDropList() {
  138. api.getPreTypeList().then((res) =>{
  139. this.getDataList();
  140. if(res.data.code === '0') {
  141. this.Adscriptions = res.data.data[1];
  142. this.tagTypes = res.data.data[4];
  143. }
  144. });
  145. this.getDeptList();
  146. },
  147. getDeptList(){
  148. const depts = localStorage.getItem("precDeptList");
  149. const list = depts?JSON.parse(depts):[];
  150. if(list&&list.length>0){
  151. this.deptList = list;
  152. return ;
  153. }
  154. api.getDeptList({moduleType:0,type:1}).then((res) =>{
  155. if(res.data.code === '0') {
  156. this.deptList = res.data.data&&res.data.data.deptDTOS||[];
  157. localStorage.setItem("precDeptList",JSON.stringify(this.deptList));
  158. }
  159. });
  160. },
  161. getDataList(isTurnPage) {
  162. const param = this.getFilterItems(isTurnPage);
  163. this.searched = true;
  164. api.getModuleList(param).then((res) => {
  165. if (res.data.code === '0') {
  166. const list = res.data.data&&res.data.data.records?[...res.data.data.records]:[];
  167. for (var i = 0; i < list.length; i++) {
  168. for (var j = 0; j < this.tagTypes.length; j++) {
  169. if(list[i].moduleType == this.tagTypes[j].val) {
  170. list[i].tagTypeCn = this.tagTypes[j].name;
  171. }
  172. }
  173. //后台数据typeCn转换为筛选中对应的字段名称
  174. for (var z = 0; z < this.Adscriptions.length; z++) {
  175. if(list[i].type == this.Adscriptions[z].val) {
  176. list[i].typeCn = this.Adscriptions[z].name;
  177. }
  178. }
  179. }
  180. this.list = list;
  181. this.total = res.data.data.total;
  182. }else{
  183. this.$message({
  184. message: res.data.msg,
  185. type: 'warning'
  186. });
  187. }
  188. })
  189. },
  190. filterDatas() {
  191. this.currentPage = 1;
  192. this.getDataList();
  193. },
  194. addModule() {
  195. const pam = this.searched?{currentPage:this.currentPage,
  196. filter:this.filter}:{currentPage:this.currentPage};
  197. this.$router.push({name:'AddQuestionModules',
  198. params:pam});
  199. },
  200. modifyModule(row) {
  201. api.getModuleDetail({moduleId:row.id,type:row.type}).then((res)=>{
  202. const {code,data,msg} = res.data;
  203. if(code=='0'){
  204. const item = Object.assign({},row,data);
  205. const pam = this.searched?{currentPage:this.currentPage,
  206. filter:this.filter}:{currentPage:this.currentPage};
  207. this.$router.push({name:'AddQuestionModules',params:Object.assign(pam,{isEdit:true,data:item})});
  208. }else{
  209. this.$message({
  210. message: msg,
  211. type: 'warning'
  212. });
  213. }
  214. });
  215. },
  216. currentChange(next) {
  217. this.currentPage = next;
  218. this.getDataList(true);
  219. },
  220. getFilterItems(isTurnPage) {
  221. //翻页时筛选条件没点确定则清空
  222. if(isTurnPage&&!this.searched){
  223. this.filter = {
  224. name: '', //模板名称
  225. type: '', //模板归属
  226. moduleType: '', //模板类型
  227. relationId:'', //归属科室
  228. }
  229. };
  230. const param = {
  231. name: this.filter.name,
  232. type:this.filter.type,
  233. moduleType: this.filter.moduleType,
  234. relationId: this.filter.moduleType==1?this.filter.relationId:'',
  235. current: this.currentPage,
  236. size: this.pageSize,
  237. };
  238. return param;
  239. },
  240. indexMethod(index) {
  241. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  242. },
  243. getTagType(val) {
  244. return val
  245. },
  246. warning(msg,type){
  247. this.$message({
  248. showClose: true,
  249. message:msg,
  250. type:type||'warning'
  251. })
  252. },
  253. showConfirmDialog(msg,resolve){
  254. this.$alert(msg, '提示', {
  255. confirmButtonText: '确定',
  256. type: 'warning'
  257. }).then(() => {
  258. resolve();
  259. }).catch(() => {});
  260. },
  261. showDelDialog(row){
  262. const param = {
  263. "ids": row.id,
  264. };
  265. this.showConfirmDialog('是否删除该模板?',()=>{
  266. api.delModule(param).then((res)=>{
  267. if(res.data.code=='0'){
  268. if(!this.searched){
  269. //未点确认时清空搜索条件
  270. this.filter={
  271. name: '', //模板名称
  272. type: '', //模板归属
  273. moduleType: '', //模板类型
  274. relationId:'', //归属科室
  275. };
  276. }
  277. if(this.list.length==1){
  278. //当前在最后一页且只有一条数据时,删除后跳到前一页
  279. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  280. }
  281. this.getDataList();
  282. this.warning(res.data.msg || '操作成功','success');
  283. }else{
  284. this.warning(res.data.msg);
  285. }
  286. }).catch((error)=>{
  287. this.warning(error);
  288. })
  289. });
  290. }
  291. }
  292. }
  293. </script>
  294. <style lang="less">
  295. @import "../../less/admin.less";
  296. .delete{
  297. color: red
  298. }
  299. .delete:hover {
  300. color: red;
  301. }
  302. .el-select .el-input .el-icon-arrow-up{
  303. display: inline-block!important;
  304. }
  305. .el-select .el-input .el-icon-circle-close{
  306. float:left;
  307. }
  308. </style>