CombinQuestion.vue 9.7 KB

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