SimpleQuestion.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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.controlType[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="copyIndeptTag(scope.row)" 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: 'simpleQuestion',
  93. data: function() {
  94. return {
  95. list: [],
  96. tagTypes: [],
  97. Adscriptions: [],
  98. tagTypesList:[],
  99. searched:false,
  100. filter: {
  101. tagType: [], //标签类型
  102. controlType: [],
  103. tagAdscription: '', //标签归属
  104. tagSysName: '', //标签系统名称
  105. },
  106. currentPage: 1,
  107. pageSize: 10,
  108. total: 0,
  109. }
  110. },
  111. created() {
  112. this.getDropList();
  113. },
  114. watch:{
  115. 'filter':{
  116. handler:function(){
  117. this.searched = false;
  118. },
  119. deep:true
  120. }
  121. },
  122. beforeRouteEnter(to, from, next){
  123. next(vm => {
  124. //const pm = to.param;
  125. Object.assign(vm,to.params);
  126. })
  127. },
  128. methods: {
  129. getDropList() {
  130. api.getPreTypeList().then((res) =>{
  131. this.getDataList();
  132. if(res.data.code === '0') {
  133. this.Adscriptions = res.data.data[1];
  134. this.tagTypes = res.data.data[2];
  135. this.tagTypes = this.tagTypes.filter(item => item.val != 0) //去掉名称为默认值的填写单类型
  136. }
  137. })
  138. },
  139. getDataList() {
  140. const param = this.getFilterItems();
  141. this.searched = true;
  142. api.getQuestionList(param).then((res) => {
  143. const list = [...res.data.data.records];
  144. for (var i = 0; i < list.length; i++) {
  145. for (var j = 0; j < this.tagTypes.length; j++) {
  146. if(list[i].controlType == this.tagTypes[j].val) {
  147. list[i].tagTypeCn = this.tagTypes[j].name;
  148. }
  149. }
  150. //后台数据typeCn转换为筛选中对应的字段名称
  151. for (var z = 0; z < this.Adscriptions.length; z++) {
  152. if(list[i].type == this.Adscriptions[z].val) {
  153. list[i].typeCn = this.Adscriptions[z].name;
  154. }
  155. }
  156. }
  157. this.list = list;
  158. this.total = res.data.data.total;
  159. })
  160. },
  161. filterDatas() {
  162. this.currentPage = 1;
  163. this.getDataList();
  164. },
  165. addIndeptTag() {
  166. const pam = this.searched?{currentPage:this.currentPage,
  167. filter:this.filter}:{currentPage:this.currentPage};
  168. this.$router.push({name:'AddSimpleQuestion',
  169. params:pam})
  170. },
  171. copyIndeptTag(row){
  172. api.questionDetail({id:row.id}).then((res)=>{
  173. const {code,data,msg} = res.data;
  174. if(code=='0'){
  175. const item = Object.assign({},row,data);
  176. const pam = this.searched?{currentPage:this.currentPage,
  177. filter:this.filter}:{currentPage:this.currentPage};
  178. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isCopy:true,data:item})});
  179. }else{
  180. this.$message({
  181. message: msg,
  182. type: 'warning'
  183. });
  184. }
  185. });
  186. },
  187. modifyIndeptTag(row) {
  188. api.questionDetail({id:row.id}).then((res)=>{
  189. const {code,data,msg} = res.data;
  190. if(code=='0'){
  191. const item = Object.assign({},row,data);
  192. const pam = this.searched?{currentPage:this.currentPage,
  193. filter:this.filter}:{currentPage:this.currentPage};
  194. this.$router.push({name:'AddSimpleQuestion',params:Object.assign(pam,{isEdit:true,data:item})});
  195. }else{
  196. this.$message({
  197. message: msg,
  198. type: 'warning'
  199. });
  200. }
  201. });
  202. //this.$router.push({name:'AddIndeptLabel',params:{isEdit:true,data:row}});
  203. },
  204. currentChange(next) {
  205. this.currentPage = next;
  206. this.getDataList();
  207. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  208. // this.list = this.cacheData[next];
  209. // } else {
  210. // this.getDataList();
  211. // }
  212. },
  213. getFilterItems() {
  214. const param = {
  215. tagTypeList: [1],
  216. current: this.currentPage,
  217. size: this.pageSize,
  218. type: this.filter.tagAdscription,
  219. tagName: this.filter.tagSysName,
  220. controlTypeList: this.filter.controlType[0] ? this.filter.controlType: []
  221. };
  222. return param;
  223. },
  224. indexMethod(index) {
  225. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  226. },
  227. getTagType(val) {
  228. return val
  229. },
  230. warning(msg,type){
  231. this.$message({
  232. showClose: true,
  233. message:msg,
  234. type:type||'warning'
  235. })
  236. },
  237. showConfirmDialog(msg,resolve){
  238. this.$alert(msg, '提示', {
  239. confirmButtonText: '确定',
  240. type: 'warning'
  241. }).then(() => {
  242. resolve();
  243. }).catch(() => {});
  244. },
  245. showDelDialog(row){
  246. const param = {
  247. "ids": row.id,
  248. "type": row.type
  249. };
  250. this.showConfirmDialog('是否删除该填写单?',()=>{
  251. api.questionDel(param).then((res)=>{
  252. if(res.data.code=='0'){
  253. if(!this.searched){
  254. //未点确认时清空搜索条件
  255. this.filter={
  256. tagType: [], //标签类型
  257. controlType: [],
  258. tagAdscription: '', //标签归属
  259. tagSysName: '', //标签系统名称
  260. };
  261. }
  262. this.getDataList();
  263. this.warning(res.data.msg || '操作成功','success');
  264. }else{
  265. this.warning(res.data.msg);
  266. }
  267. }).catch((error)=>{
  268. this.warning(error);
  269. })
  270. });
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="less">
  276. @import "../../less/admin.less";
  277. .delete{
  278. color: red
  279. }
  280. .delete:hover {
  281. color: red;
  282. }
  283. .el-select .el-input .el-icon-arrow-up{
  284. display: inline-block!important;
  285. }
  286. .el-select .el-input .el-icon-circle-close{
  287. float:left;
  288. }
  289. </style>